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
|
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
using namespace boost::numeric::ublas;
void InitRandom()
{
srand(time(NULL));
}
float Random( float Min, float Max )
{
return (rand() / (float)(RAND_MAX) * (Max - Min)) + Min;
}
int main( int argc, char ** argv )
{
mapped_matrix<float> m1(100, 100), m2(100, 100), m3(100, 100);
InitRandom();
for( unsigned i=0; i<m1.size1(); ++i )
{
for( unsigned j=0; j<m1.size2(); ++j )
{
m1(i, j) = Random(-5.0, 5.0);
m2(i, j) = Random(-5.0, 5.0);
}
}
m3 = prod(m1, m2);
return EXIT_SUCCESS;
} |
Partager