int mxW_CVodeBBDgcom(long int Nlocal, realtype t, N_Vector y, void *user_data) { cvmPbData fwdPb; mxArray *mx_in[4], *mx_out[2]; int ret; /* Extract global interface data from user-data */ fwdPb = (cvmPbData) user_data; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleScalar(t); /* current t */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[2] = fwdPb->GCOMfct; /* matlab function handle */ mx_in[3] = fwdPb->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[1]), N); mexCallMATLAB(2,mx_out,4,mx_in,"cvm_gcom"); ret = (int)*mxGetPr(mx_out[0]); if (!mxIsEmpty(mx_out[1])) { UpdateUserData(mx_out[1], fwdPb); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); return(ret); }
int mtlb_IdaSensRes(int Nsens, realtype tres, N_Vector yy, N_Vector yp, N_Vector rr, N_Vector *yyS, N_Vector *ypS, N_Vector *rrS, void *rdataS, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { mxArray *mx_in[9], *mx_out[3]; int is, ret; double *tmp_yyS, *tmp_ypS, *tmp_rrS; /* Inputs to the Matlab function */ mx_in[0] = mxCreateScalarDouble(tres); /* current t */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */ mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* current rr */ mx_in[4] = mxCreateScalarDouble(Ns); /* number of sensitivities */ mx_in[5] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current yyS */ mx_in[6] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current ypS */ mx_in[7] = mx_SRESfct; /* matlab function handle */ mx_in[8] = mx_data; /* matlab user data */ /* Call matlab wrapper */ GetData(yy, mxGetPr(mx_in[1]), N); GetData(yp, mxGetPr(mx_in[2]), N); GetData(rr, mxGetPr(mx_in[3]), N); tmp_yyS = mxGetPr(mx_in[5]); tmp_ypS = mxGetPr(mx_in[6]); for (is=0; is<Ns; is++) { GetData(yyS[is], &tmp_yyS[is*N], N); GetData(ypS[is], &tmp_ypS[is*N], N); } mexCallMATLAB(3,mx_out,9,mx_in,"idm_resS"); tmp_rrS = mxGetPr(mx_out[0]); for(is=0; is<Ns; is++) PutData(rrS[is], &tmp_rrS[is*N], N); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2]); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_in[4]); mxDestroyArray(mx_in[5]); mxDestroyArray(mx_in[6]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_KINSys(N_Vector y, N_Vector fy, void *user_data ) { kimInterfaceData kimData; mxArray *mx_in[3], *mx_out[3]; int ret; /* Extract global interface data from user-data */ kimData = (kimInterfaceData) user_data; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[1] = kimData->SYSfct; /* matlab function handle */ mx_in[2] = kimData->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[0]), N); mexCallMATLAB(3,mx_out,3,mx_in,"kim_sys"); PutData(fy, mxGetPr(mx_out[0]), N); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], kimData); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mtlb_IdaDenseJacB(long int NeqB, realtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, N_Vector rrB, realtype c_jB, void *jac_dataB, DenseMat JacB, N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B) { double *JB_data; long int i; mxArray *mx_in[10], *mx_out[3]; int ret; /* Inputs to the Matlab function */ mx_in[0] = mxCreateScalarDouble(-1.0); /* type=-1: backward ODE */ mx_in[1] = mxCreateScalarDouble(tt); /* current t */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */ mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */ mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */ mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */ mx_in[6] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current rrB */ mx_in[7] = mxCreateScalarDouble(c_jB); /* current c_jB */ mx_in[8] = mx_JACfctB; /* matlab function handle */ mx_in[9] = mx_data; /* matlab user data */ /* Call matlab wrapper */ GetData(yy, mxGetPr(mx_in[2]), N); GetData(yp, mxGetPr(mx_in[3]), N); GetData(yyB, mxGetPr(mx_in[4]), NB); GetData(ypB, mxGetPr(mx_in[5]), NB); GetData(rrB, mxGetPr(mx_in[6]), NB); mexCallMATLAB(3,mx_out,10,mx_in,"idm_djac"); JB_data = mxGetPr(mx_out[0]); for (i=0; i<NB; i++) memcpy(DENSE_COL(JacB,i), JB_data + i*NB, NB*sizeof(double)); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2]); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_in[4]); mxDestroyArray(mx_in[5]); mxDestroyArray(mx_in[6]); mxDestroyArray(mx_in[7]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mtlb_IdaSpilsPsolB(realtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, N_Vector rrB, N_Vector rvecB, N_Vector zvecB, realtype c_jB, realtype deltaB, void *prec_dataB, N_Vector tmpB) { mxArray *mx_in[11], *mx_out[3]; int ret; /* Inputs to the Matlab function */ mx_in[0] = mxCreateScalarDouble(-1.0); /* type=-1: backward ODE */ mx_in[1] = mxCreateScalarDouble(tt); /* current t */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */ mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */ mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */ mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */ mx_in[6] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current rrB */ mx_in[7] = mxCreateDoubleMatrix(NB,1,mxREAL); /* right hand side rB */ mx_in[8] = mxCreateScalarDouble(c_jB); /* current c_jB */ mx_in[9] = mx_PSOLfctB; /* matlab function handle */ mx_in[10] = mx_data; /* matlab user data */ /* Call matlab wrapper */ GetData(yy, mxGetPr(mx_in[2]), N); GetData(yp, mxGetPr(mx_in[3]), N); GetData(yyB, mxGetPr(mx_in[4]), NB); GetData(ypB, mxGetPr(mx_in[5]), NB); GetData(rrB, mxGetPr(mx_in[6]), NB); GetData(rvecB, mxGetPr(mx_in[7]), NB); mexCallMATLAB(3,mx_out,11,mx_in,"idm_psol"); PutData(zvecB, mxGetPr(mx_out[0]), NB); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2]); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_in[4]); mxDestroyArray(mx_in[5]); mxDestroyArray(mx_in[6]); mxDestroyArray(mx_in[7]); mxDestroyArray(mx_in[8]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_CVodeSensRhs(int Nsens, realtype t, N_Vector y, N_Vector yd, N_Vector *yS, N_Vector *ySd, void *user_data, N_Vector tmp1, N_Vector tmp2) { cvmPbData fwdPb; mxArray *mx_in[7], *mx_out[3]; int is, ret; double *tmp; /* Extract global interface data from user-data */ fwdPb = (cvmPbData) user_data; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleScalar(t); /* current t */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yd */ mx_in[3] = mxCreateDoubleScalar(Ns); /* number of sensitivities */ mx_in[4] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current yS */ mx_in[5] = fwdPb->SRHSfct; /* matlab function handle */ mx_in[6] = fwdPb->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[1]), N); GetData(yd, mxGetPr(mx_in[2]), N); tmp = mxGetPr(mx_in[4]); for (is=0; is<Ns; is++) GetData(yS[is], &tmp[is*N], N); mexCallMATLAB(3,mx_out,7,mx_in,"cvm_rhsS"); tmp = mxGetPr(mx_out[0]); for(is=0;is<Ns;is++) PutData(ySd[is], &tmp[is*N], N); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], fwdPb); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_in[4]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_CVodeQUADfctBS(realtype t, N_Vector y, N_Vector *yS, N_Vector yB, N_Vector yQBd, void *user_dataB) { cvmPbData fwdPb, bckPb; mxArray *mx_in[8], *mx_out[3]; int is, ret; double *tmp; /* Extract global interface data from user-data */ bckPb = (cvmPbData) user_dataB; fwdPb = bckPb->fwd; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleScalar(1.0); /* type=1: dependent on yS */ mx_in[1] = mxCreateDoubleScalar(t); /* current t */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[3] = mxCreateDoubleScalar(Ns); /* number of sensitivities */ mx_in[4] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current yS */ mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */ mx_in[6] = bckPb->QUADfct; /* matlab function handle */ mx_in[7] = bckPb->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[2]), N); tmp = mxGetPr(mx_in[4]); for (is=0; is<Ns; is++) GetData(yS[is], &tmp[is*N], N); GetData(yB, mxGetPr(mx_in[5]), NB); mexCallMATLAB(3,mx_out,8,mx_in,"cvm_rhsQB"); PutData(yQBd, mxGetPr(mx_out[0]), NqB); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], bckPb); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_in[4]); mxDestroyArray(mx_in[5]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_CVodeSpilsPsetB(realtype t, N_Vector y, N_Vector yB, N_Vector fyB, booleantype jokB, booleantype *jcurPtrB, realtype gammaB, void *user_dataB, N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B) { cvmPbData fwdPb, bckPb; mxArray *mx_in[8], *mx_out[3]; int ret; /* Extract global interface data from user-data */ bckPb = (cvmPbData) user_dataB; fwdPb = bckPb->fwd; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleScalar(t); /* current t */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[2] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */ mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current fyB */ mx_in[4] = mxCreateLogicalScalar(jokB); /* jokB flag */ mx_in[5] = mxCreateDoubleScalar(gammaB); /* gammaB value */ mx_in[6] = bckPb->PSETfct; /* matlab function handle */ mx_in[7] = bckPb->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[1]), N); GetData(yB, mxGetPr(mx_in[2]), NB); GetData(fyB, mxGetPr(mx_in[3]), NB); mexCallMATLAB(3,mx_out,8,mx_in,"cvm_psetB"); *jcurPtrB = mxIsLogicalScalarTrue(mx_out[0]); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], bckPb); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_in[4]); mxDestroyArray(mx_in[5]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mtlb_IdaBandJac(long int Neq, long int mupper, long int mlower, realtype tt, N_Vector yy, N_Vector yp, N_Vector rr, realtype c_j, void *jac_data, BandMat Jac, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { double *J_data; long int eband, i; int ret; mxArray *mx_in[8], *mx_out[3]; /* Inputs to the Matlab function */ mx_in[0] = mxCreateScalarDouble(1.0); /* type=1: forward ODE */ mx_in[1] = mxCreateScalarDouble(tt); /* current t */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */ mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */ mx_in[4] = mxCreateDoubleMatrix(N,1,mxREAL); /* current rr */ mx_in[5] = mxCreateScalarDouble(c_j); /* current c_j */ mx_in[6] = mx_JACfct; /* matlab function handle */ mx_in[7] = mx_data; /* matlab user data */ /* Call matlab wrapper */ GetData(yy, mxGetPr(mx_in[2]), N); GetData(yp, mxGetPr(mx_in[3]), N); GetData(rr, mxGetPr(mx_in[4]), N); mexCallMATLAB(3,mx_out,8,mx_in,"idm_bjac"); /* Extract data */ eband = mupper + mlower + 1; J_data = mxGetPr(mx_out[0]); for (i=0; i<N; i++) memcpy(BAND_COL(Jac,i) - mupper, J_data + i*eband, eband*sizeof(double)); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2]); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_in[4]); mxDestroyArray(mx_in[5]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_CVodeBandJacB(long int NeqB, long int mupperB, long int mlowerB, realtype t, N_Vector y, N_Vector yB, N_Vector fyB, DlsMat JB, void *user_dataB, N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B) { cvmPbData fwdPb, bckPb; double *JB_data; mxArray *mx_in[6], *mx_out[3]; long int ebandB, i; int ret; /* Extract global interface data from user-data */ bckPb = (cvmPbData) user_dataB; fwdPb = bckPb->fwd; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleScalar(t); /* current t */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[2] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */ mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current fyB */ mx_in[4] = bckPb->JACfct; /* matlab function handle */ mx_in[5] = bckPb->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[1]), N); GetData(yB, mxGetPr(mx_in[2]), NB); GetData(fyB, mxGetPr(mx_in[3]), NB); mexCallMATLAB(3,mx_out,6,mx_in,"cvm_bjacB"); ebandB = mupperB + mlowerB + 1; JB_data = mxGetPr(mx_out[0]); for (i=0;i<NB;i++) memcpy(BAND_COL(JB,i) - mupperB, JB_data + i*ebandB, ebandB*sizeof(double)); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], bckPb); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_CVodeSpilsPsolB(realtype t, N_Vector y, N_Vector yB, N_Vector fyB, N_Vector rB, N_Vector zB, realtype gammaB, realtype deltaB, int lrB, void *user_dataB, N_Vector tmpB) { cvmPbData fwdPb, bckPb; mxArray *mx_in[7], *mx_out[3]; int ret; /* Extract global interface data from user-data */ bckPb = (cvmPbData) user_dataB; fwdPb = bckPb->fwd; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleScalar(t); /* current t */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[2] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */ mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current fyB */ mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* right hand side rB */ mx_in[5] = bckPb->PSOLfct; /* matlab function handle */ mx_in[6] = bckPb->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[1]), N); GetData(yB, mxGetPr(mx_in[2]), NB); GetData(fyB, mxGetPr(mx_in[3]), NB); GetData(rB, mxGetPr(mx_in[4]), NB); mexCallMATLAB(3,mx_out,7,mx_in,"cvm_psolB"); PutData(zB, mxGetPr(mx_out[0]), NB); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], bckPb); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_in[4]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_KINSpilsPsol(N_Vector y, N_Vector yscale, N_Vector fy, N_Vector fscale, N_Vector v, void *user_data, N_Vector vtemp) { kimInterfaceData kimData; mxArray *mx_in[7], *mx_out[3]; int ret; /* Extract global interface data from user-data */ kimData = (kimInterfaceData) user_data; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yscale */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current fy */ mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* current fscale */ mx_in[4] = mxCreateDoubleMatrix(N,1,mxREAL); /* right hand side */ mx_in[5] = kimData->PSOLfct; /* matlab function handle */ mx_in[6] = kimData->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[0]), N); GetData(yscale, mxGetPr(mx_in[1]), N); GetData(fy, mxGetPr(mx_in[2]), N); GetData(fscale, mxGetPr(mx_in[3]), N); GetData(v, mxGetPr(mx_in[4]), N); mexCallMATLAB(3,mx_out,7,mx_in,"kim_psol"); PutData(v, mxGetPr(mx_out[0]), N); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], kimData); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_in[4]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mtlb_IdaSpilsJac(realtype tt, N_Vector yy, N_Vector yp, N_Vector rr, N_Vector v, N_Vector Jv, realtype c_j, void *jac_data, N_Vector tmp1, N_Vector tmp2) { mxArray *mx_in[9], *mx_out[3]; int ret; /* Inputs to the Matlab function */ mx_in[0] = mxCreateScalarDouble(1.0); /* type=1: forward ODE */ mx_in[1] = mxCreateScalarDouble(tt); /* current t */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */ mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */ mx_in[4] = mxCreateDoubleMatrix(N,1,mxREAL); /* current rr */ mx_in[5] = mxCreateDoubleMatrix(N,1,mxREAL); /* vector v */ mx_in[6] = mxCreateScalarDouble(c_j); /* current c_j */ mx_in[7] = mx_JACfct; /* matlab function handle */ mx_in[8] = mx_data; /* matlab user data */ /* Call matlab wrapper */ GetData(yy, mxGetPr(mx_in[2]), N); GetData(yp, mxGetPr(mx_in[3]), N); GetData(rr, mxGetPr(mx_in[4]), N); GetData(v, mxGetPr(mx_in[5]), N); mexCallMATLAB(3,mx_out,9,mx_in,"idm_jtv"); PutData(Jv, mxGetPr(mx_out[0]), N); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2]); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_in[4]); mxDestroyArray(mx_in[5]); mxDestroyArray(mx_in[6]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_CVodeBandJac(long int Neq, long int mupper, long int mlower, realtype t, N_Vector y, N_Vector fy, DlsMat J, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { cvmPbData fwdPb; double *J_data; long int eband, i; int ret; mxArray *mx_in[5], *mx_out[3]; /* Extract global interface data from user-data */ fwdPb = (cvmPbData) user_data; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleScalar(t); /* current t */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current fy */ mx_in[3] = fwdPb->JACfct; /* matlab function handle */ mx_in[4] = fwdPb->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[1]), N); GetData(fy, mxGetPr(mx_in[2]), N); mexCallMATLAB(3,mx_out,5,mx_in,"cvm_bjac"); /* Extract data */ eband = mupper + mlower + 1; J_data = mxGetPr(mx_out[0]); for (i=0;i<N;i++) memcpy(BAND_COL(J,i) - mupper, J_data + i*eband, eband*sizeof(double)); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], fwdPb); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mtlb_IdaQuadFctB(realtype tt, N_Vector yy, N_Vector yp, N_Vector yyB, N_Vector ypB, N_Vector ypQB, void *rdataQB) { mxArray *mx_in[8], *mx_out[3]; int ret; /* Inputs to the Matlab function */ mx_in[0] = mxCreateScalarDouble(-1.0); /* type=-1: backward ODE */ mx_in[1] = mxCreateScalarDouble(tt); /* current t */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */ mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */ mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */ mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */ mx_in[6] = mx_QUADfctB; /* matlab function handle */ mx_in[7] = mx_data; /* matlab user data */ /* Call matlab wrapper */ GetData(yy, mxGetPr(mx_in[2]), N); GetData(yp, mxGetPr(mx_in[3]), N); GetData(yyB, mxGetPr(mx_in[4]), NB); GetData(ypB, mxGetPr(mx_in[5]), NB); mexCallMATLAB(3,mx_out,8,mx_in,"idm_rhsQ"); PutData(ypQB, mxGetPr(mx_out[0]), NqB); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2]); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_in[4]); mxDestroyArray(mx_in[5]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_KINBandJac(int Neq, int mupper, int mlower, N_Vector y, N_Vector fy, DlsMat J, void *user_data, N_Vector tmp1, N_Vector tmp2) { kimInterfaceData kimData; double *J_data; mxArray *mx_in[4], *mx_out[3]; int eband, i, ret; /* Extract global interface data from user-data */ kimData = (kimInterfaceData) user_data; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current fy */ mx_in[2] = kimData->JACfct; /* matlab function handle */ mx_in[3] = kimData->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[0]), N); GetData(fy, mxGetPr(mx_in[1]), N); mexCallMATLAB(3,mx_out,4,mx_in,"kim_bjac"); eband = mupper + mlower + 1; J_data = mxGetPr(mx_out[0]); for (i=0;i<N;i++) memcpy(BAND_COL(J,i) - mupper, J_data + i*eband, eband*sizeof(double)); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], kimData); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_CVodeSpilsJac(N_Vector v, N_Vector Jv, realtype t, N_Vector y, N_Vector fy, void *user_data, N_Vector tmp) { cvmPbData fwdPb; mxArray *mx_in[6], *mx_out[3]; int ret; /* Extract global interface data from user-data */ fwdPb = (cvmPbData) user_data; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleScalar(t); /* current t */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current fy */ mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* vector v */ mx_in[4] = fwdPb->JACfct; /* matlab function handle */ mx_in[5] = fwdPb->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[1]), N); GetData(fy, mxGetPr(mx_in[2]), N); GetData(v, mxGetPr(mx_in[3]), N); mexCallMATLAB(3,mx_out,6,mx_in,"cvm_jtv"); PutData(Jv, mxGetPr(mx_out[0]), N); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], fwdPb); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_KINSpilsJac(N_Vector v, N_Vector Jv, N_Vector y, booleantype *new_y, void *user_data) { kimInterfaceData kimData; mxArray *mx_in[5], *mx_out[4]; int ret; /* Extract global interface data from user-data */ kimData = (kimInterfaceData) user_data; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* vector v */ mx_in[2] = mxCreateLogicalScalar(*new_y); /* */ mx_in[3] = kimData->JACfct; /* matlab function handle */ mx_in[4] = kimData->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[0]), N); GetData(v, mxGetPr(mx_in[1]), N); mexCallMATLAB(4,mx_out,5,mx_in,"kim_jtv"); PutData(Jv, mxGetPr(mx_out[0]), N); *new_y = mxIsLogicalScalarTrue(mx_out[1]); ret = (int)*mxGetPr(mx_out[2]); if (!mxIsEmpty(mx_out[3])) { UpdateUserData(mx_out[3], kimData); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); mxDestroyArray(mx_out[3]); return(ret); }
int mxW_CVodeQUADfctB(realtype t, N_Vector y, N_Vector yB, N_Vector yQBd, void *user_dataB) { cvmPbData fwdPb, bckPb; mxArray *mx_in[6], *mx_out[3]; int ret; /* Extract global interface data from user-data */ bckPb = (cvmPbData) user_dataB; fwdPb = bckPb->fwd; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleScalar(0.0); /* type=0: not dependent on yS */ mx_in[1] = mxCreateDoubleScalar(t); /* current t */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */ mx_in[4] = bckPb->QUADfct; /* matlab function handle */ mx_in[5] = bckPb->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[2]), N); GetData(yB, mxGetPr(mx_in[3]), NB); mexCallMATLAB(3,mx_out,6,mx_in,"cvm_rhsQB"); PutData(yQBd, mxGetPr(mx_out[0]), NqB); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], bckPb); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mtlb_IdaBBDgloc(long int Nlocal, realtype tt, N_Vector yy, N_Vector yp, N_Vector gval, void *res_data) { mxArray *mx_in[6], *mx_out[3]; int ret; /* Inputs to the Matlab function */ mx_in[0] = mxCreateScalarDouble(1.0); /* type=1: forward ODE */ mx_in[1] = mxCreateScalarDouble(tt); /* current t */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */ mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */ mx_in[4] = mx_GLOCfct; /* matlab function handle */ mx_in[5] = mx_data; /* matlab user data */ /* Call matlab wrapper */ GetData(yy, mxGetPr(mx_in[2]), N); GetData(yp, mxGetPr(mx_in[3]), N); mexCallMATLAB(3,mx_out,6,mx_in,"idm_gloc"); PutData(gval, mxGetPr(mx_out[0]), N); ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2]); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_in[3]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mtlb_IdaGfct(realtype t, N_Vector yy, N_Vector yp, realtype *gout, void *g_data) { double *gdata; int i, ret; mxArray *mx_in[5], *mx_out[3]; /* Inputs to the Matlab function */ mx_in[0] = mxCreateScalarDouble(t); /* current t */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */ mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */ mx_in[3] = mx_Gfct; /* matlab function handle */ mx_in[4] = mx_data; /* matlab user data */ /* Call matlab wrapper */ GetData(yy, mxGetPr(mx_in[1]), N); GetData(yp, mxGetPr(mx_in[2]), N); mexCallMATLAB(3,mx_out,5,mx_in,"idm_root"); gdata = mxGetPr(mx_out[0]); for (i=0; i<Ng; i++) gout[i] = gdata[i]; ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2]); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_in[2]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
int mxW_CVodeGfct(realtype t, N_Vector y, double *g, void *user_data) { cvmPbData fwdPb; double *gdata; int i, ret; mxArray *mx_in[4], *mx_out[3]; /* Extract global interface data from user-data */ fwdPb = (cvmPbData) user_data; /* Inputs to the Matlab function */ mx_in[0] = mxCreateDoubleScalar(t); /* current t */ mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */ mx_in[2] = fwdPb->Gfct; /* matlab function handle */ mx_in[3] = fwdPb->mtlb_data; /* matlab user data */ /* Call matlab wrapper */ GetData(y, mxGetPr(mx_in[1]), N); mexCallMATLAB(3,mx_out,4,mx_in,"cvm_root"); gdata = mxGetPr(mx_out[0]); for (i=0;i<Ng;i++) g[i] = gdata[i]; ret = (int)*mxGetPr(mx_out[1]); if (!mxIsEmpty(mx_out[2])) { UpdateUserData(mx_out[2], fwdPb); } /* Free temporary space */ mxDestroyArray(mx_in[0]); mxDestroyArray(mx_in[1]); mxDestroyArray(mx_out[0]); mxDestroyArray(mx_out[1]); mxDestroyArray(mx_out[2]); return(ret); }
/******************************************************************* * 根據 URLParaType 執行 POST 的要求 * * return HttpRespondType *******************************************************************/ int DoPostRequest(REQUEST_REC * r, BOARDHEADER * board, POST_FILE * pf) { int result, URLParaType; char *form_data, *boardname; result = WEB_ERROR; URLParaType = r->URLParaType; boardname = board->filename; /* Get FORM data */ if ((form_data = GetFormBody(r->content_length, WEBBBS_ERROR_MESSAGE)) == NULL) return WEB_ERROR; #ifdef DEBUG weblog_line(server->debug_log, form_data); fflush(server->debug_log); #endif if (PSCorrect == nLogin && URLParaType == PostSend) { /* PostSend allow username&password in form body without login */ char pass[PASSLEN * 3]; GetPara2(username, "Name", form_data, IDLEN, ""); /* get userdata from form */ GetPara2(pass, "Password", form_data, PASSLEN * 3, ""); Convert(pass, password); PSCorrect = CheckUserPassword(username, password); } if (URLParaType == PostSend || URLParaType == TreaSend || URLParaType == PostEdit || URLParaType == TreaEdit || URLParaType == PostForward || URLParaType == TreaForward || URLParaType == PostDelete || URLParaType == TreaDelete || URLParaType == SkinModify || URLParaType == AccessListModify ) { int perm; /* boardname should set in advance, now in ParseURI() */ if (get_board(board, boardname) <= 0 || board->filename[0] == '\0') return WEB_BOARD_NOT_FOUND; if ((perm = CheckBoardPerm(board, &curuser)) != WEB_OK) return perm; } if (PSCorrect == Correct || (PSCorrect == gLogin && (URLParaType == PostSend || URLParaType == TreaSend)) || URLParaType == UserNew) { int start, end; char path[PATHLEN]; switch (URLParaType) { case PostSend: case TreaSend: if ((result = PostArticle(form_data, board, pf))) { #if 1 if (URLParaType == TreaSend) { if (strlen(pf->POST_NAME)) sprintf(skin_file->filename, "/%streasure/%s/%s/$", BBS_SUBDIR, boardname, pf->POST_NAME); else sprintf(skin_file->filename, "/%streasure/%s/$", BBS_SUBDIR, boardname); } else { sprintf(skin_file->filename, "/%sboards/%s/", BBS_SUBDIR, boardname); } #endif if (PSCorrect == Correct) UpdateUserRec(URLParaType, &curuser, board); } break; case MailSend: if ((result = PostArticle(form_data, board, pf))) { sprintf(skin_file->filename, "/%smail/", BBS_SUBDIR); UpdateUserRec(URLParaType, &curuser, NULL); } break; case PostEdit: case TreaEdit: if ((result = EditArticle(form_data, board, pf))) { sprintf(skin_file->filename, "/%s%s.html", BBS_SUBDIR, pf->POST_NAME); } break; case PostForward: case TreaForward: case MailForward: if ((result = ForwardArticle(form_data, board, pf))) { find_list_range(&start, &end, pf->num, DEFAULT_PAGE_SIZE, pf->total_rec); setdotfile(path, pf->POST_NAME, NULL); sprintf(skin_file->filename, "/%s%s%d-%d", BBS_SUBDIR, path, start, end); } break; case PostDelete: case TreaDelete: case MailDelete: if ((result = DeleteArticle(form_data, board, pf))) { if (URLParaType == PostDelete) { find_list_range(&start, &end, pf->num, DEFAULT_PAGE_SIZE, pf->total_rec); sprintf(skin_file->filename, "/%sboards/%s/%d-%d", BBS_SUBDIR, boardname, start, end); } else if (URLParaType == TreaDelete) { setdotfile(path, pf->POST_NAME, NULL); sprintf(skin_file->filename, "/%s%s", BBS_SUBDIR, path); } else /* MailDelete */ { sprintf(skin_file->filename, "/%smail/", BBS_SUBDIR); } } break; case UserNew: if ((result = NewUser(form_data, &curuser))) sprintf(skin_file->filename, "%s%s%s", HTML_PATH, BBS_SUBDIR, HTML_UserNewOK); break; case UserIdent: if ((result = DoUserIdent(form_data, &curuser))) sprintf(skin_file->filename, "%s%s%s", HTML_PATH, BBS_SUBDIR, HTML_UserIdentOK); break; case UserData: if ((result = UpdateUserData(form_data, &curuser))) sprintf(skin_file->filename, "/%susers/%s", BBS_SUBDIR, HTML_UserData); break; case UserPlan: if ((result = UpdateUserPlan(form_data, &curuser))) sprintf(skin_file->filename, "/%susers/%s", BBS_SUBDIR, HTML_UserPlan); break; case UserSign: if ((result = UpdateUserSign(form_data, &curuser))) sprintf(skin_file->filename, "/%susers/%s", BBS_SUBDIR, HTML_UserSign); break; case UserFriend: if ((result = UpdateUserFriend(form_data, &curuser))) sprintf(skin_file->filename, "/%susers/%s", BBS_SUBDIR, HTML_UserFriend); break; #ifdef WEB_ADMIN case BoardModify: /* admin function */ if (!HAS_PERM(PERM_SYSOP) #ifdef NSYSUBBS || !strstr(request_rec->fromhost, "140.17.12.") #endif ) { sprintf(WEBBBS_ERROR_MESSAGE, "%s 沒有權限修改看板設定", username); result = WEB_ERROR; } else if ((result = ModifyBoard(form_data, board))) sprintf(skin_file->filename, "/%sboards/%s/%s", BBS_SUBDIR, boardname, HTML_BoardModify); break; #endif case SkinModify: /* customize board skins */ if (strcmp(username, board->owner) && !HAS_PERM(PERM_SYSOP)) { sprintf(WEBBBS_ERROR_MESSAGE, "%s 沒有權限修改討論區介面", username); result = WEB_ERROR; } else if (!(board->brdtype & BRD_WEBSKIN)) { sprintf(WEBBBS_ERROR_MESSAGE, "討論區 [%s] 尚未打開自定介面功\能", board->filename); result = WEB_ERROR; } else if ((result = ModifySkin(form_data, board, pf)))
BOOL CSH_ETFVistor::ChkData() { BOOL bRet = TRUE; // 1.1.检查柜台matching表中的数据是否与委托一致 if (!(bRet = GetMatchedData())) { // 获取Matcing表数据失败 return bRet; } // 获取客户最新的股份和资金数据 if (!UpdateUserData()) { g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "更新测试数据失败!"); bRet = FALSE; } else { // 1.2.检查captial表中【资金余额】不变 if (m_fCptlBln_Old != m_fCptlBln_New) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.2 Fail!"); } if (strcmp(m_szTrdId, "0B") == 0) { // ETF买入 //======================校验资金=============================== // 1.3.检查captial表中【资金可用 AVAILABLE】减少 应该等于 Matching表中的【SETT_AMT】 // 由于精度问题,允许1以内的差异 if (abs(CutFloatPnt(m_fCptlAvl_Old - m_fCptlAvl_New) - m_fMatched_OrderFrzAmt) > 1) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.3 Fail!"); } // 1.4.检查captial表中【交易冻结 TRD_FRZ】增加 等于Matching表中的【ORDER_FRZ_AMT】-【SETT_AMT】 if (abs(CutFloatPnt( m_fCptlTrdFrz_New - m_fCptlTrdFrz_Old) - CutFloatPnt(m_fMatched_OrderFrzAmt - m_fMatched_SettAmt)) > 1) { float n1 = m_fCptlTrdFrz_New - m_fCptlTrdFrz_Old; float n2 = m_fMatched_SettAmt; bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.4 Fail!"); } // 1.5 在途和在途可用,无变化 if (CutFloatPnt( m_fCptlOutstanding_New - m_fCptlOutstanding_Old) != 0 || CutFloatPnt( m_fCptlOtdAvl_New - m_fCptlOtdAvl_Old) != 0) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.5 Fail!"); } //======================校验股份=============================== // 1.6 检查Shares表中ETF份额的【SHARE_BLN】、【SHARE_AVL】、【SHARE_TRD_FRZ】无变化 // TODO:国债ETF比较特殊,买入成交后,SHARE_AVL立即增加 if (m_nShareBln_New - m_nShareBln_Old != 0 ||m_nShareAvl_New - m_nShareAvl_Old != 0 ||m_nShareTrdFrz_New - m_nShareTrdFrz_Old != 0) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.6 Fail!"); } // 1.7 检查Shares表中ETF份额的【SHARE_OTD】增加等于 matching表中的【MATCHED_QTY】 if (m_nShareOtd_New - m_nShareOtd_Old != m_nMatched_Qty) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.7 Fail!"); } } else if (strcmp(m_szTrdId, "0S") == 0) { // ETF卖出 //======================校验资金=============================== // 1.3.检查captial表中的【资金可用 AVAILABLE】、【OUTSTANDING】、【OTD_AVL】增加 应该等于Matching表中的【SETT_AMT】 if (abs(CutFloatPnt(m_fCptlAvl_New - m_fCptlAvl_Old) - m_fMatched_SettAmt) > 1 || abs(CutFloatPnt(m_fCptlOutstanding_New - m_fCptlOutstanding_Old) - m_fMatched_SettAmt) > 1 || abs(CutFloatPnt(m_fCptlOtdAvl_New- m_fCptlOtdAvl_Old) - m_fMatched_SettAmt) > 1) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.3 Fail!"); } // 1.4.检查captial表中【交易冻结 TRD_FRZ】无变化 if (CutFloatPnt( m_fCptlTrdFrz_New - m_fCptlTrdFrz_Old) != 0) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.4 Fail!"); } //======================校验股份=============================== // 1.5 检查Shares表中【股份余额 SHARE_BLN】不变 if (m_nShareBln_New != m_nShareBln_Old) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.7 Fail!"); } // 1.8 检查Shares表中【股份可用 SHARE_AVL】减少 应该等于Matching表中的【ORDER_QTY】 if (m_nShareAvl_Old - m_nShareAvl_New != m_nOrder_Qty) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.8 Fail!"); } // 1.9 检查Shares表中【股份冻结 SHARE_TRD_FRZ】增加 应该等于Matching表中的【ORDER_QTY】-【MATCHED_qty】 if ((m_nShareTrdFrz_New - m_nShareTrdFrz_Old) != (m_nOrder_Qty - m_nMatched_Qty)) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.9 Fail!"); } // 2.0 检查Shares表中【在途股份】 不变 if (m_nShareOtd_New != m_nShareOtd_Old) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 2.0 Fail!"); } } } return bRet; }
BOOL CSB_SellVistor::ChkData() { /* 检查以下信息 1.1.检查柜台matching表中的数据是否与委托一致 1.2.检查captial表中【资金余额 BALANCE】 1.3.检查captial表中【资金可用 AVAILABLE】 1.4.检查captial表中【交易冻结 TRD_FRZ】 1.5.检查captial表中【在途资金 OUTSTANDING】 1.6.检查captial表中【在途可用 OTD_AVL】 1.7 检查Shares表中【股份余额 SHARE_BLN】 1.8 检查Shares表中【股份可用 SHARE_AVL】 1.9 检查Shares表中【股份冻结 SHARE_TRD_FRZ】 2.0 检查Shares表中【在途股份】 */ BOOL bRet = TRUE; // 1.1.检查柜台matching表中的数据是否与委托一致 if (!(bRet = GetMatchedData())) { // 获取Matcing表数据失败 return bRet; } // 获取客户最新的股份和资金数据 if (!UpdateUserData()) { g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "更新测试数据失败!"); bRet = FALSE; } else { // 1.2.检查captial表中【资金余额】不变 if (m_fCptlBln_Old != m_fCptlBln_New) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.2 Fail!"); } // 1.3.检查captial表中【资金可用 AVAILABLE】增加 应该等于 Matching表中的【SETT_AMT】 // 由于精度问题,允许1以内的差异 if (abs(CutFloatPnt(m_fCptlAvl_New - m_fCptlAvl_Old) - m_fMatched_SettAmt) > 1) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.3 Fail!"); } // 1.4.检查captial表中【交易冻结 TRD_FRZ】不变 if (m_fCptlTrdFrz_New != m_fCptlTrdFrz_Old) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.4 Fail!"); } // 1.5.检查captial表中【在途资金 OUTSTANDING】增加 应该等于Matching表中的【SETT_AMT】 if (abs(CutFloatPnt(m_fCptlOutstanding_New - m_fCptlOutstanding_Old) - m_fMatched_SettAmt) > 1) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.5 Fail!"); } // 1.6.检查captial表中【在途可用 OTD_AVL】增加 应该等于Matching表中的【SETT_AMT】 if (abs(CutFloatPnt(m_fCptlOtdAvl_New - m_fCptlOtdAvl_Old) - m_fMatched_SettAmt) > 1) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.6 Fail!"); } // 1.7 检查Shares表中【股份余额 SHARE_BLN】不变 if (m_nShareBln_New != m_nShareBln_Old) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.7 Fail!"); } // 1.8 检查Shares表中【股份可用 SHARE_AVL】减少 应该等于Matching表中的【ORDER_QTY】 // TODO: 此检查点存在问题,集中交易系统存在缺陷: [JZJY BUG-136] A股卖出操作【市价委托】中的剩余撤销 不起作用, 依然被冻结 if (m_nShareAvl_Old - m_nShareAvl_New != m_nOrder_Qty) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.8 Fail!"); } // 1.9 检查Shares表中【股份冻结 SHARE_TRD_FRZ】增加 应该等于Matching表中的【ORDER_QTY】-【MATCHED_qty】 if ((m_nShareTrdFrz_New - m_nShareTrdFrz_Old) != (m_nOrder_Qty - m_nMatched_Qty)) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.9 Fail!"); } // 2.0 检查Shares表中【在途股份】 不变 if (m_nShareOtd_New != m_nShareOtd_Old) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 2.0 Fail!"); } } return bRet; }
BOOL CSZB_BuyVistor::ChkData() { /* 检查以下信息 1.1.检查柜台matching表中的数据是否与委托一致 1.2.检查captial表中【资金余额】 1.3.检查captial表中【资金可用】 1.4.检查captial表中【交易冻结】 1.5 检查Shares表中【在途股份】 */ BOOL bRet = TRUE; // 1.1.检查柜台matching表中的数据是否与委托一致 if (!(bRet = GetMatchedData())) { // 获取Matcing表数据失败 return bRet; } // 获取客户最新的股份和资金数据 if (!UpdateUserData()) { g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "更新测试数据失败!"); bRet = FALSE; } else { // 1.2.检查captial表中【资金余额】不变 if (m_fCptlBln_Old != m_fCptlBln_New) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.2 Fail!"); } // 1.3.检查captial表中【资金可用 AVAILABLE】减少 应该等于 Matching表中的【ORDER_FRZ_AMT】 // 由于精度问题,允许1以内的差异 if (abs(CutFloatPnt(m_fCptlAvl_Old - m_fCptlAvl_New) - m_fMatched_OrderFrzAmt) > 1) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.3 Fail!"); } // 1.4.检查captial表中【交易冻结 TRD_FRZ】增加 等于Matching表中的【ORDER_FRZ_AMT】-【SETT_AMT】 if (abs(CutFloatPnt( m_fCptlTrdFrz_New - m_fCptlTrdFrz_Old) - CutFloatPnt(m_fMatched_OrderFrzAmt - m_fMatched_SettAmt)) > 1) { float n1 = m_fCptlTrdFrz_New - m_fCptlTrdFrz_Old; float n2 = m_fMatched_SettAmt; bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.4 Fail!"); } // 1.5 检查Shares表中【在途股份】增加matching表中的【成交数量】 if (m_nShareOtd_New - m_nShareOtd_Old != m_nMatched_Qty) { bRet = FALSE; g_pLog->WriteRunLog(CHKPNT_MODE, LOG_WARN, "Chk 1.5 Fail!"); } } return bRet; }