File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1531,6 +1531,25 @@ public void transform(final DoubleUnaryOperator operator)
15311531 }
15321532 }
15331533 }
1534+
1535+ /**
1536+ * Applys the given operator to all elements, returning a new Matrix.
1537+ * @param operator Operator to be applied
1538+ * @return new Matrix with the result
1539+ * @throws NullPointerException iff operator == null
1540+ */
1541+ public Matrix transformEquals (final DoubleUnaryOperator operator )
1542+ {
1543+ final Matrix M = new Matrix (this .m , this .n );
1544+ for (int i = 0 ; i < this .m ; i ++)
1545+ {
1546+ for (int j = 0 ; j < this .n ; j ++)
1547+ {
1548+ M .A [i ][j ] = operator .applyAsDouble (this .A [i ][j ]);
1549+ }
1550+ }
1551+ return M ;
1552+ }
15341553
15351554 /**
15361555 * Matrix transpose.
You can’t perform that action at this time.
0 commit comments