Boost logo

Ublas :

From: Ian McCulloch (ianmcc_at_[hidden])
Date: 2005-09-18 15:45:24


ZhiQiang Chen wrote:

> Dear all,
>
> I found some weird error in the following code:
>
> //////////////////////////////////////////////////////////////////////
> #include <boost/numeric/ublas/io.hpp>
> #include <boost/numeric/ublas/matrix.hpp>
> #include <boost/numeric/ublas/vector.hpp>
>
> using std::cout;
> using std::endl;
>
> int main()
> {
> namespace ublas = boost::numeric::ublas;
> using namespace ublas;
>
> typedef ublas::vector<double> Vector;
> typedef ublas::matrix<double> Matrix;
> typedef ublas::zero_vector<double> ZeroVec;
> typedef ublas::zero_matrix<double> ZeroMat;
> typedef Vector::size_type size_type;
>
> size_type N = 5;
>
> Matrix mat(ZeroMat(N, N)); // works fine
>
> Vector vec(ZeroVec(N)); // error incurred when compiled

This declares a function taking one argument, a ZeroVec named N, and
returning Vector.

> // Vector vec(ZeroVec(N +1 -1)); // works fine
> // Vector vec(ZeroVec(5)); // works fine

These cannot be parsed as a function prototype, and are therefore treated as
expressions. Further options to make it not look like a function would be

   Vector vec((ZeroVec(N))); // extra brackets
   Vector vec = ZeroVec(N);

HTH,
Ian