Skip to content

Commit

Permalink
Enhance matrix classes
Browse files Browse the repository at this point in the history
Add new methods
Prepare for rename of existing methods
  • Loading branch information
jodastephen committed Oct 12, 2015
1 parent 4dcb5af commit 63e7365
Show file tree
Hide file tree
Showing 9 changed files with 2,226 additions and 319 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static DoubleMatrix2D getTranspose(DoubleMatrix2D matrix) {
public static DoubleMatrix2D getIdentityMatrix2D(int dimension) {
ArgChecker.isTrue(dimension >= 0, "dimension must be >= 0");
if (dimension == 0) {
return DoubleMatrix2D.EMPTY_MATRIX;
return DoubleMatrix2D.EMPTY;
}
if (dimension == 1) {
return new DoubleMatrix2D(new double[][] {new double[] {1}});
Expand All @@ -61,7 +61,7 @@ public static DoubleMatrix2D getTwoDimensionalDiagonalMatrix(DoubleMatrix1D vect
ArgChecker.notNull(vector, "vector");
int n = vector.size();
if (n == 0) {
return DoubleMatrix2D.EMPTY_MATRIX;
return DoubleMatrix2D.EMPTY;
}
double[][] data = new double[n][n];
for (int i = 0; i < n; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@
*/
public class IdentityMatrix extends DoubleMatrix2D {

private final int _size;
/**
* Serialization version.
*/
private static final long serialVersionUID = 1L;

public IdentityMatrix(int size) {
super(size, size);
ArgChecker.isTrue(size > 0, "size must be > 0");
for (int i = 0; i < size; i++) {
getData()[i][i] = 1.0;
}
_size = size;
}

@Override
public int size() {
return _size * _size;
}

@Override
Expand All @@ -38,7 +35,7 @@ public double getEntry(int index1, int index2) {
* @return size
*/
public int getSize() {
return _size;
return rowCount();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public DoubleMatrix1D evaluate(final DoubleMatrix1D x) {

@Override
public DoubleMatrix2D calculateJacobian(final DoubleMatrix1D x) {
return DoubleMatrix2D.EMPTY_MATRIX;
return DoubleMatrix2D.EMPTY;
}

@Override
Expand Down
Loading

0 comments on commit 63e7365

Please sign in to comment.