• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NV_LENGTH_S函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NV_LENGTH_S函数的典型用法代码示例。如果您正苦于以下问题:C++ NV_LENGTH_S函数的具体用法?C++ NV_LENGTH_S怎么用?C++ NV_LENGTH_S使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NV_LENGTH_S函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Vaxpy_Serial

static void Vaxpy_Serial(realtype a, N_Vector x, N_Vector y)
{
  long int i, N;
  realtype *xd, *yd;

  xd = yd = NULL;

  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);
  yd = NV_DATA_S(y);

  if (a == ONE) {
    for (i = 0; i < N; i++)
      yd[i] += xd[i];
    return;
  }

  if (a == -ONE) {
    for (i = 0; i < N; i++)
      yd[i] -= xd[i];
    return;
  }

  for (i = 0; i < N; i++)
    yd[i] += a*xd[i];

  return;
}
开发者ID:thomasklau,项目名称:simbody,代码行数:28,代码来源:nvector_serial.c


示例2: N_VCloneEmpty_Serial

N_Vector N_VCloneEmpty_Serial(N_Vector w)
{
  N_Vector v;
  N_Vector_Ops ops;
  N_VectorContent_Serial content;

  if (w == NULL) return(NULL);

  /* Create vector */
  v = NULL;
  v = (N_Vector) malloc(sizeof *v);
  if (v == NULL) return(NULL);

  /* Create vector operation structure */
  ops = NULL;
  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
  if (ops == NULL) { free(v); return(NULL); }
  
  ops->nvclone           = w->ops->nvclone;
  ops->nvcloneempty      = w->ops->nvcloneempty;
  ops->nvdestroy         = w->ops->nvdestroy;
  ops->nvspace           = w->ops->nvspace;
  ops->nvgetarraypointer = w->ops->nvgetarraypointer;
  ops->nvsetarraypointer = w->ops->nvsetarraypointer;
  ops->nvlinearsum       = w->ops->nvlinearsum;
  ops->nvconst           = w->ops->nvconst;  
  ops->nvprod            = w->ops->nvprod;   
  ops->nvdiv             = w->ops->nvdiv;
  ops->nvscale           = w->ops->nvscale; 
  ops->nvabs             = w->ops->nvabs;
  ops->nvinv             = w->ops->nvinv;
  ops->nvaddconst        = w->ops->nvaddconst;
  ops->nvdotprod         = w->ops->nvdotprod;
  ops->nvmaxnorm         = w->ops->nvmaxnorm;
  ops->nvwrmsnormmask    = w->ops->nvwrmsnormmask;
  ops->nvwrmsnorm        = w->ops->nvwrmsnorm;
  ops->nvmin             = w->ops->nvmin;
  ops->nvwl2norm         = w->ops->nvwl2norm;
  ops->nvl1norm          = w->ops->nvl1norm;
  ops->nvcompare         = w->ops->nvcompare;    
  ops->nvinvtest         = w->ops->nvinvtest;
  ops->nvconstrmask      = w->ops->nvconstrmask;
  ops->nvminquotient     = w->ops->nvminquotient;
  ops->nvlength          = w->ops->nvlength;

  /* Create content */
  content = NULL;
  content = (N_VectorContent_Serial) malloc(sizeof(struct _N_VectorContent_Serial));
  if (content == NULL) { free(ops); free(v); return(NULL); }

  content->length   = NV_LENGTH_S(w);
  content->own_data = FALSE;
  content->data     = NULL;

  /* Attach content and ops */
  v->content = content;
  v->ops     = ops;

  return(v);
}
开发者ID:BrechtBa,项目名称:casadi,代码行数:60,代码来源:nvector_serial.c


示例3: N_VConstrMask_Serial

booleantype N_VConstrMask_Serial(N_Vector c, N_Vector x, N_Vector m)
{
  long int i, N;
  booleantype test;
  realtype *cd, *xd, *md;

  cd = xd = md = NULL;

  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);
  cd = NV_DATA_S(c);
  md = NV_DATA_S(m);

  test = TRUE;

  for (i = 0; i < N; i++) {
    md[i] = ZERO;
    if (cd[i] == ZERO) continue;
    if (cd[i] > ONEPT5 || cd[i] < -ONEPT5) {
      if ( xd[i]*cd[i] <= ZERO) { test = FALSE; md[i] = ONE; }
      continue;
    }
    if ( cd[i] > HALF || cd[i] < -HALF) {
      if (xd[i]*cd[i] < ZERO ) { test = FALSE; md[i] = ONE; }
    }
  }

  return(test);
}
开发者ID:thomasklau,项目名称:simbody,代码行数:29,代码来源:nvector_serial.c


