/** * Bring each element to the power d * * @param degree * @param d * @return the input */ public static <T extends Matrix> T powInplace(T degree, double d) { for (final MatrixEntry ent : degree) { degree.setElement(ent.getRowIndex(), ent.getColumnIndex(), Math.pow(ent.getValue(), d)); } return degree; }
@Override public void dotTimesEquals( final Matrix other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensions(other); for (final MatrixEntry entry : this) { entry.setValue(entry.getValue() * other.get(entry.getRowIndex(), entry.getColumnIndex())); } }
public void scaleEquals( double scaleFactor) { // Iterators loop over all values, or all nonzero, values in "this". // The resulting matrix doesn't need to element-wise multiply the // zero values, since the result would be zero anyway. for (MatrixEntry e : this) { e.setValue(e.getValue() * scaleFactor); } }
private Map<String, Double> prepareY(Matrix secondObject) { final Map<String, Double> ret = new HashMap<String, Double>(); for (final MatrixEntry me : secondObject) { ret.put(me.getColumnIndex() + "", me.getValue()); } return ret; }
else if ( firstEntry.getRowIndex() < secondEntry.getRowIndex() ) else if ( firstEntry.getRowIndex() > secondEntry.getRowIndex() ) if ( firstEntry.getColumnIndex() < secondEntry.getColumnIndex() ) else if ( firstEntry.getColumnIndex() > secondEntry.getColumnIndex() )
/** * Sum the matrix entries * * @param A * @return the sum */ public static double sum(Matrix A) { double sum = 0; for (final MatrixEntry matrixEntry : A) { sum += matrixEntry.getValue(); } return sum; }
/** * {@inheritDoc} * @return {@inheritDoc} */ public MatrixEntry next() { no.uib.cipr.matrix.MatrixEntry internalNext = getInternalIterator().next(); getEntry().setRowIndex(internalNext.row()); getEntry().setColumnIndex(internalNext.column()); return getEntry(); }
else if ( firstEntry.getRowIndex() < secondEntry.getRowIndex() ) else if ( firstEntry.getRowIndex() > secondEntry.getRowIndex() ) if ( firstEntry.getColumnIndex() < secondEntry.getColumnIndex() ) else if ( firstEntry.getColumnIndex() > secondEntry.getColumnIndex() )
/** * @param mat * @return checks elements using {@link Double#isNaN()} */ public static boolean containsNaN(Matrix mat) { for (final MatrixEntry matrixEntry : mat) { if (Double.isNaN(matrixEntry.getValue())) { return true; } } return false; }
public void scaleEquals( double scaleFactor) { // Iterators loop over all values, or all nonzero, values in "this". // The resulting matrix doesn't need to element-wise multiply the // zero values, since the result would be zero anyway. for (MatrixEntry e : this) { e.setValue(e.getValue() * scaleFactor); } }
/** * {@inheritDoc} * @return {@inheritDoc} */ public MatrixEntry next() { no.uib.cipr.matrix.MatrixEntry internalNext = getInternalIterator().next(); getEntry().setRowIndex(internalNext.row()); getEntry().setColumnIndex(internalNext.column()); return getEntry(); }
private static double[][] fromMatrix(Matrix a) { final double[][] ret = new double[a.getNumRows()][a.getNumColumns()]; for (final MatrixEntry ds : a) { ret[ds.getRowIndex()][ds.getColumnIndex()] = ds.getValue(); } return ret; }
@Override public void dotTimesEquals( final Matrix other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensions(other); for (final MatrixEntry entry : this) { entry.setValue(entry.getValue() * other.get(entry.getRowIndex(), entry.getColumnIndex())); } }
else if ( firstEntry.getRowIndex() < secondEntry.getRowIndex() ) else if ( firstEntry.getRowIndex() > secondEntry.getRowIndex() ) if ( firstEntry.getColumnIndex() < secondEntry.getColumnIndex() ) else if ( firstEntry.getColumnIndex() > secondEntry.getColumnIndex() )
/** * @param mat * @return checks elements using {@link Double#isInfinite()} */ public static boolean containsInfinity(Matrix mat) { for (final MatrixEntry matrixEntry : mat) { if (Double.isInfinite(matrixEntry.getValue())) { return true; } } return false; }
public void scaleEquals( double scaleFactor) { // Iterators loop over all values, or all nonzero, values in "this". // The resulting matrix doesn't need to element-wise multiply the // zero values, since the result would be zero anyway. for (MatrixEntry e : this) { e.setValue(e.getValue() * scaleFactor); } }
/** * {@inheritDoc} * @return {@inheritDoc} */ public MatrixEntry next() { no.uib.cipr.matrix.MatrixEntry internalNext = getInternalIterator().next(); getEntry().setRowIndex(internalNext.row()); getEntry().setColumnIndex(internalNext.column()); return getEntry(); }
@Override public void minusEquals( final Matrix other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensions(other); for (final MatrixEntry entry : other) { this.decrement(entry.getRowIndex(), entry.getColumnIndex(), entry.getValue()); } }
@Override public void dotTimesEquals( final Matrix other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensions(other); for (final MatrixEntry entry : this) { entry.setValue(entry.getValue() * other.get(entry.getRowIndex(), entry.getColumnIndex())); } }
this.getFirstInternalEntry().getRowIndex() ); this.getInternalEntry().setColumnIndex( this.getFirstInternalEntry().getColumnIndex() ); this.getFirstInternalEntry().getRowIndex() ); this.getInternalEntry().setColumnIndex( this.getFirstInternalEntry().getColumnIndex() ); this.getSecondInternalEntry().getRowIndex() ); this.getInternalEntry().setColumnIndex( this.getSecondInternalEntry().getColumnIndex() ); this.getSecondInternalEntry().getRowIndex() ); this.getInternalEntry().setColumnIndex( this.getSecondInternalEntry().getColumnIndex() ); this.getFirstInternalEntry().getRowIndex() ); this.getInternalEntry().setColumnIndex( this.getFirstInternalEntry().getColumnIndex() );