Constructing a matrix of submatrices in JBLAS

22 views
Skip to first unread message

Vincent Russo

unread,
Feb 6, 2016, 1:46:03 PM2/6/16
to jblas-users

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 IO, 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!

Reply all
Reply to author
Forward
0 new messages