How to reference nested classes in templates?

21 views
Skip to first unread message

Charles Bouillaguet

unread,
Sep 16, 2016, 4:52:14 AM9/16/16
to cython-users
Dear all,

I am trying to hook LinBox into sage more tightly, and LinBox makes extensive use of templates, amongst other kinds of nastiness.

LinBox has classes for various mathematical domains, and a lot functions are templated by the domain on which they operate. I am typically facing:

template<Matrix>
void determinant(Matrix::Field::Element &result, const Matrix &A);
                 ^^^^^^^^^^^^^^^^^^^^^^

The Matrix class describes either a sparse or dense matrix, over the integers/rationals/modulo-p-implemented-as-floats, etc.

The problem is that I don't know how to refer to the nested classes of the template class. If I write the following cython declaration:

cdef extern from "linbox/solutions/det.h" namespace "LinBox":
    cdef void determinant[Matrix] (Matrix.Field.Element &result, const Matrix &A) 

I get an error: "Matrix is not a cimported module".

The only workaround I have found so far is to give up on genericity and write :

cdef extern from "linbox/solutions/det.h" namespace "LinBox":
    cdef void determinant(TheFieldIWant &result, const TheMatrixIWant &A) 
    cdef void determinant(TheOtherFieldIWant &result, const TheOtherMatrixIWant &A) 
    ...

Some advice would be much appreciated! :-)

Best regards,
--
Charles Bouillaguet

Robert Bradshaw

unread,
Sep 18, 2016, 1:57:06 AM9/18/16
to cython...@googlegroups.com
I'm assuming that Matrix::Field::Element is a typedef (of a typedef)
in the Matrix class? This feature was just recently added and will be
available in the next release.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "cython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cython-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages