Boost logo

Ublas :

Subject: Re: [ublas] [bindings] Workspaces
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2008-12-12 08:36:51

Rutger ter Borg wrote:
> I agree. Whatever interface we end up with, if a user can pass
> lapack::function( ..., optimal_workspace() );
> lapack::function( ..., minimal_workspace() );
> lapack::function( ..., workspace( a ) );
> lapack::function( ..., workspace( a, b ) );
> lapack::function( ..., workspace( a, b, c ) );
> would be clean and consistent to me.

This is indeed clean. I can see the big picture now. Instead of

> /// Select the number of workspaces depending on the value_type
> template <typename T>
> struct n_workspace_args { };

we simply need a compile time way to tell whether a value_type is
actually a complex value_type. The simplest way to achieve this would
probably be to extent the type_traits traits struct/class by a "static
const bool is_complex = false ;" member. The template function
template<typename A, typename B, typename C> XXX workspace(A& a, B& b,
C& c) could then simply return a XXX=boost::tuple<A&, B&, C&>.

Karl Meerbergen wrote:
> > We might also consider to make the
> > order of arguments passed to workspace arbitrary, by adding
> > retrieve methods for each value_type into the workspace1 ...
> > classes.
> >
> I have thought of that. Since the value_type of the arrays are fixed
> anyway that should be quite easy to do.

It may be easy to do (if you know how to do it), but I'm not sure
whether this is really worth it. It's certainly no major restriction to
the user if he has to provide the workspace arguments in the same order
as the corresponding lapack routine (i.e. complex first, then real, and
then integer).

Karl Meerbergen wrote:
> Yesterday, I suggested to add workspace3. No reactions so far. I have
> started the implementation in boost.sandbox, but I want agreement with
> the ml before continuing.

I really like the proposed

workspace( a )
workspace( a, b )
workspace( a, b, c )

semantic. Whether workspace( a, b, c ) returns a boost::tuple<A&, B&,
C&> or a workspace3<A,B,C> (or something completely different) is less
important to me. Just to be clear, workspace( a, b ) would return
boost::tuple<A&, B&> or a workspace2<A,B> and workspace( a ) would
return boost::tuple<A&> or a workspace1<A>.