Difficulties using SMatrix::SimilarityT

Dear ROOTers

In my code, I have to calculate A’WA where W is symmetric. In order to do this, I found the method ROOT::Math::SimilarityT.

Using the following minimalized code:

typedef double value_t; ROOT::Math::SMatrix<value_t,8,4> A; ... fill A ... ROOT::Math::MatRepSym<value_t,8> W; ... fill W ... and then ATWA = ROOT::Math::SimilarityT(A,W); where ATWA is MatRepSym<value_t,4> as well.

When I try to compile this, I get

[code]lxplus303:SurveyAnalysis/src> scramv1 b
Reading cached build data

Local Products Rules … started
Local Products Rules … done
Compiling {snip}CMSSW_3_5_0/src/Alignment/SurveyAnalysis/src/SurveyPxbImageLocalFit.cc
{snip}/CMSSW_3_5_0/src/Alignment/SurveyAnalysis/src/SurveyPxbImageLocalFit.cc: In member function ‘void SurveyPxbImageLocalFit::doFit()’:
{snip}/CMSSW_3_5_0/src/Alignment/SurveyAnalysis/src/SurveyPxbImageLocalFit.cc:81: error: no matching function for call to ‘Similarity(ROOT::Math::SMatrix<double, 8u, 4u, ROOT::Math::MatRepStd<double, 8u, 4u> >&, ROOT::Math::MatRepSym<double, 8u>&)’
gmake: *** [tmp/slc5_ia32_gcc434/src/Alignment/SurveyAnalysis/src/AlignmentSurveyAnalysis/SurveyPxbImageLocalFit.o] Error 1[/code]

(As you can see, I use the incarnation of ROOT in CMSSW, tf. scramv1 as build tool and ROOT in version 5.22/00d (branches/v5-22-00-patches@29532, Jan 27 2010, 15:18:00 on linux))

Doing the same thing using normal matrices and writing the expression as ATWA = ROOT::Math::Transpose(A) * W * A; works fine. I can live with this, but assume that it is less efficient than SimilarityT (this will be calculated several hundred times per call of my routine).

Any help is appreciated.

Kind regards,

Frank

Hi,

Sorry for my late reply. I hope you have found the problem in the meantime. If not, you need to use a symmetric matrix type in the Similarity function.
MatRepSym is just the representation type and not the matrix class.

Here is a possible working code:

typedef double value_t; 
ROOT::Math::SMatrix<value_t,8,4> A; 

ROOT::Math::SMatrix<value_t, 8, 8, ROOT::Math::MatRepSym<value_t,8> > W; 
// after filling the matrix A and W 


ROOT::Math::SMatrix<value_t, 4, 4, ROOT::Math::MatRepSym<value_t,4> >  ATWA = ROOT::Math::SimilarityT(A,W);

See also the ref doc at

project-mathlibs.web.cern.ch/pro … d75ed428ac

Best Regards

Lorenzo