Boost logo

Boost Users :

From: Jon Agiato (JonAgiato_at_[hidden])
Date: 2002-11-14 07:10:22


----- Original Message -----
  From: Toon Knapen
  To: Boost-Users_at_[hidden]
  Sent: Thursday, November 14, 2002 2:58 AM
  Subject: Re: [Boost-Users] Problem with matrix_expressions

  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)

  Many thanks to Fresl and Knapen! I will get the hang of this sooner or later.

  Jon Agiato
  JonAgiato_at_[hidden]

[Non-text portions of this message have been removed]


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