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

mikera.arrayz.impl.JoinedArray 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.arrayz.impl;

import mikera.arrayz.Arrayz;
import mikera.arrayz.INDArray;
import mikera.vectorz.Op;
import mikera.vectorz.util.ErrorMessages;

/**
 * Array created by joining two arrays along a specific dimension
 * 
 * @author Mike
 *
 */
public class JoinedArray extends BaseShapedArray {
	private static final long serialVersionUID = 4929988077055768422L;

	final INDArray left;
	final INDArray right;
	final int dimension;
	final int split;
	
	private JoinedArray(INDArray left, INDArray right, int dim) {
		super(left.getShapeClone());
		this.left=left;
		this.right=right;
		dimension=dim;
		this.split=shape[dimension];
		shape[dimension]+=right.getShape(dimension);
	}
	
	public static INDArray join(INDArray a, INDArray b, int dim) {
		int n=a.dimensionality();
		if (b.dimensionality()!=n) throw new IllegalArgumentException(ErrorMessages.incompatibleShapes(a, b));
		
		for (int i=0; i=sliceCount())) {
			throw new IndexOutOfBoundsException(ErrorMessages.invalidIndex(this, x));
		}
		if (x=sliceCount())) {
				throw new IndexOutOfBoundsException(ErrorMessages.invalidIndex(this, x,y));
			}
			if (x=sliceCount())) {
				throw new IndexOutOfBoundsException(ErrorMessages.invalidIndex(this, x,y));
			}
			if (y




© 2015 - 2025 Weber Informatics LLC | Privacy Policy