#pragma once /*st.h*/ #include <stdio.h> #include <math.h> class st { public: double est[4][4] = { 0.0 }; static const st gamma0; static const st gamma1; static const st gamma2; static const st gamma3; st operator+(const st& e2)const; st operator-(const st& e2)const; st operator*(const st& e2)const; st operator/(const st& e2)const; st operator+(double s)const; st operator-(double s)const; st operator*(double s)const; st operator/(double s)const; //st operator+(double s, const st& e2); //st operator-(double s, const st& e2); //st operator/(double s, const st& e2); //st operator*(double s, const st& e2); st operator+()const; st operator-()const; st& operator+=(const st& e2); st& operator-=(const st& e2); st& operator*=(const st& e2); st& operator/=(const st& e2); st& operator =(double s); st& operator+=(double s); st& operator-=(double s); st& operator*=(double s); st& operator/=(double s); double DETST()const; st IST()const; static st WST(const st& e1, const st& e2); static st VST(const st& e1, const st& e2); static st CST(const st& e1, const st& e2); static st AST(const st& e1, const st& e2); st WST(const st& e2)const; st VST(const st& e2)const; st CST(const st& e2)const; st AST(const st& e2)const; st ATST(const st& T)const; st PTST(const st& T)const; st RST(double u[4])const; st BST(double u[4])const; st MST(double m[4])const; }; const st st::gamma0 = { 0.0,0.0,0.0,0.0,1.0 }; const st st::gamma1 = { 0.0,0.0,0.0,0.0,0.0,1.0 }; const st st::gamma2 = { 0.0,0.0,0.0,0.0,0.0,0.0,1.0 }; const st st::gamma3 = { 0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0 }; st st::operator+(const st& e2)const { st e3; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { e3.est[i][j] = est[i][j] + e2.est[i][j]; } } return e3; } st st::operator-(const st& e2)const { st e3; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { e3.est[i][j] = est[i][j] - e2.est[i][j]; } } return e3; } st st::operator*(const st& e2)const { st e3; e3.est[0][0] = est[0][0] * e2.est[0][0] - est[2][0] * e2.est[2][0] - est[1][0] * e2.est[1][0] + est[1][1] * e2.est[1][1] + est[1][2] * e2.est[1][2] + est[1][3] * e2.est[1][3] - est[3][0] * e2.est[3][0] + est[3][1] * e2.est[3][1] + est[3][2] * e2.est[3][2] + est[3][3] * e2.est[3][3] + est[0][1] * e2.est[0][1] + est[0][2] * e2.est[0][2] + est[0][3] * e2.est[0][3] - est[2][1] * e2.est[2][1] - est[2][2] * e2.est[2][2] - est[2][3] * e2.est[2][3]; e3.est[1][0] = est[0][0] * e2.est[1][0] + est[1][0] * e2.est[0][0] - est[2][0] * e2.est[3][0] + est[3][0] * e2.est[2][0] - est[1][1] * e2.est[0][1] - est[1][2] * e2.est[0][2] - est[1][3] * e2.est[0][3] + est[0][1] * e2.est[1][1] + est[0][2] * e2.est[1][2] + est[0][3] * e2.est[1][3] - est[3][1] * e2.est[2][1] - est[3][2] * e2.est[2][2] - est[3][3] * e2.est[2][3] - est[2][1] * e2.est[3][1] - est[2][2] * e2.est[3][2] - est[2][3] * e2.est[3][3]; e3.est[1][1] = est[0][0] * e2.est[1][1] + est[1][1] * e2.est[0][0] - est[2][0] * e2.est[3][1] + est[3][1] * e2.est[2][0] - est[1][0] * e2.est[0][1] - est[1][2] * e2.est[2][3] + est[1][3] * e2.est[2][2] + est[0][1] * e2.est[1][0] - est[2][2] * e2.est[1][3] + est[2][3] * e2.est[1][2] - est[3][0] * e2.est[2][1] + est[3][2] * e2.est[0][3] - est[3][3] * e2.est[0][2] - est[2][1] * e2.est[3][0] - est[0][2] * e2.est[3][3] + est[0][3] * e2.est[3][2]; e3.est[1][2] = est[0][0] * e2.est[1][2] + est[1][2] * e2.est[0][0] - est[2][0] * e2.est[3][2] + est[3][2] * e2.est[2][0] - est[1][0] * e2.est[0][2] - est[1][3] * e2.est[2][1] + est[1][1] * e2.est[2][3] + est[0][2] * e2.est[1][0] - est[2][3] * e2.est[1][1] + est[2][1] * e2.est[1][3] - est[3][0] * e2.est[2][2] + est[3][3] * e2.est[0][1] - est[3][1] * e2.est[0][3] - est[2][2] * e2.est[3][0] - est[0][3] * e2.est[3][1] + est[0][1] * e2.est[3][3]; e3.est[1][3] = est[0][0] * e2.est[1][3] + est[1][3] * e2.est[0][0] - est[2][0] * e2.est[3][3] + est[3][3] * e2.est[2][0] - est[1][0] * e2.est[0][3] - est[1][1] * e2.est[2][2] + est[1][2] * e2.est[2][1] + est[0][3] * e2.est[1][0] - est[2][1] * e2.est[1][2] + est[2][2] * e2.est[1][1] - est[3][0] * e2.est[2][3] + est[3][1] * e2.est[0][2] - est[3][2] * e2.est[0][1] - est[2][3] * e2.est[3][0] - est[0][1] * e2.est[3][2] + est[0][2] * e2.est[3][1]; e3.est[0][1] = est[0][0] * e2.est[0][1] + est[0][1] * e2.est[0][0] - est[2][0] * e2.est[2][1] - est[2][1] * e2.est[2][0] + est[1][0] * e2.est[1][1] - est[1][1] * e2.est[1][0] + est[3][0] * e2.est[3][1] - est[3][1] * e2.est[3][0] + est[1][2] * e2.est[3][3] - est[1][3] * e2.est[3][2] - est[3][2] * e2.est[1][3] + est[3][3] * e2.est[1][2] - est[0][2] * e2.est[2][3] + est[0][3] * e2.est[2][2] - est[2][2] * e2.est[0][3] + est[2][3] * e2.est[0][2]; e3.est[0][2] = est[0][0] * e2.est[0][2] + est[0][2] * e2.est[0][0] - est[2][0] * e2.est[2][2] - est[2][2] * e2.est[2][0] + est[1][0] * e2.est[1][2] - est[1][2] * e2.est[1][0] + est[3][0] * e2.est[3][2] - est[3][2] * e2.est[3][0] + est[1][3] * e2.est[3][1] - est[1][1] * e2.est[3][3] - est[3][3] * e2.est[1][1] + est[3][1] * e2.est[1][3] - est[0][3] * e2.est[2][1] + est[0][1] * e2.est[2][3] - est[2][3] * e2.est[0][1] + est[2][1] * e2.est[0][3]; e3.est[0][3] = est[0][0] * e2.est[0][3] + est[0][3] * e2.est[0][0] - est[2][0] * e2.est[2][3] - est[2][3] * e2.est[2][0] + est[1][0] * e2.est[1][3] - est[1][3] * e2.est[1][0] + est[3][0] * e2.est[3][3] - est[3][3] * e2.est[3][0] + est[1][1] * e2.est[3][2] - est[1][2] * e2.est[3][1] - est[3][1] * e2.est[1][2] + est[3][2] * e2.est[1][1] - est[0][1] * e2.est[2][2] + est[0][2] * e2.est[2][1] - est[2][1] * e2.est[0][2] + est[2][2] * e2.est[0][1]; e3.est[2][1] = est[0][0] * e2.est[2][1] + est[2][1] * e2.est[0][0] + est[2][0] * e2.est[0][1] + est[0][1] * e2.est[2][0] + est[1][2] * e2.est[1][3] - est[1][3] * e2.est[1][2] + est[3][2] * e2.est[3][3] - est[3][3] * e2.est[3][2] - est[1][0] * e2.est[3][1] + est[1][1] * e2.est[3][0] + est[3][0] * e2.est[1][1] - est[3][1] * e2.est[1][0] + est[0][2] * e2.est[0][3] - est[0][3] * e2.est[0][2] - est[2][2] * e2.est[2][3] + est[2][3] * e2.est[2][2]; e3.est[2][2] = est[0][0] * e2.est[2][2] + est[2][2] * e2.est[0][0] + est[2][0] * e2.est[0][2] + est[0][2] * e2.est[2][0] + est[1][3] * e2.est[1][1] - est[1][1] * e2.est[1][3] + est[3][3] * e2.est[3][1] - est[3][1] * e2.est[3][3] - est[1][0] * e2.est[3][2] + est[1][2] * e2.est[3][0] + est[3][0] * e2.est[1][2] - est[3][2] * e2.est[1][0] + est[0][3] * e2.est[0][1] - est[0][1] * e2.est[0][3] - est[2][3] * e2.est[2][1] + est[2][1] * e2.est[2][3]; e3.est[2][3] = est[0][0] * e2.est[2][3] + est[2][3] * e2.est[0][0] + est[2][0] * e2.est[0][3] + est[0][3] * e2.est[2][0] + est[1][1] * e2.est[1][2] - est[1][2] * e2.est[1][1] + est[3][1] * e2.est[3][2] - est[3][2] * e2.est[3][1] - est[1][0] * e2.est[3][3] + est[1][3] * e2.est[3][0] + est[3][0] * e2.est[1][3] - est[3][3] * e2.est[1][0] + est[0][1] * e2.est[0][2] - est[0][2] * e2.est[0][1] - est[2][1] * e2.est[2][2] + est[2][2] * e2.est[2][1]; e3.est[3][0] = est[0][0] * e2.est[3][0] + est[3][0] * e2.est[0][0] + est[2][0] * e2.est[1][0] - est[1][0] * e2.est[2][0] + est[1][1] * e2.est[2][1] + est[1][2] * e2.est[2][2] + est[1][3] * e2.est[2][3] + est[2][1] * e2.est[1][1] + est[2][2] * e2.est[1][2] + est[2][3] * e2.est[1][3] - est[3][1] * e2.est[0][1] - est[3][2] * e2.est[0][2] - est[3][3] * e2.est[0][3] + est[0][1] * e2.est[3][1] + est[0][2] * e2.est[3][2] + est[0][3] * e2.est[3][3]; e3.est[3][1] = est[0][0] * e2.est[3][1] + est[3][1] * e2.est[0][0] + est[2][0] * e2.est[1][1] - est[1][1] * e2.est[2][0] + est[1][0] * e2.est[2][1] - est[1][2] * e2.est[0][3] + est[1][3] * e2.est[0][2] + est[2][1] * e2.est[1][0] + est[0][2] * e2.est[1][3] - est[0][3] * e2.est[1][2] - est[3][0] * e2.est[0][1] - est[3][2] * e2.est[2][3] + est[3][3] * e2.est[2][2] + est[0][1] * e2.est[3][0] - est[2][2] * e2.est[3][3] + est[2][3] * e2.est[3][2]; e3.est[3][2] = est[0][0] * e2.est[3][2] + est[3][2] * e2.est[0][0] + est[2][0] * e2.est[1][2] - est[1][2] * e2.est[2][0] + est[1][0] * e2.est[2][2] - est[1][3] * e2.est[0][1] + est[1][1] * e2.est[0][3] + est[2][2] * e2.est[1][0] + est[0][3] * e2.est[1][1] - est[0][1] * e2.est[1][3] - est[3][0] * e2.est[0][2] - est[3][3] * e2.est[2][1] + est[3][1] * e2.est[2][3] + est[0][2] * e2.est[3][0] - est[2][3] * e2.est[3][1] + est[2][1] * e2.est[3][3]; e3.est[3][3] = est[0][0] * e2.est[3][3] + est[3][3] * e2.est[0][0] + est[2][0] * e2.est[1][3] - est[1][3] * e2.est[2][0] + est[1][0] * e2.est[2][3] - est[1][1] * e2.est[0][2] + est[1][2] * e2.est[0][1] + est[2][3] * e2.est[1][0] + est[0][1] * e2.est[1][2] - est[0][2] * e2.est[1][1] - est[3][0] * e2.est[0][3] - est[3][1] * e2.est[2][2] + est[3][2] * e2.est[2][1] + est[0][3] * e2.est[3][0] - est[2][1] * e2.est[3][2] + est[2][2] * e2.est[3][1]; e3.est[2][0] = est[0][0] * e2.est[2][0] + est[2][0] * e2.est[0][0] + est[1][0] * e2.est[3][0] - est[1][1] * e2.est[3][1] - est[1][2] * e2.est[3][2] - est[1][3] * e2.est[3][3] - est[3][0] * e2.est[1][0] + est[3][1] * e2.est[1][1] + est[3][2] * e2.est[1][2] + est[3][3] * e2.est[1][3] + est[0][1] * e2.est[2][1] + est[0][2] * e2.est[2][2] + est[0][3] * e2.est[2][3] + est[2][1] * e2.est[0][1] + est[2][2] * e2.est[0][2] + est[2][3] * e2.est[0][3]; return e3; } st st::operator/(const st& e2)const { return *this * e2.IST(); } st st::operator+(double s)const { st e3 = *this; e3.est[0][0] += s; return e3; } st st::operator-(double s)const { st e3 = *this; e3.est[0][0] -= s; return e3; } st st::operator*(double s)const { st e3; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { e3.est[i][j] = est[i][j] * s; } } return e3; } st st::operator/(double s)const { st e3; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { e3.est[i][j] = est[i][j] / s; } } return e3; } st operator+(double s, const st& e2) { st e3 = e2; e3.est[0][0] += s; return e3; } st operator-(double s, const st& e2) { st e3 = -e2; e3.est[0][0] += s; return e3; } st operator*(double s, const st& e2) { st e3; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { e3.est[i][j] = s * e2.est[i][j]; } } return e3; } st operator/(double s, const st& e2) { return s * e2.IST(); } st st::operator+()const { return *this; } st st::operator-()const { st e2; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { e2.est[i][j] = -est[i][j]; } } return e2; } st& st::operator+=(const st& e2) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { est[i][j] += e2.est[i][j]; } } return *this; } st& st::operator-=(const st& e2) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { est[i][j] -= e2.est[i][j]; } } return *this; } st& st::operator*=(const st& e2) { *this = *this * e2; return *this; } st& st::operator/=(const st& e2) { *this = *this / e2; return *this; } st& st::operator =(double s) { st e = { s }; *this = e; return *this; } st& st::operator+=(double s) { est[0][0] += s; return *this; } st& st::operator-=(double s) { est[0][0] -= s; return *this; } st& st::operator*=(double s) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { est[i][j] *= s; } } return *this; } st& st::operator/=(double s) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { est[i][j] = est[i][j] / s; } } return *this; } double st::DETST()const { st e2 = *this; e2.est[0][0] *= -1; e2.est[3][0] *= -1; e2.est[3][1] *= -1; e2.est[3][2] *= -1; e2.est[3][3] *= -1; e2.est[2][0] *= -1; st e3 = *this * e2; e3.est[0][0] *= -1; return (*this * e2 * e3).est[0][0]; } st st::IST()const { const double EPS = pow(24.0, -24.0); double det = DETST(); if (fabs(det) > EPS) { st e = { 1 / det }, e2 = *this; e2.est[0][0] *= -1; e2.est[3][0] *= -1; e2.est[3][1] *= -1; e2.est[3][2] *= -1; e2.est[3][3] *= -1; e2.est[2][0] *= -1; st e3 = *this * e2; e3.est[0][0] *= -1; return e2 * e3 * e; } printf("\a"); return *this; } st st::WST(const st& e1, const st& e2) { st e3; e3.est[0][0] = e1.est[0][0] * e2.est[0][0]; e3.est[1][0] = e1.est[0][0] * e2.est[1][0] + e1.est[1][0] * e2.est[0][0]; e3.est[1][1] = e1.est[0][0] * e2.est[1][1] + e1.est[1][1] * e2.est[0][0]; e3.est[1][2] = e1.est[0][0] * e2.est[1][2] + e1.est[1][2] * e2.est[0][0]; e3.est[1][3] = e1.est[0][0] * e2.est[1][3] + e1.est[1][3] * e2.est[0][0]; e3.est[0][1] = e1.est[0][0] * e2.est[0][1] + e1.est[0][1] * e2.est[0][0] + e1.est[1][0] * e2.est[1][1] - e1.est[1][1] * e2.est[1][0]; e3.est[0][2] = e1.est[0][0] * e2.est[0][2] + e1.est[0][2] * e2.est[0][0] + e1.est[1][0] * e2.est[1][2] - e1.est[1][2] * e2.est[1][0]; e3.est[0][3] = e1.est[0][0] * e2.est[0][3] + e1.est[0][3] * e2.est[0][0] + e1.est[1][0] * e2.est[1][3] - e1.est[1][3] * e2.est[1][0]; e3.est[2][1] = e1.est[0][0] * e2.est[2][1] + e1.est[2][1] * e2.est[0][0] + e1.est[1][2] * e2.est[1][3] - e1.est[1][3] * e2.est[1][2]; e3.est[2][2] = e1.est[0][0] * e2.est[2][2] + e1.est[2][2] * e2.est[0][0] + e1.est[1][3] * e2.est[1][1] - e1.est[1][1] * e2.est[1][3]; e3.est[2][3] = e1.est[0][0] * e2.est[2][3] + e1.est[2][3] * e2.est[0][0] + e1.est[1][1] * e2.est[1][2] - e1.est[1][2] * e2.est[1][1]; e3.est[3][0] = e1.est[0][0] * e2.est[3][0] + e1.est[3][0] * e2.est[0][0] + e1.est[1][1] * e2.est[2][1] + e1.est[1][2] * e2.est[2][2] + e1.est[1][3] * e2.est[2][3] + e1.est[2][1] * e2.est[1][1] + e1.est[2][2] * e2.est[1][2] + e1.est[2][3] * e2.est[1][3]; e3.est[3][1] = e1.est[0][0] * e2.est[3][1] + e1.est[3][1] * e2.est[0][0] + e1.est[1][0] * e2.est[2][1] - e1.est[1][2] * e2.est[0][3] + e1.est[1][3] * e2.est[0][2] + e1.est[2][1] * e2.est[1][0] + e1.est[0][2] * e2.est[1][3] - e1.est[0][3] * e2.est[1][2]; e3.est[3][2] = e1.est[0][0] * e2.est[3][2] + e1.est[3][2] * e2.est[0][0] + e1.est[1][0] * e2.est[2][2] - e1.est[1][3] * e2.est[0][1] + e1.est[1][1] * e2.est[0][3] + e1.est[2][2] * e2.est[1][0] + e1.est[0][3] * e2.est[1][1] - e1.est[0][1] * e2.est[1][3]; e3.est[3][3] = e1.est[0][0] * e2.est[3][3] + e1.est[3][3] * e2.est[0][0] + e1.est[1][0] * e2.est[2][3] - e1.est[1][1] * e2.est[0][2] + e1.est[1][2] * e2.est[0][1] + e1.est[2][3] * e2.est[1][0] + e1.est[0][1] * e2.est[1][2] - e1.est[0][2] * e2.est[1][1]; e3.est[2][0] = e1.est[0][0] * e2.est[2][0] + e1.est[2][0] * e2.est[0][0] + e1.est[1][0] * e2.est[3][0] - e1.est[1][1] * e2.est[3][1] - e1.est[1][2] * e2.est[3][2] - e1.est[1][3] * e2.est[3][3] - e1.est[3][0] * e2.est[1][0] + e1.est[3][1] * e2.est[1][1] + e1.est[3][2] * e2.est[1][2] + e1.est[3][3] * e2.est[1][3] + e1.est[0][1] * e2.est[2][1] + e1.est[0][2] * e2.est[2][2] + e1.est[0][3] * e2.est[2][3] + e1.est[2][1] * e2.est[0][1] + e1.est[2][2] * e2.est[0][2] + e1.est[2][3] * e2.est[0][3]; return e3; } st st::VST(const st& e1, const st& e2) { return e1 * e2 - WST(e1, e2); } st st::CST(const st& e1, const st& e2) { return (e1 * e2 + e2 * e1) / 2.0; } st st::AST(const st& e1, const st& e2) { return (e1 * e2 - e2 * e1) / 2.0; } st st::WST(const st& e2)const { return WST(*this, e2); } st st::VST(const st& e2)const { return VST(*this, e2); } st st::CST(const st& e2)const { return VST(*this, e2); } st st::AST(const st& e2)const { return AST(*this, e2); } st st::ATST(const st& T)const { const double EPS = pow(24.0, -24.0); if (fabs(T.DETST()) > EPS) { return T.IST() * *this * T; } printf("\a"); return *this; } st st::PTST(const st& T)const { const double EPS = pow(24.0, -24.0); if (fabs(T.DETST()) > EPS) { return T * *this * T.IST(); } printf("\a"); return *this; } st st::RST(double u[4])const { st T; T.est[0][0] = cos(u[0] / 2.0); T.est[2][1] = sin(u[0] / 2.0) * u[1] / sqrt(u[1] * u[1] + u[2] * u[2] + u[3] * u[3]); T.est[2][2] = sin(u[0] / 2.0) * u[2] / sqrt(u[1] * u[1] + u[2] * u[2] + u[3] * u[3]); T.est[2][3] = sin(u[0] / 2.0) * u[3] / sqrt(u[1] * u[1] + u[2] * u[2] + u[3] * u[3]); return ATST(T); } st st::BST(double u[4])const { st T; T.est[0][0] = cosh(u[0] / 2.0); T.est[0][1] = sinh(u[0] / 2.0) * u[1] / sqrt(u[1] * u[1] + u[2] * u[2] + u[3] * u[3]); T.est[0][2] = sinh(u[0] / 2.0) * u[2] / sqrt(u[1] * u[1] + u[2] * u[2] + u[3] * u[3]); T.est[0][3] = sinh(u[0] / 2.0) * u[3] / sqrt(u[1] * u[1] + u[2] * u[2] + u[3] * u[3]); return ATST(T); } st st::MST(double m[4])const { st M; M.est[1][0] = m[0]; M.est[1][1] = m[1]; M.est[1][2] = m[2]; M.est[1][3] = m[3]; return -ATST(M); }