Skip to main content

Backend-agnostic vector spaces and linear operators.

Project description

SpaceCore

SpaceCore is a lightweight backend-agnostic library for working with vector spaces and linear operators.

It provides a small set of abstractions for:

  • backend-aware numerical operations
  • contexts carrying backend and dtype information
  • structured vector spaces
  • structured linear operators
  • conversion between compatible contexts

Installation

Base install:

pip install spacecore

With JAX support:

pip install "spacecore[jax]"
  • spacecore[jax]: installs optional JAX support.
  • GPU users should install the appropriate CUDA-enabled JAX build first, following the official JAX installation guide.

Main concepts

Context

A Context specifies how objects are represented, in particular:

  • backend (NumPy, JAX, etc.)
  • dtype
  • validation/conversion behavior

Space

A Space describes the structure of objects space, for example:

  • VectorSpace - Euclidean space
  • HermitianSpace - space of Hermitian (symmetric) matrices
  • ProductSpace - Cartesian product of spaces

LinOp

A LinOp represents a linear operator between spaces, for example:

  • DenseLinOp - linear operator represented by dense matrix
  • SparseLinOp - linear operator represented by sparse matrix
  • BlockDiagonalLinOp - linear operator from $X_1 \times \dots \times X_k$ to $Y_1 \times \dots \times Y_k$
  • StackedLinOp - linear operator from $X$ to $Y_1 \times \dots \times Y_k$
  • SumToSingleLinOp - linear operator from $X_1 \times \dots \times X_k$ to $Y$

Minimal example

import numpy as np
import spacecore as sc

sc.set_context('numpy', dtype='float64')

X = sc.VectorSpace((3,))
Y = sc.VectorSpace((2,))

A = np.array(
    [[1.0, 2.0, 3.0],
     [0.0, 1.0, 0.0]]
)
linop = sc.DenseLinOp(
    A,
    dom=X,
    cod=Y,
)

x = X.ctx.asarray([1.0, 0.0, -1.0])
y = linop.apply(x)

print(y)

Status

SpaceCore is currently experimental and under active development. The public API may still evolve.

Tutorials

See the tutorials/ directory for usage examples and design guidance.

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spacecore-0.1.3.tar.gz (37.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spacecore-0.1.3-py3-none-any.whl (42.3 kB view details)

Uploaded Python 3

File details

Details for the file spacecore-0.1.3.tar.gz.

File metadata

  • Download URL: spacecore-0.1.3.tar.gz
  • Upload date:
  • Size: 37.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spacecore-0.1.3.tar.gz
Algorithm Hash digest
SHA256 08ec98211ed400d403aa34c460b83ec5fd39f57865083da9a55dcf3df61419a3
MD5 fb0ab9b92e6673dbccacf09659d7820a
BLAKE2b-256 21777744c51080542a24ec1edf0ee84034866e4142c740353563dee441f8cf67

See more details on using hashes here.

Provenance

The following attestation bundles were made for spacecore-0.1.3.tar.gz:

Publisher: ci.yml on Pavlo3P/SpaceCore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spacecore-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: spacecore-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 42.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spacecore-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c50e7f5998beaa037b173342f609cf03e9254346321febf7617ed7266b63d8f6
MD5 48b3c910b431c8a7183af1b50d04b093
BLAKE2b-256 e05e883edc996e936c2447b45937de2e452bbb49e503803aea1f083d3578f038

See more details on using hashes here.

Provenance

The following attestation bundles were made for spacecore-0.1.3-py3-none-any.whl:

Publisher: ci.yml on Pavlo3P/SpaceCore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page