Skip to content

Commit 677f4e1

Browse files
committed
Support for DoubleBinaryOperator
1 parent 7e8a343 commit 677f4e1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

bin/jama2/Matrix.class

364 Bytes
Binary file not shown.

src/jama2/Matrix.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Locale;
1313
import java.util.Random;
1414
import java.util.Vector;
15+
import java.util.function.DoubleBinaryOperator;
1516
import java.util.function.DoubleUnaryOperator;
1617

1718
import 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.

0 commit comments

Comments
 (0)