Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate rows/cols in favour of getRows/getColumns #190

Open
wants to merge 8 commits into
base: SNAPSHOT
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 41 additions & 19 deletions main/ejml-simple/src/org/ejml/simple/ConstMatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public interface ConstMatrix<T extends ConstMatrix<T>> {
T plus( double beta, ConstMatrix<?> B );

/**
* Computes the dot product (a.k.a. inner product) between this vector and vector 'v'.
* Computes the dot product (or inner product) between this vector and vector 'v'.
*
* @param v The second vector in the dot product. Not modified.
* @return dot product
Expand Down Expand Up @@ -526,6 +526,46 @@ default int getNumElements() {
*/
T getColumn( int col );

/**
* Extracts the specified rows from the matrix.
*
* @param begin First row (inclusive).
* @param end Last row (exclusive).
* @return Submatrix that contains the specified rows.
* @deprecated Inconsistent API. Use {@link #getRows(int, int)} instead.
*/
@Deprecated
T rows( int begin, int end );

/**
* Extracts the specified rows from the matrix.
*
* @param begin First row (inclusive).
* @param end Last row (exclusive).
* @return Submatrix that contains the specified rows.
*/
T getRows( int begin, int end );

/**
* Extracts the specified columns from the matrix.
*
* @param begin First column (inclusive).
* @param end Last column (exclusive).
* @return Submatrix that contains the specified columns.
* @deprecated Inconsistent API. Use {@link #getColumns(int, int)} instead.
*/
@Deprecated
T cols( int begin, int end );

/**
* Extracts the specified columns from the matrix.
*
* @param begin First column (inclusive).
* @param end Last column (exclusive).
* @return Submatrix that contains the specified columns.
*/
T getColumns( int begin, int end );

/**
* <p>
* If a vector then a square matrix is returned if a matrix then a vector of diagonal ements is returned
Expand Down Expand Up @@ -750,24 +790,6 @@ default int getNumElements() {
*/
int bits();

/**
* Extracts the specified rows from the matrix.
*
* @param begin First row (inclusive).
* @param end Last row (exclusive).
* @return Submatrix that contains the specified rows.
*/
T rows( int begin, int end );

/**
* Extracts the specified columns from the matrix.
*
* @param begin First column (inclusive).
* @param end Last column (exclusive).
* @return Submatrix that contains the specified columns.
*/
T cols( int begin, int end );

/**
* <p>Concatenates all the matrices together along their columns. If the rows do not match the upper elements
* are set to zero.</p>
Expand Down
82 changes: 71 additions & 11 deletions main/ejml-simple/src/org/ejml/simple/SimpleBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,32 +104,80 @@ protected T createComplexMatrix( int numRows, int numCols ) {
* when an operation is needed that is not provided by this class.
* </p>
*
* @return Reference to the internal DMatrixRMaj.
* @return Reference to the internal matrix.
*/
public <InnerType extends Matrix> InnerType getMatrix() {
return (InnerType)mat;
}

/**
* <p>
* Returns a reference to the matrix that it uses internally if this is a {@link DMatrixRMaj}.
* Otherwise attempts to convert the internal matrix to a {@link DMatrixRMaj}.
* </p>
*
* @return Reference to the internal matrix or converted internal matrix.
*/
public DMatrixRMaj getDDRM() {
return (mat.getType() == MatrixType.DDRM) ? (DMatrixRMaj)mat : (DMatrixRMaj)ConvertMatrixType.convert(mat, MatrixType.DDRM);
}

/**
* <p>
* Returns a reference to the matrix that it uses internally if this is a {@link FMatrixRMaj}.
* Otherwise attempts to convert the internal matrix to a {@link FMatrixRMaj}.
* </p>
*
* @return Reference to the internal matrix or converted internal matrix.
*/
public FMatrixRMaj getFDRM() {
return (mat.getType() == MatrixType.FDRM) ? (FMatrixRMaj)mat : (FMatrixRMaj)ConvertMatrixType.convert(mat, MatrixType.FDRM);
}

/**
* <p>
* Returns a reference to the matrix that it uses internally if this is a {@link ZMatrixRMaj}.
* Otherwise attempts to convert the internal matrix to a {@link ZMatrixRMaj}.
* </p>
*
* @return Reference to the internal matrix or converted internal matrix.
*/
public ZMatrixRMaj getZDRM() {
return (mat.getType() == MatrixType.ZDRM) ? (ZMatrixRMaj)mat : (ZMatrixRMaj)ConvertMatrixType.convert(mat, MatrixType.ZDRM);
}

/**
* <p>
* Returns a reference to the matrix that it uses internally if this is a {@link CMatrixRMaj}.
* Otherwise attempts to convert the internal matrix to a {@link CMatrixRMaj}.
* </p>
*
* @return Reference to the internal matrix or converted internal matrix.
*/
public CMatrixRMaj getCDRM() {
return (mat.getType() == MatrixType.CDRM) ? (CMatrixRMaj)mat : (CMatrixRMaj)ConvertMatrixType.convert(mat, MatrixType.CDRM);
}

/**
* <p>
* Returns a reference to the matrix that it uses internally if this is a {@link DMatrixSparseCSC}.
* Otherwise attempts to convert the internal matrix to a {@link DMatrixSparseCSC}.
* </p>
*
* @return Reference to the internal matrix or converted internal matrix.
*/
public DMatrixSparseCSC getDSCC() {
return (mat.getType() == MatrixType.DSCC) ? (DMatrixSparseCSC)mat : (DMatrixSparseCSC)ConvertMatrixType.convert(mat, MatrixType.DSCC);
}

/**
* <p>
* Returns a reference to the matrix that it uses internally if this is a {@link FMatrixSparseCSC}.
* Otherwise attempts to convert the internal matrix to a {@link FMatrixSparseCSC}.
* </p>
*
* @return Reference to the internal matrix or converted internal matrix.
*/
public FMatrixSparseCSC getFSCC() {
return (mat.getType() == MatrixType.FSCC) ? (FMatrixSparseCSC)mat : (FMatrixSparseCSC)ConvertMatrixType.convert(mat, MatrixType.FSCC);
}
Expand Down Expand Up @@ -661,6 +709,28 @@ public void setColumn( int column, ConstMatrix<?> src ) {
// NOTE: For sparse to sparse this method is very inefficient...
}

/** {@inheritDoc} */
@Deprecated
@Override public T rows( int begin, int end ) {
return extractMatrix(begin, end, 0, SimpleMatrix.END);
}

/** {@inheritDoc} */
@Override public T getRows( int begin, int end ) {
return extractMatrix(begin, end, 0, SimpleMatrix.END);
}

/** {@inheritDoc} */
@Deprecated
@Override public T cols( int begin, int end ) {
return extractMatrix(0, SimpleMatrix.END, begin, end);
}

/** {@inheritDoc} */
@Override public T getColumns( int begin, int end ) {
return extractMatrix(0, SimpleMatrix.END, begin, end);
}

/**
* Converts a real array/vector into a complex one by setting imaginary component to zero
*/
Expand Down Expand Up @@ -1273,16 +1343,6 @@ public void printDimensions() {
return (T)combined;
}

/** {@inheritDoc} */
@Override public T rows( int begin, int end ) {
return extractMatrix(begin, end, 0, SimpleMatrix.END);
}

/** {@inheritDoc} */
@Override public T cols( int begin, int end ) {
return extractMatrix(0, SimpleMatrix.END, begin, end);
}

/** {@inheritDoc} */
@Override public MatrixType getType() {
return mat.getType();
Expand Down
Loading