function
Tests.RuleChecks.fdExpMixedJacobian
Central difference of exp_mixed in one of its three differentiated slots
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| input | X0 | Real | [10] | Initial state |
| input | l | Real | [9] | Left increment |
| input | r | Real | [9] | Right increment |
| input | B | Real | [2, 2] | Coupling matrix |
| input | slot | Integer | | 1 initial state, 2 left increment, 3 right increment |
| input | step | Real | | Central-difference step |
| output | J | Real | [9, 9] |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function fdExpMixedJacobian
"Central difference of exp_mixed in one of its three differentiated slots"
input Real X0[10] "Initial state";
input Real l[9] "Left increment";
input Real r[9] "Right increment";
input Real B[2, 2] "Coupling matrix";
input Integer slot "1 initial state, 2 left increment, 3 right increment";
input Real step "Central-difference step";
output Real J[9, 9];
protected
Real baseInverse[10];
Real basis[9, 9];
Real forwardElement[10];
Real backwardElement[10];
algorithm
baseInverse := LieGroups.SE23.Quat.inverse(
LieGroups.SE23.Quat.exp_mixed(X0, l, r, B));
basis := identity(9);
for j in 1:9 loop
if slot == 1 then
forwardElement := LieGroups.SE23.Quat.exp_mixed(
LieGroups.SE23.Quat.product(X0,
LieGroups.SE23.Quat.exp_map(step * basis[:, j])), l, r, B);
backwardElement := LieGroups.SE23.Quat.exp_mixed(
LieGroups.SE23.Quat.product(X0,
LieGroups.SE23.Quat.exp_map(-step * basis[:, j])), l, r, B);
elseif slot == 2 then
forwardElement := LieGroups.SE23.Quat.exp_mixed(
X0, l + step * basis[:, j], r, B);
backwardElement := LieGroups.SE23.Quat.exp_mixed(
X0, l - step * basis[:, j], r, B);
else
forwardElement := LieGroups.SE23.Quat.exp_mixed(
X0, l, r + step * basis[:, j], B);
backwardElement := LieGroups.SE23.Quat.exp_mixed(
X0, l, r - step * basis[:, j], B);
end if;
J[:, j] := (LieGroups.SE23.Quat.log_map(LieGroups.SE23.Quat.product(
baseInverse, forwardElement))
- LieGroups.SE23.Quat.log_map(LieGroups.SE23.Quat.product(
baseInverse, backwardElement))) / (2.0 * step);
end for;
end fdExpMixedJacobian;