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.
Could some kind soul kindly tell me how to do this.
I've looked at the help for the diagonal function and i am unable to do what i wish to. Furthermore i dont understand the meaning of axis1 and axis2:
>>> help (diagonal)
Help on function diagonal in module Numeric:

diagonal(a, offset=0, axis1=0, axis2=1)
    diagonal(a, offset=0, axis1=0, axis2=1) returns all offset diagonals
    defined by the given dimensions of the array.

>>>

Thanking you,
Satya




Find out what India is talking about on - Yahoo! Answers India
Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW
-------------------------------------------------------------------------
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