|
Re: matrix inside a matrix?: msg#00287lib.boost.user
Stephen Crowley wrote: > Is it possible to define a matrix that is part of a larger matrix, without > having to create temporaries and copy part of the larger? > > /----------\ > | | | > | SM | | > |----| LM | > | | > \----------/ > > I need to extract a sub-section of a matrix, multiply it, and then copy it > back. > I am currently using a temporary, but I have a feeling there must be a better > way. I suppose you are using ublas ;o) `template <typename Matrix> class matrix_range' seems to be what you are looking for: ============================================== using namespace boost::numeric::ublas; matrix<double> LM (10, 10); // init LM matrix<double> M1 (4, 4); // init M1 matrix_range<matrix<double> > SM (LM, range (1, 5), range (2, 6)); LM = prod (M1, LM); =============================================== matrix_range<> gives you a view of a part (a block) of a matrix. Note that class `range' follows `convention' of iterator ranges: `range (1, 5)' is `[1, 5)', i.e. `1, 2, 3, 4'. There is also function `project()', so there's no need to declare matrix_range<>: =============================================== project (M, range (1, 5), range (2, 6)) = prod (M1, project (M, range (1, 5), range (2, 6))); =============================================== More details on: http://64.226.201.52/libs/numeric/ublas/doc/matrix_proxy.htm#matrix_range Hope this help, fres ------------------------ Yahoo! Groups Sponsor ---------------------~--> Get 128 Bit SSL Encryption! http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/EbFolB/TM ---------------------------------------------------------------------~-> Info: <http://www.boost.org> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl> Unsubscribe: <mailto:boost-users-unsubscribe@xxxxxxxxxxxxxxx> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Is intrusive_ptr the thing to use?: 00287, Stephen Crowley |
|---|---|
| Next by Date: | Regex Match() Abortion: 00287, eydelber |
| Previous by Thread: | matrix inside a matrix?i: 00287, Stephen Crowley |
| Next by Thread: | Regex Match() Abortion: 00287, eydelber |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |