3 ms·
Well... MATLAB (matrix laboratory), and its GNU counterpart Octave kind of do this. The primary data type is an n-dimensional matrix. Of course, there's a lot t
by MayeulC 6y ago
Well... MATLAB (matrix laboratory), and its GNU counterpart Octave kind of do this. The primary data type is an n-dimensional matrix. Of course, there's a lot to say about the rest of the language (and it's untyped/interpreted, though BLAS handles matrix operations so it's extremely fast for vectored code), but it is very nice to work with vast amounts of data in it, and numpy tries to mimic parts of its syntax. That's something I would really like to see in other languages, but depending on the use-case, you can also mix languages...
u=rand(5) % 5-by-5 matrix
v=rand(5,5,5,5,5,5) % 6-dimensional matrix, each dimension 5 long
v2=v(1,2,3,:,:) % 1-by-1-by-1-by-5-by-5 matrix
w=u(:,3) % take every line in the third column, so that's a vertical 5-by-1 vector
x=5*w*w' % matrix multiplication of w and its transpose, times a scalar
y=rand(5).*x % element-wise multiplication