Carlos Córdoba wrote:
> Thanks for your quick answers. Coming from Mathematica, I was expecting to
> add lists as vectors, multiply real numbers by lists, etc, without
> sub-classing or using another types (such as vectors in sage)
>
> Do you advise me to add things to the preparser to have this behaviour or
> not? If so, how can I do it?
>   

You might get some of the functionality you want by using numpy arrays.

sage: import numpy
sage: a0 = numpy.array([1,2,3,4])
sage: a0
array([1, 2, 3, 4], dtype=object)

sage: a1 = numpy.array([5,6,7,8])
sage: a0+a1
array([6, 8, 10, 12], dtype=object)

sage: a0*2.5
array([2.50000000000000, 5.00000000000000, 7.50000000000000,
       10.0000000000000], dtype=object)

sage: 
a0*a1                                                                   
array([5, 12, 21, 32], dtype=object)

numpy and sage don't cooperate perfectly at the moment, as numpy does 
not accept sage's native types.  But, there are workarounds:

http://wiki.sagemath.org/faq#Typeissuesusingscipy.2CcvxoptornumpyfromSage

This situation may be resolved in sage-4.1.1, assuming a recently 
developed patch survives the referee process.
--
Kevin Horton

--~--~---------~--~----~------------~-------~--~----~
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
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to