示例4: N_VMinQuotient_Serial

realtype N_VMinQuotient_Serial(N_Vector num, N_Vector denom)
{
  booleantype notEvenOnce;
  long int i, N;
  realtype *nd, *dd, min;

  nd = dd = NULL;

  N  = NV_LENGTH_S(num);
  nd = NV_DATA_S(num);
  dd = NV_DATA_S(denom);

  notEvenOnce = TRUE;
  min = BIG_REAL;

  for (i = 0; i < N; i++) {
    if (dd[i] == ZERO) continue;
    else {
      if (!notEvenOnce) min = MIN(min, nd[i]/dd[i]);
      else {
    min = nd[i]/dd[i];
        notEvenOnce = FALSE;
      }
    }
  }

  return(min);
}
开发者ID:thomasklau,项目名称:simbody,代码行数:28,代码来源:nvector_serial.c


示例5: N_VScale_Serial

void N_VScale_Serial(realtype c, N_Vector x, N_Vector z)
{
  long int i, N;
  realtype *xd, *zd;

  xd = zd = NULL;

  if (z == x) {  /* BLAS usage: scale x <- cx */
    VScaleBy_Serial(c, x);
    return;
  }

  if (c == ONE) {
    VCopy_Serial(x, z);
  } else if (c == -ONE) {
    VNeg_Serial(x, z);
  } else {
    N  = NV_LENGTH_S(x);
    xd = NV_DATA_S(x);
    zd = NV_DATA_S(z);
    for (i = 0; i < N; i++)
      zd[i] = c*xd[i];
  }

  return;
}
开发者ID:thomasklau,项目名称:simbody,代码行数:26,代码来源:nvector_serial.c


示例6: N_VSpace_Serial

void N_VSpace_Serial(N_Vector v, long int *lrw, long int *liw)
{
  *lrw = NV_LENGTH_S(v);
  *liw = 1;

  return;
}
开发者ID:thomasklau,项目名称:simbody,代码行数:7,代码来源:nvector_serial.c


示例7: N_VClone_Serial

N_Vector N_VClone_Serial(N_Vector w)
{
  N_Vector v;
  realtype *data;
  long int length;

  v = NULL;
  v = N_VCloneEmpty_Serial(w);
  if (v == NULL) return(NULL);

  length = NV_LENGTH_S(w);

  /* Create data */
  if (length > 0) {

    /* Allocate memory */
    data = NULL;
    data = (realtype *) malloc(length * sizeof(realtype));
    if(data == NULL) { N_VDestroy_Serial(v); return(NULL); }

    /* Attach data */
    NV_OWN_DATA_S(v) = TRUE;
    NV_DATA_S(v)     = data;

  }

  return(v);
}
开发者ID:thomasklau,项目名称:simbody,代码行数:28,代码来源:nvector_serial.c


示例8: sunml_lsolver_lapack_band

CAMLprim value sunml_lsolver_lapack_band(value vnvec, value vbmat)
{
    CAMLparam2(vnvec, vbmat);
#if SUNDIALS_LIB_VERSION >= 300 && defined SUNDIALS_ML_LAPACK
    SUNMatrix bmat = MAT_VAL(vbmat);
    SUNLinearSolver ls = SUNLapackBand(NVEC_VAL(vnvec), bmat);

    if (ls == NULL) {
	if (SUNBandMatrix_Rows(bmat) != SUNBandMatrix_Columns(bmat))
	    caml_raise_constant(LSOLVER_EXN(MatrixNotSquare));

	if (SUNBandMatrix_StoredUpperBandwidth(bmat) <
	    SUNMIN(SUNBandMatrix_Rows(bmat) - 1,
		   SUNBandMatrix_LowerBandwidth(bmat)
		   + SUNBandMatrix_UpperBandwidth(bmat)))
	    caml_raise_constant(LSOLVER_EXN(InsufficientStorageUpperBandwidth));

	if (SUNBandMatrix_Rows(bmat) != NV_LENGTH_S(NVEC_VAL(vnvec)))
	    caml_raise_constant(LSOLVER_EXN(MatrixVectorMismatch));

	caml_raise_out_of_memory();
    }

    CAMLreturn(alloc_lsolver(ls));
#else
    CAMLreturn(Val_unit);
#endif
}
开发者ID:inria-parkas,项目名称:sundialsml,代码行数:28,代码来源:sundials_linearsolver_ml.c


