/** * Gets the number of rows in the matrix. * * @return The number of rows in the matrix. */ @Override public int getNumRow() { return mat.getNumRows(); }
public void setRow(int row, double... values) { if (values.length != mat.getNumCols()) { throw new IllegalArgumentException( "Call setRow received an array of length " + values.length + ". " + "The dimensions of the matrix is " + mat.getNumRows() + " by " + mat.getNumCols() + "."); } for (int i = 0; i < values.length; i++) { mat.set(row, i, values[i]); } }
public void setColumn(int column, double... values) { if (values.length != mat.getNumCols()) { throw new IllegalArgumentException( "Call setRow received an array of length " + values.length + ". " + "The dimensions of the matrix is " + mat.getNumRows() + " by " + mat.getNumCols() + "."); } for (int i = 0; i < values.length; i++) { mat.set(i, column, values[i]); } }
int numCategories = confusion.getNumRows();
/** * Use to sample the panel to see what is being displayed at the location clicked. All coordinates * are in panel coordinates. * * @param pixelX x-axis in panel coordinates * @param pixelY y-axis in panel coordinates * @param output (Optional) storage for output. * @return Information on what is at the specified location */ public LocationInfo whatIsAtPoint( int pixelX , int pixelY , LocationInfo output ) { if( output == null ) output = new LocationInfo(); int numCategories = confusion.getNumRows(); synchronized ( this ) { if( pixelX >= gridWidth ) { output.insideMatrix = false; output.col = output.row = pixelY*numCategories/gridHeight; } else { output.insideMatrix = true; output.row = pixelY*numCategories/gridHeight; output.col = pixelX*numCategories/gridWidth; } } return output; }
/** * Converts {@link DMatrix4} into {@link DMatrixRMaj}. * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrixRMaj convert(DMatrix4 input , DMatrixRMaj output ) { if( output == null) output = new DMatrixRMaj(4,1); if( output.getNumRows() != 1 && output.getNumCols() != 1 ) throw new IllegalArgumentException("One row or column must have a length of 1 for it to be a vector"); int length = Math.max(output.getNumRows(),output.getNumCols()); if( length != 4 ) throw new IllegalArgumentException("Length of input vector is not 4. It is "+length); output.data[0] = input.a1; output.data[1] = input.a2; output.data[2] = input.a3; output.data[3] = input.a4; return output; }
/** * Converts {@link DMatrixRMaj} into {@link DMatrix4} * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrix4 convert(DMatrixRMaj input , DMatrix4 output ) { if( output == null) output = new DMatrix4(); if( input.getNumRows() != 1 && input.getNumCols() != 1 ) throw new IllegalArgumentException("One row or column must have a length of 1 for it to be a vector"); int length = Math.max(input.getNumRows(),input.getNumCols()); if( length != 4 ) throw new IllegalArgumentException("Length of input vector is not 4. It is "+length); output.a1 = input.data[0]; output.a2 = input.data[1]; output.a3 = input.data[2]; output.a4 = input.data[3]; return output; }
/** * Converts {@link DMatrixRMaj} into {@link DMatrix3} * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrix3 convert(DMatrixRMaj input , DMatrix3 output ) { if( output == null) output = new DMatrix3(); if( input.getNumRows() != 1 && input.getNumCols() != 1 ) throw new IllegalArgumentException("One row or column must have a length of 1 for it to be a vector"); int length = Math.max(input.getNumRows(),input.getNumCols()); if( length != 3 ) throw new IllegalArgumentException("Length of input vector is not 3. It is "+length); output.a1 = input.data[0]; output.a2 = input.data[1]; output.a3 = input.data[2]; return output; }
/** * Converts {@link DMatrix3} into {@link DMatrixRMaj}. * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrixRMaj convert(DMatrix3 input , DMatrixRMaj output ) { if( output == null) output = new DMatrixRMaj(3,1); if( output.getNumRows() != 1 && output.getNumCols() != 1 ) throw new IllegalArgumentException("One row or column must have a length of 1 for it to be a vector"); int length = Math.max(output.getNumRows(),output.getNumCols()); if( length != 3 ) throw new IllegalArgumentException("Length of input vector is not 3. It is "+length); output.data[0] = input.a1; output.data[1] = input.a2; output.data[2] = input.a3; return output; }
/** * Converts {@link DMatrix2} into {@link DMatrixRMaj}. * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrixRMaj convert(DMatrix2 input , DMatrixRMaj output ) { if( output == null) output = new DMatrixRMaj(2,1); if( output.getNumRows() != 1 && output.getNumCols() != 1 ) throw new IllegalArgumentException("One row or column must have a length of 1 for it to be a vector"); int length = Math.max(output.getNumRows(),output.getNumCols()); if( length != 2 ) throw new IllegalArgumentException("Length of input vector is not 2. It is "+length); output.data[0] = input.a1; output.data[1] = input.a2; return output; }
/** * Converts {@link DMatrixRMaj} into {@link DMatrix2} * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrix2 convert(DMatrixRMaj input , DMatrix2 output ) { if( output == null) output = new DMatrix2(); if( input.getNumRows() != 1 && input.getNumCols() != 1 ) throw new IllegalArgumentException("One row or column must have a length of 1 for it to be a vector"); int length = Math.max(input.getNumRows(),input.getNumCols()); if( length != 2 ) throw new IllegalArgumentException("Length of input vector is not 2. It is "+length); output.a1 = input.data[0]; output.a2 = input.data[1]; return output; }
/** * Converts {@link DMatrixRMaj} into {@link DMatrix6} * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrix6 convert(DMatrixRMaj input , DMatrix6 output ) { if( output == null) output = new DMatrix6(); if( input.getNumRows() != 1 && input.getNumCols() != 1 ) throw new IllegalArgumentException("One row or column must have a length of 1 for it to be a vector"); int length = Math.max(input.getNumRows(),input.getNumCols()); if( length != 6 ) throw new IllegalArgumentException("Length of input vector is not 6. It is "+length); output.a1 = input.data[0]; output.a2 = input.data[1]; output.a3 = input.data[2]; output.a4 = input.data[3]; output.a5 = input.data[4]; output.a6 = input.data[5]; return output; }
/** * Converts {@link DMatrix5} into {@link DMatrixRMaj}. * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrixRMaj convert(DMatrix5 input , DMatrixRMaj output ) { if( output == null) output = new DMatrixRMaj(5,1); if( output.getNumRows() != 1 && output.getNumCols() != 1 ) throw new IllegalArgumentException("One row or column must have a length of 1 for it to be a vector"); int length = Math.max(output.getNumRows(),output.getNumCols()); if( length != 5 ) throw new IllegalArgumentException("Length of input vector is not 5. It is "+length); output.data[0] = input.a1; output.data[1] = input.a2; output.data[2] = input.a3; output.data[3] = input.a4; output.data[4] = input.a5; return output; }
/** * Converts {@link DMatrixRMaj} into {@link DMatrix5} * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrix5 convert(DMatrixRMaj input , DMatrix5 output ) { if( output == null) output = new DMatrix5(); if( input.getNumRows() != 1 && input.getNumCols() != 1 ) throw new IllegalArgumentException("One row or column must have a length of 1 for it to be a vector"); int length = Math.max(input.getNumRows(),input.getNumCols()); if( length != 5 ) throw new IllegalArgumentException("Length of input vector is not 5. It is "+length); output.a1 = input.data[0]; output.a2 = input.data[1]; output.a3 = input.data[2]; output.a4 = input.data[3]; output.a5 = input.data[4]; return output; }
/** * Converts {@link DMatrix6} into {@link DMatrixRMaj}. * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrixRMaj convert(DMatrix6 input , DMatrixRMaj output ) { if( output == null) output = new DMatrixRMaj(6,1); if( output.getNumRows() != 1 && output.getNumCols() != 1 ) throw new IllegalArgumentException("One row or column must have a length of 1 for it to be a vector"); int length = Math.max(output.getNumRows(),output.getNumCols()); if( length != 6 ) throw new IllegalArgumentException("Length of input vector is not 6. It is "+length); output.data[0] = input.a1; output.data[1] = input.a2; output.data[2] = input.a3; output.data[3] = input.a4; output.data[4] = input.a5; output.data[5] = input.a6; return output; }
private static <S extends DMatrix> void checkJacobianShape(S found, DMatrixRMaj expected) { if( expected.getNumRows() != found.getNumRows() || expected.getNumCols() != found.getNumCols() ) { String message = "Expected "+expected.getNumRows()+"x"+expected.getNumCols() + " Found "+found.getNumRows()+"x"+found.getNumCols(); throw new RuntimeException("Unexpected jacobian shape. "+message); } }
private static <S extends DMatrix> void checkJacobianShape(S found, DMatrixRMaj expected) { if( expected.getNumRows() != found.getNumRows() || expected.getNumCols() != found.getNumCols() ) { String message = "Expected "+expected.getNumRows()+"x"+expected.getNumCols() + " Found "+found.getNumRows()+"x"+found.getNumCols(); throw new RuntimeException("Unexpected jacobian shape. "+message); } }
/** * Converts {@link DMatrixRMaj} into {@link DMatrix2x2} * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrix2x2 convert(DMatrixRMaj input , DMatrix2x2 output ) { if( output == null) output = new DMatrix2x2(); if( input.getNumRows() != output.getNumRows() ) throw new IllegalArgumentException("Number of rows do not match"); if( input.getNumCols() != output.getNumCols() ) throw new IllegalArgumentException("Number of columns do not match"); output.a11 = input.data[0]; output.a12 = input.data[1]; output.a21 = input.data[2]; output.a22 = input.data[3]; return output; }
/** * Converts {@link DMatrixRMaj} into {@link DMatrix3x3} * * @param input Input matrix. * @param output Output matrix. If null a new matrix will be declared. * @return Converted matrix. */ public static DMatrix3x3 convert(DMatrixRMaj input , DMatrix3x3 output ) { if( output == null) output = new DMatrix3x3(); if( input.getNumRows() != output.getNumRows() ) throw new IllegalArgumentException("Number of rows do not match"); if( input.getNumCols() != output.getNumCols() ) throw new IllegalArgumentException("Number of columns do not match"); output.a11 = input.data[0]; output.a12 = input.data[1]; output.a13 = input.data[2]; output.a21 = input.data[3]; output.a22 = input.data[4]; output.a23 = input.data[5]; output.a31 = input.data[6]; output.a32 = input.data[7]; output.a33 = input.data[8]; return output; }
int numRow = mat.getNumRows();