Can someone please give me the name or algebraic way of performing this matrix operation.
I have NxN matrix, in the example let N=2.
So A is:
A = a11 a12
a21 a22
The expanded matrix I am going for has the form:
C = A11 A12
A21 A22
C is N^2 x N^2 size, so in this example 4x4, each block in C is derived from A in a way that in corresponding position you turn on only one element in A.
I'm sorry I can't explain this any better, but here:
A11 = a11 0 A12 = 0 a12 A21 = 0 0 A22 = 0 0
0 0 0 0 a21 0 0 a22
It's as if you wrote original A matrix as sum of N^2 individual matrices and packed those terms in C (honoring the order). The other way of describing is if you stretched A in all directions.
Numerically this is easy to implement, I did it as:
C=zeros(N*N,N*N);
for (int i=0; i<N; i++) {
for (int j=0; j<N; j++) {
C(i*N+i, j*N+j)=A(i,j)
}
};
but I need to explain this operation theoretically it seems as some intuitive expansion of general matrix but I don't know algebra that well and google isn't helpful.
I also have problem describing the operation when you have matrix A, vectorize it row wise, so Avec=[a11 a12 a21 a22] and then create N^2xN^2 diagonal matrix D whose diagonal is Avec, is it mathematically correct to say D=diag(vec(A))?
You can describe the operation you are performing with a map $T: M_{n\times n}(\mathbb R) \to M_{n^2\times n^2}(\mathbb R)$, where $M_{n \times n}(\mathbb R)$ is the vector space of $n \times n$ matrices with real-valued entries. Define $T$ by $T: A \mapsto \begin{pmatrix} A_{1,1} & \ldots & A_{1,n} \\ \vdots & \ddots & \vdots \\A_{n,1} & \ldots & A_{n,n} \end{pmatrix}$, where $A_{i, j}$ is the matrix whose entries are everywhere zero except in row $i$, column $j$, and that entry is the $i,j$-th entry of $A$ itself.
As for your other question about creating a diagonal matrix with $n$ real values $a_1, \ldots, a_n$, saying $D = \text{diag}(a_1, \ldots, a_n)$ is indeed valid, and $D$ is the $n \times n$ matrix whose entries are zero except along the diagonal, where they are the values $a_1, \ldots, a_n$.