88 */
99
1010#include " codac2_peibos_tools.h"
11+ #include " codac2_template_tools.h"
1112#include " codac2_inversion.h"
1213#include " codac2_IntvFullPivLU.h"
1314
14- #include < iostream>
15-
16- using namespace std ;
1715using namespace codac2 ;
1816
1917namespace codac2
2018{
21- double split (const IntervalVector& X, double eps, vector<IntervalVector>& boxes)
19+ double split (const IntervalVector& X, double eps, std:: vector<IntervalVector>& boxes)
2220 {
2321 if (X.max_diam ()<=eps)
2422 {
@@ -58,25 +56,24 @@ namespace codac2
5856 Index m = A.cols ();
5957 Index n = A.rows ();
6058
61- IntervalMatrix A_int (A);
62-
63- IntvFullPivLU LUdec ((IntervalMatrix) A_int.transpose ());
59+ IntvFullPivLU LUdec ((Matrix) A.transpose ());
6460 IntervalMatrix N = LUdec.kernel ();
6561
66- vector<int > col_indices;
62+ std:: vector<int > col_indices;
6763
6864 for (int i = 0 ; i < m; i++)
6965 if (! (A.col (i).isZero ()) )
7066 col_indices.push_back (i);
7167
72- // A_reduced is composed of the non empty vectors of A_int
73- IntervalMatrix A_reduced (n, col_indices.size ());
68+ // A_reduced is composed of the non empty vectors of A
69+
70+ Matrix A_reduced (n, col_indices.size ());
7471 for (int i = 0 ; i < (int ) col_indices.size (); i++)
75- A_reduced.col (i) = A_int .col (col_indices[i]);
72+ A_reduced.col (i) = A .col (col_indices[i]);
7673
7774 // Construct the new matrix A_tild = [A_reduced | N]
78- IntervalMatrix A_tild (n,n);
79- A_tild << A_reduced,N;
75+ Matrix A_tild (n,n);
76+ A_tild << A_reduced,N. mid () ;
8077
8178 IntervalMatrix Q = inverse_enclosure (A_tild.transpose () * A_tild);
8279
@@ -87,42 +84,7 @@ namespace codac2
8784 for (int i = 0 ; i < m; i++)
8885 mult (i,i) += e_vec (i);
8986
90- // From here we have an IntervalMatrix A_inf, meaning that each generator is an interval vector
91- IntervalMatrix A_inf = A_tild * mult;
92-
93- // The initial parallelepiped is <y> = Y*[-1,1]^n
94- Matrix Y = A_inf.smig ();
95-
96- // The following is similar to the previous operations. The difference is that here the Matrix Y is square and not interval
97-
98- // rho2 is the sum of the radiuses of the circle enclosing each interval generator
99- Interval rho2 (0 .);
100-
101- for (int i = 0 ; i < n; i++)
102- rho2 += A_inf.col (i).rad ().norm ();
103-
104- IntervalMatrix M = Y.transpose () * Y;
105-
106- double eps = 1e-10 * M.norm ().ub ();
107- double cond_Y = condition_number (Y);
108-
109- if (cond_Y>1e10 )
110- {
111- cerr << " Warning: ill-conditioned matrix in the inflate process. The result may not be guaranteed " << endl;
112- M += IntervalMatrix::Identity (n,n)*eps; // if Y is ill-conditioned, we add a small term to M to make it invertible
113- }
114-
115- IntervalMatrix Q2 = inverse_enclosure (M);
116-
117- IntervalMatrix Y2 = IntervalMatrix::zero (n,n);
118-
119- Interval factor = sqrt (1.0 + eps * cond_Y);
120- for (int i = 0 ; i < n; i++)
121- if (cond_Y>1e10 )
122- Y2 .col (i) = Y.col (i)*(1 +rho2*sqrt (Q2 (i,i))*factor); // sufficient to keep the guarantee ?
123- else
124- Y2 .col (i) = Y.col (i)*(1 +rho2*sqrt (Q2 (i,i)));
125-
126- return Y2 .smag ();
87+ return ((A_tild.template cast <Interval>()) * mult).smag ();
12788 }
89+
12890}
0 commit comments