SpaceCore#
SpaceCore provides typed vector spaces, structured elements, linear operators, functionals, and small linear-algebra utilities for backend-aware numerical code.
A SpaceCore operator is a typed map \(A : X \to Y\) between spaces
\(X\) and \(Y\). The spaces carry the rules needed to validate elements,
compute inner products, flatten structured values, and interpret adjoints.
rapply is the metric adjoint with respect to the domain and codomain inner
products; it is the coordinate conjugate transpose only in Euclidean geometry.
Where do I start?#
First-time users should start with 1 · Backend and Context, then work through 2 · Linear algebra: spaces, operators, conjugate gradients and 3 · Functionals and gradient descent. For structured unknowns continue with 4 · Tree spaces: structured elements and block operators. The worked examples — a Tikhonov inverse problem, optimal transport, manifold descent, and conic optimisation — apply these pieces to real problems. If your problem uses non-Euclidean geometry, read Geometry and Riesz Maps before relying on adjoints or solver preconditions.
What SpaceCore is not#
SpaceCore is not a full solver suite and not a replacement for NumPy, SciPy, JAX, Torch, CuPy, PETSc, Krylov.jl, or PyLops. Its native solvers are a small correctness baseline and substrate layer for space-aware algorithms. External adapters and backend-specific fast paths can be added where a project needs solver breadth or production performance.
Installation#
pip install spacecore
pip install "spacecore[jax]"
pip install "spacecore[torch]"
pip install "spacecore[cupy]"
Minimal example#
import numpy as np
import spacecore as sc
ctx = sc.Context(sc.NumpyOps(), dtype=np.float64)
X = sc.DenseCoordinateSpace((2,), ctx)
A = sc.DenseLinOp(ctx.asarray([[2.0, 0.0], [0.0, 3.0]]), X, X, ctx)
b = ctx.asarray([4.0, 9.0])
result = sc.cg(A, b, tol=1e-12, maxiter=10)
print(result.x)
print(result.converged)
Expected output:
[2. 3.]
True