I'm a physics guy, so programing is not at the top of the to-do list for me
(yet), but I might take it on, since I've been meaning to learn python as a
primer for programming in general. Also, I use sage over all the other software
they have at school, and sometimes bugs in sage keep me too busy. Getting to
know it's innards might help those situations out.
Thanks!
El nov 23, 2011, a las 5:12 a.m., Jason Grout escribió:
> On 11/23/11 1:32 AM, Tom Boothby wrote:
>> This is a little on the terse side, but it works quite generally.
>
>
> And it isn't quite the same as Callable symbolic expressions. I.e., if you
> have two variables, you can't specify the order when you create the matrix.
>
> On the other hand, doing something like
>
>
> sage: var('x,y')
> (x, y)
> sage:
> M=matrix(CallableSymbolicExpressionRing((x,y)),[[x+2*y,sin(x),cos(y)],[x,y,x^2+y]])
> sage: M(1,2)
> [ 5 sin(1) cos(2)]
> [ 1 2 3]
>
> Really behaves like a callable expression. It prints sort of ugly, though:
>
> sage: M
> [(x, y) |--> x + 2*y (x, y) |--> sin(x) (x, y) |--> cos(y)]
> [ (x, y) |--> x (x, y) |--> y (x, y) |--> x^2 + y]
>
>
> That could be improved, e.g., see the printing for vectors over callable
> symbolic rings, which print the arguments outside of the vector:
>
> sage: M[0]
> (x, y) |--> (x + 2*y, sin(x), cos(y))
>
>
> Note that the syntax f(x,y)=... is preparsed as:
>
> sage: preparse('f(x,y)=[[x^2,y],[x,y]]')
> '__tmp__=var("x,y"); f =
> symbolic_expression([[x**Integer(2),y],[x,y]]).function(x,y)'
>
> so really all that is needed is changing the symbolic_expression function to
> create a symbolic matrix if a list of lists (or tuples) is given, and then
> adding a .function() method to a symbolic matrix to give a matrix with base
> ring CallableSymbolicExpressionRing (as above). Bonus points if you make
> those matrices print out with the arguments first, instead of having the
> arguments inside of each element. I've done this for vectors [1], so that
> could be a pattern for what to do here.
>
> Thanks,
>
> Jason
>
> [1] See the symbolic_expression code, which has this case:
>
> elif isinstance(x, (tuple,list)):
> return vector(SR,x)
>
> --
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/sage-support
> URL: http://www.sagemath.org
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org