4

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!

Vincent Russo
  • 1,087
  • 3
  • 20
  • 33
  • Have you thought about using for loops and the internal data of each matrix? if you just create one long array of doubles, you can then initialise the final matrix with this array. – Sheldon Jan 04 '17 at 10:34

0 Answers0