dynamic array

Hi,
Hi,

I want to create an array and to put it in a loop in order to use one function but for different data. So I have many observations (numobs) which I want to put in a function (NLS_Q)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
numobs_t = (int*)malloc(numobs+1);
for(numobs = 1; numobs <=20; numobs++){
numobs_t[numobs];
	theta  = parameters[0][0]; 
	kappa  = parameters[1][0];
	sigmav = parameters[2][0];
	rho    = parameters[7][0];

	beta_start[0] = kappa + 0.01;				

	NLS_Q(beta_start, data, beta_start[0]
		  numobs_t[numobs], 1, 8, numopt_sv,
		  kappa, theta, sigmav, rho, results);
		  
	results_NLSQ[1][0] = results[1][0];


When I debug the program I got the following error:
1>Compiling...
1>File_parameter.cpp
1>e:\File_parameter.cpp(231) : error C2665: 'NLS_Q' : none of the 3 overloads could convert all the argument types
1> e:\File_estimation.cpp(58): could be 'void NLS_Q(double *,double **,int *,int,int,int,double,double,double,double,double **)'
1> while trying to match the argument list '(double *, double **, int, int, int, int, double, double, double, double, double **)'

I use #include "File_estimation.cpp" in the main file File_parameters.cpp.

The function NLS_Q is defined in the File_estimation.cpp as follows:

1
2
3
void NLS_Q(double *beta_start, double **data, int *numobs_t, int numpar, int colvar, int numopt,
           double kappa, double theta, double sigmav, double rho,
           double **results)

The line File_parameter.cpp(231) is line 13 in the first code and the line File_estimation.cpp(58)File_estimation.cpp(58) is line 1 in the second code

Can someone give me a clue for solving the problem?

10x!
And if I replace *numobs_t by numobs_t I can compile the file but then I get another error:

Invalid allocation size: 4294967295

and the call stack window shows:

> File_parameter.exe!NLS_Q(double * beta_start=0x000d4900, double * * data=0x01d37028, int numobs_t=-842150451, int numpar=1, int colvar=8, int numopt=1, double kappa=0.0072039180000000001, double theta=1.5610421390000000, double sigmav=0.11090398999999999, double rho=-0.71798054600000005, double * * results=0x02e1daa8) Line 64 + 0x19 bytes C++

and a brekpoint is triggered for the following line in the File_estimation.cpp
 
double *fvec = new double[numobs_t];

Last edited on
Topic archived. No new replies allowed.