Skip to content

Commit 7e8a343

Browse files
committed
Support for DoubleUnaryOperator, part 2
1 parent 306f099 commit 7e8a343

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

bin/jama2/Matrix.class

296 Bytes
Binary file not shown.

src/jama2/Matrix.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)