@Override public double getMaxValue() { this.compress(); double max = this.getEntryCount() < this.getDimensionality() ? 0.0 : Double.NEGATIVE_INFINITY; for (final double value : this.values) { if (value > max) { max = value; } } return max; }
@Override public double getMinValue() { this.compress(); double min = this.getEntryCount() < this.getDimensionality() ? 0.0 : Double.POSITIVE_INFINITY; for (final double value : this.values) { if (value < min) { min = value; } } return min; }
@Override public double getMaxValue() { this.compress(); double max = this.getEntryCount() < this.getDimensionality() ? 0.0 : Double.NEGATIVE_INFINITY; for (final double value : this.values) { if (value > max) { max = value; } } return max; }
@Override public double getMinValue() { this.compress(); double min = this.getEntryCount() < this.getDimensionality() ? 0.0 : Double.POSITIVE_INFINITY; for (final double value : this.values) { if (value < min) { min = value; } } return min; }
@Override public double getMinValue() { this.compress(); double min = this.getEntryCount() < this.getDimensionality() ? 0.0 : Double.POSITIVE_INFINITY; for (final double value : this.values) { if (value < min) { min = value; } } return min; }
@Override public double getMaxValue() { this.compress(); double max = this.getEntryCount() < this.getDimensionality() ? 0.0 : Double.NEGATIVE_INFINITY; for (final double value : this.values) { if (value > max) { max = value; } } return max; }
@Override public final Matrix outerProduct( final SparseVector other) { compress(); other.compress(); int numRows = getDimensionality(); int numCols = other.getDimensionality(); SparseMatrix result = new SparseMatrix(numRows, numCols, true); int idx = 0; for (int i = 0; i < numRows; ++i) { SparseVector row = new SparseVector(numCols); if ((idx < indices.length) && (indices[idx] == i)) { for (int j = 0; j < other.indices.length; ++j) { row.elements.put(other.indices[j], new MutableDouble(values[idx] * other.values[j])); } ++idx; } result.setRowInternal(i, row); } return result; }
@Override public final Matrix outerProduct( final SparseVector other) { compress(); other.compress(); int numRows = getDimensionality(); int numCols = other.getDimensionality(); SparseMatrix result = new SparseMatrix(numRows, numCols, true); int idx = 0; for (int i = 0; i < numRows; ++i) { SparseVector row = new SparseVector(numCols); if ((idx < indices.length) && (indices[idx] == i)) { for (int j = 0; j < other.indices.length; ++j) { row.elements.put(other.indices[j], new MutableDouble(values[idx] * other.values[j])); } ++idx; } result.setRowInternal(i, row); } return result; }
@Override public final Matrix outerProduct( final SparseVector other) { compress(); other.compress(); int numRows = getDimensionality(); int numCols = other.getDimensionality(); SparseMatrix result = new SparseMatrix(numRows, numCols, true); int idx = 0; for (int i = 0; i < numRows; ++i) { SparseVector row = new SparseVector(numCols); if ((idx < indices.length) && (indices[idx] == i)) { for (int j = 0; j < other.indices.length; ++j) { row.elements.put(other.indices[j], new MutableDouble(values[idx] * other.values[j])); } ++idx; } result.setRowInternal(i, row); } return result; }
@Override public final Matrix outerProduct( final DenseVector other) { compress(); int numRows = getDimensionality(); int numCols = other.getDimensionality(); // This is debatable. The issue is that each row is likely to be dense, // but many rows are likely to be completely empty. My current thinking // is that storing the empty rows as dense vectors is a complete waste, // and the additional overehead of storing the dense rows as sparse // vectors is decreased when the sparse matrix is optimized. SparseMatrix result = new SparseMatrix(numRows, numCols, true); int idx = 0; for (int i = 0; i < numRows; ++i) { SparseVector row = new SparseVector(numCols); if ((idx < indices.length) && (indices[idx] == i)) { for (int j = 0; j < numCols; ++j) { row.elements.put(j, new MutableDouble(values[idx] * other.values[j])); } ++idx; } result.setRowInternal(i, row); } return result; }
@Override public final Matrix outerProduct( final DenseVector other) { compress(); int numRows = getDimensionality(); int numCols = other.getDimensionality(); // This is debatable. The issue is that each row is likely to be dense, // but many rows are likely to be completely empty. My current thinking // is that storing the empty rows as dense vectors is a complete waste, // and the additional overehead of storing the dense rows as sparse // vectors is decreased when the sparse matrix is optimized. SparseMatrix result = new SparseMatrix(numRows, numCols, true); int idx = 0; for (int i = 0; i < numRows; ++i) { SparseVector row = new SparseVector(numCols); if ((idx < indices.length) && (indices[idx] == i)) { for (int j = 0; j < numCols; ++j) { row.elements.put(j, new MutableDouble(values[idx] * other.values[j])); } ++idx; } result.setRowInternal(i, row); } return result; }
@Override public final Matrix outerProduct( final DenseVector other) { compress(); int numRows = getDimensionality(); int numCols = other.getDimensionality(); // This is debatable. The issue is that each row is likely to be dense, // but many rows are likely to be completely empty. My current thinking // is that storing the empty rows as dense vectors is a complete waste, // and the additional overehead of storing the dense rows as sparse // vectors is decreased when the sparse matrix is optimized. SparseMatrix result = new SparseMatrix(numRows, numCols, true); int idx = 0; for (int i = 0; i < numRows; ++i) { SparseVector row = new SparseVector(numCols); if ((idx < indices.length) && (indices[idx] == i)) { for (int j = 0; j < numCols; ++j) { row.elements.put(j, new MutableDouble(values[idx] * other.values[j])); } ++idx; } result.setRowInternal(i, row); } return result; }
int len = values.length + other.getDimensionality(); int nnz = countNonZeros() + other.countNonZeros(); if (nnz > SparseVector.SPARSE_TO_DENSE_THRESHOLD * len) double[] vals = other.getValues(); int idx = 0; final int otherDimensionality = other.getDimensionality(); for (int i = 0; i < otherDimensionality; ++i)
int len = values.length + other.getDimensionality(); int nnz = countNonZeros() + other.countNonZeros(); if (nnz > SparseVector.SPARSE_TO_DENSE_THRESHOLD * len) double[] vals = other.getValues(); int idx = 0; final int otherDimensionality = other.getDimensionality(); for (int i = 0; i < otherDimensionality; ++i)
int len = values.length + other.getDimensionality(); int nnz = countNonZeros() + other.countNonZeros(); if (nnz > SparseVector.SPARSE_TO_DENSE_THRESHOLD * len) double[] vals = other.getValues(); int idx = 0; final int otherDimensionality = other.getDimensionality(); for (int i = 0; i < otherDimensionality; ++i)
@Override public final Matrix outerProduct( final SparseVector other) { int numRows = getDimensionality(); int numCols = other.getDimensionality(); SparseMatrix result = new SparseMatrix(numRows, numCols, true); other.compress(); int[] locs = other.getIndices(); double[] vals = other.getValues(); for (int i = 0; i < numRows; ++i) { SparseVector row = new SparseVector(numCols); for (int j = 0; j < locs.length; ++j) { row.setElement(locs[j], values[i] * vals[j]); } result.setRowInternal(i, row); } return result; }
@Override public final Matrix outerProduct( final SparseVector other) { int numRows = getDimensionality(); int numCols = other.getDimensionality(); SparseMatrix result = new SparseMatrix(numRows, numCols, true); other.compress(); int[] locs = other.getIndices(); double[] vals = other.getValues(); for (int i = 0; i < numRows; ++i) { SparseVector row = new SparseVector(numCols); for (int j = 0; j < locs.length; ++j) { row.setElement(locs[j], values[i] * vals[j]); } result.setRowInternal(i, row); } return result; }
@Override public final Matrix outerProduct( final SparseVector other) { int numRows = getDimensionality(); int numCols = other.getDimensionality(); SparseMatrix result = new SparseMatrix(numRows, numCols, true); other.compress(); int[] locs = other.getIndices(); double[] vals = other.getValues(); for (int i = 0; i < numRows; ++i) { SparseVector row = new SparseVector(numCols); for (int j = 0; j < locs.length; ++j) { row.setElement(locs[j], values[i] * vals[j]); } result.setRowInternal(i, row); } return result; }