Numerical Computation/Need for interpolation subroutine(akima spline)

Hi Every One,
I am working on an assignment that needs to be submitted on 08-08-2008. The IDE in use is Dev-C++ 4.9.9.2.
Basically, everything works well untill the program requests for values which are not avalable for a given energy 'energy[0]'. It will run but at those points spit out garbage for the needed values 'parameters'.

Discription of function:
1. The function must return a pointer to an arrary of six elements of type double
2. Assept two arrarys as parameters
a) The first arrary is of type double and takes two elements. The second element is redundant. ele[0] gives the point for which the parameters are to be computed.
b) The second arrary is of type char and gives the name of the data file from which the interpolation is to be done.
3. The preferred interpolation method is the akima spline (can be found in the GSL).

Thanks for Your interest.
So, what's the input? A file? Array B? SHA1(array B)? A series of tubes? Come on.
Hi Every One,
I am working on an assignment that needs to be submitted on 08-08-2008. The IDE in use is Dev-C++ 4.9.9.2.
Basically, everything works well untill the program requests for values which are not avalable for a given energy 'energy[0]'. It will run but at those points spit out garbage for the needed values 'parameters'.
Discription of function:
1. The function must return a pointer to an arrary of six elements of type double
2. Assept two arrarys as parameters
a) The first arrary is of type double and takes two elements. The second element is redundant. ele[0] gives the point for which the parameters are to be computed.
b) The second arrary is of type char and gives the name of the data file from which the interpolation is to be done.
3. The preferred interpolation method is the akima spline (can be found in the GSL).

Thanks for Your interest.


Hi helios,
to clearify things I took the liberty to do some preliminary coding of the function:
1. The function is called from within another function;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
           double *call_interp_function(double energy,char filename);   //function declaration
           double *call_interp_function(double energy,char filename);  //function call

           double *call_interp_function(double energy,char filename){    //function definition
           double *Para=new double[6];
           string line1,line2,line3,line4,line5;
           getline(fop,line1);  // skips 5 lines to get to data
           getline(fop,line2);
           getline(fop,line3);
           getline(fop,line4);
           getline(fop,line5);
       
      
          //  FUNCTION STATMENTS
      
       
         return Para;
    }

the arrary 'energy' was originally obtained from the file Zeq.txt
Zeq.txt
Energy Serpentine
keV Zeq
40 4
50 5.10912
60 5.07855
70 5.02045
80 5.01561
90 4.93014
100 4.95412

(Please note that the energy values were divided by a 1000 to convert from keV to MeV) and below are - possible file names that may be passed by the array filename.

GPEABFC.04.txt
G-P Energy Absorption Buildup Factor Coefficients Beryllium
E(MeV) b c a X d

0.015 2.597 0.964 0.020 12.81 -0.0195
0.020 3.819 1.501 -0.086 16.20 0.0274
0.030 5.682 2.348 -0.190 14.96 0.0674
0.040 5.706 2.771 -0.222 14.91 0.0771
0.050 5.186 2.923 -0.229 15.43 0.0747
0.060 4.750 2.950 -0.227 16.03 0.0689
0.080 4.196 2.877 -0.217 17.74 0.0596
0.100 3.842 2.783 -0.210 19.63 0.0630
0.150 3.212 2.600 -0.199 19.35 0.0582
0.200 3.098 2.416 -0.189 17.56 0.0573
0.300 2.722 2.183 -0.175 15.88 0.0592
0.400 2.519 2.060 -0.168 15.38 0.0640
0.500 2.395 1.912 -0.154 14.75 0.0605
0.600 2.287 1.810 -0.144 14.46 0.0619
0.800 2.159 1.632 -0.121 13.99 0.0528
1.000 2.081 1.491 -0.099 14.06 0.0439
1.500 1.933 1.296 -0.065 13.59 0.0291
2.000 1.837 1.182 -0.042 13.81 0.0193
3.000 1.712 1.060 -0.015 13.20 0.0073
4.000 1.639 0.978 0.006 13.80 -0.0039
5.000 1.575 0.941 0.015 13.97 -0.0071
6.000 1.535 0.897 0.028 13.94 -0.0143
8.000 1.455 0.869 0.036 10.77 -0.0140
10.000 1.405 0.842 0.044 13.44 -0.0218
15.000 1.313 0.818 0.051 13.60 -0.0256


