Boost logo

Ublas :

Subject: Re: [ublas] [bindings] Initial support for glas and mtl containers
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2010-01-15 08:07:49

Karl Meerbergen wrote:

> Dear Rutger,
> It may be possible to create bindings to all objects that satisfy the
> glas::StridedDenseVectorCollection and
> glas::StridedDenseMatrixCollection concepts. With the old bindings that
> was easy to do with a single traits specialization. (For example, that
> would automatically include std::vector). I will see if I can do the
> same with the new traits system. I am rather busy at the moment with
> other things so it will not be ready soon.

Thanks Karl,

those meta-functions in glas make it very easy to write bindings. In theory,
one specialization could be used for the whole of glas, but that's probably
not the most readable one. The granularity is up to the author of the

I just committed an example of a single specialization that binds
DenseVectorCollection and all its existing descendants (including fixed size
stuff). See numeric/bindings/glas/dense_vector_collection.hpp. Not sure if
views/proxies like ranges etc. are collections or expressions? In the latter
case it may be beneficial to have an adaptor work for expressions, too.

See below for a short code example.



#include <glas/container/dense_vector.hpp>
#include <glas/container/fixed_size_dense_vector.hpp>
#include <boost/numeric/bindings/glas/dense_vector_collection.hpp>
#include <boost/numeric/bindings/noop.hpp>
#include <boost/numeric/bindings/blas/level1/set.hpp>
#include <boost/numeric/bindings/io.hpp>
namespace bindings = boost::numeric::bindings;
namespace blas = boost::numeric::bindings::blas;
int main() {
    glas::dense_vector< double > v( 10 );
    std::cout << bindings::noop( v ) << std::endl;
    glas::fixed_size_dense_vector< 10, double > w ;
    blas::set( 5.0, w );
    std::cout << bindings::noop( w ) << std::endl;