Skip to content

Commit 6f2d1d1

Browse files
committed
Update README.md
1 parent be9f966 commit 6f2d1d1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Brief Examples
2323
--------------
2424
**Matrix inversion**
2525
```java
26+
// We want simple dense matrix that uses 2D array as internal representation
2627
Matrix a = new Basic2DMatrix(new double[][] {
2728
{ 1.0, 2.0, 3.0 },
2829
{ 4.0, 5.0, 6.0 },
@@ -36,27 +37,28 @@ Matrix b = inverter.invert(LinearAlgebra.DENSE_FACTORY);
3637
```
3738
**System of linear equations**
3839
```java
39-
// A coefficient matrix
40-
Matrix a = new Basic2DMatrix(new double[][] {
40+
// The coefficient matrix 'a' is a CRS (Compressed Sparse Row) matrix
41+
Matrix a = new CRSMatrix(new double[][] {
4142
{ 1.0, 2.0, 3.0 },
4243
{ 4.0, 5.0, 6.0 },
4344
{ 7.0, 8.0. 9.0 }
4445
});
4546

46-
// A right hand side vector
47+
// A right hand side vector, which is simple dense vector
4748
Vector b = new BasicVector(new double[] {
48-
{ 1.0, 2.0, 3.0 }
49+
1.0, 2.0, 3.0
4950
});
5051

5152
// We will use standard Forward-Back Substitution method,
5253
// which is based on LU decomposition and can be used with square systems
5354
LinearSystemSolver solver = a.withSolver(LinearAlgebra.FORWARD_BACK_SUBSTITUTION);
54-
// The 'x' vector will be dense
55-
Vector x = solver.solve(b, LinearAlgebra.DENSE_FACTORY);
55+
// The 'x' vector will be sparse
56+
Vector x = solver.solve(b, LinearAlgebra.SPARSE_FACTORY);
5657
```
5758
**Matrix decomposition**
5859
```java
59-
Matrix a = new Basic2DMatrix(new double[][] {
60+
// We want simple dense matrix, which is based on 1D double's array
61+
Matrix a = new Basic1DMatrix(new double[][] {
6062
{ 1.0, 2.0, 3.0 },
6163
{ 4.0, 5.0, 6.0 },
6264
{ 7.0, 8.0. 9.0 }

0 commit comments

Comments
 (0)