private com.sun.jna.Pointer newIntParam(int rowCount) { fastmath.IntVector ib = new fastmath.IntVector(1); ib.setElementAt(0, rowCount); return(com.sun.jna.Native.getDirectBufferPointer(ib.getBuffer())); }
// Fastmath.instance.dcopy(X.size, X.getBuffer().asDoubleBuffer(), // X.getIncrement(), Y.getBuffer().asDoubleBuffer(), Y.getIncrement()); public static int dgetrf(fastmath.AbstractMatrix A, fastmath.IntVector ipiv) { return(dgetrf(A.isColMajor(), A.getRowCount(), A.getColCount(), A.getBuffer(), A. getOffset(0, 0), A.getRowCount(), ipiv.getBuffer())); }
/// <exception cref="fastmath.exceptions.NotInvertableException"/> public virtual fastmath.DoubleColMatrix invert() { fastmath.IntVector pivots = new fastmath.IntVector(getRowCount()); com.sun.jna.Pointer rowCount = newIntParam(getRowCount()); com.sun.jna.Pointer colCount = newIntParam(getColCount()); fastmath.IntVector output = new fastmath.IntVector(1); com.sun.jna.Pointer outBuffer = com.sun.jna.Native.getDirectBufferPointer(output. getBuffer()); com.sun.jna.Pointer pivotBuffer = com.sun.jna.Native.getDirectBufferPointer(pivots .getBuffer()); fastmath.LAPACK.instance.dgetrf_(rowCount, colCount, getPointer(), rowCount, pivotBuffer , outBuffer); if (output.elementAt(0) > 0) { throw new fastmath.exceptions.NotInvertableException(output.elementAt(0)); } else { if (output.elementAt(0) < 0) { throw new System.ArgumentException("the " + -output.elementAt(0) + "-th argument had an illegal value" ); } } fastmath.Vector workspace = new fastmath.Vector(1024); com.sun.jna.Pointer lwork = newIntParam(workspace.size); fastmath.LAPACK.instance.dgetri_(rowCount, getPointer(), rowCount, pivotBuffer, workspace .getPointer(), lwork, outBuffer); if (output.elementAt(0) > 0) { throw new fastmath.exceptions.NotInvertableException(output.elementAt(0)); } else { if (output.elementAt(0) < 0) { throw new System.ArgumentException("the " + -output.elementAt(0) + "-th argument had an illegal value" ); } } return(this); }