1 | /* Test program to test resize of symmetric matrix, adapted from example
|
---|
2 | * provided at http://www.boost.org/libs/numeric/ublas/doc/symmetric.htm
|
---|
3 | *
|
---|
4 | * author: Tinne De Laet (first dot last at mech dot kuleuven dot be)
|
---|
5 | */
|
---|
6 |
|
---|
7 |
|
---|
8 | #include <boost/numeric/ublas/symmetric.hpp>
|
---|
9 | #include <boost/numeric/ublas/io.hpp>
|
---|
10 |
|
---|
11 | int main () {
|
---|
12 | using namespace boost::numeric::ublas;
|
---|
13 |
|
---|
14 | // Check resize for matrix
|
---|
15 | matrix<double> m (3, 3);
|
---|
16 | for (unsigned i = 0; i < m.size1 (); ++ i)
|
---|
17 | for (unsigned j = 0; j < m.size2 (); ++ j)
|
---|
18 | m (i, j) = 3 * i + j;
|
---|
19 | std::cout << "original m" << m << "\n" << std::endl;
|
---|
20 |
|
---|
21 | std::cout << "Resize m to bigger size" << std::endl;
|
---|
22 | m.resize(m.size1 () +2, m.size2 () +2,true);
|
---|
23 | std::cout << "m resized: " << m << " \n" << std::endl;
|
---|
24 |
|
---|
25 | std::cout << "Resize m to smaller size" << std::endl;
|
---|
26 | m.resize(m.size1 () -1, m.size2 () -1,true);
|
---|
27 | std::cout << "m resized: " << m << " \n" << std::endl;
|
---|
28 |
|
---|
29 | // Check resize for symmetric matrix
|
---|
30 | symmetric_matrix<double, lower> ml (3, 3);
|
---|
31 |
|
---|
32 | for (unsigned i = 0; i < ml.size1 (); ++ i)
|
---|
33 | for (unsigned j = 0; j <= i; ++ j)
|
---|
34 | ml (i, j) = 3 * i + j;
|
---|
35 | std::cout << "original ml" << ml << " \n" << std::endl;
|
---|
36 |
|
---|
37 | symmetric_matrix<double, upper> mu (3, 3);
|
---|
38 | for (unsigned i = 0; i < mu.size1 (); ++ i)
|
---|
39 | for (unsigned j = i; j < mu.size2 (); ++ j)
|
---|
40 | mu (i, j) = 3 * i + j;
|
---|
41 | std::cout << "original mu" << mu << " \n" << std::endl;
|
---|
42 |
|
---|
43 | std::cout << "Resize ml to bigger size" << std::endl;
|
---|
44 | ml.resize(ml.size1 () +2,true);
|
---|
45 | std::cout << "ml resized: " << m << " \n" << std::endl;
|
---|
46 |
|
---|
47 | std::cout << "Resize ml to smaller size" << std::endl;
|
---|
48 | ml.resize(ml.size1 () -1,true);
|
---|
49 | std::cout << "ml resized: " << m << " \n" << std::endl;
|
---|
50 |
|
---|
51 | std::cout << "Resize mu to smaller size" << std::endl;
|
---|
52 | mu.resize(mu.size1 () -1,true);
|
---|
53 | std::cout << "mu resized: " << m << " \n" << std::endl;
|
---|
54 |
|
---|
55 | std::cout << "Resize mu to bigger size" << std::endl;
|
---|
56 | mu.resize(mu.size1 () +1,true);
|
---|
57 | std::cout << "mu resized: " << m << " \n" << std::endl;
|
---|
58 | }
|
---|
59 |
|
---|