Problem
bocpy ships a dense 2-D Matrix and nothing else. Anything users do that is naturally N-dimensional — image stacks, batched feature tensors, multi-channel audio, simulation grids, anything with a leading batch axis — has to be flattened by hand or coordinated as a Python list of Matrix objects. Both lose the in-place, cown-friendly arithmetic that makes Matrix worth using in the first place.
Desired functionality
A first-class Tensor Python type with arbitrary-rank contiguous storage of doubles, the same arithmetic surface as Matrix (elementwise binary, elementwise unary, scalar binary, aggregates with optional axis=), and the same cown / sub-interpreter round-trip story. Users should be able to put a Tensor inside a Cown, mutate it from a behavior, and observe the change in the next behavior, exactly as they do today with Matrix.
Constraints
- Contiguous storage only — no strides, no views, no transpose-without-copy.
- Same-shape binary ops only; mismatched shapes raise immediately.
- No matmul on
Tensor. Rank-2 linear algebra stays on Matrix.
Matrix is untouched by this work.
Out of scope
Broadcasting, full Matrix-parity indexing, Matrix/Tensor unification, views, reshape, fancy indexing.
Open questions
- Are rank-0 tensors a valid shape?
- Does a rank-reducing aggregate on a rank-
k Tensor always return a rank-k-1 Tensor, including the rank-1 → rank-0 case?
- Constructor shape: a single positional shape tuple, named factory methods, or both?
Problem
bocpy ships a dense 2-D
Matrixand nothing else. Anything users do that is naturally N-dimensional — image stacks, batched feature tensors, multi-channel audio, simulation grids, anything with a leading batch axis — has to be flattened by hand or coordinated as a Python list ofMatrixobjects. Both lose the in-place, cown-friendly arithmetic that makesMatrixworth using in the first place.Desired functionality
A first-class
TensorPython type with arbitrary-rank contiguous storage of doubles, the same arithmetic surface asMatrix(elementwise binary, elementwise unary, scalar binary, aggregates with optionalaxis=), and the same cown / sub-interpreter round-trip story. Users should be able to put aTensorinside aCown, mutate it from a behavior, and observe the change in the next behavior, exactly as they do today withMatrix.Constraints
Tensor. Rank-2 linear algebra stays onMatrix.Matrixis untouched by this work.Out of scope
Broadcasting, full Matrix-parity indexing, Matrix/Tensor unification, views, reshape, fancy indexing.
Open questions
kTensor always return a rank-k-1Tensor, including the rank-1 → rank-0 case?