Sunday, October 18, 2015

matrices - Is there a way to extract the diagonal from a matrix with simple matrix operations



I have a square matrix A. Is there a way I can apply operations like addition, subtraction, matrix multiplication, matrix inverse and transpose to get the diagonal of the matrix. For example having:
(1234)


I would like to get (1,4).




P.S. based on the conversation with mvw, here is a better description:



I am on board of an alien space ship and the board computer allows only matrix operations but access to the individual matrix elements is blocked. I can only use addition, subtraction, matrix multiplication, matrix inverse and transpose. No access to individual row/column/element. I can only create matrices of any dimension (1xn), (nx1), (nx2n) that have all zeros or all ones. Is there a way for me to get a diagonal vector?


Answer



Note: This solution is not working for the updated question.
D=diag(a11,,ann)=ni=1P(i)AP(i)


where P(i) is the projection on the i-th coordinate:

(P(i))jk=δijδjk(i,j,k{1,,n})

and δ is the Kronecker delta (1 for same index values, otherwise 0).



Transforming the diagonal matrix D into a row vector can be done by
d=uTD


where each of the n components of u is 1.

u=(1,1,,1)T

Combining both gives
d=iuTP(i)AP(i)=ieTiAP(i)

where ei is the i-th canonical base vector.



Example:




octave> A, P1, P2, u
A =
1 2
3 4

P1 =
1 0
0 0


P2 =
0 0
0 1

u =
1
1

octave> u'*(P1*A*P1+P2*A*P2)
ans =

1 4

No comments:

Post a Comment

analysis - Injection, making bijection

I have injection f:AB and I want to get bijection. Can I just resting codomain to f(A)? I know that every function i...