コード例 #1
0
 public static double max(Matrix u) {
   double max = -Double.MAX_VALUE;
   for (MatrixEntry matrixEntry : u) {
     max = Math.max(max, matrixEntry.getValue());
   }
   return max;
 }
コード例 #2
0
 public static double min(Matrix u) {
   double min = Double.MAX_VALUE;
   for (MatrixEntry matrixEntry : u) {
     min = Math.min(min, matrixEntry.getValue());
   }
   return min;
 }
コード例 #3
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);
   }
 }
コード例 #4
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);
    }
  }