1 #ifndef __JMATH_JSVD3D__
2 #define __JMATH_JSVD3D__
14 namespace JPP {
using namespace JMATH; }
76 const double w = q[3];
77 const double x = q[0];
78 const double y = q[1];
79 const double z = q[2];
81 const double xx =
x*
x;
82 const double yy =
y*
y;
83 const double zz =
z*
z;
84 const double xz =
x*
z;
85 const double xy =
x*
y;
86 const double yz =
y*
z;
87 const double wx =
w*
x;
88 const double wy =
w*
y;
89 const double wz =
w*
z;
91 V.
a00 = 1.0 - 2.0*(yy + zz);
V.
a01 = 2.0*(xy - wz);
V.
a02 = 2.0*(xz + wy);
92 V.
a10 = 2.0*(xy + wz);
V.
a11 = 1.0 - 2.0*(xx + zz);
V.
a12 = 2.0*(yz - wx);
93 V.
a20 = 2.0*(xz - wy);
V.
a21 = 2.0*(yz + wx);
V.
a22 = 1.0 - 2.0*(xx + yy);
168 const double sp1 = -1.0 + 2.0*q1.
sh*q1.
sh;
169 const double sp2 = -1.0 + 2.0*q2.
sh*q2.
sh;
170 const double sp3 = -1.0 + 2.0*q3.
sh*q3.
sh;
173 Q.a01 = 4.0*q2.
ch*q3.
ch*sp1*q2.
sh*q3.
sh + 2.0*q1.
ch*q1.
sh*sp3;
174 Q.a02 = 4.0*q1.
ch*q3.
ch*q1.
sh*q3.
sh - 2.0*q2.
ch*sp1*q2.
sh*sp3;
176 Q.a10 = -2.0*q1.
ch*q1.
sh*sp2;
180 Q.a20 = 2.0*q2.
ch*q2.
sh;
181 Q.a21 = -2.0*q3.
ch*sp2*q3.
sh;
194 double w = fabs(
S.
a00);
196 if (fabs(
S.
a11) > w) { w = fabs(
S.
a11); }
197 if (fabs(
S.
a22) > w) { w = fabs(
S.
a22); }
201 const double s00 = (fabs(
S.
a00) >= w ? 1.0 /
S.
a00 : 0.0);
202 const double s11 = (fabs(
S.
a11) >= w ? 1.0 /
S.
a11 : 0.0);
203 const double s22 = (fabs(
S.
a22) >= w ? 1.0 /
S.
a22 : 0.0);
252 for (
int i = 0;
i != 4; ++
i) {
279 static const double GAMMA = sqrt(8.0) + 3.0;
280 static const double CSTAR = cos(
PI/8.0);
281 static const double SSTAR =
sin(
PI/8.0);
285 double ch = 2.0*(S.
a00 - S.
a11);
288 if (GAMMA*sh*sh < ch*ch) {
290 const double w = 1.0 / sqrt(ch*ch+sh*sh);
301 const double scale = ch*ch + sh*sh;
302 const double a = (ch+sh)*(ch-sh) /
scale;
303 const double b = (2.0*sh*ch) / scale;
308 double s10 = S.
a10;
double s11 = S.
a11;
309 double s20 = S.
a20;
double s21 = S.
a21;
double s22 = S.
a22;
314 S.
a00 = a*( a*s00 + b*s10) + b*( a*s10 + b*s11);
315 S.
a10 = a*(-b*s00 + a*s10) + b*(-b*s10 + a*s11);
316 S.
a11 = -b*(-b*s00 + a*s10) + a*(-b*s10 + a*s11);
317 S.
a20 = a*s20 + b*s21;
318 S.
a21 = -b*s20 + a*s21;
340 (*this)[3] -= tmp[
z];
341 (*this)[
x] += tmp[
y];
342 (*this)[
y] -= tmp[
x];
367 return x*x + y*y + z*
z;
389 const double rho = sqrt(a*a + b*b);
398 const double w = 1.0 / sqrt(
ch*
ch +
sh*
sh);
404 inline double geta()
const {
return 1.0 - 2.0*
sh*
sh; }
Auxiliary class for quaternion computation.
Q(UTCMax_s-UTCMin_s)-livetime_s
static double getLengthSquared(const double x, const double y, const double z)
Get length squared.
JMatrix3D & mul(const double factor)
Scale matrix.
JMatrix3D & transpose()
Transpose.
double sh
sine rotation angle
JGivens(const double a, const double b)
Constructor.
JSVD3D()
Default constructor.
static constexpr double EPSILON
JQuaternion(JMatrix3S &S)
Constructor.
JSVD3D(const JMatrix3D &A)
Constructor.
double ch
cosine rotation angle
double getb() const
get new b value
void decompose(const JMatrix3D &A)
Decompose given matrix.
Singular value decomposition.
double geta() const
get new a value
static const double PI
Mathematical constants.
void conjugate(const int x, const int y, const int z, JMatrix3S &S)
Get conjugate of symmetric matrix for given order.
then JCookie sh JDataQuality D $DETECTOR_ID R
then usage $script[energy[distance[z of PMT]]] fi case set_variable z
const JMatrix3D & invert(const double precision=1.0e-12) const
Get inverted matrix.
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
void scale(vector< double > &v, double c)
scale vector content