Skip to content

Commit a5e30a7

Browse files
committed
Fixed method names, fixed documentation
1 parent ae3d737 commit a5e30a7

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

bin/jama2/Matrix.class

0 Bytes
Binary file not shown.

src/jama2/Matrix.java

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,75 +1518,83 @@ public double trace()
15181518
}
15191519

15201520
/**
1521-
* Applys the given operator to all elements, modifying this Matrix.
1522-
* @param operator Operator to be applied
1523-
* @throws NullPointerException iff operator == null
1521+
* Applys the given operator to all elements, returning a new Matrix.
1522+
* @param operator Operator to be applied to this Matrix and B
1523+
* @return new Matrix with the result
1524+
* @throws NullPointerException iff operator == null or B == null
1525+
* @see {@link #transformEquals(DoubleUnaryOperator)}
1526+
* to modify this Matrix instead of returning a new one
15241527
*/
1525-
public void transform(final DoubleUnaryOperator operator)
1528+
public Matrix transform(final DoubleUnaryOperator operator)
15261529
{
1530+
final Matrix M = new Matrix(this.m, this.n);
15271531
for (int i = 0; i < this.m; i++)
15281532
{
15291533
for (int j = 0; j < this.n; j++)
15301534
{
1531-
this.A[i][j] = operator.applyAsDouble(this.A[i][j]);
1535+
M.A[i][j] = operator.applyAsDouble(this.A[i][j]);
15321536
}
15331537
}
1538+
return M;
15341539
}
15351540

15361541
/**
1537-
* Applys the given operator to all elements, returning a new Matrix.
1542+
* Applys the given operator to all elements, modifying this Matrix.
15381543
* @param operator Operator to be applied
1539-
* @return new Matrix with the result
15401544
* @throws NullPointerException iff operator == null
1545+
* @see {@link #transform(DoubleUnaryOperator)}
1546+
* to return a new Matrix instead of modifying this Matrix
15411547
*/
1542-
public Matrix transformEquals(final DoubleUnaryOperator operator)
1548+
public void transformEquals(final DoubleUnaryOperator operator)
15431549
{
1544-
final Matrix M = new Matrix(this.m, this.n);
15451550
for (int i = 0; i < this.m; i++)
15461551
{
15471552
for (int j = 0; j < this.n; j++)
15481553
{
1549-
M.A[i][j] = operator.applyAsDouble(this.A[i][j]);
1554+
this.A[i][j] = operator.applyAsDouble(this.A[i][j]);
15501555
}
15511556
}
1552-
return M;
15531557
}
15541558

15551559
/**
1556-
* Applys the given operator to all elements, modifying this Matrix.
1560+
* Applys the given operator to all elements, returning a new Matrix.
15571561
* @param B another Matrix
15581562
* @param operator Operator to be applied
1563+
* @return new Matrix with the result
15591564
* @throws NullPointerException iff operator == null
1565+
* @see {@link #transformEquals(Matrix, DoubleBinaryOperator)}
1566+
* to modify this Matrix instead of returning a new one
15601567
*/
1561-
public void transform(final Matrix B, final DoubleBinaryOperator operator)
1568+
public Matrix transform(final Matrix B, final DoubleBinaryOperator operator)
15621569
{
1570+
final Matrix M = new Matrix(this.m, this.n);
15631571
for (int i = 0; i < this.m; i++)
15641572
{
15651573
for (int j = 0; j < this.n; j++)
15661574
{
1567-
this.A[i][j] = operator.applyAsDouble(this.A[i][j], B.A[i][j]);
1575+
M.A[i][j] = operator.applyAsDouble(this.A[i][j], B.A[i][j]);
15681576
}
15691577
}
1578+
return M;
15701579
}
15711580

15721581
/**
1573-
* Applys the given operator to all elements, returning a new Matrix.
1582+
* Applys the given operator to all elements, modifying this Matrix.
15741583
* @param B another Matrix
1575-
* @param operator Operator to be applied
1576-
* @return new Matrix with the result
1577-
* @throws NullPointerException iff operator == null
1584+
* @param operator Operator to be applied to this Matrix and B
1585+
* @throws NullPointerException iff operator == null or B == null
1586+
* @see {@link #transform(Matrix, DoubleBinaryOperator)}
1587+
* to return a new Matrix instead of modifying this Matrix
15781588
*/
1579-
public Matrix transformEquals(final Matrix B, final DoubleBinaryOperator operator)
1589+
public void transformEquals(final Matrix B, final DoubleBinaryOperator operator)
15801590
{
1581-
final Matrix M = new Matrix(this.m, this.n);
15821591
for (int i = 0; i < this.m; i++)
15831592
{
15841593
for (int j = 0; j < this.n; j++)
15851594
{
1586-
M.A[i][j] = operator.applyAsDouble(this.A[i][j], B.A[i][j]);
1595+
this.A[i][j] = operator.applyAsDouble(this.A[i][j], B.A[i][j]);
15871596
}
15881597
}
1589-
return M;
15901598
}
15911599

15921600
/**

0 commit comments

Comments
 (0)