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
| #include <iostream>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix.hpp>
using namespace boost::numeric::ublas;
int main () {
vector<double> v (3);
vector<double> w (3);
vector<double> t (3);
v[0] = 1.; v[1] = 0.; v[2] = 0.;
w[0] = 0.; w[1] = 1.; w[2] = 0.;
t[0] = 2.; t[1] = 0.; t[2] = 0.;
std::cout << v << std::endl; //Affiche : [3](1,0,0)
std::cout << w << std::endl; //Affiche : [3](0,1,0)
std::cout << t << std::endl; //Affiche : [3](2,0,0)
matrix<double> m = outer_prod ( v, w );
std::cout << m << std::endl; //Affiche : [3,3]((0,1,0)(0,0,0)(0,0,0)) là je comprends pas!!!
m = outer_prod ( v, t );
std::cout << m << std::endl; //Affiche : [3,3]((2,0,0)(0,0,0)(0,0,0)) là je comprends pas!!!
double val = inner_prod ( v, w );
std::cout << val << std::endl; //Affiche : 0 là c'est OK, c'est bien le produit scalaire
val = inner_prod ( v, t );
std::cout << val << std::endl; //Affiche : 2 là c'est OK, c'est bien le produit scalaire
system ("pause");
} |