Boost logo

Ublas :

Subject: [ublas] [bindings] New traits system
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2009-11-27 04:03:17


Dear all,

Herewith some news surrounding the numeric_bindings. I've rewritten the
traits part from the ground up, with simplicity, flexibility and efficiency
in mind.

Most notable differences:

 * Full MPL-compatible support for static matrices and vectors, for all the
compile-time-junkies out there.
 * No more separate matrix and vector trait classes, all through one adaptor
 * Built-in automatic reinterpretations (matrix->vector, vector->matrix,
scalar->matrix (!), etc.) for all objects
 * Proxies and views through meta-adaptors, e.g., row(), column(), trans(),
upper(), lower()
 * Compile-time selected iterators (so far, linear data structures only,
triangular and yale sparse to come)
 * IO support; pretty printing (will give nice output for all bindable
objects)
 * Easier directory structure (std/vector.hpp, ublas/vector.hpp, etc.).
Directory name is the most specific namespace-name of the object, filename
is the lower-cased name of the object.
 * Support for C arrays, standard vectors, uBLAS, TNT, eigen2, more to be
added such as glas and mtl4

Some examples of what's possible:

double a[5][10];
std::cout << column( a, 0 ) << std::endl;
std::sort( begin( row( a, 2 ) ), end( row( a, 2 ) ) );
std::cout << result_of::num_rows<double[5][10]>::type::value << std::endl;
for( result_of::begin< T, 1 >::type i = begin< 1 >( t ); i != end< 1 >( t );
++i ) {
}

some bits are still a bit rough, but hopefully you're getting the idea. And,
of course, what drives all this, is the user-friendliness of calls to blas
and lapack. The goal is to be able to do

blas::some_op( trans( a ), row( b, 2 ) );

for any matrix and/or vector object. I would like to push this towards a
first kind of official RFC. I you're interested in the effort of getting a
(the second) stable version of numeric_bindings out of the door, please
don't hestitate to get involved.

Thanks!

Cheers,

Rutger