| Hi, is it possible to define totally symbolic matrices. Something like So that c[i,j] = sum(a[i,k]*b[k,i],k,1,M) or do you really always need an non-symblic matrix size? If you really always need a non-symblic matrix type, is it possible to define the symbolic variables automatically? Something like Thanks! Manuel |
| There is the Tensor module in sympy. If that is the type of thing that you're looking for (ie explicit indices). The was some code put on the sage devel group last year: abstract matrics, which allows basic manipulation of abstract matrices and vectors. It's not complete, but it does the basics and should be easy to extend if you need more. As far as I can tell, it hasn't been worked on since the original postings. I hope it's ok if I post the code here: |
| I'm not sure if there's a way to define a symbolic matrix the way you describe above. However, one could create a matrix populated only by distinct symbolic variables. Here's a quick, though supposedly not quickest, way to do so: The second line just creates a string with the variable names $a_{ij}$ for $i,j \in \mathbb{Z}_n$ and the third parses the string and creates a list of the symbolic variables. I can now create another matrix $B$ and multiply them: It's not completely automatic, and perhaps not pretty, but I hope it helps.
This isn't a very "beautiful" method, but I can't think of anything better. :-) Anybody know of a cleaner approach? By the way, I would put an underscore between the indices, so the variables would read: "a_1_0", "b_3_5", and "c_23_829" (just an example). And would this method work for sparse matrices?
Kelvin Li (Apr 12 '11)
I agree that it's not pretty, but even if Sage had the ability to define these "purely symbolic" matrices one would have to call the elements _something_. Perhaps this sort fo thing would happen in the __init__() method. Also, I use the notation "a_ij" instead of "a_i_j" because when you execute "show(a_ij)", or enable typesetting in the Sage Notebook, it looks prettier. :)
cswiercz (Apr 12 '11)
Ignoring all else, I would like to reference and name the elements consistently: a[1,2] being printed exactly as "a[1,2]". Then again, I can't ignore the facts. :-)
Kelvin Li (Apr 12 '11)
You say it's not the quickest way to do this (*this* being define lots of symbolic variables and populate a matrix with them), so what is the quickest way?
benjaminfjones (Apr 19 '11) |
Asked: Apr 12 '11
Seen: 746 times
Last updated: Apr 13 '11
powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.