Skip to content

Commit ae3d737

Browse files
committed
Support for DoubleBinaryOperator, part 2
1 parent 677f4e1 commit ae3d737

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

bin/jama2/Matrix.class

317 Bytes
Binary file not shown.

src/jama2/Matrix.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,26 @@ public void transform(final Matrix B, final DoubleBinaryOperator operator)
15681568
}
15691569
}
15701570
}
1571+
1572+
/**
1573+
* Applys the given operator to all elements, returning a new Matrix.
1574+
* @param B another Matrix
1575+
* @param operator Operator to be applied
1576+
* @return new Matrix with the result
1577+
* @throws NullPointerException iff operator == null
1578+
*/
1579+
public Matrix transformEquals(final Matrix B, final DoubleBinaryOperator operator)
1580+
{
1581+
final Matrix M = new Matrix(this.m, this.n);
1582+
for (int i = 0; i < this.m; i++)
1583+
{
1584+
for (int j = 0; j < this.n; j++)
1585+
{
1586+
M.A[i][j] = operator.applyAsDouble(this.A[i][j], B.A[i][j]);
1587+
}
1588+
}
1589+
return M;
1590+
}
15711591

15721592
/**
15731593
* Matrix transpose.

0 commit comments

Comments
 (0)