ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 14 Aug 2017 21:58:15 +0200Defining functions acting on matrix elements?https://ask.sagemath.org/question/38524/defining-functions-acting-on-matrix-elements/Hi guys, how can I define a function able to act on the elements of a matrix, with the matrix being the input to the function? I would like the function to be a callable symbolic expression, which I hear can be differentiated and so on, whereas other entities cannot.
Here's a sample of what I mean:
f(M) = M[0,0]+M[1,1]
that is, the user will ensure that `M` is correctly defined as a matrix of size at least 2x2 before being passed to `f(M)`, but at this stage the symbol `M` is intended just as a dummy variable, similar to `z` in a definition like `g(z) = conjugate(z)`. Unfortunately, my code does not seem to work...
Thank you for your suggestions!AskerMon, 14 Aug 2017 21:58:15 +0200https://ask.sagemath.org/question/38524/