# Ticket #11334: trac11334-numpy.rst.patch

File trac11334-numpy.rst.patch, 2.3 KB (added by fbissey, 9 years ago)

first draft at updating the documentation

• ## doc/en/numerical_sage/numpy.rst

```# HG changeset patch
# User Francois Bissey <francois.bissey@canterbury.ac.nz>
# Date 1326836640 -46800
# Node ID 8d780ec50b3fa0207163493be3e0f9847629c80d
# Parent  92c93226b64f933e0af00bbcbd1a8a79c444f43f
trac 11334: update to numpy-1.6.1 documentation.

diff --git a/doc/en/numerical_sage/numpy.rst b/doc/en/numerical_sage/numpy.rst```
 a NumPy arrays can store any type of python object. However, for speed, numeric types are automatically converted to native hardware types (i.e., ``int``, ``float``, etc.) when possible.  If the value or (i.e., ``int``, ``float``, etc.) when possible. This behavior was broken in numpy-1.6 and over, the conversion from sage object depends on the context but most of the time the conversion will have to be done manually to get a native hardware type. If the value or precision of a number cannot be handled by a native hardware type, then an array of Sage objects will be created.  You can do calculations on these arrays, but they may be slower than using native sage: l[3:6] array([ 3.,  4.,  5.]) You can do basic arithmetic operations You can do basic arithmetic operations, note how the multiplication by a sage scalar is not automatically converted, .. link sage: l+l array([  0.,   2.,   4.,   6.,   8.,  10.,  12.,  14.,  16.,  18.]) sage: 2.5*l array([0.000000000000000, 2.50000000000000, 5.00000000000000, 7.50000000000000, 10.0000000000000, 12.5000000000000, 15.0000000000000, 17.5000000000000, 20.0000000000000, 22.5000000000000], dtype=object) sage: numpy.array(2.5*l,dtype=float) array([  0. ,   2.5,   5. ,   7.5,  10. ,  12.5,  15. ,  17.5,  20. ,  22.5]) Note that ``l*l`` will multiply the elements of ``l`` componentwise. To get sage: def f(x,y): ...       return x**2+y**2 sage: from numpy import meshgrid sage: x=numpy.r_[0.0:1.0:5*j] sage: y=numpy.r_[0.0:1.0:5*j] sage: x=numpy.array[numpy.r_[0.0:1.0:5*j],dtype=float] sage: y=numpy.array[numpy.r_[0.0:1.0:5*j],dtype=float] sage: xx,yy= meshgrid(x,y) sage: xx array([[ 0.  ,  0.25,  0.5 ,  0.75,  1.  ],