TGraph2D Interpolate

I have a discrete data set with values f(xi,yi)=zi and I would like to interpolate a z value for any given x,y value. Using the TGraph2D->Interpolate() function should do the job but for some values I only get 0 as a return value. Please see the attached files for illustration.

OS: Windows XP
Root version: 5.10

Thanks for any suggestions.

Frank
example.zip (11.2 KB)

Olivier will investigate your problem on Monday.

Rene

I just had a quick look. I unziped your file. I get the macro power2.c and the directory “data”. I renamed power2.c into power.C because power2.c doesn’t not have any power2() function. Then I ran power.C and I get:

root [0] .x power.C
Looking for data files ...
OK
Reading all data ...
Error: strtok param[0] type mismatch C:\cygwin\home\Olivier\roottest\power.C(105
)
*** Interpreter error recovered ***
root [1]

Did I missed something ?

Sorry I forgot to change the function name in the macro.

I do not get the strtok error on my system. As far as I can see you are running the macro under cygwin. I am running it directly under Windows.

Your macro was missing:
#include <stdio.h>

Now I can run it. I get the following output:

root [0] .x power.C
Processing power.C...
Looking for data files ...
OK
Reading all data ...
5 0.6
5 0.8
5 1
5 1.2
5 1.4
5 1.6
5 1.8
6 0.6
6 0.8
6 1
6 1.2
6 1.4
6 1.6
6 1.8
7 0.6
7 0.8
7 1
7 1.2
7 1.4
7 1.6
7 1.8
OK
Interpolating data ...
OK
49.5545
root [1]

Is that what you also get ?

My macro is running without the stdio.h include. Here is what I get as a result

root [0] .x power.c
Looking for data files ...
OK
Reading all data ...
5 0.6
5 0.8
5 1
5 1.2
5 1.4
5 1.6
5 1.8
6 0.6
6 0.8
6 1
6 1.2
6 1.4
6 1.6
6 1.8
7 0.6
7 0.8
7 1
7 1.2
7 1.4
7 1.6
7 1.8
OK
Interpolating data ...
OK
0
root [1]

The interpolated return value on my system is 0. What version of Root are you running?

I am running the last version: 5.17/09

Any idea where the problem could be?

Some fix was done in 5/12 to avoid the kind of problem shown here:
couet.home.cern.ch/couet/root/ht13.html
if the point you use in Interpolate() falls in one of these “hole” you will get 0 as result.
Changing the number of points might help with the root version you are using.

I updated to 5.17 and the program works fine.

Thanks!