📄 spcfun.c
字号:
*/
mlfIndexAssign(
&curve,
"(?,?)",
mlfPlus(count, mlfScalar(1.0)),
mlfCreateColonIndex(),
mlfPlus(
mlfTimes(
R,
mlfPlus(
mlfMtimes(
mlfScalar(0.5),
mlfSpcfun_irfshift(
mlfIndexRef(
irfTemp, "(?,?)", mlfIndexRef(top, "(?)", i), i),
mlfIndexRef(
irfTemp,
"(?,?)",
mlfPlus(mlfIndexRef(top, "(?)", i), mlfScalar(1.0)),
i),
mlfIndexRef(shift, "(?)", i))),
mlfIndexRef(curve, "(?,?)", count, mlfCreateColonIndex()))),
mlfMtimes(
mlfScalar(0.5),
mlfSpcfun_irfshift(
mlfIndexRef(
irfTemp,
"(?,?)",
mlfPlus(mlfIndexRef(top, "(?)", i), mlfScalar(1.0)),
i),
mlfIndexRef(
irfTemp,
"(?,?)",
mlfPlus(mlfIndexRef(top, "(?)", i), mlfScalar(2.0)),
i),
mlfIndexRef(shift, "(?)", i)))));
/*
* curve(count,:)) + 0.5 * irfshift(irfTemp(top(i)+1,i),irfTemp(top(i)+2,i),shift(i));
* end
*/
}
/*
* a(:,i) = curve\dataTemp(:,i);
*/
mlfIndexAssign(
&a,
"(?,?)",
mlfCreateColonIndex(),
i,
mlfMldivide(
curve, mlfIndexRef(dataTemp, "(?,?)", mlfCreateColonIndex(), i)));
/*
* z(:,i) = curve*a(:,i);
*/
mlfIndexAssign(
&z,
"(?,?)",
mlfCreateColonIndex(),
i,
mlfMtimes(curve, mlfIndexRef(a, "(?,?)", mlfCreateColonIndex(), i)));
/*
* end
*/
}
/*
* f = (z - dataTemp)./weight(spcLeftEnd:spcRightEnd,:);
*/
mlfAssign(
&f,
mlfRdivide(
mlfMinus(z, dataTemp),
mlfIndexRef(
weight,
"(?,?)",
mlfColon(spcLeftEnd, spcRightEnd, NULL),
mlfCreateColonIndex())));
/*
* amps = a;
*/
mlfAssign(&s, a);
/*
* fit=z;
*/
mlfAssign(&fit, z);
/*
* chisq = trace(f'*f)/(numPoints*numCurves-(numTao + numTaoFixed)-(numTao + numTaoFixed)*numCurves-numCurves);
*/
mlfAssign(
&chisq,
mlfMrdivide(
mlfTrace(mlfMtimes(mlfCtranspose(f), f)),
mlfMinus(
mlfMinus(
mlfMinus(
mlfMtimes(numPoints, numCurves), mlfPlus(numTao, numTaoFixed)),
mlfMtimes(mlfPlus(numTao, numTaoFixed), numCurves)),
numCurves)));
/*
* set(textBox,'string',['chisq = ' num2str(chisq)])
*/
mclPrintAns(
&ans,
mlfNSet(
0,
textBox,
mxCreateString("string"),
mlfHorzcat(mxCreateString("chisq = "), mlfNum2str(chisq, NULL), NULL),
NULL));
/*
* drawnow;
*/
mlfDrawnow(NULL);
mclValidateOutputs("spcfun", 1, nargout_, &f);
mxDestroyArray(R);
mxDestroyArray(a);
mxDestroyArray(ans);
mxDestroyArray(bottom);
mxDestroyArray(count);
mxDestroyArray(curve);
mxDestroyArray(dataTemp);
mxDestroyArray(i);
mxDestroyArray(irfTemp);
mxDestroyArray(numCurves);
mxDestroyArray(numPoints);
mxDestroyArray(shift);
mxDestroyArray(tao);
mxDestroyArray(taoFit);
mxDestroyArray(top);
mxDestroyArray(tpch);
mxDestroyArray(z);
/*
*
*/
return f;
}
/*
* The function "mlfSpcfun" contains the normal interface for the "spcfun"
* M-function from file "C:\MATLABR11\asufit24\spcfun.m" (lines 1-70). This
* function processes any input arguments and passes them to the implementation
* version of the function, appearing above.
*/
mxArray * mlfSpcfun(mxArray * params) {
int nargout = 1;
mxArray * f = mclGetUninitializedArray();
mlfEnterNewContext(0, 1, params);
f = Mspcfun(nargout, params);
mlfRestorePreviousContext(0, 1, params);
return mlfReturnValue(f);
}
/*
* The function "mlxSpcfun" contains the feval interface for the "spcfun"
* M-function from file "C:\MATLABR11\asufit24\spcfun.m" (lines 1-70). The
* feval function calls the implementation version of spcfun through this
* function. This function processes any input arguments and passes them to the
* implementation version of the function, appearing above.
*/
void mlxSpcfun(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
mxArray * mprhs[1];
mxArray * mplhs[1];
int i;
if (nlhs > 1) {
mlfError(
mxCreateString(
"Run-time Error: File: spcfun Line: 1 Column: "
"0 The function \"spcfun\" was called with mor"
"e than the declared number of outputs (1)"));
}
if (nrhs > 1) {
mlfError(
mxCreateString(
"Run-time Error: File: spcfun Line: 1 Column: "
"0 The function \"spcfun\" was called with mor"
"e than the declared number of inputs (1)"));
}
for (i = 0; i < 1; ++i) {
mplhs[i] = NULL;
}
for (i = 0; i < 1 && i < nrhs; ++i) {
mprhs[i] = prhs[i];
}
for (; i < 1; ++i) {
mprhs[i] = NULL;
}
mlfEnterNewContext(0, 1, mprhs[0]);
mplhs[0] = Mspcfun(nlhs, mprhs[0]);
mlfRestorePreviousContext(0, 1, mprhs[0]);
plhs[0] = mplhs[0];
}
/*
* The function "Mspcfun_irfshift" is the implementation version of the
* "spcfun/irfshift" M-function from file "C:\MATLABR11\asufit24\spcfun.m"
* (lines 70-71). It contains the actual compiled code for that M-function. It
* is a static function and must only be called from one of the interface
* functions, appearing below.
*/
/*
* function G = irfshift(f1,f2,x0)
*/
static mxArray * Mspcfun_irfshift(int nargout_,
mxArray * f1,
mxArray * f2,
mxArray * x0) {
mxArray * G = mclGetUninitializedArray();
mclValidateInputs("spcfun/irfshift", 3, &f1, &f2, &x0);
/*
* G = f1 + (x0 - floor(x0)) * (f2 - f1);
*/
mlfAssign(
&G, mlfPlus(f1, mlfMtimes(mlfMinus(x0, mlfFloor(x0)), mlfMinus(f2, f1))));
mclValidateOutputs("spcfun/irfshift", 1, nargout_, &G);
return G;
}
/*
* The function "mlfSpcfun_irfshift" contains the normal interface for the
* "spcfun/irfshift" M-function from file "C:\MATLABR11\asufit24\spcfun.m"
* (lines 70-71). This function processes any input arguments and passes them
* to the implementation version of the function, appearing above.
*/
static mxArray * mlfSpcfun_irfshift(mxArray * f1, mxArray * f2, mxArray * x0) {
int nargout = 1;
mxArray * G = mclGetUninitializedArray();
mlfEnterNewContext(0, 3, f1, f2, x0);
G = Mspcfun_irfshift(nargout, f1, f2, x0);
mlfRestorePreviousContext(0, 3, f1, f2, x0);
return mlfReturnValue(G);
}
/*
* The function "mlxSpcfun_irfshift" contains the feval interface for the
* "spcfun/irfshift" M-function from file "C:\MATLABR11\asufit24\spcfun.m"
* (lines 70-71). The feval function calls the implementation version of
* spcfun/irfshift through this function. This function processes any input
* arguments and passes them to the implementation version of the function,
* appearing above.
*/
static void mlxSpcfun_irfshift(int nlhs,
mxArray * plhs[],
int nrhs,
mxArray * prhs[]) {
mxArray * mprhs[3];
mxArray * mplhs[1];
int i;
if (nlhs > 1) {
mlfError(
mxCreateString(
"Run-time Error: File: spcfun/irfshift Line: 70 Colu"
"mn: 0 The function \"spcfun/irfshift\" was called w"
"ith more than the declared number of outputs (1)"));
}
if (nrhs > 3) {
mlfError(
mxCreateString(
"Run-time Error: File: spcfun/irfshift Line: 70 Colu"
"mn: 0 The function \"spcfun/irfshift\" was called w"
"ith more than the declared number of inputs (3)"));
}
for (i = 0; i < 1; ++i) {
mplhs[i] = NULL;
}
for (i = 0; i < 3 && i < nrhs; ++i) {
mprhs[i] = prhs[i];
}
for (; i < 3; ++i) {
mprhs[i] = NULL;
}
mlfEnterNewContext(0, 3, mprhs[0], mprhs[1], mprhs[2]);
mplhs[0] = Mspcfun_irfshift(nlhs, mprhs[0], mprhs[1], mprhs[2]);
mlfRestorePreviousContext(0, 3, mprhs[0], mprhs[1], mprhs[2]);
plhs[0] = mplhs[0];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -