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.1.tar.gz (35.4 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.1-py3-none-any.whl (40.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spacecore-0.1.1.tar.gz
  • Upload date:
  • Size: 35.4 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.1.tar.gz
Algorithm Hash digest
SHA256 77f95f1a1fb1fea6be08ef5756a1f11f29279289a24675c0db5bd44c1c11695d
MD5 c297a7cd356f63ae164067ed69f5f3d5
BLAKE2b-256 8e6d5dc28561876c1344ed1cf8615668b97a6352176b7c5786917d0ccb0f18b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for spacecore-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: spacecore-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 40.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 104cfd70b3d7531cd4af0995e8da0ce8f68877775a81d2dffc34f7df884b1742
MD5 182fcec42022b00210ad385c01f8f7f4
BLAKE2b-256 91a938c7385d292883195ec2d3834e76806778a90b72b885832ee0fce6a0475d

See more details on using hashes here.

Provenance

The following attestation bundles were made for spacecore-0.1.1-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