I would like to repeat a vector A
of length n
on a diagonal m
times to obtain a (n+m-1) x m
matrix B
. As an example let's say A = [a;b;c;d]
, m = 4
. This should result in
B =
[a 0 0 0;
b a 0 0;
c b a 0;
d c b a;
0 d c b;
0 0 d c;
0 0 0 d]
Any suggestions for a fast way to achieve this? blkdiag(repmat(A,1,m))
does not help me in this case as it creates a (n*m) x m
matrix.
In the end I am actually just interested in the matrix product D
of a third matrix C
with B
:
D=C*B
If you see another option to obtain D
without having to generate B
, I would appreciate it. But a solution for the problem above would make me very happy as well! n
and m
will be quite big by the way.
Thanks!
B
, and multiply all the zeros over there... I just corious to know if it works... – Adiel