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/prerequisites.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,4 +29,4 @@ using namespace daecpp;
29
29
|`daecpp::int_type`|`uint32_t` (default), <br> `uint64_t` if `DAECPP_LONG` is defined | Unsigned integer type, used for sparse matrix indices |
30
30
|`daecpp::float_type`|`double` (default), <br> `float` if `DAECPP_SINGLE` is defined | Floating point scalar, used for sparse matrix coefficients |
31
31
|`daecpp::state_vector`|`std::vector<float_type>`| State vector, used, for example, to define the initial condition |
32
-
|`daecpp::state_type`|`autodiff::VectorXreal`| State vector, used for the [vector function](vector-function.html) definition so that it can be automatically (algorithmically) differentiated using `autodiff` package |
32
+
|`daecpp::state_type`|`autodiff::VectorXreal`| State vector, used for the [vector function](vector-function.html) definition so that it can be automatically (algorithmically) differentiated using [`autodiff`](https://autodiff.github.io/) package |
Copy file name to clipboardExpand all lines: docs/vector-function.md
+68-6Lines changed: 68 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,75 @@ layout: default
4
4
nav_order: 4
5
5
---
6
6
7
-
Work in progress
8
-
{: .label .label-red }
7
+
# Vector Function class
9
8
10
-
# Vector Function (the RHS) class
9
+
Vector function class defines the (nonlinear) vector function (the RHS) $$\mathbf{f}(\mathbf{x}, t)$$ of the DAE system written in the matrix-vector form:
The vector function depends on the state vector $$\mathbf{x}$$ and time $$t$$.
15
14
16
-
Text
15
+
## Vector function definition
16
+
17
+
The main vector function class `daecpp::VectorFunction` is an abstract class that provides an interface to define the vector function $$\mathbf{f}(\mathbf{x}, t)$$.
18
+
In order to make use of this class, the user should inherit it and overload the `()` operator:
The operator `()` takes the state vector `x` at time `t` and updates the vector function `f`.
32
+
Vector `f` is already pre-allocated with `f.size() == x.size()` and should be used in the function directly (without pre-allocation and `push_back`-like methods).
33
+
The elements of vectors `x` and `f` can be accessed using square brackets `[]`.
34
+
35
+
{: .note }
36
+
The type of vectors `f` and `x` is `daecpp::state_type`, which is an [`autodiff`](https://autodiff.github.io/)'s type used to perform automatic (algorithmic) differentiation of the vector function `f`. See [`dae-cpp` types](https://dae-cpp.github.io/prerequisites.html#dae-cpp-types) section.
37
+
38
+
## Examples
39
+
40
+
Consider the following vector function $$\mathbf{f}(\mathbf{x}, t)$$, where $$\mathbf{x} = \{x,y,z\}$$, as an example:
41
+
42
+
$$
43
+
\mathbf{f}(\mathbf{x}, t) =
44
+
\begin{vmatrix}
45
+
z + 1 \\
46
+
x^2 + y \\
47
+
2t
48
+
\end{vmatrix}.
49
+
$$
50
+
51
+
In the code, this vector function can be defined as
Inhereting the `daecpp::VectorFunction` class is a good practice (it serves as a blueprint), however, the user is allowed to define vector functions using their own custom classes, for example:
0 commit comments