I am looking for a matrix operation of the form: B = M*A*N
where A
is some general square matrix and M
and N
are the matrices I want to find.
Such that the columns of B
are the diagonals of A
. The first column the main diagonal, the second the diagonal shifted by 1 from the main and so on.
e.g. In MATLAB syntax:
A = [1, 2, 3
4, 5, 6
7, 8, 9]
and
B = [1, 2, 3
5, 6, 4
9, 7, 8]
Edit: It seems a pure linear algebra solution doesn't exist. So I'll be more precise about what I was trying to do:
For some vector v
of size 1 x m
. Then define C = repmat(v,m,1)
. My matrix is A = C-C.';
.
Therefore, A
is essentially all differences of values in v
but I'm only interested in the difference up to some distance between values.
Those are the diagonals of A
; but m
is so large that the construction of such m x m
matrices causes out-of-memory issues.
I'm looking for a way to extract those diagonals in a way that is as efficient as possible (in MATLAB).
Thanks!
M
andN
? IsN
=M
^-1? That would simplify the problem – titus.andronicusB=M*A*N
) and two unknowns (M
andN
), need more information to solve this! Or do you just want a function which sets up matrixB
for a givenA
? – Wolfie