TMatrix oddity

This is a bit difficult to describe. I’ve attached code for a simple case.

Suffice to say, I have a class called Simple. Within simple I have two MatrixD created in the constructor.

I have a simple function for the class, AddMeasurement.

I can declare this class on the command line and call AddMeasurement many times without a problem.

If I put this in a simple script I can do the same.

If instead in the script I make the multiple calls via a for loop things get very confused. The TMatrixD objects don’t appear to have the same properties.

Is this a feature, or a misunderstanding on my part?

NOTE: the attachment is a single file with three parts since I didn’t know how to put 3 attachments on this message. Thanks

test3.C (2.7 KB)

Hi Chris,

Compiling your code:

g++ -c root-config --cflags test3.C
g++ root-config --glibs test3.o -o test3

everything is fine, but indeed running this script in the
Cint interpreter gives problems, even without a loop
with the CVS head on MacOSX 10.3.5 . I will pass it on to
the Cint experts .



The script as-is does not compile

test3.C(131): error: expression must have (pointer-to-) function type H(i,i) = 1.0;

That is another odd feature of using the interpretter. Since I do a new on TMatrix for H you would expect that the right way to access the elements is

(*H)(0,0) = 1.0

However, this doesn’t work on the interpreter.

I have been being rather lazy about writing things and just using the interpreter rather than complining and then loading them as a shared library. I suppose the latter would be better for catching errors and higher likelyhood of success.


Use the form

TMatrixD &M = *H;
M(0,0) = 1;