namedtensor / notation

108 stars 5 forks source link

Matrix power #69

Open rightaditya opened 3 years ago

rightaditya commented 3 years ago

I didn't see it in the document, so I assume there isn't a decided-upon notation for it yet, but are there any suggestions for how to handle matrix powers? For example, I need to distinguish between f(M) = M^2 as the elementwise product of M and M (e.g., f: R^{i,j} -> R^{i,j}) and g(M) = M^2 as the matrix product of M and M over (e.g., g: R^{i,i} -> R^{j,k}).

I could imagine something analogous to \odot and \ndot where specifying the axis makes it a matrix product rather than elementwise product. But the obvious first-pass attempt of M^2_{ax} isn't great---it looks too similar to indexing, even though it's missing the actual index, and the elementwise version M^2 is too easy to misread. Putting the axis under the variable (e.g., \underset{ax}{M^2}) seems a bit better but could be misleading if applied to a long expression (e.g., \underset{ax}{(M + N + P)^2}, where it might appear to apply only to N). Something like M\overset{2}{\odot} and M\overset{2}{\ndot{ax}} might work. It takes up a fair bit of vertical space, but it's not that much worse than the amount you lose anyway with the underset axis.