Backend-agnostic vector spaces and linear operators.
Project description
SpaceCore
SpaceCore provides typed vector spaces, structured elements, linear operators,
functionals, and small linear-algebra utilities for backend-aware numerical
code. An operator is a typed map A : X -> Y between spaces, not merely an
array. Spaces carry the rules needed to validate elements, compute inner
products, flatten structured values, and interpret adjoints.
The execution backend is explicit. A Context owns the backend operations,
default dtype, and validation policy used by spaces and operators. NumPy is the
baseline backend; JAX, Torch, and CuPy are optional backends when their extras
are installed.
SpaceCore's native solvers are intentionally small. They are a correctness baseline and substrate layer for space-aware algorithms, not a replacement for mature solver ecosystems such as SciPy, PETSc, Krylov.jl, or PyLops. External adapters and backend-specific fast paths can be layered on top where breadth or performance is required.
Install
pip install spacecore
pip install "spacecore[jax]"
pip install "spacecore[torch]"
pip install "spacecore[cupy]"
Python 3.11+ is required.
Quick Start
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
Core Ideas
Spaces. DenseCoordinateSpace, DenseVectorSpace,
ElementwiseJordanSpace, EuclideanElementwiseJordanSpace, HermitianSpace,
ProductSpace, and StackedSpace describe element structure and geometry.
Dense coordinate spaces can use Euclidean or weighted inner products.
import numpy as np
import spacecore as sc
ctx = sc.Context(sc.NumpyOps(), dtype=np.float64)
weights = ctx.asarray([2.0, 5.0])
X = sc.DenseCoordinateSpace((2,), ctx, geometry=sc.WeightedInnerProduct(weights))
x = ctx.asarray([1.0, 2.0])
y = ctx.asarray([3.0, 4.0])
print(X.inner(x, y))
print(X.riesz(x))
Expected output:
46.0
[ 2. 10.]
Linear operators. DenseLinOp, SparseLinOp, DiagonalLinOp,
MatrixFreeLinOp, IdentityLinOp, ZeroLinOp, and the algebraic operators
represent maps A : X -> Y. apply computes the forward map. rapply
computes the metric adjoint: the coordinate conjugate transpose only agrees
with it when both spaces use Euclidean geometry.
import numpy as np
import spacecore as sc
ctx = sc.Context(sc.NumpyOps(), dtype=np.float64)
X = sc.DenseCoordinateSpace((2,), ctx)
A = sc.DiagonalLinOp(ctx.asarray([2.0, 3.0]), X, ctx)
print(A.apply(ctx.asarray([1.0, 2.0])))
print(A.rapply(ctx.asarray([1.0, 1.0])))
Expected output:
[2. 6.]
[2. 3.]
Functionals. LinearFunctional, InnerProductFunctional,
MatrixFreeLinearFunctional, QuadraticForm, and LinOpQuadraticForm model
scalar-valued maps on spaces. Gradients are represented in the domain geometry.
Linear algebra. cg, lsqr, lanczos_smallest, power_iteration, and
expm_multiply operate on SpaceCore operators and spaces. They document their
mathematical preconditions; for example cg expects a square Hermitian positive
definite map A : X -> X with respect to X.inner.
Backends. NumpyOps is always available. JaxOps, TorchOps, and
CuPyOps are exported only when their optional dependencies are installed.
Backend portability means SpaceCore uses the same abstract operations and data
model; it does not erase backend-specific dtype, device, sparse, tracing, or
autograd behavior.
Batching
A space describes one element type. Batched computation is handled by vectorized
application methods such as vapply, rvapply, vvalue, and backend
vectorization. Batching does not change the mathematical domain or codomain of
an operator unless the operator itself is explicitly built over a stacked or
product space.
Documentation
Project Status
SpaceCore is experimental 0.3.x software. Core abstractions are usable for
research and prototyping, but API details may still change before a stable
release.
Contributing
Bug reports, feature requests, and PRs are welcome. See CONTRIBUTING.md.
License
Apache 2.0. See LICENSE.
Citation
@software{spacecore,
author = {Pavlo Pelikh},
title = {SpaceCore: Backend-aware vector spaces and linear operators},
url = {https://github.com/Pavlo3P/SpaceCore},
year = {2026},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spacecore-0.3.2.tar.gz.
File metadata
- Download URL: spacecore-0.3.2.tar.gz
- Upload date:
- Size: 394.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7e8926eb9321b2ba0b0bf30c012e1185d9adb4cc70f6ec83f312abb7a2d3bec
|
|
| MD5 |
bd11b0ff455a6ad2d4d5fddb348d452f
|
|
| BLAKE2b-256 |
a75bcfdc4a78cdfd72a8801d0449cdafcba40dbaf36cd9a7965748a9a9949df9
|
Provenance
The following attestation bundles were made for spacecore-0.3.2.tar.gz:
Publisher:
ci.yml on Pavlo3P/SpaceCore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spacecore-0.3.2.tar.gz -
Subject digest:
e7e8926eb9321b2ba0b0bf30c012e1185d9adb4cc70f6ec83f312abb7a2d3bec - Sigstore transparency entry: 1781822549
- Sigstore integration time:
-
Permalink:
Pavlo3P/SpaceCore@484887e336bd8289692567cb7dfa277bf4a64d4c -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/Pavlo3P
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@484887e336bd8289692567cb7dfa277bf4a64d4c -
Trigger Event:
push
-
Statement type:
File details
Details for the file spacecore-0.3.2-py3-none-any.whl.
File metadata
- Download URL: spacecore-0.3.2-py3-none-any.whl
- Upload date:
- Size: 132.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c4ab35024fa987bcfd6f0065d5156934c363f870a79b9b711206d15d6614264
|
|
| MD5 |
554ca905d27e6bbc66e92a87bc5264db
|
|
| BLAKE2b-256 |
aa284e76f23db13aadb47525c1ebf3d58dce658d63a2cd25809d5278a3805bad
|
Provenance
The following attestation bundles were made for spacecore-0.3.2-py3-none-any.whl:
Publisher:
ci.yml on Pavlo3P/SpaceCore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spacecore-0.3.2-py3-none-any.whl -
Subject digest:
4c4ab35024fa987bcfd6f0065d5156934c363f870a79b9b711206d15d6614264 - Sigstore transparency entry: 1781822828
- Sigstore integration time:
-
Permalink:
Pavlo3P/SpaceCore@484887e336bd8289692567cb7dfa277bf4a64d4c -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/Pavlo3P
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@484887e336bd8289692567cb7dfa277bf4a64d4c -
Trigger Event:
push
-
Statement type: