codac 1.5.6
Loading...
Searching...
No Matches
codac2_linear_ctc.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <string>
14#include "codac2_Collection.h"
16#include "codac2_Matrix.h"
19
20namespace codac2
21{
22 class CtcLinearBase
23 {
24 public:
25
26 virtual void contract(IntervalMatrix& A, IntervalVector& x, IntervalVector& b) const = 0;
27 virtual std::shared_ptr<CtcLinearBase> copy() const = 0;
28 virtual ~CtcLinearBase() = default;
29 };
30
56 class CtcGaussElim : public CtcLinearBase
57 {
58 public:
59
64 { }
65
74 void contract(IntervalMatrix& A, IntervalVector& x, IntervalVector& b) const;
75
76 virtual std::shared_ptr<CtcLinearBase> copy() const
77 {
78 return std::make_shared<CtcGaussElim>(*this);
79 }
80 };
81
82
108 class CtcGaussSeidel : public CtcLinearBase
109 {
110 public:
111
116 { }
117
126 void contract(IntervalMatrix& A, IntervalVector& x, IntervalVector& b) const;
127
128 virtual std::shared_ptr<CtcLinearBase> copy() const
129 {
130 return std::make_shared<CtcGaussSeidel>(*this);
131 }
132 };
133
134
155 class CtcLinearPrecond : public CtcLinearBase
156 {
157 public:
158
167 template<typename C>
168 requires (std::is_base_of_v<CtcLinearBase,C> || std::is_same_v<std::shared_ptr<CtcLinearBase>,C>)
169 CtcLinearPrecond(const C& ctc_no_precond)
170 : _ctc_no_precond(ctc_no_precond)
171 { }
172
181 void contract(IntervalMatrix& A, IntervalVector& x, IntervalVector& b) const
182 {
183 assert_release(A.is_squared() && A.rows() == x.size() && A.rows() == b.size());
184
185 IntervalMatrix A0 = A.mid();
186 IntervalMatrix A0_inv = A.mid().inverse().template cast<Interval>();
187 IntervalMatrix Ap = A0_inv*A;
188 IntervalVector bp = A0_inv*b;
189
190 _ctc_no_precond.front()->contract(Ap,x,bp);
191
192 b &= A0*bp;
193 A &= A0*Ap;
194 }
195
196 virtual std::shared_ptr<CtcLinearBase> copy() const
197 {
198 return std::make_shared<CtcLinearPrecond>(*this);
199 }
200
201
202 protected:
203
204 const Collection<CtcLinearBase> _ctc_no_precond;
205 };
206}
CtcGaussElim()
Creates a contractor based on the Gauss elimination.
Definition codac2_linear_ctc.h:63
void contract(IntervalMatrix &A, IntervalVector &x, IntervalVector &b) const
Creates the domains according to the linear system: .
void contract(IntervalMatrix &A, IntervalVector &x, IntervalVector &b) const
Creates the domains according to the linear system: .
CtcGaussSeidel()
Creates a contractor based on the Gauss Seidel method.
Definition codac2_linear_ctc.h:115
void contract(IntervalMatrix &A, IntervalVector &x, IntervalVector &b) const
Creates the domains according to the linear system: .
Definition codac2_linear_ctc.h:181
CtcLinearPrecond(const C &ctc_no_precond)
Creates a contractor performing preconditioning before calling some provided linear contractor.
Definition codac2_linear_ctc.h:169