Boost logo

Ublas :

Subject: Re: [ublas] poll: what's your uBLAS I/O usage ?
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2010-05-31 21:46:48


Gunter Winkler <guwi17 <at> gmx.de> writes:
> I'd like using the serialization this way (or using the funny "&"
> notation). I see a the big advantage, that it is a) easy to provide a
> working serialization for each uBlas container and b) easy to provide
> different format. One could even imagine to provide a "console_archive"
> for pretty printing matrices to std::out.

I agree, sounds like the right approach. And it could abstract the
difference
in implementation for row vs. column major matrices which would be a pain
for
other interfaces.
(as an aside, if anyone decides to take this further I think we could have
serialization of classes as matlab structs using something like the
name-value
pairs in the XML serialization here.
http://www.boost.org/doc/libs/1_43_0/libs/serialization/doc/index.html )

Can I ask for a suggestion or two on implementation? In particular, I want
to know if I am using the
boost::numeric::bindings in a smart way as I think this should be ublas
independent.

See the attached file for a starting point of the templates.

1) Since this wouldn't just be ublas specific, I wonder what we should call
the function that adds the 'name' to the structure and in what namespace it
should live in?

Perhaps it could reuse the name value pair mechanism in
boost::serialization that is primarily intended for XML archives (see
http://www.boost.org/doc/libs/1_43_0/boost/serialization/nvp.hpp
Do people think this could work and
that boost::serialization::make_nvp(const char* name, T& t) is the right
signature/namespace for this?

2) Matio is LGPL and would be required for the code here:Is that
reasonable? Is this the sort of code that should be in the numeric
bindings? http://sourceforge.net/projects/matio/

3) Assuming that we used make_nvp instead of the method I suggested in
anearlier email, the specilizations will be in the operator& and operator<<
functions.

4) You can see how I setup a few of the specializations here. A few
questions about the bindings:
  a) Am I using the right metafunctions for the specializations? (matio
seems to require contiguous row_major memory)

  b) How do I get the begin() and end() pointers to the data when using
matrices row_major and column_major? I figured out begin() for vectors but
was confused for matrices.

  c) Are there any tricks/utilities for converting the storage orderings
from column to row major? I could do a transpose, but how can you do it in
a data structure independent way?

  d) On a similar note, are there utilities to help with non-contiguous
structures getting into a chunk of contiguous memory? If so, then these
could be specialized for other than linear_array

Thanks,
Jesse