//*********************************************************** // // NXV4 "Math-on-Paper" software // // package : MTX class _____________________________________ // // supports: move semantix // operators + - * / L,R-val context // += -= *= /= // fabs() // ~ - unary operators L,R-val // mtx i.e. int // float // double // real // cpx // cpx // cpx // cpx // type_casts between the types // cout << overload // // TOTAL = 5084 instantiated op/f's // _____________________________________ // // // authors : Mihai-Tiberiu Dima (1) // Maria Dima (2) // // Meshcheryakov Laboratory of Information Techn. // Joint Institute for Nuclear Research // Dubna-Russia // // on leave from: // // Hyperion Univ. Bucharest-Romania // // // date : MTX4/v1.0.alfa / Mon Mar 07 12:45:54 CET 2022 // //*********************************************************** #include #include #include "cpx.hh" #include "vec.hh" #include "mtx.hh" using namespace std ; using namespace cpx4 ; using namespace vec4 ; using namespace mtx4 ; int main() { // vec4::utf8x = true ; // mtx4::utf8x = true ; // matrix elements as scalar products, as // in quantum mechanics: // // M_nn = ( n | M | n ) // // matrix eigen-vectors = columns of U // // U = eigen(M) // // ( n_i | n_j ) = delta_ij // // // to use this example do the following: // rm test.cc // ln -s e4.cc test.cc // make test // make run using fltx = float ; using dblx = double ; using real = long double ; double e = exp(1) ; double pi = 3.14159265853 ; cpx i(0,1) ; mtx M( 0.807, 0.807, 0, -0.807, 0.807, 0, 0, 0, 1 ) ; auto E = eigen(M) ; vec> n1(E.x11, E.x21, E.x31) ; vec> n2(E.x12, E.x22, E.x32) ; vec> n3(E.x13, E.x23, E.x33) ; cout << endl ; cout << noboolalpha << endl ; cout << endl ; cout << " _____________________________________" << endl ; cout << endl ; cout << endl ; cout << endl ; cout << " " << "M_11 = " << (n1|M|n1) << endl ; cout << " " << "M_22 = " << (n2|M|n2) << endl ; cout << " " << "M_33 = " << (n3|M|n3) << endl ; cout << endl ; cout << " ( n1 | n1 ) = " << (n1|n1) << " ( n1 | n2 ) = " << (n1|n2) << " ( n1 | n3 ) = " << (n1|n3) << endl ; cout << " ( n2 | n1 ) = " << (n2|n1) << " ( n2 | n2 ) = " << (n2|n2) << " ( n2 | n3 ) = " << (n2|n3) << endl ; cout << " ( n3 | n1 ) = " << (n3|n1) << " ( n3 | n2 ) = " << (n3|n2) << " ( n3 | n3 ) = " << (n3|n3) << endl ; cout << " _____________________________________" << endl ; cout << endl ; cout << endl ; cout << endl ; }