本文整理汇总了C++中N_VSetArrayPointer函数的典型用法代码示例。如果您正苦于以下问题:C++ N_VSetArrayPointer函数的具体用法?C++ N_VSetArrayPointer怎么用?C++ N_VSetArrayPointer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了N_VSetArrayPointer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: f
/*-----------------------------------------------------------------
cvDlsDenseDQJac
-----------------------------------------------------------------
This routine generates a dense difference quotient approximation
to the Jacobian of f(t,y). It assumes that a dense SUNMatrix is
stored column-wise, and that elements within each column are
contiguous. The address of the jth column of J is obtained via
the accessor function SUNDenseMatrix_Column, and this pointer
is associated with an N_Vector using the N_VSetArrayPointer
function. Finally, the actual computation of the jth column of
the Jacobian is done with a call to N_VLinearSum.
-----------------------------------------------------------------*/
int cvDlsDenseDQJac(realtype t, N_Vector y, N_Vector fy,
SUNMatrix Jac, CVodeMem cv_mem, N_Vector tmp1)
{
realtype fnorm, minInc, inc, inc_inv, yjsaved, srur;
realtype *y_data, *ewt_data;
N_Vector ftemp, jthCol;
sunindextype j, N;
int retval = 0;
CVDlsMem cvdls_mem;
/* access DlsMem interface structure */
cvdls_mem = (CVDlsMem) cv_mem->cv_lmem;
/* access matrix dimension */
N = SUNDenseMatrix_Rows(Jac);
/* Rename work vector for readibility */
ftemp = tmp1;
/* Create an empty vector for matrix column calculations */
jthCol = N_VCloneEmpty(tmp1);
/* Obtain pointers to the data for ewt, y */
ewt_data = N_VGetArrayPointer(cv_mem->cv_ewt);
y_data = N_VGetArrayPointer(y);
/* Set minimum increment based on uround and norm of f */
srur = SUNRsqrt(cv_mem->cv_uround);
fnorm = N_VWrmsNorm(fy, cv_mem->cv_ewt);
minInc = (fnorm != ZERO) ?
(MIN_INC_MULT * SUNRabs(cv_mem->cv_h) * cv_mem->cv_uround * N * fnorm) : ONE;
for (j = 0; j < N; j++) {
/* Generate the jth col of J(tn,y) */
N_VSetArrayPointer(SUNDenseMatrix_Column(Jac,j), jthCol);
yjsaved = y_data[j];
inc = SUNMAX(srur*SUNRabs(yjsaved), minInc/ewt_data[j]);
y_data[j] += inc;
retval = cv_mem->cv_f(t, y, ftemp, cv_mem->cv_user_data);
cvdls_mem->nfeDQ++;
if (retval != 0) break;
y_data[j] = yjsaved;
inc_inv = ONE/inc;
N_VLinearSum(inc_inv, ftemp, -inc_inv, fy, jthCol);
/* DENSE_COL(Jac,j) = N_VGetArrayPointer(jthCol); /\*UNNECESSARY?? *\/ */
}
/* Destroy jthCol vector */
N_VSetArrayPointer(NULL, jthCol); /* SHOULDN'T BE NEEDED */
N_VDestroy(jthCol);
return(retval);
}
开发者ID:sn248,项目名称:Rcppsbmod,代码行数:72,代码来源:cvode_direct.c
示例2: KINDenseDQJac
static int KINDenseDQJac(long int n, DenseMat J,
N_Vector u, N_Vector fu, void *jac_data,
N_Vector tmp1, N_Vector tmp2)
{
realtype inc, inc_inv, ujsaved, ujscale, sign;
realtype *tmp2_data, *u_data, *uscale_data;
N_Vector ftemp, jthCol;
long int j;
int retval;
KINMem kin_mem;
KINDenseMem kindense_mem;
/* jac_data points to kin_mem */
kin_mem = (KINMem) jac_data;
kindense_mem = (KINDenseMem) lmem;
/* Save pointer to the array in tmp2 */
tmp2_data = N_VGetArrayPointer(tmp2);
/* Rename work vectors for readibility */
ftemp = tmp1;
jthCol = tmp2;
/* Obtain pointers to the data for u and uscale */
u_data = N_VGetArrayPointer(u);
uscale_data = N_VGetArrayPointer(uscale);
/* This is the only for loop for 0..N-1 in KINSOL */
for (j = 0; j < n; j++) {
/* Generate the jth col of J(u) */
N_VSetArrayPointer(DENSE_COL(J,j), jthCol);
ujsaved = u_data[j];
ujscale = ONE/uscale_data[j];
sign = (ujsaved >= ZERO) ? ONE : -ONE;
inc = sqrt_relfunc*MAX(ABS(ujsaved), ujscale)*sign;
u_data[j] += inc;
retval = func(u, ftemp, f_data);
if (retval != 0) return(-1);
u_data[j] = ujsaved;
inc_inv = ONE/inc;
N_VLinearSum(inc_inv, ftemp, -inc_inv, fu, jthCol);
}
/* Restore original array pointer in tmp2 */
N_VSetArrayPointer(tmp2_data, tmp2);
/* Increment counter nfeD */
nfeD += n;
return(0);
}
开发者ID:AidanRocke,项目名称:CelegansNeuromechanicalGaitModulation,代码行数:60,代码来源:kinsol_dense.c
示例3: FIDA_SETVIN
void FIDA_SETVIN(char key_name[], realtype *vval, int *ier)
{
N_Vector Vec;
*ier = 0;
if (!strncmp(key_name,"ID_VEC",6)) {
Vec = NULL;
Vec = N_VCloneEmpty(F2C_IDA_vec);
if (Vec == NULL) {
*ier = -1;
return;
}
N_VSetArrayPointer(vval, Vec);
IDASetId(IDA_idamem, Vec);
N_VDestroy(Vec);
} else if (!strncmp(key_name,"CONSTR_VEC",10)) {
Vec = NULL;
Vec = N_VCloneEmpty(F2C_IDA_vec);
if (Vec == NULL) {
*ier = -1;
return;
}
N_VSetArrayPointer(vval, Vec);
IDASetConstraints(IDA_idamem, Vec);
N_VDestroy(Vec);
} else {
*ier = -99;
printf("FIDASETVIN: Unrecognized key.\n\n");
}
}
开发者ID:ladlung,项目名称:CERENA,代码行数:32,代码来源:fida.c
示例4: CVDenseDQJac
static void CVDenseDQJac(long int N, DenseMat J, realtype t,
N_Vector y, N_Vector fy, void *jac_data,
N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
{
realtype fnorm, minInc, inc, inc_inv, yjsaved, srur;
realtype *tmp2_data, *y_data, *ewt_data;
N_Vector ftemp, jthCol;
long int j;
CVodeMem cv_mem;
CVDenseMem cvdense_mem;
/* jac_data points to cvode_mem */
cv_mem = (CVodeMem) jac_data;
cvdense_mem = (CVDenseMem) lmem;
/* Save pointer to the array in tmp2 */
tmp2_data = N_VGetArrayPointer(tmp2);
/* Rename work vectors for readibility */
ftemp = tmp1;
jthCol = tmp2;
/* Obtain pointers to the data for ewt, y */
ewt_data = N_VGetArrayPointer(ewt);
y_data = N_VGetArrayPointer(y);
/* Set minimum increment based on uround and norm of f */
srur = RSqrt(uround);
fnorm = N_VWrmsNorm(fy, ewt);
minInc = (fnorm != ZERO) ?
(MIN_INC_MULT * ABS(h) * uround * N * fnorm) : ONE;
/* This is the only for loop for 0..N-1 in CVODE */
for (j = 0; j < N; j++) {
/* Generate the jth col of J(tn,y) */
N_VSetArrayPointer(DENSE_COL(J,j), jthCol);
yjsaved = y_data[j];
inc = MAX(srur*ABS(yjsaved), minInc/ewt_data[j]);
y_data[j] += inc;
f(tn, y, ftemp, f_data);
y_data[j] = yjsaved;
inc_inv = ONE/inc;
N_VLinearSum(inc_inv, ftemp, -inc_inv, fy, jthCol);
DENSE_COL(J,j) = N_VGetArrayPointer(jthCol);
}
/* Restore original array pointer in tmp2 */
N_VSetArrayPointer(tmp2_data, tmp2);
/* Increment counter nfeD */
nfeD += N;
}
开发者ID:vortexlaboratory,项目名称:neuron,代码行数:59,代码来源:cvdense.c
示例5: FIDA_REINIT
void FIDA_REINIT(realtype *t0, realtype *yy0, realtype *yp0,
int *iatol, realtype *rtol, realtype *atol,
int *ier)
{
N_Vector Vatol;
*ier = 0;
/* Initialize all pointers to NULL */
Vatol = NULL;
/* Attach user's yy0 to F2C_IDA_vec */
N_VSetArrayPointer(yy0, F2C_IDA_vec);
/* Attach user's yp0 to F2C_IDA_ypvec */
N_VSetArrayPointer(yp0, F2C_IDA_ypvec);
/* Call IDAReInit */
*ier = IDAReInit(IDA_idamem, *t0, F2C_IDA_vec, F2C_IDA_ypvec);
/* Reset data pointers */
N_VSetArrayPointer(NULL, F2C_IDA_vec);
N_VSetArrayPointer(NULL, F2C_IDA_ypvec);
/* On failure, exit */
if (*ier != IDA_SUCCESS) {
*ier = -1;
return;
}
/* Set tolerances */
switch (*iatol) {
case 1:
*ier = IDASStolerances(IDA_idamem, *rtol, *atol);
break;
case 2:
Vatol = NULL;
Vatol= N_VCloneEmpty(F2C_IDA_vec);
if (Vatol == NULL) {
*ier = -1;
return;
}
N_VSetArrayPointer(atol, Vatol);
*ier = IDASVtolerances(IDA_idamem, *rtol, Vatol);
N_VDestroy(Vatol);
break;
}
/* On failure, exit */
if (*ier != IDA_SUCCESS) {
*ier = -1;
return;
}
return;
}
开发者ID:ladlung,项目名称:CERENA,代码行数:56,代码来源:fida.c
示例6: FCV_REINIT
void FCV_REINIT(realtype *t0, realtype *y0,
int *iatol, realtype *rtol, realtype *atol,
int *ier)
{
N_Vector Vatol;
*ier = 0;
/* Initialize all pointers to NULL */
Vatol = NULL;
/* Set data in F2C_CVODE_vec to y0 */
N_VSetArrayPointer(y0, F2C_CVODE_vec);
/* Call CVReInit */
*ier = CVodeReInit(CV_cvodemem, *t0, F2C_CVODE_vec);
/* Reset data pointers */
N_VSetArrayPointer(NULL, F2C_CVODE_vec);
/* On failure, exit */
if (*ier != CV_SUCCESS) {
*ier = -1;
return;
}
/* Set tolerances */
switch (*iatol) {
case 1:
*ier = CVodeSStolerances(CV_cvodemem, *rtol, *atol);
break;
case 2:
Vatol = NULL;
Vatol = N_VCloneEmpty(F2C_CVODE_vec);
if (Vatol == NULL) {
*ier = -1;
return;
}
N_VSetArrayPointer(atol, Vatol);
*ier = CVodeSVtolerances(CV_cvodemem, *rtol, Vatol);
N_VDestroy(Vatol);
break;
}
/* On failure, exit */
if (*ier != CV_SUCCESS) {
*ier = -1;
return;
}
return;
}
开发者ID:polymec,项目名称:polymec-dev,代码行数:52,代码来源:fcvode.c
示例7: FIDA_GETESTLOCALERR
void FIDA_GETESTLOCALERR(realtype *ele, int *ier)
{
/* Attach user data to vector */
N_VSetArrayPointer(ele, F2C_IDA_vec);
*ier = 0;
*ier = IDAGetEstLocalErrors(IDA_idamem, F2C_IDA_vec);
/* Reset data pointers */
N_VSetArrayPointer(NULL, F2C_IDA_vec);
return;
}
开发者ID:ladlung,项目名称:CERENA,代码行数:13,代码来源:fida.c
示例8: FIDA_GETERRWEIGHTS
void FIDA_GETERRWEIGHTS(realtype *eweight, int *ier)
{
/* Attach user data to vector */
N_VSetArrayPointer(eweight, F2C_IDA_vec);
*ier = 0;
*ier = IDAGetErrWeights(IDA_idamem, F2C_IDA_vec);
/* Reset data pointer */
N_VSetArrayPointer(NULL, F2C_IDA_vec);
return;
}
开发者ID:ladlung,项目名称:CERENA,代码行数:13,代码来源:fida.c
示例9: FIDA_GETDKY
void FIDA_GETDKY(realtype *t, int *k, realtype *dky, int *ier)
{
/* Attach user data to vectors */
N_VSetArrayPointer(dky, F2C_IDA_vec);
*ier = 0;
*ier = IDAGetDky(IDA_idamem, *t, *k, F2C_IDA_vec);
/* Reset data pointers */
N_VSetArrayPointer(NULL, F2C_IDA_vec);
return;
}
开发者ID:ladlung,项目名称:CERENA,代码行数:13,代码来源:fida.c
示例10: FCV_GETERRWEIGHTS
void FCV_GETERRWEIGHTS(realtype *eweight, int *ier)
{
/* Attach user data to vector */
realtype *f2c_data = N_VGetArrayPointer(F2C_CVODE_vec);
N_VSetArrayPointer(eweight, F2C_CVODE_vec);
*ier = 0;
*ier = CVodeGetErrWeights(CV_cvodemem, F2C_CVODE_vec);
/* Reset data pointers */
N_VSetArrayPointer(f2c_data, F2C_CVODE_vec);
return;
}
开发者ID:polymec,项目名称:polymec-dev,代码行数:14,代码来源:fcvode.c
示例11: FCV_GETESTLOCALERR
void FCV_GETESTLOCALERR(realtype *ele, int *ier)
{
/* Attach user data to vector */
realtype *f2c_data = N_VGetArrayPointer(F2C_CVODE_vec);
N_VSetArrayPointer(ele, F2C_CVODE_vec);
*ier = 0;
*ier = CVodeGetEstLocalErrors(CV_cvodemem, F2C_CVODE_vec);
/* Reset data pointers */
N_VSetArrayPointer(f2c_data, F2C_CVODE_vec);
return;
}
开发者ID:polymec,项目名称:polymec-dev,代码行数:14,代码来源:fcvode.c
示例12: FIDA_GETSOL
void FIDA_GETSOL(realtype *t, realtype *yret, realtype *ypret, int *ier)
{
/* Attach user data to vectors */
N_VSetArrayPointer(yret, F2C_IDA_vec);
N_VSetArrayPointer(ypret, F2C_IDA_ypvec);
*ier = 0;
*ier = IDAGetSolution(IDA_idamem, *t, F2C_IDA_vec, F2C_IDA_ypvec);
/* Reset data pointers */
N_VSetArrayPointer(NULL, F2C_IDA_vec);
N_VSetArrayPointer(NULL, F2C_IDA_ypvec);
return;
}
开发者ID:A1kmm,项目名称:modml-solver,代码行数:15,代码来源:fida.c
示例13: FIDA_GETDKY
void FIDA_GETDKY(realtype *t, int *k, realtype *dky, int *ier)
{
/* Store existing F2C_IDA_vec data pointer */
realtype *f2c_data = N_VGetArrayPointer(F2C_IDA_vec);
/* Attach user data to vectors */
N_VSetArrayPointer(dky, F2C_IDA_vec);
*ier = 0;
*ier = IDAGetDky(IDA_idamem, *t, *k, F2C_IDA_vec);
/* Reset data pointers */
N_VSetArrayPointer(f2c_data, F2C_IDA_vec);
return;
}
开发者ID:luca-heltai,项目名称:sundials,代码行数:16,代码来源:fida.c
示例14: FIDA_GETESTLOCALERR
void FIDA_GETESTLOCALERR(realtype *ele, int *ier)
{
/* Store existing F2C_IDA_vec data pointer */
realtype *f2c_data = N_VGetArrayPointer(F2C_IDA_vec);
/* Attach user data to vector */
N_VSetArrayPointer(ele, F2C_IDA_vec);
*ier = 0;
*ier = IDAGetEstLocalErrors(IDA_idamem, F2C_IDA_vec);
/* Reset data pointers */
N_VSetArrayPointer(f2c_data, F2C_IDA_vec);
return;
}
开发者ID:luca-heltai,项目名称:sundials,代码行数:16,代码来源:fida.c
示例15: FARK_SETRESTOLERANCE
/* Fortran interface routine to set residual tolerance
scalar/array; functions as an all-in-one interface to the C
routines ARKodeResStolerance and ARKodeResVtolerance;
see farkode.h for further details */
void FARK_SETRESTOLERANCE(int *itol, realtype *atol, int *ier) {
N_Vector Vatol;
realtype abstol;
*ier = 0;
/* Set tolerance, based on itol argument */
abstol=1.e-9;
switch (*itol) {
case 1:
if (*atol > 0.0) abstol = *atol;
*ier = ARKodeResStolerance(ARK_arkodemem, abstol);
break;
case 2:
Vatol = NULL;
Vatol = N_VCloneEmpty(F2C_ARKODE_vec);
if (Vatol == NULL) {
*ier = -1;
return;
}
N_VSetArrayPointer(atol, Vatol);
if (N_VMin(Vatol) <= 0.0) N_VConst(abstol, Vatol);
*ier = ARKodeResVtolerance(ARK_arkodemem, Vatol);
N_VDestroy(Vatol);
break;
}
return;
}
开发者ID:luca-heltai,项目名称:sundials,代码行数:34,代码来源:farkode.c
示例16: TSInterpolate_Sundials
static PetscErrorCode TSInterpolate_Sundials(TS ts,PetscReal t,Vec X)
{
TS_Sundials *cvode = (TS_Sundials*)ts->data;
N_Vector y;
PetscErrorCode ierr;
PetscScalar *x_data;
PetscInt glosize,locsize;
PetscFunctionBegin;
/* get the vector size */
ierr = VecGetSize(X,&glosize);CHKERRQ(ierr);
ierr = VecGetLocalSize(X,&locsize);CHKERRQ(ierr);
/* allocate the memory for N_Vec y */
y = N_VNew_Parallel(cvode->comm_sundials,locsize,glosize);
if (!y) SETERRQ(PETSC_COMM_SELF,1,"Interpolated y is not allocated");
ierr = VecGetArray(X,&x_data);CHKERRQ(ierr);
N_VSetArrayPointer((realtype *)x_data,y);
ierr = CVodeGetDky(cvode->mem,t,0,y);CHKERRQ(ierr);
ierr = VecRestoreArray(X,&x_data);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
开发者ID:Kun-Qu,项目名称:petsc,代码行数:25,代码来源:sundials.c
示例17: FARK_GETERRWEIGHTS
/* Fortran interface to C routine ARKodeGetErrWeights; see
farkode.h for further details */
void FARK_GETERRWEIGHTS(realtype *eweight, int *ier) {
/* store pointer existing F2C_ARKODE_vec data array */
realtype *f2c_data = N_VGetArrayPointer(F2C_ARKODE_vec);
/* attach output data array to F2C_ARKODE_vec */
N_VSetArrayPointer(eweight, F2C_ARKODE_vec);
/* call ARKodeGetErrWeights */
*ier = 0;
*ier = ARKodeGetErrWeights(ARK_arkodemem, F2C_ARKODE_vec);
/* reattach F2C_ARKODE_vec to previous data array */
N_VSetArrayPointer(f2c_data, F2C_ARKODE_vec);
return;
}
开发者ID:luca-heltai,项目名称:sundials,代码行数:18,代码来源:farkode.c
示例18: FARK_DKY
/* Fortran interface to C routine ARKodeGetDky; see farkode.h
for further details */
void FARK_DKY(realtype *t, int *k, realtype *dky, int *ier) {
/* store pointer existing F2C_ARKODE_vec data array */
realtype *f2c_data = N_VGetArrayPointer(F2C_ARKODE_vec);
/* attach output data array to F2C_ARKODE_vec */
N_VSetArrayPointer(dky, F2C_ARKODE_vec);
/* call ARKodeGetDky */
*ier = 0;
*ier = ARKodeGetDky(ARK_arkodemem, *t, *k, F2C_ARKODE_vec);
/* reattach F2C_ARKODE_vec to previous data array */
N_VSetArrayPointer(f2c_data, F2C_ARKODE_vec);
return;
}
开发者ID:luca-heltai,项目名称:sundials,代码行数:18,代码来源:farkode.c
示例19: FARK_FREE
/* Fortran interface to C routine ARKStepFree; see farkode.h for
further details */
void FARK_FREE() {
ARKodeMem ark_mem;
ark_mem = (ARKodeMem) ARK_arkodemem;
/* free user_data structure */
if (ark_mem->user_data)
free(ark_mem->user_data);
ark_mem->user_data = NULL;
/* free main integrator memory structure (internally
frees time step module, rootfinding, interpolation structures) */
ARKStepFree(&ARK_arkodemem);
/* free interface vector / matrices / linear solvers */
N_VSetArrayPointer(NULL, F2C_ARKODE_vec);
N_VDestroy(F2C_ARKODE_vec);
if (F2C_ARKODE_matrix)
SUNMatDestroy(F2C_ARKODE_matrix);
if (F2C_ARKODE_mass_matrix)
SUNMatDestroy(F2C_ARKODE_mass_matrix);
if (F2C_ARKODE_linsol)
SUNLinSolFree(F2C_ARKODE_linsol);
if (F2C_ARKODE_mass_sol)
SUNLinSolFree(F2C_ARKODE_mass_sol);
return;
}
开发者ID:polymec,项目名称:polymec-dev,代码行数:29,代码来源:farkode.c
示例20: FIDA_GETERRWEIGHTS
void FIDA_GETERRWEIGHTS(realtype *eweight, int *ier)
{
/* Store existing F2C_IDA_vec data pointer */
realtype *f2c_data = N_VGetArrayPointer(F2C_IDA_vec);
/* Attach user data to vector */
N_VSetArrayPointer(eweight, F2C_IDA_vec);
*ier = 0;
*ier = IDAGetErrWeights(IDA_idamem, F2C_IDA_vec);
/* Reset data pointer */
N_VSetArrayPointer(f2c_data, F2C_IDA_vec);
return;
}
开发者ID:luca-heltai,项目名称:sundials,代码行数:16,代码来源:fida.c
注:本文中的N_VSetArrayPointer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论