1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| int main()
{
// Variables
double a;
double b;
double x1;
double x2;
// Vector
mylib::Vector3 u;
mylib::Vector3 v;
// Matrix
mylib::Matrix2 m;
mylib::Matrix2 n;
mylib::Matrix2 o;
// Input
std::cin>>a;
std::cin>>b;
std::cin>>u[0]>>u[1]>>u[2];
std::cin>>v[0]>>v[1]>>v[2];
std::cin>>m[0][0]>>m[0][1]>>m[1][0]>>m[1][1];
std::cin>>n[0][0]>>n[0][1]>>n[1][0]>>n[1][1];
// Norm of the cross product of u and v
x1 = mylib::norm(mylib::crossprod(u, v));
/* Code that I want to be generated :
x1 = sqrt((u[2]*v[3]-u[3]*v[2])*
(u[2]*v[3]-u[3]*v[2])+
(u[3]*v[1]-u[1]*v[3])*
(u[3]*v[1]-u[1]*v[3])+
(u[1]*v[2]-u[2]*v[1])*
(u[1]*v[2]-u[2]*v[1])
); */
// Determinant of sin of all elements of m multiplied by a
x2 = a*mylib::det(mylib::sin(m));
/* Code that I want to be generated :
x2 = a*(std::sin(m[0][0])*std::sin(m[1][1])-
std::sin(m[0][1])*std::sin(m[1][0])
); */
// Multiplication of two matrix (with one transposition) and a scalar
o = b*(mylib::transpose(m)*n);
/* Code that I want to be generated :
o[0][0] = b*(m[0][0]*n[0][0]+m[1][0]*n[1][0]);
o[0][1] = b*(m[0][0]*n[0][1]+m[1][0]*n[1][1]);
o[1][0] = b*(m[0][1]*n[0][0]+m[1][1]*n[1][0]);
o[1][1] = b*(m[0][1]*n[0][1]+m[1][1]*n[1][1]); */
return 0;
} |
Partager