Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


Regina Henschel wrote:
There is no mathematical problem, but I'm uncertain about coding
style. The algorithms work on matrices. They have a lot of parts
which are nearly identical but the matrices are transposed. How to
handle that?

Hi Regina,

I'd suggest using templates to achieve that - this way, you'll get
the same runtime performance, but avoid all the (semantically)
duplicated code.

There are multiple ways to tackle that, to avoid changing your code
too much, I'd suggest passing a permutating type as template
parameter to each of the methods in need of variation, e.g.:

template< class Selector >
bool calculateQRdecomposition(
   ScMatrixRef pMatA,
   ::std::vector< double>& pVecR, 
   SCSIZE nK,
   SCSIZE nN,
   Selector const& rSelector )
{
   for (SCSIZE major = 0; major < rSelector.getMajor(nK,nN); major+)
   ...
      for (SCSIZE minor = major; minor < rSelector.getMinor(nK,nN); minor++)
         pMatA->PutDouble( pMatA->GetDouble(
                               rSelector.getCol(major,minor),
                               rSelector.getRow(major,minor))/fScale,
                           rSelector.getCol(major,minor),
                           rSelector.getRow(major,minor));

etc - the Selector class then has simple inline 
double blah(a,b) { return a; } permutation methods - if you like, we
could have a look at that during the HackFest next weekend.

Otherwise - lovely code!

Cheers,

-- Thorsten

Attachment: pgpeDFwYq6PPP.pgp
Description: PGP signature


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.