numpy.ones

blank Remember: To use numpy, you must first have SAGE line: import numpy media type="custom" key="21833672" The most basic example. The numbers are automatically of type float=numpy.float64 y1 || __ evaluate __ array([1., 1., 1., 1., 1.])
 * Reference:** http://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros.html
 * Examples:**
 * y1=numpy.ones(5) [[image:blank15.png]][[image:blank15.png]]

You can specify dtype. y2 || __ evaluate __ array([1, 1, 1, 1, 1])
 * y2=numpy.ones(5,int)[[image:blank15.png]]

Here is a 2-dimensional array. y3=numpy.ones((n,m)) y3 || __ evaluate __ array([ 1., 1.], [ 1., 1.],  [ 1., 1.],  [ 1., 1.],  [ 1., 1.])
 * n=5; m=2;

You can multiply each element by a constant. y=numpy.ones(n-1)*2/h^2 y || __ evaluate __ array([ 50., 50., 50., 50., 50., 50., 50., 50., 50.])
 * x0=0;xend=2;n=10;h=(xend-x0)/n; [[image:blank15.png]]#h=1/5[[image:blank15.png]]