R1 Shapes (NxM Matrices)
This guide explains the Release 1 shape model: vectors are 1D, matrices are 2D, and rectangular (rows×cols) dense matrices are supported end-to-end (allocation, indexing, transpose views, NumPy interop, and persistence).
Goal
- Create vectors and matrices with NumPy-like shape semantics.
- Use rectangular dense matrices safely.
- Know what is still square-only.
Minimal example
import pycauset as pc
A = pc.zeros((2, 3), dtype="float64")
B = pc.ones((3, 4), dtype="float64")
C = A @ B
assert A.shape == (2, 3)
assert B.shape == (3, 4)
assert C.shape == (2, 4)
Constructors vs allocators
Data constructors (matrix, vector)
- pycauset.matrix constructs from data (aligned with
np.array). - pycauset.vector constructs from data.
Important: these constructors do not interpret tuples as shapes.
import pycauset as pc
m = pc.matrix(((1, 2), (3, 4))) # 2D data -> matrix
v = pc.matrix((1, 2, 3)) # 1D data -> vector
Shape allocators (zeros, ones, empty)
Use shape-based allocation when you want size-first creation:
dtype is required for these APIs.
empty(...) does not guarantee initialization; see the API page for details.
Shape, size, and length
Release 1 aligns these basics with NumPy:
- Matrices:
shape == (rows, cols) - Vectors:
shape == (n,) size()returns the total element count.len(x)is the first dimension:rowsfor matrices,nfor vectors.
See pycauset.MatrixBase and pycauset.VectorBase.
Transpose is usually a metadata view
Most dense objects support transpose as a zero-copy view:
What is still square-only
Two distinct categories remain square-only:
- Square-only structures (by definition): triangular/causal, diagonal, symmetric/antisymmetric.
- Square-only operations (by math/implementation): determinant, inverse, many spectral routines.
For the current status list, see: