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: pgpa52g8Hkh2U.pgp
Description: PGP signature

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to