Constructing a matrix of submatrices in JBLAS

176 views Asked by At

Using JBLAS, I've defined the following matrices:

DoubleMatrix I = DoubleMatrix.ones(5,5);
DoubleMatrix O = DoubleMatrix.zeros(5,5); 
DoubleMatrix B = new DoubleMatrix(new double[][]
            { {1,1,0,0,0}, {1,1,1,0,0}, {0,1,1,1,0}, {0,0,1,1,1}, {0,0,0,1,1} });

I want to construct a matrix A that is composed of the I, O, and B matrices such that A has the following form:

A = [ B I O O O; 
      I B I O O; 
      O I B I O; 
      O O I B I; 
      O O O I B ];

There are functions in JBLAS that support horizontal and vertical concatenation, but I wonder if there is a cleaner way in which to construct A that doesn't involve calling these functions for each submatrix. Any help would be greatly appreciated, and thanks again!

0

There are 0 answers