[Tutor] Unity matrix
Stuart Murdock
s.e.murdock at soton.ac.uk
Tue Sep 28 23:28:42 CEST 2004
Hi Danny,
Danny Yoo wrote:
>On Tue, 28 Sep 2004, Stuart Murdock wrote:
>
>
>
>>Does anyone know if there is a builtin to numarray (or an add on ) to
>>give me a unity matrix. It would look better than trying to add ones
>>along the diagonal of a zeros.
>>
>>
>
>Hi Stuart,
>
>
>You're probably looking for the identity() function:
>
>###
>
>
Brilliant, thats exactly what I am looking for.
Stuart
>>>>numarray.identity(5)
>>>>
>>>>
>array([[1, 0, 0, 0, 0],
> [0, 1, 0, 0, 0],
> [0, 0, 1, 0, 0],
> [0, 0, 0, 1, 0],
> [0, 0, 0, 0, 1]])
>###
>
>Numarray has extensive documentation --- you can find more information on
>the array-generating functions here:
>
> http://stsdas.stsci.edu/numarray/Doc/node22.html#l2h-36
>
>
>.
>
>
>
--
Stuart Murdock Ph.D,
Research Fellow,
Dept. of Chemistry / E-Science,
University of Southampton,
Highfield, Southampton,
SO17 1BJ, United Kingdom
http://www.biosimgrid.org
More information about the Tutor
mailing list