public static boolean containsNaN(DenseMatrix64F matrix) { for (int i = 0; i < matrix.numRows; i++) { for (int j = 0; j < matrix.numCols; j++) { if (Double.isNaN(matrix.unsafe_get(i, j))) return true; } } return false; }
public static boolean containsNaN(DenseMatrix64F matrix) { for (int i = 0; i < matrix.numRows; i++) { for (int j = 0; j < matrix.numCols; j++) { if (Double.isNaN(matrix.unsafe_get(i, j))) return true; } } return false; }
@Override public void getDiagonal(double[] diag, double[] off) { diag[0] = UBV.get(0); for( int i = 1; i < n; i++ ) { diag[i] = UBV.unsafe_get(i,i); off[i-1] = UBV.unsafe_get(i-1,i); } }
@Override public void getDiagonal(double[] diag, double[] off) { diag[0] = B.get(0); for( int i = 1; i < n; i++ ) { diag[i] = B.unsafe_get(i,i); off[i-1] = B.unsafe_get(i-1,i); } }
@Override public void getDiagonal(double[] diag, double[] off) { diag[0] = B.get(0); for( int i = 1; i < n; i++ ) { diag[i] = B.unsafe_get(i,i); off[i-1] = B.unsafe_get(i-1,i); } }
@Override public void getDiagonal(double[] diag, double[] off) { diag[0] = UBV.get(0); for( int i = 1; i < n; i++ ) { diag[i] = UBV.unsafe_get(i,i); off[i-1] = UBV.unsafe_get(i-1,i); } }
@Override public void getDiagonal(double[] diag, double[] off) { diag[0] = UBV.get(0); for( int i = 1; i < n; i++ ) { diag[i] = UBV.unsafe_get(i,i); off[i-1] = UBV.unsafe_get(i-1,i); } }
@Override public void getDiagonal(double[] diag, double[] off) { diag[0] = B.get(0); for( int i = 1; i < n; i++ ) { diag[i] = B.unsafe_get(i,i); off[i-1] = B.unsafe_get(i-1,i); } }
/** * * Differentiates a row vector by subtracting the previous element from the current element * * @param vectorToDiff Row vector * @param startRow Row to start at * @param numberOfRows Rows to differentiate * @param vectorToPack Result row vector */ public static void diff(DenseMatrix64F vectorToDiff, int startRow, int numberOfRows, DenseMatrix64F vectorToPack) { for (int i = 1; i < numberOfRows; i++) { vectorToPack.unsafe_set(i - 1, 0, vectorToDiff.unsafe_get(startRow + i, 0) - vectorToDiff.unsafe_get(startRow + i - 1, 0)); } }
/** * * Differentiates a row vector by subtracting the previous element from the current element * * @param vectorToDiff Row vector * @param startRow Row to start at * @param numberOfRows Rows to differentiate * @param vectorToPack Result row vector */ public static void diff(DenseMatrix64F vectorToDiff, int startRow, int numberOfRows, DenseMatrix64F vectorToPack) { for (int i = 1; i < numberOfRows; i++) { vectorToPack.unsafe_set(i - 1, 0, vectorToDiff.unsafe_get(startRow + i, 0) - vectorToDiff.unsafe_get(startRow + i - 1, 0)); } }
private void set(DoubleYoVariable[] var, DenseMatrix64F value) { for (int i = 0; i < segments; i++) { var[i].set(value.unsafe_get(i, 0)); } }
private void set(YoDouble[] var, DenseMatrix64F value) { for (int i = 0; i < segments; i++) { var[i].set(value.unsafe_get(i, 0)); } }
/** * Writes the upper triangular matrix into the specified matrix. * * @param upper Where the upper triangular matrix is writen to. */ @Override public DenseMatrix64F getUpper( DenseMatrix64F upper ) { int numRows = LU.numRows < LU.numCols ? LU.numRows : LU.numCols; int numCols = LU.numCols; upper = UtilDecompositons_D64.checkZerosLT(upper,numRows,numCols); for( int i = 0; i < numRows; i++ ) { for( int j = i; j < numCols; j++ ) { upper.unsafe_set(i,j, LU.unsafe_get(i,j)); } } return upper; }
@Override public DenseMatrix64F getT( DenseMatrix64F T ) { // write the values to T if( lower ) { T = UtilDecompositons_D64.checkZerosUT(T,n,n); for( int i = 0; i < n; i++ ) { for( int j = 0; j <= i; j++ ) { T.unsafe_set(i,j,this.T.unsafe_get(i,j)); } } } else { T = UtilDecompositons_D64.checkZerosLT(T,n,n); for( int i = 0; i < n; i++ ) { for( int j = i; j < n; j++ ) { T.unsafe_set(i,j,this.T.unsafe_get(i,j)); } } } return T; }
public static void scaleColumn(double alpha, int column, DenseMatrix64F matrix) { if( column < 0 || column >= matrix.getNumCols()) throw new IllegalArgumentException("Specified column index is out of bounds: " + column + ", number of columns in matrix: " + matrix.getNumCols()); for (int row = 0; row < matrix.getNumRows(); row++) matrix.unsafe_set(row, column, alpha * matrix.unsafe_get(row, column)); }
public static void scaleRow(double alpha, int row, DenseMatrix64F matrix) { if( row < 0 || row >= matrix.getNumRows()) throw new IllegalArgumentException("Specified row index is out of bounds: " + row + ", number of rows in matrix: " + matrix.getNumRows()); for (int column = 0; column < matrix.getNumCols(); column++) matrix.unsafe_set(row, column, alpha * matrix.unsafe_get(row, column)); }
/** * C=diagxmat(vec,B) C=diag(vec) * B */ public static DenseMatrix64F diagxmat(final RowD1Matrix64F diag, final RowD1Matrix64F B) { //if (!MatrixFeatures.isVector(diag)) //logger.info("diagXMat: sizes A,B: diag is NOT vector."); DenseMatrix64F result = B.copy(); for (int i = 0; i < result.numRows; i++) { for (int j = 0; j < result.numCols; j++) { result.unsafe_set(i, j, result.unsafe_get(i, j) * diag.get(i)); } } return result; } // END diagxmat
/** * <p> * Scales the elements of {@param column} of {@param matrix} by the value {@param alpha}. * </p> * * @param alpha value to scale by * @param column column to scale * @param matrix matrix modify */ public static void scaleColumn(double alpha, int column, DenseMatrix64F matrix) { if (column < 0 || column >= matrix.getNumCols()) throw new IllegalArgumentException("Specified column index is out of bounds: " + column + ", number of columns in matrix: " + matrix.getNumCols()); for (int row = 0; row < matrix.getNumRows(); row++) matrix.unsafe_set(row, column, alpha * matrix.unsafe_get(row, column)); }
/** * <p> * Scales the elements of {@param row} of {@param matrix} by the value {@param alpha}. * </p> * * @param alpha value to scale by * @param row row to scale * @param matrix matrix modify */ public static void scaleRow(double alpha, int row, DenseMatrix64F matrix) { if (row < 0 || row >= matrix.getNumRows()) throw new IllegalArgumentException("Specified row index is out of bounds: " + row + ", number of rows in matrix: " + matrix.getNumRows()); for (int column = 0; column < matrix.getNumCols(); column++) matrix.unsafe_set(row, column, alpha * matrix.unsafe_get(row, column)); }
@Override public void process() { DenseMatrix64F mA = ((VariableMatrix)A).matrix; if(MatrixFeatures.isVector(mA)) { int N = mA.getNumElements(); output.matrix.reshape(N,N); CommonOps.diag(output.matrix,N,mA.data); } else { int N = Math.min(mA.numCols,mA.numRows); output.matrix.reshape(N,1); for (int i = 0; i < N; i++) { output.matrix.data[i] = mA.unsafe_get(i,i); } } } };