3 ms·
Coffeescript-inspired syntax is nice, but unfortunately Matlab is clearly superior for anything mathematical than most other languages, so drawing some inspirat
by tomp 15y ago
Coffeescript-inspired syntax is nice, but unfortunately Matlab is clearly superior for anything mathematical than most other languages, so drawing some inspiration from it wouldn't hurt...
For example:
m1 = matrix([1, 2, 5],
[2, -1, 6],
[5, 10, -1])
why not adapt a simpler syntax for constructing multi-dimensional arrays:
m1 = [1 2 5; # commas are optional
2, -1, 6;
5, 10, -1]
Also, a special constructor for matrices and vectors is redundant - in a mathematical language, a list/array is the special case, not a matrix/vector. Besides, vectors are just a special case of matrices, no need to treat them differently, especially since the dot product is not overloaded in Calculize.
Matlab also wins by having a special syntax for matrix transpose. Now, this depends on the implementation ( AFAIK, Matlab doesn't actually transpose the matrix, it simply uses a different algorithm for further calculations), but would still be nice, since it's often useful (necessary) when trying to multiply matrices.
- sesqu 15y agoI don't think you should consider vectors a special case of matrices - that makes tensors difficult to handle. The other way around generalizes better.
- JadeNB 15y ago> I don't think you should consider vectors a special case of matrices - that makes tensors difficult to handle. The other way around generalizes better. I guess (from the first sentence) that you mean to regard matrices as a special case of tensors (which certainly generalises well), rather than of vectors (which is possible but ugly)?
- sesqu 15y agoNo, I certainly do mean to regard matrices as a special case of vectors. While it's true that one rarely needs more than 3 dimensions to their array, I see no point in setting an upper limit.
- tomp 15y agoProbably this is just a lapsus lingue, but what you are saying makes no sense. Vectors are a special case of matrices, which are a special case of tensors (finally, scalars, which is just a fancy name for plain numbers, are a special case of vectors). Although there are many mathematical representation of all these objects (geometrical, functional, etc.), they can be written as multidimensional arrays (after selecting for a base). Thus, scalars are 1x1 matrices, and a vector of size n is actually a nx1 matrix. Although a common high-school notation of a vector is x = (1, 2, 3), a vector is actually x = [ 1 2 3 ] Tensors are the extension of matrices to further dimensions.
- sesqu 15y agoRight. And how would you characterize the 4-dimensional extension, in terms of the first three? Or do you simply draw the line at two dimensions, figuring that's as much as anyone will ever need?
- JadeNB 15y agoWhat are the two dimensions of which you speak here? The 'row' and 'column' dimensions of a matrix? If so, that's exactly what tensors do: A matrix is a 2-tensor (better, a (1, 1)-tensor, but let's not get into that). If you want an m-dimensional generalisation, just use an m-tensor.