/** * Inserts matrix 'src' into matrix 'dest' with the (0,0) of src at (row,col) in dest. * This is equivalent to calling extract(src,0,src.numRows,0,src.numCols,dest,destY0,destX0). * * @param src matrix that is being copied into dest. Not modified. * @param dest Where src is being copied into. Modified. * @param destY0 Start row for the copy into dest. * @param destX0 Start column for the copy into dest. */ public static void insert( ReshapeMatrix64F src, ReshapeMatrix64F dest, int destY0, int destX0) { extract(src,0,src.numRows,0,src.numCols,dest,destY0,destX0); }
public void packBlock(DenseMatrix64F dstBlock, int blockId, int destX0, int destY0) { int startIndex = blockStarts[blockId]; int endIndex = blockStarts[blockId + 1]; CommonOps.extract(this, startIndex, endIndex, startIndex, endIndex, dstBlock, destX0, destY0); }
/** * Inserts matrix 'src' into matrix 'dest' with the (0,0) of src at (row,col) in dest. * This is equivalent to calling extract(src,0,src.numRows,0,src.numCols,dest,destY0,destX0). * * @param src matrix that is being copied into dest. Not modified. * @param dest Where src is being copied into. Modified. * @param destY0 Start row for the copy into dest. * @param destX0 Start column for the copy into dest. */ public static void insert( ReshapeMatrix64F src, ReshapeMatrix64F dest, int destY0, int destX0) { extract(src,0,src.numRows,0,src.numCols,dest,destY0,destX0); }
public static void extractColumns(DenseMatrix64F source, int[] srcColumns, DenseMatrix64F dest, int destStartColumn) { for (int i : srcColumns) { CommonOps.extract(source, 0, source.getNumRows(), i, i + 1, dest, 0, destStartColumn); destStartColumn++; } }
@Override protected void packRelevantJacobianPart(DenseMatrix64F relevantPartToPack, DenseMatrix64F fullJacobian) { CommonOps.extract(fullJacobian, 3, 6, 0, fullJacobian.getNumCols(), relevantPartToPack, 0, 0); }
public static <RowKeyType> void extractVectorBlock(DenseMatrix64F vectorBlockToPack, DenseMatrix64F bigVector, RowKeyType rowKey, Map<? super RowKeyType, Integer> rowStartIndices, Map<? super RowKeyType, Integer> sizes) { int rowStartIndex = rowStartIndices.get(rowKey); int stateSize = sizes.get(rowKey); vectorBlockToPack.reshape(stateSize, 1); CommonOps.extract(bigVector, rowStartIndex, rowStartIndex + stateSize, 0, 1, vectorBlockToPack, 0, 0); }
public static void extractRows(DenseMatrix64F source, int[] srcRows, DenseMatrix64F dest, int destStartRow) { for (int i : srcRows) { CommonOps.extract(source, i, i + 1, 0, source.getNumCols(), dest, destStartRow, 0); destStartRow++; } }
@Override protected void packRelevantJacobianPart(DenseMatrix64F relevantPartToPack, DenseMatrix64F fullJacobian) { CommonOps.extract(fullJacobian, 0, 3, 0, fullJacobian.getNumCols(), relevantPartToPack, 0, 0); }
public static void extractColumns(DenseMatrix64F source, int[] srcColumns, DenseMatrix64F dest, int destStartColumn) { for (int i : srcColumns) { CommonOps.extract(source, 0, source.getNumRows(), i, i + 1, dest, 0, destStartColumn); destStartColumn++; } }
public static <RowKeyType> void extractVectorBlock(DenseMatrix64F vectorBlockToPack, DenseMatrix64F bigVector, RowKeyType rowKey, Map<? super RowKeyType, Integer> rowStartIndices, Map<? super RowKeyType, Integer> sizes) { int rowStartIndex = rowStartIndices.get(rowKey); int stateSize = sizes.get(rowKey); vectorBlockToPack.reshape(stateSize, 1); CommonOps.extract(bigVector, rowStartIndex, rowStartIndex + stateSize, 0, 1, vectorBlockToPack, 0, 0); }
/** * Returns a vector from the PCA's basis. * * @param which Which component's vector is to be returned. * @return Vector from the PCA basis. */ public double[] getBasisVector( int which ) { if( which < 0 || which >= numComponents ) throw new IllegalArgumentException("Invalid component"); DenseMatrix64F v = new DenseMatrix64F(1,A.numCols); CommonOps.extract(V_t,which,which+1,0,A.numCols,v,0,0); return v.data; }
@Override public void process() { DenseMatrix64F A = ((VariableMatrix)inputs.get(0)).matrix; findExtents(A,inputs,1,extents); output.matrix.reshape(extents.row1-extents.row0,extents.col1-extents.col0); CommonOps.extract(A,extents.row0,extents.row1,extents.col0,extents.col1,output.matrix,0,0); } };
public void correctState(DenseMatrix64F correction) { int startIndex = 0; for(int i = 0; i < processModelElementGroups.size(); i++) { int stateMatrixSize = processModelElementGroups.get(i).getStateMatrixSize(); correctionBlock.reshape(stateMatrixSize, 1); CommonOps.extract(correction, startIndex, startIndex + stateMatrixSize, 0, 1, correctionBlock, 0, 0); processModelElementGroups.get(i).correctState(correctionBlock); startIndex += stateMatrixSize; } }
private void removeConstraintFromActiveSet(int indexInActiveSet) { if(indexInActiveSet<linearEqualityConstraintA.numRows) throw new RuntimeException("shouldn't try to remove equality constraint"); inActiveSet[indexInActiveSet]=false; DenseMatrix64F tmpA = new DenseMatrix64F(activeSetA); CommonOps.extract(tmpA, indexInActiveSet+1, tmpA.numRows, 0, tmpA.numCols, activeSetA, indexInActiveSet, 0); activeSetA.reshape(activeSetA.numRows-1,activeSetA.numCols, true); DenseMatrix64F tmpB = new DenseMatrix64F(activeSetB); CommonOps.extract(tmpB, indexInActiveSet+1, tmpB.numRows, 0, tmpB.numCols, activeSetB, indexInActiveSet, 0); activeSetB.reshape(activeSetB.numRows-1,activeSetB.numCols, true); }
private void removeConstraintFromActiveSet(int indexInActiveSet) { if(indexInActiveSet<linearEqualityConstraintA.numRows) throw new RuntimeException("shouldn't try to remove equality constraint"); inActiveSet[indexInActiveSet]=false; DenseMatrix64F tmpA = new DenseMatrix64F(activeSetA); CommonOps.extract(tmpA, indexInActiveSet+1, tmpA.numRows, 0, tmpA.numCols, activeSetA, indexInActiveSet, 0); activeSetA.reshape(activeSetA.numRows-1,activeSetA.numCols, true); DenseMatrix64F tmpB = new DenseMatrix64F(activeSetB); CommonOps.extract(tmpB, indexInActiveSet+1, tmpB.numRows, 0, tmpB.numCols, activeSetB, indexInActiveSet, 0); activeSetB.reshape(activeSetB.numRows-1,activeSetB.numCols, true); }
/** * Inserts matrix 'src' into matrix 'dest' with the (0,0) of src at (row,col) in dest. * This is equivalent to calling extract(src,0,src.numRows,0,src.numCols,dest,destY0,destX0). * * @param src matrix that is being copied into dest. Not modified. * @param dest Where src is being copied into. Modified. * @param destY0 Start row for the copy into dest. * @param destX0 Start column for the copy into dest. */ public static void insert( RealMatrix64F src, RealMatrix64F dest, int destY0, int destX0) { extract(src, 0, src.getNumRows(), 0, src.getNumCols(), dest, destY0, destX0); }
public static void extractColumns(DenseMatrix64F source, TIntArrayList srcColumns, DenseMatrix64F dest, int destStartColumn) { for (int i = 0; i < srcColumns.size(); i++) { int index = srcColumns.get(i); CommonOps.extract(source, 0, source.getNumRows(), index, index + 1, dest, 0, destStartColumn); destStartColumn++; } }
public static void extractColumns(DenseMatrix64F source, TIntArrayList srcColumns, DenseMatrix64F dest, int destStartColumn) { for (int i = 0; i < srcColumns.size(); i++) { int index = srcColumns.get(i); CommonOps.extract(source, 0, source.getNumRows(), index, index + 1, dest, 0, destStartColumn); destStartColumn++; } }
private void computeNullspace(DenseMatrix64F nullspaceToPack, DenseMatrix64F QToPack, DenseMatrix64F matrixToComputeNullspaceOf, int nullity) { nullspaceToPack.reshape(matrixToComputeNullspaceOf.getNumCols(), nullity); decomposer.decompose(matrixToComputeNullspaceOf); sigma.reshape(matrixToComputeNullspaceOf.getNumCols(), matrixToComputeNullspaceOf.getNumRows()); decomposer.getW(sigma); v.reshape(matrixToComputeNullspaceOf.getNumCols(), matrixToComputeNullspaceOf.getNumCols()); QToPack.reshape(matrixToComputeNullspaceOf.getNumCols(), matrixToComputeNullspaceOf.getNumCols() - nullity); boolean transposed = false; decomposer.getV(v, transposed); CommonOps.extract(v, 0, v.getNumRows(), 0, v.getNumCols() - nullity, QToPack, 0, 0); CommonOps.extract(v, 0, v.getNumRows(), v.getNumCols() - nullity, v.getNumCols(), nullspaceToPack, 0, 0); }
private void computeNullspace(DenseMatrix64F nullspaceToPack, DenseMatrix64F matrixToComputeNullspaceOf, int nullity) { int size = matrixToComputeNullspaceOf.getNumCols(); int rank = matrixToComputeNullspaceOf.getNumRows(); nullspaceToPack.reshape(size, nullity); Q.reshape(size, size); transposed.reshape(size, rank); CommonOps.transpose(matrixToComputeNullspaceOf, transposed); decomposer.decompose(transposed); decomposer.getQ(Q, false); CommonOps.extract(Q, 0, Q.getNumRows(), Q.getNumCols() - nullity, Q.getNumCols(), nullspaceToPack, 0, 0); }