Skip to content

Commit cbe7c99

Browse files
committed
Update sparse matrix class page
1 parent 3cc6763 commit cbe7c99

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

docs/sparse-matrix.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ sparse_matrix M; // Creates empty sparse matrix M
1515
M.reserve(2); // Reserves memory for 2 elements (optional)
1616
M.add_element(0, 1, 12.0); // Fills row 0, column 1 with value 12.0
1717
M.add_element(1, 1, 42.0); // Fills row 1, column 1 with value 42.0
18-
std::cout << M.dense(3) << '\n'; // Prints matrix on screen assuming it's a 3x3 matrix
18+
std::cout << M.dense(3) << '\n'; // Prints matrix M on screen assuming it's a 3x3 matrix
1919
```
2020

2121
## Three-array format
2222

23-
The three-array format defines a sparse matrix using two (unsigned) integer vectors of indices `i` and `j` and one floating point vector `A` of the corresponding non-zero elements of the matrix. Only non-zero elements of the sparse matrix should be defined. Theoretically, all three arrays can be empty. This will define a zero matrix where all elements are zeros.
23+
The three-array format defines a sparse matrix using two (unsigned) integer vectors of indices `i` and `j` and one floating-point vector `A` of the corresponding non-zero elements of the matrix. Only non-zero elements of the sparse matrix should be defined and stored. Theoretically, all three arrays can be empty. This will define a zero matrix where all elements are zeros.
2424

2525
{: .note }
2626
All three arrays `i`, `j`, and `A` should be the same size. This can be (and will be) checked by calling the `void check()` method of the class `daecpp::sparse_matrix`.
@@ -37,7 +37,7 @@ $$
3737
$$
3838

3939
This matrix contains only 3 non-zero elements: `1`, `2`, and `3`.
40-
Here is the matrix definition in three-array format:
40+
Here is the matrix $$\mathbf{M}$$ definition in three-array format:
4141

4242
| `i` (row index) | `j` (column index) | `A` (non-zero element) |
4343
| --------------- | ------------------ | ---------------------- |
@@ -56,18 +56,18 @@ The row and column numeration starts from `0`.
5656

5757
| Variable | Type | Description |
5858
| -------- | ---- | ----------- |
59-
| `A` | `std` vector of `double` (default) or `float` | Vector of non-zero elements `A` |
60-
| `i` | `std` vector of `uint32_t` (default) or `uint64_t` | Vector of row indices `i` |
61-
| `j` | `std` vector of `uint32_t` (default) or `uint64_t` | Vector of column indices `j` |
59+
| `A` | `std::vector<float_type>` | Vector of non-zero elements `A` |
60+
| `i` | `std::vector<int_type>` | Vector of row indices `i` |
61+
| `j` | `std::vector<int_type>` | Vector of column indices `j` |
62+
63+
For `float_type` and `int_type` definition, refer to the [Prerequisites](prerequisites.html#dae-cpp-types) section.
6264

6365
{: .note }
6466
All three vectors are initially empty an NOT preallocated
6567

6668
## Sparse Matrix class methods
6769

68-
----
69-
70-
## `void operator()(ind_i, ind_j, A_ij)`
70+
## `void operator()(int_type ind_i, int_type ind_j, float_type A_ij)`
7171

7272
<br>
7373
Adds next non-zero element to the sparse matrix.
@@ -90,7 +90,7 @@ M(0, 1, 2.0); // Duplicated element is OK, it will be summed up, i.e., the va
9090
9191
----
9292
93-
## `void add_element(ind_i, ind_j, A_ij)`
93+
## `void add_element(int_type ind_i, int_type ind_j, float_type A_ij)`
9494
9595
<br>
9696
An alias to the operator `()` defined above.
@@ -114,7 +114,7 @@ M.add_element(0, 1, 2.0); // Duplicated element will be summed up, i.e., the va
114114

115115
----
116116

117-
## `void reserve(N_elements)`
117+
## `void reserve(int_type N_elements)`
118118

119119
<br>
120120
Reserves memory for `N_elements` non-zero elements. It is strongly advised to allocate memory before filling in the sparse matrix arrays to avoid multiple copying and reallocation.
@@ -147,7 +147,7 @@ If it fails, the solver exits with error message (it is not possible to recover)
147147

148148
----
149149

150-
## `auto dense(N) const`
150+
## `auto dense(int_type N) const`
151151

152152
<br>
153153
Represents matrix in dense format. Suitable for printing using `std::cout`.
@@ -170,7 +170,7 @@ std::cout << M.dense(3) << '\n'; // Prints matrix on screen assuming it's a 3x3
170170
171171
----
172172
173-
## `Eigen::SparseMatrix<float_type> convert(N) const`
173+
## `Eigen::SparseMatrix<float_type> convert(int_type N) const`
174174
175175
<br>
176176
Converts matrix from `dae-cpp` three-array format to `Eigen::SparseMatrix` format.

0 commit comments

Comments
 (0)