AMB: The package "ndlist" is a pure-Tcl tensor manipulation package.
GitHub Repo: https://github.com/ambaker1/ndlist
Over 60 commands for tensor manipulation, including:
This package is a Tin package, so it can be easily installed and imported on the fly.
package require tin tin add -auto ndlist https://github.com/ambaker1/ndlist install.tcl tin import ndlist
Here's a few examples of what "ndlist" can do.
Full documentation is available here
set a {{1 2 3} {4 5 6} {7 8 9}} nset a {1 0} : [nget $a {0 1} :]; # {4 5 6} {1 2 3} {7 8 9} nset a : {1 0} [nget $a : {0 1}]; # {5 4 6} {2 1 3} {8 7 9}
set x [nflatten 2D {{1 2 3 4} {5 6 7 8}}]; # 1 2 3 4 5 6 7 8 set x [nreshape $x 2 2 2]; # {{1 2} {3 4}} {{5 6} {7 8}}
set x [range 10]; # 0 1 2 3 4 5 6 7 8 9 set x [nremove $x [find $x > 4]]; # 0 1 2 3 4
set x {{1 2 3} {4 5 6}} set y {{1 1 1} {2 2 2}} set z [nop2 2D $x + $y]; # {2 3 4} {6 7 8}