Пример #1
0
 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);
   }
 }
Пример #2
0
  /**
   * Inline element-wise multiplication of the elements in <code>this</code> and <code>matrix</code>
   * , modifies the elements of <code>this</code>
   *
   * @param matrix Must have same dimensions <code>this</code>
   */
  public void dotTimesEquals(final AbstractMTJMatrix matrix) {
    // make sure the matrices are the same dimension
    this.assertSameDimensions(matrix);

    // 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) {
      double otherValue = matrix.getElement(e.getRowIndex(), e.getColumnIndex());

      e.setValue(e.getValue() * otherValue);
    }
  }