All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mikera.matrixx.impl.BlockDiagonalMatrix Maven / Gradle / Ivy

Go to download

Fast double-precision vector and matrix maths library for Java, supporting N-dimensional numeric arrays.

There is a newer version: 0.67.0
Show newest version
package mikera.matrixx.impl;

import java.util.Arrays;

import mikera.arrayz.ISparse;
import mikera.matrixx.AMatrix;
import mikera.vectorz.util.IntArrays;

/**
 * Class representing a square, block diagonal matrix. 
 * 
 * Each block on the main diagonal must be a square matrix, but need not itself be diagonal.
 * 
 * @author Mike
 *
 */
public class BlockDiagonalMatrix extends ABlockMatrix implements ISparse {
	private static final long serialVersionUID = -8569790012901451992L;

	private final AMatrix[] mats;
	private final int[] sizes;
	private final int[] offsets;
	private final int blockCount;
	
	private BlockDiagonalMatrix(AMatrix[] newMats) {
		super(sumRowCounts(newMats),sumColumnCounts(newMats));
		blockCount=newMats.length;
		mats=newMats;
		sizes=new int[blockCount];
		offsets=new int[blockCount+1];
		int totalSize=0;
		for (int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy