Boost logo

Ublas :

Subject: Re: [ublas] numeric bindings
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2010-10-26 13:57:13


On 2010-10-26 18:40, Andreas Hehn wrote:
> Hello everybody,
>
> I'm not sure whether this is the right mailing list for my question
> since it's not related to the ublas itself, but to
> boost::numeric::bindings from boost sandbox.
> If there is another mailing list better suited for this please let me know.
>
> I have written a matrix class and wanted to use the interface to blas
> and lapack defined by the boost::numeric::bindings library. However the
> documentation for the library from the sandbox repository was quite
> sparse and incomplete.
> Does anyone know what concepts my matrix class must model or what
> features I have to implement to meet the requirements of this library?
>
> I tried to get the requirements from the code itself, but I couldn't
> figure it out. I'd be really thankful for some help.
>
> Regards,
>
> Andreas

Hello Andreas,

I have to admit that the documentation isn't progressing too fast due to
lack of time at the moment. If you would like to use your matrix class
with blas and/or lapack, it has to use a linear array storage format.

You tell the bindings about your class by partially specializing the
adaptor template living in the bindings::detail namespace. It has three
template parameters: TypeWithoutConst, Id, and Enable. Here, you
probably want to keep the 2nd and 3rd template parameters equal to Id
and Enable. The "Id" param is equal to the 1st param, but it keeps its
constness. You can use the Enable param for more exotic specializations
based on the enable_if template.

E.g.,

... bindings { namespace detail {

template< typename MyParam, typename Id, typename Enable >
struct adaptor< YourMatrixType< MyParam >, Id, Enable > {

   // property map
   // accessor functions

}

}} // namespace stuff

The property_map should tell the bindings all it can about your matrix
class using key-value property entries. This is compile-time stuff. The
run-time stuff is in the accessor functions, which is accessed by the
bindings routines to gather pointers and sizes and stuff (but only if it
isn't defined by the compile-time stuff already, like static sizes).

For examples of these adaptors, see, e.g., std/vector or ublas/matrix.

Hope this helps, if you have further questions, please don't hesitate to
ask.

Cheers,

Rutger