On Wed, Jul 14, 2010 at 3:04 PM, Johannes <dajo.m...@web.de> wrote:
> scalar(v,w) = v * m * w

This is not what you want to do --
http://sagemath.org/doc/tutorial/tour_functions.html explains what is
going on here.

> otherwise, if i do it this way, directly on the console it works:
> v1 = vector([1,1,1])
> v2 = vector([1,0,0])
>
> v1 * m * v2.transpose()
>
> how can i force the type in my scalarfunction to be an matrix or even a
> vector?

You can't really force types in Python functions.  If you want
something like above, you can do


sage: def scalar(v, w):
....:     return v1 * m * v2.transpose()
....:

> by the way, is there a scalarfunction defined somewhere? a
> matrixmultiplication for this seems to be a little bit much overhead for me.

This gives you the sum of the products of the corresponding entries:

sage: v1 = vector([1,1,1])
sage: v2 = vector([1,0,0])
sage: v1*v2
1

--Mike

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to