@Override public IComplexNDArray gemv(IComplexNumber alpha, IComplexNDArray a, IComplexNDArray x, IComplexNumber beta, IComplexNDArray y) { LinAlgExceptions.assertVector(x, y); LinAlgExceptions.assertMatrix(a); level2().gemv('N', 'N', alpha, a, x, beta, y); return y; }
public BaseTransformOp(INDArray x, INDArray y, INDArray z, long n) { super(x, y, z, n); if (y != null) LinAlgExceptions.assertSameLength(x, y, z); else LinAlgExceptions.assertSameLength(x, z); }
public BaseTransformOp(INDArray x, INDArray z) { super(x, z); LinAlgExceptions.assertSameShape(x, z); }
public static void assertVector(INDArray... arr) { for (INDArray a1 : arr) assertVector(a1); }
public static void assertMatrix(INDArray... arr) { for (INDArray a1 : arr) assertMatrix(a1); }
public BaseTransformOp(INDArray x, INDArray z) { super(x, z); LinAlgExceptions.assertSameLength(x, z); LinAlgExceptions.assertSameShape(x, z); }
@Override public INDArray mmuli(INDArray other, INDArray result) { LinAlgExceptions.assertMultiplies(this, other);
@Override public IComplexNumber nrm2(IComplexNDArray x) { LinAlgExceptions.assertVector(x); return level1().nrm2(x); }
@Override public IComplexNDArray gemm(IComplexNumber alpha, IComplexNDArray a, IComplexNDArray b, IComplexNumber beta, IComplexNDArray c) { LinAlgExceptions.assertMatrix(a, b, c); level3().gemm(BlasBufferUtil.getCharForTranspose(a), BlasBufferUtil.getCharForTranspose(b), BlasBufferUtil.getCharForTranspose(c), alpha, a, b, beta, c); return c; }
LinAlgExceptions.assertMultiplies(this, other);
@Override public INDArray gemv(Number alpha, INDArray a, INDArray x, double beta, INDArray y) { LinAlgExceptions.assertVector(x, y); LinAlgExceptions.assertMatrix(a); level2().gemv(BlasBufferUtil.getCharForTranspose(a), BlasBufferUtil.getCharForTranspose(x), alpha.doubleValue(), a, x, beta, y); return y; }
@Override public double nrm2(INDArray x) { LinAlgExceptions.assertVector(x); return level1().nrm2(x); }
/** * in place subtraction of two matrices * * @param other the second ndarray to subtract * @param result the result ndarray * @return the result of the subtraction */ @Override public INDArray subi(INDArray other, INDArray result) { if (other.isScalar()) { return subi(other.getDouble(0), result); } if (isScalar()) { return other.rsubi(getDouble(0), result); } if(!Shape.shapeEquals(this.shape(),other.shape())) { int[] broadcastDimensions = Shape.getBroadcastDimensions(this.shape(),other.shape()); Nd4j.getExecutioner().exec(new BroadcastSubOp(this,other,result,broadcastDimensions),broadcastDimensions); return result; } LinAlgExceptions.assertSameShape(other, result); Nd4j.getExecutioner().exec(new OldSubOp(this, other,result)); if (Nd4j.ENFORCE_NUMERICAL_STABILITY) Nd4j.clearNans(result); return result; }
@Override public INDArray gemm(double alpha, INDArray a, INDArray b, double beta, INDArray c) { LinAlgExceptions.assertMatrix(a, b, c); if (a.data().dataType() == DataBuffer.Type.FLOAT) { return gemm((float) alpha, a, b, (float) beta, c); } level3().gemm(BlasBufferUtil.getCharForTranspose(a), BlasBufferUtil.getCharForTranspose(b), BlasBufferUtil.getCharForTranspose(c), alpha, a, b, beta, c); return c; }
@Override public INDArray axpy(Number da, INDArray dx, INDArray dy) { // if(!dx.isVector()) // throw new IllegalArgumentException("Unable to use axpy on a non vector"); LinAlgExceptions.assertSameLength(dx, dy); level1().axpy(dx.length(), da.doubleValue(), dx, dy); return dy; }
LinAlgExceptions.assertMultiplies(this, other);
@Override public INDArray gemv(double alpha, INDArray a, INDArray x, double beta, INDArray y) { LinAlgExceptions.assertVector(x, y); LinAlgExceptions.assertMatrix(a); if (a.data().dataType() == DataBuffer.Type.FLOAT) { // DefaultOpExecutioner.validateDataType(DataBuffer.Type.FLOAT, a, x, y); return gemv((float) alpha, a, x, (float) beta, y); } else { level2().gemv('N', 'N', alpha, a, x, beta, y); } return y; }
@Override public INDArray copy(INDArray x, INDArray y) { LinAlgExceptions.assertVector(x, y); level1().copy(x, y); return y; }
/** * in place (element wise) multiplication of two matrices * * @param other the second ndarray to multiply * @param result the result ndarray * @return the result of the multiplication */ @Override public INDArray muli(INDArray other, INDArray result) { if (other.isScalar()) { return muli(other.getDouble(0), result); } if (isScalar()) { return other.muli(getDouble(0), result); } if(!Shape.shapeEquals(this.shape(),other.shape())) { int[] broadcastDimensions = Shape.getBroadcastDimensions(this.shape(),other.shape()); Nd4j.getExecutioner().exec(new BroadcastMulOp(this,other,result,broadcastDimensions),broadcastDimensions); return result; } LinAlgExceptions.assertSameShape(other, result); Nd4j.getExecutioner().exec(new OldMulOp(this, other, result, length())); if (Nd4j.ENFORCE_NUMERICAL_STABILITY) Nd4j.clearNans(result); return result; }
@Override public INDArray gemm(float alpha, INDArray a, INDArray b, float beta, INDArray c) { LinAlgExceptions.assertMatrix(a, b, c); if (a.data().dataType() == DataBuffer.Type.DOUBLE) { return gemm((double) alpha, a, b, (double) beta, c); } level3().gemm(BlasBufferUtil.getCharForTranspose(a), BlasBufferUtil.getCharForTranspose(b), BlasBufferUtil.getCharForTranspose(c), alpha, a, b, beta, c); return c; }