You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sparse-matrix.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,12 +15,12 @@ sparse_matrix M; // Creates empty sparse matrix M
15
15
M.reserve(2); // Reserves memory for 2 elements (optional)
16
16
M.add_element(0, 1, 12.0); // Fills row 0, column 1 with value 12.0
17
17
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
19
19
```
20
20
21
21
## Three-array format
22
22
23
-
The three-array format defines a sparse matrix using two (unsigned) integer vectors of indices `i` and `j` and one floatingpoint 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.
24
24
25
25
{: .note }
26
26
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 @@ $$
37
37
$$
38
38
39
39
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:
@@ -114,7 +114,7 @@ M.add_element(0, 1, 2.0); // Duplicated element will be summed up, i.e., the va
114
114
115
115
----
116
116
117
-
## `void reserve(N_elements)`
117
+
## `void reserve(int_type N_elements)`
118
118
119
119
<br>
120
120
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)
147
147
148
148
----
149
149
150
-
## `auto dense(N) const`
150
+
## `auto dense(int_type N) const`
151
151
152
152
<br>
153
153
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
0 commit comments