Hi Alexey,
you wrote:
I am try to use Ublas library and have some questions.
I am want to write next code:
template<class Matrix>
void ProcessRecursive(Matrix& m)
{
typedef matrix_range<typename Matrix::matrix_type> MatrixRange;
...
MatrixRange mr = project(m, range(...), range(...));
...
ProcessRecursive(mr);
...
}
void StartProcess()
{
...
matrix<double> m;
...
ProcessRecursive(m);
}
Interesting problem: the naive solution
----------
#include
using namespace boost::numeric::ublas;
template<class Matrix>
void ProcessRecursive(Matrix& m)
{
typedef matrix_range<Matrix> MatrixRange;
MatrixRange mr = project(m, range(0,m.size1()/2), range(0,m.size2()/2));
if (mr.size1() > 0 && mr.size2() > 0)
ProcessRecursive(mr);
}
void StartProcess()
{
matrix<double> m;
ProcessRecursive(m);
}
int main()
{
StartProcess();
}
----------
doesn't terminate to compile ;-)
But I have not enough type matrix_type in class matrix<...> and function
template<class M>
matrix_range<M> project(matrix_range<M>& data, const range& r1, const
range&
r2);
This one terminates compiling (and running ;-) under GCC 3.2.1:
----------
#include
using namespace boost::numeric::ublas;
template<class Matrix>
void ProcessRecursive(matrix_range<Matrix>& m)
{
typedef matrix_range MatrixRange;
MatrixRange mr = m.project(range(0,m.size1()/2), range(0,m.size2()/2));
if (mr.size1() > 0 && mr.size2() > 0)
ProcessRecursive(mr);
}
template<class Matrix>
void ProcessRecursive(Matrix& m)
{
typedef matrix_range MatrixRange;
MatrixRange mr = project (m, range(0,m.size1()/2), range(0,m.size2()/2));
if (mr.size1() > 0 && mr.size2() > 0)
ProcessRecursive(mr);
}
void StartProcess()
{
matrix<double> m;
ProcessRecursive(m);
}
int main()
{
StartProcess();
}
----------
I admit that using the undocumented matrix_range::project() is a hack.
There is almost the same function project but reciving const referens to
matrix_range and compiler can't find it even using partial template
ordering.
Which compiler are you using?
Do somebody help my to write this code correctly? Or fix library?
How?
Best,
Joerg