
Ublas : 
Subject: Re: [ublas] [newbie] submatrix and rest of a matrix
From: David Bellot (david.bellot_at_[hidden])
Date: 20091118 14:52:43
Hi Gunter,
indeed, my drawing was false. I'm not very good with ascii art. I wanted to
split in 3 with the rows not the column, but the problem remains the same
:)
In fact, I use indirect_array to generate my submatrices now and it works
pretty well.
So finally, in order to be a little bit matlab like (in my case it would be
very convenient) can I do the following, I didn't find anything that allow
to do that directly from the library:
(1) initialize an indirect_array with a vector<int> or something like that,
(2) initialize an indirect_array and do some kind of composition with range
like
indirect_array ia(range1, range2, range3, ... etc)
and last but not least in order to better understand how ublas works:
 what is the difference between matrix& , matrix_expression& and
matrix_reference
Thanks for your help. Very appreciated.
Cheers,
David
On Wed, Nov 18, 2009 at 20:33, Gunter Winkler <guwi17_at_[hidden]> wrote:
> Hello David,
>
> please read below:
>
> David Bellot schrieb:
> > Hi Ublas users,
> >
> > this is a newbie question:
> >
> > I am implementing a cross validation algorithm and for that purpose I
> > need to split up a big matrix X1 and a big vector Y1 many times in
> > different way. The idea is to use a percentage of the initial dataset
> > (X1 and Y1) to fit a model and the rest of this dataset to test it.
> >
> > Let's say my fitting procedure is
> >
> > double fit(const matrix<double>& X, const vector<double>& y)
> >
> > and initially I have my big dataset defined as
> > matrix<double> X1;
> > vector<double> Y1;
> >
> > during the loop of the crossvalidation algo, I split up X1 and Y1 in
> > the following manner to obtain a Xtraining and Ytraining dataset and
> > Xtest and Ytest dataset:
> >
> > 
> >  Xtraining  Xtest  Xtraining 
> >    
> >    
> > 
> >
> > 
> >  Ytraining  Ytest  Ytraining 
> > 
> This looks like you split the matrix into 3 sets of columns and the
> vector into 3 sets of corresponding elements.
> >
> > Of course, Xtest and Ytest is at a different position at each step of
> > the loop.
> > Xtest and Ytest are easy to obtain with a matrix_range<matrix<double> >
> > However Xtraining and Ytraining require a copy of the data to a
> > temporary matrix (and vector).
> Why do you need a copy? The indirect_array a able to select a set of
> columns and rows from a matrix.
>
> >
> > So how can I do that efficiently (indirect_array ? other ?) and do I
> > need to redefine the prototype of my fit function ?
> >
>
> mfg
> Gunter
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: david.bellot_at_[hidden]
>
 David Bellot, PhD david.bellot_at_[hidden] http://david.bellot.free.fr