GPEABFC.05.txt
G-P Energy Absorption Buildup Factor Coefficients
Boron
E(MeV) b c a X d

0.015 1.752 0.678 0.097 15.02 -0.0473
0.020 2.694 0.953 0.023 15.10 -0.0242
0.030 4.721 1.627 -0.110 14.85 0.0449
0.040 5.549 2.219 -0.182 14.33 0.0778
0.050 5.727 2.489 -0.204 14.75 0.0837
0.060 5.340 2.667 -0.218 14.84 0.0878
0.080 4.566 2.791 -0.226 14.99 0.0860
0.100 4.037 2.781 -0.224 15.38 0.0818
0.150 3.648 2.431 -0.189 17.16 0.0543
0.200 3.253 2.328 -0.183 17.94 0.0629
0.300 2.723 2.212 -0.183 15.15 0.0714
0.400 2.533 2.027 -0.167 14.34 0.0653
0.500 2.430 1.860 -0.148 14.53 0.0607
0.600 2.358 1.720 -0.129 14.73 0.0510
0.800 2.186 1.588 -0.113 14.15 0.0485
1.000 2.086 1.475 -0.096 13.96 0.0419
1.500 1.935 1.285 -0.062 14.35 0.0279
2.000 1.833 1.183 -0.042 14.13 0.0192
3.000 1.715 1.054 -0.013 12.91 0.0054
4.000 1.630 0.986 0.004 14.96 -0.0035
5.000 1.571 0.938 0.017 13.83 -0.0100
6.000 1.525 0.903 0.027 13.17 -0.0144
8.000 1.451 0.856 0.043 11.15 -0.0230
10.000 1.389 0.856 0.040 14.51 -0.0208
15.000 1.295 0.834 0.047 14.05 -0.0265


GPEABFC.06.txt
G-P Energy Absorption Buildup Factor Coefficients
Carbon
E(MeV) b c a X d

0.015 1.398 0.526 0.153 14.42 -0.0777
0.020 1.900 0.739 0.076 16.46 -0.0363
0.030 3.725 1.153 -0.027 12.57 0.0085
0.040 5.068 1.735 -0.127 14.10 0.0554
0.050 5.594 2.066 -0.164 14.48 0.0692
0.060 5.424 2.287 -0.186 14.66 0.0790
0.080 4.862 2.488 -0.204 14.81 0.0832
0.100 4.305 2.548 -0.209 14.88 0.0834
0.150 3.523 2.491 -0.205 14.96 0.0796
0.200 3.173 2.365 -0.196 14.77 0.0757
0.300 2.797 2.129 -0.175 14.96 0.0694
0.400 2.629 1.925 -0.153 14.84 0.0631
0.500 2.456 1.801 -0.138 16.05 0.0618
0.600 2.399 1.663 -0.119 14.98 0.0457
0.800 2.198 1.563 -0.109 14.09 0.0461
1.000 2.087 1.461 -0.093 14.20 0.0406
1.500 1.941 1.275 -0.060 14.29 0.0266
2.000 1.843 1.167 -0.037 14.53 0.0143
3.000 1.715 1.050 -0.011 14.52 0.0027
4.000 1.626 0.990 0.003 12.82 -0.0020
5.000 1.564 0.947 0.014 15.05 -0.0068
6.000 1.519 0.900 0.030 12.35 -0.0186
8.000 1.430 0.884 0.033 12.11 -0.0158
10.000 1.378 0.859 0.040 14.32 -0.0221
15.000 1.283 0.838 0.047 15.91 -0.0324


I hope this gives you all you need.
Just to be clear, you're not asking for someone to implement the function for you, right? 'Cause if you are, I must say good day to you, sir, and take my leave.

Assuming I'm still here: okay, so you have all those files with such-and-such formatting, and data that is actually irrelevant. What exactly is the problem? Are they being parsed incorrectly? Are they parsed correctly but processed incorrectly?
Topic archived. No new replies allowed.