Triangular Matrix Question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Triangular Matrix Question

James N. Knight
Hello all.  I'm trying to initialize a triangular matrix using the
following code.

     #include <boost/numeric/ublas/matrix.hpp>
     #include <boost/numeric/ublas/triangular.hpp>

     using namespace boost::numeric::ublas;

     int main(){

        scalar_matrix<double> sm(5,5,1.0);

        triangular_adaptor<scalar_matrix<double>,upper> tma(sm);

        triangular_matrix<double,upper> tm(tma);
     }

I'm compiling against the latest (3/23/06) cvs head of boost using
gcc4.0 on a linux machine.  A number of compiler errors are generated.
Here are the first few (I've modified them a bit for easier reading).

.../ublas/triangular.hpp: In instantiation of
‘ublas::triangular_adaptor<ublas::scalar_matrix<double>,
ublas::basic_upper<long unsigned int> >’:
test_tria.cpp:10:   instantiated from here
.../ublas/triangular.hpp:933: error: no type named ‘closure_type’ in
‘class ublas::scalar_matrix<double>’
.../ublas/triangular.hpp:965: error: no type named ‘closure_type’ in
‘class ublas::scalar_matrix<double>’
.../ublas/triangular.hpp:969: error: no type named ‘closure_type’ in
‘class ublas::scalar_matrix<double>’
.../ublas/triangular.hpp: In instantiation of
‘ublas::triangular_adaptor<ublas::scalar_matrix<double>,
ublas::basic_upper<long unsigned int> >’:
test_tria.cpp:10:   instantiated from here
.../ublas/triangular.hpp:1771: error: no type named ‘closure_type’ in
‘class ublas::scalar_matrix<double>’
.../ublas/triangular.hpp: In constructor ‘ublas::triangular_adaptor<M,
TRI>::triangular_adaptor(M&) [with M = ublas::scalar_matrix<double>, TRI
= ublas::basic_upper<long unsigned int>]’:
test_tria.cpp:10:   instantiated from here
.../ublas/triangular.hpp:947: error: using invalid field
‘ublas::triangular_adaptor<M, TRI>::data_’


It goes on from there.  Any ideas on why this is happening? Is this an
invalid use of triangular_adaptor?  I've also done it this way.

triangular_matrix<double,upper> tm(5,5);
tm.assign(scalar_matrix<double>(1.0));

This compiles, but produces an external_logic error (as expected) when I
compile and run without -DNDEBUG.  It does appear to work when I compile
without debugging though.

James
_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Reply | Threaded
Open this post in threaded view
|

Re: Triangular Matrix Question

Manoj Rajagopalan
I have often come across such errors in compiling my code. Often,
including one or more other headers solves the problem.

try including one or more of the following:
expression_types.hpp
matrix_proxy.hpp
matrix_expression.hpp
traits.hpp

you could try other header files that you suspect contain typedefs of
closure_type (there are so many!).

This is only a hack though - the best I have come up with.

cheers
Manoj



  James N. Knight wrote:

> Hello all.  I'm trying to initialize a triangular matrix using the
> following code.
>
>      #include <boost/numeric/ublas/matrix.hpp>
>      #include <boost/numeric/ublas/triangular.hpp>
>
>      using namespace boost::numeric::ublas;
>
>      int main(){
>
>         scalar_matrix<double> sm(5,5,1.0);
>
>         triangular_adaptor<scalar_matrix<double>,upper> tma(sm);
>
>         triangular_matrix<double,upper> tm(tma);
>      }
>
> I'm compiling against the latest (3/23/06) cvs head of boost using
> gcc4.0 on a linux machine.  A number of compiler errors are generated.
> Here are the first few (I've modified them a bit for easier reading).
>
> .../ublas/triangular.hpp: In instantiation of
> ‘ublas::triangular_adaptor<ublas::scalar_matrix<double>,
> ublas::basic_upper<long unsigned int> >’:
> test_tria.cpp:10:   instantiated from here
> .../ublas/triangular.hpp:933: error: no type named ‘closure_type’ in
> ‘class ublas::scalar_matrix<double>’
> .../ublas/triangular.hpp:965: error: no type named ‘closure_type’ in
> ‘class ublas::scalar_matrix<double>’
> .../ublas/triangular.hpp:969: error: no type named ‘closure_type’ in
> ‘class ublas::scalar_matrix<double>’
> .../ublas/triangular.hpp: In instantiation of
> ‘ublas::triangular_adaptor<ublas::scalar_matrix<double>,
> ublas::basic_upper<long unsigned int> >’:
> test_tria.cpp:10:   instantiated from here
> .../ublas/triangular.hpp:1771: error: no type named ‘closure_type’ in
> ‘class ublas::scalar_matrix<double>’
> .../ublas/triangular.hpp: In constructor ‘ublas::triangular_adaptor<M,
> TRI>::triangular_adaptor(M&) [with M = ublas::scalar_matrix<double>, TRI
> = ublas::basic_upper<long unsigned int>]’:
> test_tria.cpp:10:   instantiated from here
> .../ublas/triangular.hpp:947: error: using invalid field
> ‘ublas::triangular_adaptor<M, TRI>::data_’
>
>
> It goes on from there.  Any ideas on why this is happening? Is this an
> invalid use of triangular_adaptor?  I've also done it this way.
>
> triangular_matrix<double,upper> tm(5,5);
> tm.assign(scalar_matrix<double>(1.0));
>
> This compiles, but produces an external_logic error (as expected) when I
> compile and run without -DNDEBUG.  It does appear to work when I compile
> without debugging though.
>
> James
> _______________________________________________
> ublas mailing list
> [hidden email]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
>
_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Reply | Threaded
Open this post in threaded view
|

Re: Triangular Matrix Question

James N. Knight
Adding the line

typedef const matrix_reference<const self_type> closure_type;

into the definition of the scalar matrix class in matrix.hpp fixes the
problem.

I'm left wondering if this was left out for a reason though.  Most types
have a const_closure_type and a closure_type definition.  I've added
this definition for closure type but given it the same type as
const_closure_type.  I don't think it matters since you can't modify a
scalar matrix.

Maybe it was just overlooked.

Anyway, problem solved.

Nate

Manoj Rajagopalan wrote:

> I have often come across such errors in compiling my code. Often,
> including one or more other headers solves the problem.
>
> try including one or more of the following:
> expression_types.hpp
> matrix_proxy.hpp
> matrix_expression.hpp
> traits.hpp
>
> you could try other header files that you suspect contain typedefs of
> closure_type (there are so many!).
>
> This is only a hack though - the best I have come up with.
>
> cheers
> Manoj
>
>
>
>   James N. Knight wrote:
>> Hello all.  I'm trying to initialize a triangular matrix using the
>> following code.
>>
>>      #include <boost/numeric/ublas/matrix.hpp>
>>      #include <boost/numeric/ublas/triangular.hpp>
>>
>>      using namespace boost::numeric::ublas;
>>
>>      int main(){
>>
>>         scalar_matrix<double> sm(5,5,1.0);
>>
>>         triangular_adaptor<scalar_matrix<double>,upper> tma(sm);
>>
>>         triangular_matrix<double,upper> tm(tma);
>>      }
>>
>> I'm compiling against the latest (3/23/06) cvs head of boost using
>> gcc4.0 on a linux machine.  A number of compiler errors are generated.
>> Here are the first few (I've modified them a bit for easier reading).
>>
>> .../ublas/triangular.hpp: In instantiation of
>> ‘ublas::triangular_adaptor<ublas::scalar_matrix<double>,
>> ublas::basic_upper<long unsigned int> >’:
>> test_tria.cpp:10:   instantiated from here
>> .../ublas/triangular.hpp:933: error: no type named ‘closure_type’ in
>> ‘class ublas::scalar_matrix<double>’
>> .../ublas/triangular.hpp:965: error: no type named ‘closure_type’ in
>> ‘class ublas::scalar_matrix<double>’
>> .../ublas/triangular.hpp:969: error: no type named ‘closure_type’ in
>> ‘class ublas::scalar_matrix<double>’
>> .../ublas/triangular.hpp: In instantiation of
>> ‘ublas::triangular_adaptor<ublas::scalar_matrix<double>,
>> ublas::basic_upper<long unsigned int> >’:
>> test_tria.cpp:10:   instantiated from here
>> .../ublas/triangular.hpp:1771: error: no type named ‘closure_type’ in
>> ‘class ublas::scalar_matrix<double>’
>> .../ublas/triangular.hpp: In constructor ‘ublas::triangular_adaptor<M,
>> TRI>::triangular_adaptor(M&) [with M = ublas::scalar_matrix<double>, TRI
>> = ublas::basic_upper<long unsigned int>]’:
>> test_tria.cpp:10:   instantiated from here
>> .../ublas/triangular.hpp:947: error: using invalid field
>> ‘ublas::triangular_adaptor<M, TRI>::data_’
>>
>>
>> It goes on from there.  Any ideas on why this is happening? Is this an
>> invalid use of triangular_adaptor?  I've also done it this way.
>>
>> triangular_matrix<double,upper> tm(5,5);
>> tm.assign(scalar_matrix<double>(1.0));
>>
>> This compiles, but produces an external_logic error (as expected) when I
>> compile and run without -DNDEBUG.  It does appear to work when I compile
>> without debugging though.
>>
>> James
>> _______________________________________________
>> ublas mailing list
>> [hidden email]
>> http://lists.boost.org/mailman/listinfo.cgi/ublas
>>
> _______________________________________________
> ublas mailing list
> [hidden email]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
>
_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Reply | Threaded
Open this post in threaded view
|

Re: Triangular Matrix Question

Michael Stevens-5
In reply to this post by James N. Knight
James,


On Saturday, 25. March 2006 01:02, James N. Knight wrote:

> Hello all.  I'm trying to initialize a triangular matrix using the
> following code.
>
>      #include <boost/numeric/ublas/matrix.hpp>
>      #include <boost/numeric/ublas/triangular.hpp>
>
>      using namespace boost::numeric::ublas;
>
>      int main(){
>
>         scalar_matrix<double> sm(5,5,1.0);
>
>         triangular_adaptor<scalar_matrix<double>,upper> tma(sm);
>
>         triangular_matrix<double,upper> tm(tma);
>      }
>
> I'm compiling against the latest (3/23/06) cvs head of boost using
> gcc4.0 on a linux machine.  A number of compiler errors are generated.
> Here are the first few (I've modified them a bit for easier reading).

Just tried this and get the same error. Turns out to be a missing line in the
definition of scalar_matrix.

matrix.hpp line 2728 should read.
        typedef matrix_reference<self_type> closure_type;
scalar_vector also seems to have the same problem.

I will check these into Boost CVS HEAD when Sourceforges CVS server starts
working again!

Michael

--
___________________________________
Michael Stevens Systems Engineering

34128 Kassel, Germany
Phone/Fax: +49 561 5218038

Navigation Systems, Estimation  and
                 Bayesian Filtering
    http://bayesclasses.sf.net
___________________________________
_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas