Repository navigation
The twenty-first release of Chalkboard, version 3.1.0. This is an update that rebuilds the tensor namespace into a complete tensor algebra toolkit:
- Added
tens.get,tens.set,tens.slice, andtens.stackwhich respectively get an indexed subtensor or entry of a tensor, set an indexed subtensor or entry of a tensor, slice a tensor along its leading axes, and stack tensors along a new axis, and addedtens.sum,tens.mean,tens.max, andtens.minwhich reduce either all of a tensor's entries to a number or only those along a given axis, addedtens.norm,tens.normsq, andtens.normalizewhich calculate the L0, L1, L2, or LInfinity norms of tensors entrywise, and addedtens.permutewhich permutes the axes of a tensor (like NumPy'stransposewith an axes argument), and addedtens.reshapewhich changes the shape of a tensor while requiring it to keep the same number of entries (unliketens.resize, which truncates or pads with zeros) (0d1e7ea, 5623438, d27a571, 8563f8f). - Added
tens.mulContractwhich calculates the contraction between paired axes of two tensors (like NumPy'stensordot), addedtens.dotwhich calculates the dot product (Frobenius inner product) of two tensors, addedtens.mulHadamardandmatr.mulHadamardwhich calculate the Hadamard (elementwise) products of two tensors or two matrices, respectively (75a03f0, d27a571, 8563f8f). - Added
tens.symmetrizeandtens.antisymmetrizewhich calculate the symmetric and antisymmetric parts of a tensor over any of its axes, and addedtens.isSymmetricandtens.isAntisymmetricwhich check if a tensor has those symmetries (d27a571). - Added
tens.identitywhich initializes the identity tensor (the Kronecker delta generalized to any rank) andtens.LeviCivitawhich initializes the Levi-Civita tensor (the permutation symbol) of any dimension (d27a571). - Added
tens.einsumwhich calculates Einstein summations of tensors from subscript strings (for example,"ij,jk->ik"for matrix multiplication,"ii"for a trace, or"ijk,j,k->i"for a cross product with the Levi-Civita tensor) (d27a571). - Added
tens.shapewhich returns the shape of a tensor (the array of its axis lengths), and addedtens.isShapeEqual,tens.isShapeOf, andtens.isShapeUniform(8563f8f). - Removed
tens.isSizeEqual,tens.isSizeOf, andtens.isSizeUniformbecause they were replaced bytens.isShapeEqual,tens.isShapeOf, andtens.isShapeUniform, respectively (8563f8f). - Changed
tens.sizeto return the size of a tensor as its number of entries rather than the array of its axis lengths (which is now returned bytens.shape), so that the shape, size, and rank of tensors follow their standard definitions, and accordingly renamed thesizeparameters oftens.empty,tens.fill,tens.random,tens.reshape,tens.resize,tens.zero,abal.toTensor,matr.toTensor,stat.toTensor, andvect.toTensortoshape(8563f8f). - Changed every function in the
tensnamespace to validate its tensor arguments once per call so that ragged tensors and invalid entries are rejected, where entries can be numbers (includingNaNand infinities) ornullplaceholders, which structural functions liketens.copyandtens.toStringaccept and arithmetic functions reject (537adbb). - Changed
tens.addandtens.subto broadcast like NumPy (shapes are aligned from the right, and axes of length 1 or missing axes are stretched) instead of padding mismatched positions with zeros, so tensors that cannot be broadcast together now throw an error (7a8973e, 8563f8f). - Changed
tens.multo calculate the conventional tensor (outer) product, whose axes are those of the first tensor followed by those of the second tensor, instead of interleaving the axes of the two tensors (75a03f0, 5623438). - Changed
tens.transposeto reverse the order of the axes of a tensor by moving its entries by their indices (so it now matchesmatr.transposefor rank-2 tensors) instead of reshaping the tensor with its axis lengths reversed (0d1e7ea). - Changed
tens.contractto contract a tensor over any two of its axes (specified by the newaxis1andaxis2parameters, which default to the first two axes) instead of only calculating traces of rank-2 tensors and reshaping tensors of higher ranks (b275fe5). - Changed
tens.concatto use a 0-basedaxisparameter instead of a 1-basedrankparameter, and renamed therankparameters oftens.pushandtens.pulltoaxis, so that every function in thetensnamespace counts axes from 0 (5623438). - Changed
tens.resizeto be about 98.72% faster (20785.1ms → 266.1ms for a hundred calls on a 50x50x20 tensor), which also speeds upabal.toTensor,matr.toTensor,stat.toTensor, andvect.toTensor(537adbb). - Changed
stat.deviationto be about 99.98% faster (137424.7ms → 26.7ms for a thousand calls on a ten-thousand-element array),stat.varianceto be about 99.98% faster (140074.4ms → 23.7ms for a thousand calls on a ten-thousand-element array), andstat.madto be about 99.97% faster (71022.9ms → 23.3ms for a thousand calls on a ten-thousand-element array) by calculating the mean of the array once instead of once for every element (8b63379). - Fixed
tens.add,tens.sub, andtens.mulwhich were returning nonsensical results, such as strings ornull, when one operand was a number and the other was a tensor (f865021). - Fixed
tens.concatwhich was throwing an error when concatenating along any axis other than the outermost one (f865021). - Fixed
tens.isEqualandtens.isApproxEqualwhich were returningtruefor any two numbers (rank-0 tensors), and fixedtens.isApproxEqualandtens.isZerowhich were throwing errors for tensors withNaNor infinite entries (f865021, 537adbb). - Fixed
tens.pushwhich was not checking the shape of the inserted elements and could silently create ragged tensors (537adbb). - Fixed
tens.toStringandtens.printwhich were not able to handle numbers (rank-0 tensors) ornullentries (f865021). - Fixed
stat.normandstat.normsqwhich were calculating the LInfinity norm from the largest entry of the array rather than the largest absolute value (8b63379). - Fixed
stat.kurtosiswhich was missing a division by the length of the array (for example, it was returning 5.5 instead of -1.3 for[1, 2, 3, 4, 5]), and fixedstat.skewnesswhich was dividing by one less than the length of the array, so that both now consistently use population normalization likestat.variance(8b63379).
Detailed changelog: CHANGELOG.md#v310-ricci--2026-11-02
Commits: v3.0.5...v3.1.0
Website: https://zushah.github.io/Chalkboard