Boost logo

Ublas :

Subject: Re: [ublas] Matrix with vector interface.
From: Joaquim Duran (jduran.gm_at_[hidden])
Date: 2012-09-18 04:10:41


2012/9/17 Gunter Winkler <guwi17_at_[hidden]>:
> Hello,
>
> Am Monday 17 September 2012 schrieb Joaquim Duran:
>> Dear all,
>>
>> My name is Joaquim Duran. I'm new to this mail list.
>>
>> I'm using ublas for signal processing and I'm interested that the
>> matrix have a similar interface to a vector, using a proxy, to apply
>> algorithms designed for vectors. To get an idea, if the element of a
>> vector is a double, then the element of a row facade is a column. If
>> this possible to get this behavior using existing proxies?
>
> Why not using a set of vectors and a matrix view of them?
>
> ublas::generalized_vector_of_vector<
> double,
> ublas::column_major,
> ublas::vector<ublas::vector<double> > > gvov;
>
> this class has a data() function which returns a reference to the
> storage array (which is a vector<vector<double> >)
>
> So you could use gvov.data().begin() as an iterator of vectors.
>
> see
> http://www.boost.org/doc/libs/1_51_0/libs/numeric/ublas/doc/html/classboost_1_1numeric_1_1ublas_1_1generalized__vector__of__vector.html
>
> (Additionally you get a very fast swap() of column references compared
> to swapping all the elements)
>
> Alternatively you could sort the indices of the columns instead of the
> real columns and use the ublas::matrix_indirect view for further
> computations.
>
> see
> http://www.boost.org/doc/libs/1_51_0/libs/numeric/ublas/doc/html/classboost_1_1numeric_1_1ublas_1_1matrix__indirect.html#_details
>
>
> mfg
> Gunter
>

The real application is not about sorting columns of a matrix (that
was only an illustrative of my purposes).

I'm developing classes to represent signals (think in DSP, AD
conversor,...) and implement operations to filter data, down-sampling
and related operations. Currently all classes are implemented based on
bounded_vector (to represent a signal or a sample of a set of signals)
and bounded_matrix (to represent a set of signals with the same number
of samples for each signal). The advantage of bounded containers is
that the resize operations (add or remove signals or samples) don't
generate new delete/operations.

To filter each signal from a matrix, using a matrix_row or a
bounded_vector there is no difference, as each signal must be filtered
individually. The facade that I was requesting was to implement the
down-sample operation, where each signal can be downloaded
individually or all at once in a group of signals, where it is little
more efficient. So this is the reason of the request: let a matrix to
be viewed as a vector of columns, or a vector of rows, to implement
generic algorithms.

Joaquim Duran