Boost logo

Boost Users :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2002-11-14 02:58:28


On Thursday 14 November 2002 02:51, agiatojon wrote:
> Hello all,
>
> I am trying to compile the following code snippet from the
> documentation of matrix_expressions in which two matrices are used
> to display the use of addition and subtraction operations. I am not
> really sure how to post the error messages as there are literally
> hundreds of them, so here is the code as I am am pretty sure this is
> going to be one of those well known bugs kind of things. Compiled
> using VS.NET, debug mode.
>
> #include <iostream>

// include matrix.hpp instead of matrix_expression.hpp
#include <boost/numeric/ublas/matrix.hpp>

// if you want to stream ublas matrices or vectors, also
#include <boost/numeric/ublas/io.hpp>

>
> int main()
> {
> using namespace boost::numeric::ublas;
>
> matrix<double> m1(3, 3), m2(3, 3);
>
> for(int i = 0; i < std::min(m1.size1(), m2.size1()); ++i)
> for(int j = 0; j < std::min(m1.size2(), m2.size2()); ++j)
> m1(i, j) = m2(i, j) = 3 * i + j;
>
> std::cout << m1 + m2 << std::endl;
> std::cout << m1 - m2 << std::endl;
>
> std::cin.get();
> return EXIT_SUCCESS;
> }

With these two changes, it should work (at least on my linux box)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net