FEDRA emulsion software from the OPERA Collaboration
Invert< 3 > Class Reference

#include <Dinv.hh>

Static Public Member Functions

template<class Matrix >
static bool Dinv (Matrix &rhs)
 

Detailed Description

Invert<3>. $3\times3$ (sub-)matrix. Use pivotisation.

Author
T. Glebe

Member Function Documentation

◆ Dinv()

template<class Matrix >
static bool Invert< 3 >::Dinv ( Matrix &  rhs)
inlinestatic
163 {
164
165 typename Matrix::value_type* a = rhs.Array();
166
167 static typename Matrix::value_type t1, t2, t3, temp, s;
168 static typename Matrix::value_type c11, c12, c13, c21, c22, c23, c31, c32, c33, det;
169
170
171 /* COMPUTE COFACTORS. */
172 c11 = a[4] * a[8] - a[7] * a[5];
173 c12 = a[7] * a[2] - a[1] * a[8];
174 c13 = a[1] * a[5] - a[4] * a[2];
175 c21 = a[5] * a[6] - a[8] * a[3];
176 c22 = a[8] * a[0] - a[2] * a[6];
177 c23 = a[2] * a[3] - a[5] * a[0];
178 c31 = a[3] * a[7] - a[6] * a[4];
179 c32 = a[6] * a[1] - a[0] * a[7];
180 c33 = a[0] * a[4] - a[3] * a[1];
181
182 t1 = fabs(a[0]);
183 t2 = fabs(a[1]);
184 t3 = fabs(a[2]);
185
186 /* (SET TEMP=PIVOT AND DET=PIVOT*DET.) */
187 if(t1 < t2) {
188 if (t3 < t2) {
189 /* (PIVOT IS A21) */
190 temp = a[1];
191 det = c13 * c32 - c12 * c33;
192 } else {
193 /* (PIVOT IS A31) */
194 temp = a[2];
195 det = c23 * c12 - c22 * c13;
196 }
197 } else {
198 if(t3 < t1) {
199 /* (PIVOT IS A11) */
200 temp = a[0];
201 det = c22 * c33 - c23 * c32;
202 } else {
203 /* (PIVOT IS A31) */
204 temp = a[2];
205 det = c23 * c12 - c22 * c13;
206 }
207 }
208
209 if (det == 0.) {
210 return false;
211 }
212
213 /* SET ELEMENTS OF INVERSE IN A. */
214 s = temp / det;
215 a[0] = s * c11;
216 a[3] = s * c21;
217 a[6] = s * c31;
218 a[1] = s * c12;
219 a[4] = s * c22;
220 a[7] = s * c32;
221 a[2] = s * c13;
222 a[5] = s * c23;
223 a[8] = s * c33;
224 return true;
225 }
Expr< UnaryOp< Fabs< T >, Expr< A, T, D >, T >, T, D > fabs(const Expr< A, T, D > &rhs)
Definition: UnaryOperators.hh:96
void a()
Definition: check_aligned.C:59
s
Definition: check_shower.C:55

The documentation for this class was generated from the following file: