On 9/15/06, Satya Upadhya <[EMAIL PROTECTED]> wrote:
Dear Friends,
my question is the following:

Suppose i have the following code:

>>> from LinearAlgebra import *

>>> from Numeric import *
>>> A = [1,2,1,3,1,3,4,1,2]
>>> B = reshape(A,(3,3))
>>> C = sum(B,1)
>>> C
array([4, 7, 7])
>>>

Now, my problem is to construct a degree matrix D which is a 3 * 3 matrix with diagonal elements 4,7,7 (obtained from the elements of C) and all off-diagonal elements equal to 0.

Is this what you want to do?

In [2]: a = array([4, 7, 7])

In [3]: diagflat(a)
Out[3]:
array([[4, 0, 0],
       [0, 7, 0],
       [0, 0, 7]])

Chuck


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to