Boost logo

Ublas :

From: Ram (ramkaka_at_[hidden])
Date: 2006-08-14 17:42:18


Hey,

I am trying to get the following code to compile, but am not able to get it
to do so. The example code on the webpage (where the matrix is defined in
the int main() ) works fine.

Thanks,

RAm

------------------
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>

class foo {
public:
  static boost::numeric::ublas::matrix<double> m (3,3);
  static int bar();
};

int foo::bar() {
    for (unsigned i = 0; i < m.size1 (); ++ i)
        for (unsigned j = 0; j < m.size2 (); ++ j)
            m (i, j) = 3 * i + j;
    std::cout << m << std::endl;
}

int main () {
  // using namespace boost::numeric::ublas;

return 0;
}
-------------------

But I get the following error:

g++ btest.cpp -o btest
btest.cpp:7: error: expected identifier before numeric constant
btest.cpp:7: error: expected ',' or '...' before numeric constant
btest.cpp: In static member function 'static int foo::bar()':
btest.cpp:12: error: request for member 'size1' in 'foo::m', which is of
non-class type 'boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_row_major<unsigned int, int>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >
()(int)'
btest.cpp:13: error: request for member 'size2' in 'foo::m', which is of
non-class type 'boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_row_major<unsigned int, int>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >
()(int)'
btest.cpp:14: error: no matching function for call to 'foo::m(unsigned int&,
unsigned int&)'
btest.cpp:7: note: candidates are: static
boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_row_major<unsigned int, int>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >
foo::m(int)
btest.cpp:15: warning: the address of 'static
boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_row_major<unsigned int, int>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >
foo::m(int)', will always evaluate as 'true'
make: *** [btest] Error 1