File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 1212import java .util .Locale ;
1313import java .util .Random ;
1414import java .util .Vector ;
15+ import java .util .function .DoubleBinaryOperator ;
1516import java .util .function .DoubleUnaryOperator ;
1617
1718import static jama2 .util .Maths .hypot ;
@@ -1550,6 +1551,23 @@ public Matrix transformEquals(final DoubleUnaryOperator operator)
15501551 }
15511552 return M ;
15521553 }
1554+
1555+ /**
1556+ * Applys the given operator to all elements, modifying this Matrix.
1557+ * @param B another Matrix
1558+ * @param operator Operator to be applied
1559+ * @throws NullPointerException iff operator == null
1560+ */
1561+ public void transform (final Matrix B , final DoubleBinaryOperator operator )
1562+ {
1563+ for (int i = 0 ; i < this .m ; i ++)
1564+ {
1565+ for (int j = 0 ; j < this .n ; j ++)
1566+ {
1567+ this .A [i ][j ] = operator .applyAsDouble (this .A [i ][j ], B .A [i ][j ]);
1568+ }
1569+ }
1570+ }
15531571
15541572 /**
15551573 * Matrix transpose.
You can’t perform that action at this time.
0 commit comments