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

mikera.matrixx.impl.ADenseArrayMatrix 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 mikera.arrayz.INDArray;
import mikera.arrayz.impl.IDenseArray;
import mikera.matrixx.AMatrix;
import mikera.vectorz.AVector;
import mikera.vectorz.Op2;
import mikera.vectorz.Tools;
import mikera.vectorz.Vector;
import mikera.vectorz.Vectorz;
import mikera.vectorz.impl.ADenseArrayVector;
import mikera.vectorz.impl.AStridedVector;
import mikera.vectorz.impl.ArraySubVector;
import mikera.vectorz.util.DoubleArrays;
import mikera.vectorz.util.ErrorMessages;

/**
 * Abstract base class for matrices wrapping a dense (rows*cols) subset of a double[] array
 * @author Mike
 */
public abstract class ADenseArrayMatrix extends AStridedMatrix implements IFastRows, IDenseArray {
	private static final long serialVersionUID = -2144964424833585026L;

	protected ADenseArrayMatrix(double[] data, int rows, int cols) {
		super(data, rows, cols);
	}

	@Override
	public abstract int getArrayOffset();
	
	@Override
	public boolean isPackedArray() {
		return (getArrayOffset()==0) && (data.length ==(rows*cols));
	}
	
	@Override
	public boolean isZero() {
		return DoubleArrays.isZero(data, getArrayOffset(), rows*cols);
	}
	
	@Override
	public boolean isUpperTriangular() {
		// triangular test, taking into account cache layout to access via rows
		int rc=rowCount();
		int cc=columnCount();
		int offset=getArrayOffset();
		for (int i=1; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy