[sage-support] Re: Filling a matrix with functions
On Tuesday, March 24, 2015 at 12:49:57 PM UTC+1, Oscar Alberto Castillo Felisola wrote: I'd like to obtain something like f11 = function('f11', t,r) f12 = function('f12', t,r) f21 = function('f21', t,r) f22 = function('f22', t,r) M = matrix(2,2, [[f11, f12], [f21, f22]]) Since this is doable via a functional mapping from the indices to the desired objects, you can use the matrix to do this via the lambda operator: sage: var(t r) (t, r) sage: matrix(5, 5, lambda x,y : function(f%s%s % (x,y), t, r)) [f00(t, r) f01(t, r) f02(t, r) f03(t, r) f04(t, r)] [f10(t, r) f11(t, r) f12(t, r) f13(t, r) f14(t, r)] [f20(t, r) f21(t, r) f22(t, r) f23(t, r) f24(t, r)] [f30(t, r) f31(t, r) f32(t, r) f33(t, r) f34(t, r)] [f40(t, r) f41(t, r) f42(t, r) f43(t, r) f44(t, r)] It's zero-based indexed, as everything else in Python, but you can fix it easily. Hope this helps. -- Harald -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Filling a matrix with functions
Thank you very much Harald! -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Filling a matrix with functions
On Tuesday, March 24, 2015 at 11:05:21 AM UTC+1, Oscar Alberto Castillo Felisola wrote: but for huge matrices it is boring and make no sense. Can you describe a rule or pattern how this matrix should be filled? -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Filling a matrix with functions
I'd like to obtain something like f11 = function('f11', t,r) f12 = function('f12', t,r) f21 = function('f21', t,r) f22 = function('f22', t,r) M = matrix(2,2, [[f11, f12], [f21, f22]]) Note that in principle all the functions depend on the same variables. If the assignation of functions could be used as components of a metric of sagemanifold, would be even better. -- You received this message because you are subscribed to the Google Groups sage-support group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.