2.59 make copies of each value into matrix into a larger matrix

Do the following transformation. Take each element of matrix, and replace it by a 2 by 2 matrix with its values in places.

kron() in Matlab and KroneckerProduct in Mathematica and Maple can be used for this.

pict

Mathematica

mat = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; 
kernel = {{1, 1}, {1, 1}}; 
KroneckerProduct[mat, kernel]
 

Another method that can be used in this, but I prefer the kron method above:

mat = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; 
Map[ConstantArray[#, {2, 2}] &, mat, {2}] 
ArrayFlatten[%, 2]
 

{{1, 1, 2, 2, 3, 3}, 
 {1, 1, 2, 2, 3, 3}, 
 {4, 4, 5, 5, 6, 6}, 
 {4, 4, 5, 5, 6, 6}, 
 {7, 7, 8, 8, 9, 9}, 
 {7, 7, 8, 8, 9, 9}}
 

 

Matlab

A=[1 2 3; 4 5 6; 7 8 9] 
kernel=ones(2,2) 
kron(A,kernel)
 

     1     1     2     2     3     3 
     1     1     2     2     3     3 
     4     4     5     5     6     6 
     4     4     5     5     6     6 
     7     7     8     8     9     9 
     7     7     8     8     9     9
 

 

Maple

restart; 
mat := Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]); 
kernel :=  Matrix([[1, 1], [1, 1]]); 
LinearAlgebra:-KroneckerProduct(mat,kernel)
 

\[ \left [\begin {array}{cccccc} 1 & 1 & 2 & 2 & 3 & 3 \\ 1 & 1 & 2 & 2 & 3 & 3 \\ 4 & 4 & 5 & 5 & 6 & 6 \\ 4 & 4 & 5 & 5 & 6 & 6 \\ 7 & 7 & 8 & 8 & 9 & 9 \\ 7 & 7 & 8 & 8 & 9 & 9 \end {array}\right ] \]