codac 1.5.6
Loading...
Searching...
No Matches
codac2_inversion.h File Reference
#include <ostream>
#include "codac2_Matrix.h"
#include "codac2_IntervalMatrix.h"
Include dependency graph for codac2_inversion.h:

Go to the source code of this file.

Functions

IntervalMatrix codac2::infinite_sum_enclosure (const IntervalMatrix &A, double &mrad)
 Compute an upper bound of A+A^2+A^3+..., with A a matrix of intervals as an "error term" (use only bounds on coefficients)
 
template<LeftOrRightInv O = LEFT_INV, typename OtherDerived, typename OtherDerived_>
IntervalMatrix codac2::inverse_correction (const Eigen::MatrixBase< OtherDerived > &A, const Eigen::MatrixBase< OtherDerived_ > &B)
 Correct the approximate inverse of a matrix.
 
template<typename OtherDerived>
IntervalMatrix codac2::inverse_enclosure (const Eigen::MatrixBase< OtherDerived > &A)
 Enclosure of the inverse of a (non-singular) matrix expression.
 
IntervalMatrix codac2::inverse_enclosure (const IntervalMatrix &A)
 Enclosure of the inverse of a matrix of intervals.
 

Detailed Description

Date
2024
Author
Damien Massé
License: GNU Lesser General Public License (LGPL)

Function Documentation

◆ infinite_sum_enclosure()

IntervalMatrix codac2::infinite_sum_enclosure ( const IntervalMatrix & A,
double & mrad )

Compute an upper bound of A+A^2+A^3+..., with A a matrix of intervals as an "error term" (use only bounds on coefficients)

The function also returns mrad, which gives an idea of the “magnification” of the matrix during calculation (in particular, if mrad = oo, then the inversion calculation (e.g., performed by Eigen) has somehow failed and some coefficients of the output interval matrix are [-oo,+oo]).

Precondition
A is a square matrix
Parameters
Aa matrix of intervals (supposed around 0)
mradthe maximum radius of the result added (output argument)
Returns
the enclosure. May include (-oo,oo)

◆ inverse_correction()

template<LeftOrRightInv O = LEFT_INV, typename OtherDerived, typename OtherDerived_>
IntervalMatrix codac2::inverse_correction ( const Eigen::MatrixBase< OtherDerived > & A,
const Eigen::MatrixBase< OtherDerived_ > & B )
inline

Correct the approximate inverse of a matrix.

Precondition
A and B are square matrices
Template Parameters
Oif LEFT_INV, use the inverse of BA (otherwise use the inverse of AB, left inverse is normally better)
Parameters
Aa matrix expression
Ba (almost punctual) approximation of its inverse,
Returns
the enclosure
48 {
49 assert_release(A.is_squared());
50 assert_release(B.is_squared());
51
52 auto A_ = A.template cast<Interval>();
53 auto B_ = B.template cast<Interval>();
54
55 Index N = A_.rows();
56 assert_release(N==B_.rows());
57
58 auto Id = IntervalMatrix::Identity(N,N);
59 auto erMat = [&]() { if constexpr(O == LEFT_INV) return -B_*A_+Id; else return -A_*B_+Id; }();
60
61 double mrad=0.0;
62 IntervalMatrix E = infinite_sum_enclosure(erMat,mrad);
63 IntervalMatrix Ep = Id+erMat*(Id+E);
64 /* one could use several iterations here, either
65 using mrad, or directly */
66
67 auto res = (O == LEFT_INV) ? IntervalMatrix(Ep*B_) : IntervalMatrix(B_*Ep);
68
69 // We want the presence of non-invertible matrices to
70 // result in coefficients of the form [-oo,+oo].
71 if (mrad==oo) {
72 for (Index c=0;c<N;c++) {
73 for (Index r=0;r<N;r++) {
74 if (Ep(r,c).is_unbounded()) {
75 for (Index k=0;k<N;k++) {
76 if constexpr(O == LEFT_INV)
77 res(r,k) = Interval();
78 else
79 res(k,c) = Interval();
80 }
81 }
82 }
83 }
84 }
85 return res;
86 }

◆ inverse_enclosure() [1/2]

template<typename OtherDerived>
IntervalMatrix codac2::inverse_enclosure ( const Eigen::MatrixBase< OtherDerived > & A)
inline

Enclosure of the inverse of a (non-singular) matrix expression.

Precondition
A is a square matrix
Parameters
Aa matrix expression
Returns
the enclosure. Can have (-oo,oo) coefficients if A is singular or almost singular
98 {
99 assert_release(A.is_squared());
100 Index N=A.rows();
102 A.fullPivLu().solve(Matrix::Identity(N,N)));
103 }
IntervalMatrix inverse_correction(const Eigen::MatrixBase< OtherDerived > &A, const Eigen::MatrixBase< OtherDerived_ > &B)
Correct the approximate inverse of a matrix.
Definition codac2_inversion.h:47

◆ inverse_enclosure() [2/2]

IntervalMatrix codac2::inverse_enclosure ( const IntervalMatrix & A)

Enclosure of the inverse of a matrix of intervals.

Precondition
A is a square matrix
Parameters
Aa matrix of intervals
Returns
the enclosure. Can have (-oo,oo) coefficients if the inversion "failed"