On 9/15/06, Satya Upadhya <sat...@ya...> 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
|