Thanks very much Philippe!
Nicolas
--On mardi 23 mars 2004 14:46 -0600 Philippe Canal <pcanal@fnal.gov> wrote:
> Hi,
>
> When mat is TMatrixD* you have to use something like:
>
> (*mat)(row,col)
>
> Cheers,
> Philippe.
>
> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Nicolas Arnaud
> Sent: Tuesday, March 23, 2004 12:53 PM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] Strange behavior with TMatrixD
>
>
>
> Hi rooters,
>
> I have a problem with an object of type TMatrixD. I could isolate it and so
> wrote a short
> code -- testMatrixD.cc, see below -- to reproduce the problem.
>
> In short: the instruction
>
> mat( row, col ) = 10 * row + col;
>
> is OK when mat is a TMatrixD, but not when mat is a TMatrixD*.
>
> Indeed:
>
> // TMatrixD case
> ----------------
>
> .x testMatrixD.cc++
>
> I get the normal root output:
>
> (int)0
>
> // TMatrixD* case
> -----------------
>
> .x testMatrixD.cc++
>
> I have a compilation error:
>
> /home/narnaud/BaBar/Root/testMatrixD.cc: In function `int testMatrixD()':
> /home/narnaud/BaBar/Root/testMatrixD.cc:32: `mat' cannot be used as a
> function
>
> On the other hand, when I simply run the code interactively with
>
> .x testMatrixD.cc
>
> everything works well in both cases!
>
> Any idea on what's wrong with my file?
>
> Thanks in advance,
>
> Nicolas
>
> PS I'm using ROOT 3.10/02 on linux.
>
> code testMatrixD.cc
> -------------------
>
># ifndef __CINT__
>
># include <TROOT.h>
># include <TSystem.h>
>
># include <stdlib.h>
># include <stdio.h>
># include <Riostream.h>
>
> int testMatrixD();
>
> int main()
> {
> return testMatrixD();
> }
>
># endif
>
># include <TMatrixD.h>
>
> int testMatrixD()
> {
> // matrix
> //TMatrixD mat( 2, 2 );
>
> // pointer on a matrix
> TMatrixD *mat;
> mat = new TMatrixD( 2, 2 );
>
> for( int row = 0 ; row < 2 ; row ++ ) {
> for( int col = 0 ; col < 2 ; col ++ ) {
> mat( row, col ) = 10 * row + col;
> }
> }
>
> return( 0 );
> }
>
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET