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 };
29
55 class CtcGaussElim : public CtcLinearBase
56 {
57 public:
58
63 { }
64
73 void contract(IntervalMatrix& A, IntervalVector& x, IntervalVector& b) const;
74
75 virtual std::shared_ptr<CtcLinearBase> copy() const
76 {
77 return std::make_shared<CtcGaussElim>(*this);
78 }
79 };
80
81
107 class CtcGaussSeidel : public CtcLinearBase
108 {
109 public:
110
115 { }
116
125 void contract(IntervalMatrix& A, IntervalVector& x, IntervalVector& b) const;
126
127 virtual std::shared_ptr<CtcLinearBase> copy() const
128 {
129 return std::make_shared<CtcGaussSeidel>(*this);
130 }
131 };
132
133
154 class CtcLinearPrecond : public CtcLinearBase
155 {
156 public:
157
166 template<typename C>
167 requires (std::is_base_of_v<CtcLinearBase,C> || std::is_same_v<std::shared_ptr<CtcLinearBase>,C>)
168 CtcLinearPrecond(const C& ctc_no_precond)
169 : _ctc_no_precond(ctc_no_precond)
170 { }
171
180 void contract(IntervalMatrix& A, IntervalVector& x, IntervalVector& b) const
181 {
182 assert_release(A.is_squared() && A.rows() == x.size() && A.rows() == b.size());
183
184 IntervalMatrix A0 = A.mid();
185 IntervalMatrix A0_inv = A.mid().inverse().template cast<Interval>();
186 IntervalMatrix Ap = A0_inv*A;
187 IntervalVector bp = A0_inv*b;
188
189 _ctc_no_precond.front().contract(Ap,x,bp);
190
191 b &= A0*bp;
192 A &= A0*Ap;
193 }
194
195 virtual std::shared_ptr<CtcLinearBase> copy() const
196 {
197 return std::make_shared<CtcLinearPrecond>(*this);
198 }
199
200
201 protected:
202
203 const Collection<CtcLinearBase> _ctc_no_precond;
204 };
205}
CtcGaussElim()
Creates a contractor based on the Gauss elimination.
Definition codac2_linear_ctc.h:62
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:114
void contract(IntervalMatrix &A, IntervalVector &x, IntervalVector &b) const
Creates the domains according to the linear system: .
Definition codac2_linear_ctc.h:180
CtcLinearPrecond(const C &ctc_no_precond)
Creates a contractor performing preconditioning before calling some provided linear contractor.
Definition codac2_linear_ctc.h:168