void PairCopulaInvVfun_VecPar(int family, const double *theta, double *U, double *V, double *u, unsigned int n) { unsigned int i; switch(family){ case 2: { // 1 Parameter: AsymFGM double UU, VV; for (i=0;i<n;i++) { UU = CheckBounds(U[i]); VV = CheckBounds(V[i]); u[i] = invvfun_bisect(family,theta[i],UU,VV,n); } break; } case 16: case 17: { // 2 Parameters: Tawn1, Tawn2 double UU, VV; for (i=0;i<n;i++) { UU = CheckBounds(U[i]); VV = CheckBounds(V[i]); u[i] = invvfun_bisect(family,theta[i],theta[i+n],UU,VV,n); } break; } case 18: { // 3 Parameters: Tawn double UU, VV; for (i=0;i<n;i++) { UU = CheckBounds(U[i]); VV = CheckBounds(V[i]); u[i] = invvfun_bisect(family,theta[i],theta[i+n],theta[i+2*n],UU,VV,n); } break; } default: { // symmetric copulas PairCopulaInvHfun_VecPar(family, theta, V, U, u, n); break; } } return; }
void PairCopulaInvVfun_VecPar(int family, int rotation, const double *theta, double *U, double *V, double *u, unsigned int n) { if(rotation>0) { Rotate_Obs(U,V,rotation,n); } unsigned int i; switch(rotation){ case 0: { PairCopulaInvVfun_VecPar(family, theta, U, V, u, n); break; } case 90: { PairCopulaInvHfun_VecPar(family, theta, V, U, u, n); break; } case 180: { PairCopulaInvVfun_VecPar(family, theta, U, V, u, n); for (i=0;i<n;i++) u[i]=1-u[i]; break; } case 270: { PairCopulaInvHfun_VecPar(family, theta, V, U, u, n); for (i=0;i<n;i++) u[i]=1-u[i]; break; } } return; }
// FunctionID 6: PCInvHfun void PCInvHfun(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { //declare variables double *U, *V, *theta, *u, *Rotation; double *Family; int family, rotation; unsigned int n, N; //figure out dimensions n = (unsigned int)mxGetM(prhs[2]); N = (unsigned int)mxGetM(prhs[4]); //associate inputs Family = mxGetPr(prhs[1]); family = (int) *Family; theta = mxGetPr(prhs[4]); //associate outputs plhs[0] = mxCreateDoubleMatrix(n,1,mxREAL); u = mxGetPr(plhs[0]); if (N == n) { if (nrhs==6 && !mxIsEmpty(prhs[5])) { mxArray *U_in, *V_in; U_in = mxDuplicateArray(prhs[2]); V_in = mxDuplicateArray(prhs[3]); U = mxGetPr(U_in); V = mxGetPr(V_in); Rotation = mxGetPr(prhs[5]); rotation = (int) *Rotation; PairCopulaInvHfun_VecPar(family,rotation,theta,U,V,u,n); } else { U = mxGetPr(prhs[2]); V = mxGetPr(prhs[3]); PairCopulaInvHfun_VecPar(family,theta,U,V,u,n); } } else { if (nrhs==6 && !mxIsEmpty(prhs[5])) { mxArray *U_in, *V_in; U_in = mxDuplicateArray(prhs[2]); V_in = mxDuplicateArray(prhs[3]); U = mxGetPr(U_in); V = mxGetPr(V_in); Rotation = mxGetPr(prhs[5]); rotation = (int) *Rotation; PairCopulaInvHfun(family,rotation,theta,U,V,u,n); } else { U = mxGetPr(prhs[2]); V = mxGetPr(prhs[3]); PairCopulaInvHfun(family,theta,U,V,u,n); } } return; }