Hello,
Here is the problem I am having:
In the following code (tried to keep it as short as possible), I
create a vector [vec1] and a matrix [mat1] in the respective test
functions. Then, I create [vec2] and [mat2] in main, but when I print
them they have the values of [vec1] and [mat1]. Why is this happening?
I am quite new to boost, so I may miss something quite fundamental. I
really appreciate you help.
System: Fedora Core 4, boost-1.33.1.-5, g++ 4.0.2
Regards,
Vasilios
----------------------------------------------------------------------------------------------------------------------------------------------------------
#include
#include
#include
typedef boost::numeric::ublas::matrix<double> ublas_matrix;
typedef boost::numeric::ublas::vector<double> ublas_vector;
using std::cout;
using std::endl;
void test_matrix();
void test_vector();
int main() {
test_matrix();
ublas_matrix mat2(3, 2);
cout << "m2 = " << mat2 << endl;
test_vector();
ublas_vector vec2(4);
cout << "v2 = " << vec2 << endl;
}
void test_matrix() {
unsigned m = 3, n = 2;
ublas_matrix mat1(m, n);
for (unsigned i = 0; i < m; ++ i)
for (unsigned j = 0; j < n; ++ j)
mat1(i, j) = 5.0;
}
void test_vector() {
ublas_vector vec1(4);
for (unsigned i = 0; i < vec1.size(); ++i)
vec1(i) = i;
}
----------------------------------------------------------------------------------------------------------------------------------------------------------