示例9: vmin

static void* vmin(NrnThread* nt) {
  realtype min;
  int i = nt->id;
  if (NV_LENGTH_S(xarg(i))) {
	  min = N_VMin_Serial(xarg(i));
	  lockmin(min);
}
  return (void*)0;
}
开发者ID:nrnhines,项目名称:nrn,代码行数:9,代码来源:nvector_nrnthread.c


示例10: VScaleBy_Serial

static void VScaleBy_Serial(realtype a, N_Vector x)
{
  long int i, N;
  realtype *xd;

  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);

  for (i=0; i < N; i++)
    *xd++ *= a;
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:11,代码来源:nvector_serial.c


示例11: N_VConst_Serial

void N_VConst_Serial(realtype c, N_Vector z)
{
  long int i, N;
  realtype *zd;

  N  = NV_LENGTH_S(z);
  zd = NV_DATA_S(z);

  for (i=0; i < N; i++) 
    *zd++ = c;
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:11,代码来源:nvector_serial.c


示例12: N_VAddConst_Serial

void N_VAddConst_Serial(N_Vector x, realtype b, N_Vector z)
{
  long int i, N;
  realtype *xd, *zd;
  
  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);
  zd = NV_DATA_S(z);

  for (i=0; i < N; i++) 
    *zd++ = (*xd++) + b; 
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:12,代码来源:nvector_serial.c


示例13: N_VAbs_Serial

void N_VAbs_Serial(N_Vector x, N_Vector z)
{
  long int i, N;
  realtype *xd, *zd;

  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);
  zd = NV_DATA_S(z);

  for (i=0; i < N; i++, xd++, zd++)
    *zd = ABS(*xd);
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:12,代码来源:nvector_serial.c


示例14: VNeg_Serial

static void VNeg_Serial(N_Vector x, N_Vector z)
{
  long int i, N;
  realtype *xd, *zd;

  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);
  zd = NV_DATA_S(z);
  
  for (i=0; i < N; i++)
    *zd++ = -(*xd++);
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:12,代码来源:nvector_serial.c


示例15: N_VOneMask_Serial

void N_VOneMask_Serial(N_Vector x)
{
  long int i, N;
  realtype *xd;

  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);

  for (i=0; i<N; i++,xd++) {
    if (*xd != ZERO) *xd = ONE;
  }
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:12,代码来源:nvector_serial.c


示例16: N_VInv_Serial

void N_VInv_Serial(N_Vector x, N_Vector z)
{
  long int i, N;
  realtype *xd, *zd;

  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);
  zd = NV_DATA_S(z);

  for (i=0; i < N; i++)
    *zd++ = ONE / (*xd++);
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:12,代码来源:nvector_serial.c


示例17: N_VCompare_Serial

void N_VCompare_Serial(realtype c, N_Vector x, N_Vector z)
{
  long int i, N;
  realtype *xd, *zd;
  
  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);
  zd = NV_DATA_S(z);

  for (i=0; i < N; i++, xd++, zd++) {
    *zd = (ABS(*xd) >= c) ? ONE : ZERO;
  }
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:13,代码来源:nvector_serial.c


示例18: N_VDiv_Serial

void N_VDiv_Serial(N_Vector x, N_Vector y, N_Vector z)
{
  long int i, N;
  realtype *xd, *yd, *zd;

  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);
  yd = NV_DATA_S(y);
  zd = NV_DATA_S(z);

  for (i=0; i < N; i++)
    *zd++ = (*xd++) / (*yd++);
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:13,代码来源:nvector_serial.c


示例19: VLin2_Serial

static void VLin2_Serial(realtype a, N_Vector x, N_Vector y, N_Vector z)
{
  long int i, N;
  realtype *xd, *yd, *zd;

  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);
  yd = NV_DATA_S(y);
  zd = NV_DATA_S(z);

  for (i=0; i < N; i++)
    *zd++ = a * (*xd++) - (*yd++);
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:13,代码来源:nvector_serial.c


示例20: N_VL1Norm_Serial

realtype N_VL1Norm_Serial(N_Vector x)
{
  long int i, N;
  realtype sum = ZERO, *xd;
  
  N  = NV_LENGTH_S(x);
  xd = NV_DATA_S(x);
  
  for (i=0; i<N; i++)  
    sum += ABS(xd[i]);

  return(sum);
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:13,代码来源:nvector_serial.c



注:本文中的NV_LENGTH_S函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NV_MAT_V函数代码示例发布时间:2022-05-30
下一篇:
C++ NV_ERROR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap