[General Information]
Function Name=Exponential2D
Brief Description=Non-Linear Exponential Function
Function Source=fgroup.Exponential2D
Function Type=Built-in
Function Form=Expression
Number Of Parameters=4
Number Of Independent Variables=2
Number Of Dependent Variables=1
Analytical Derivatives for User-Defined=Off


[Fitting Parameters]
Naming Method=User-Defined
Names=z0,B,C,D
Meanings=?
Initial Values=--(V)
Lower Bounds=--(X, OFF)
Upper Bounds=--(X, OFF)
Number Of Significant Digits=


[Formula]
z = z0 + B*exp(-x/C)*exp(-y/D);


[Constraints]



[Constants]


[Parameters Initialization]
#define VEC_SIZE 50

Nag_2d_Scat_Method method = Nag_RC;
Nag_Scat_Struct comm;
NagError fail;

fail.code = NE_NOERROR;
fail.print = 0;

nag_2d_scat_interpolant(method, x_data.GetSize(), x_data, y_data, z_data, &comm, NULL, &fail);
if (fail.code != NE_NOERROR)
{
	printf("%s\n", fail.message);
	nag_2d_scat_free(&comm);
	return;
}

double dxMin, dxMax, dyMin, dyMax;
x_data.GetMinMax(dxMin, dxMax);
y_data.GetMinMax(dyMin, dyMax);
vector vX(VEC_SIZE), vY(VEC_SIZE), vZ(VEC_SIZE);

double coeff[3];
fitpoly(x_z_curve, 2, coeff);
vX.Data(dxMin, dxMax, (dxMax-dxMin)/(VEC_SIZE-1));
vY = (coeff[2] < 0) ? xatymax(y_z_curve) : xatymin(y_z_curve);
nag_2d_scat_eval(&comm, VEC_SIZE, vX, vY, vZ, &fail);
if (fail.code != NE_NOERROR)
{
	printf("%s\n", fail.message);
}

Curve x_curve(vX, vZ);

vX = (coeff[2] < 0) ? xatymax(x_z_curve) : xatymax(x_z_curve);
vY.Data(dyMin, dyMax, (dyMax-dyMin)/(VEC_SIZE-1));
nag_2d_scat_eval(&comm, VEC_SIZE, vX, vY, vZ, &fail);
if (fail.code != NE_NOERROR)
{
	printf("%s\n", fail.message);
}
nag_2d_scat_free(&comm);

Curve y_curve(vY, vZ);

if (coeff[2] < 0)
{
	z0 =  max(vZ); 
	B =  min(vZ)-z0;
	C = abs(xatymax(x_curve)-xatymin(x_curve));
	D = abs(xatymax(y_curve)-xatymin(y_curve));
	
}
else
{
       z0 = min(vZ);
       B = max(vZ) - z0;
       C = abs(xatymax(x_curve)-xatymin(x_curve));
       D = abs(xatymax(y_curve)-xatymin(y_curve));
	
}



[Initializations]



[After Fitting]



[On Param Change]



[Independent Variables]
x=
y=


[Dependent Variables]
z=


[Controls]
General Linear Constraints=Off
Initialization Scripts=Off
Scripts After Fitting=Off
Number Of Duplicates=N/A
Duplicate Offset=N/A
Duplicate Unit=N/A
Generate Curves After Fitting=Yes
Curve Point Spacing=Uniform on X-Axis Scale
Generate Peaks After Fitting=Yes
Generate Peaks During Fitting=Yes
Generate Peaks with Baseline=Yes
Paste Parameters to Plot After Fitting=Yes
Paste Parameters to Notes Window After Fitting=Yes
Generate Residuals After Fitting=No
Keep Parameters=No
Enable Parameters Initialization=0
Compile On Param Change Script=1


[Compile Function]
Compile=0
Compile Parameters Initialization=1
On Param Change Scripts Enabled=N/A


[Origin C Function Header]



[Origin C Parameter Initialization Header]
#include <origin.h>
#include <OC_nag8.h>


