On Thu, Apr 3, 2014 at 11:03 AM, Henry Schreiner
<
henrysch...@gmail.com> wrote:
> Are there any plans to add support for integer templates to cython? I'd like
> to have a general wrapper for std::array (would help with std::tuple, too).
Not at the moment, though I can see how it would be useful. A
> On Saturday, March 16, 2013 11:50:00 AM UTC-5, Robert Bradshaw wrote:
>>
>> On Sat, Mar 16, 2013 at 3:56 AM, csd <
char...@gmail.com> wrote:
>> > Hi all,
>> >
>> > I am currently trying to wrap a C++ template class in Cython
>> > representing a
>> > sparse matrix. Here is a snippet of the C++ code:
>> >
>> > template <class T, int S=Eigen::ColMajor>
>> > class SparseMatrixExt:public SparseMatrix<T, S> {
>> > ...
>> >
>> > Basically T is the data type of the elements of the matrix (int, float
>> > etc.)
>> > and S is an integer which dictates how entries are stored. When I try to
>> > wrap this in Cython I get the error "unknown type in template argument"
>> > referring to a fixed value of S. As far as I know, int template types
>> > are
>> > not yet supported, but what is the best way around this issue?
>>
>> You can do
>>
>> cdef extern from *:
>> ctypedef void* int_parameter
>> int_parameter one "1"
>> int_parameter two "2"
>> int_parameter three "3"
>>
>> cdef SparseMatrixExt<double, two> *m = new SparseMatrixExt<double, two>()
>>
>> - Robert
>