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

C++ IDX函数代码示例

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

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



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

示例1: int

/*
 *  finds the first occurrence of a text in a text
 *
 *  Considering characters that signed char cannot represent and implementations where "plain" char
 *  is signed, casts to unsigned char * are added.
 */
int (text_find)(text_t s, int i, int j, text_t str)
{
    assert(str.len >= 0 && str.str);    /* validity check for texts */
    assert(s.len >= 0 && s.str);

    i = IDX(i, s.len);
    j = IDX(j, s.len);

    if (i > j)
        SWAP(i, j);

    assert(i >= 0 && j <= s.len);    /* validity check for position; see text_pos() */

    if (str.len == 0)    /* finding empty text always succeeds */
        return i + 1;
    else if (str.len == 1) {    /* finding-character case */
        for (; i < j; i++)    /* note that < is used */
            if (((unsigned char *)s.str)[i] == *(unsigned char *)str.str)
                return i + 1;
    } else
        for (; i + str.len <= j; i++)    /* note that <= is used and str.len added */
            if (EQUAL(s, i, str))
                return i + 1;

    return 0;
}
开发者ID:mycoboco,项目名称:beluga,代码行数:32,代码来源:text.c


示例2: qleftright

void
// qleftright(const int idim, const hydroparam_t H, hydrovarwork_t * Hvw)
qleftright(const int idim,
           const int Hnx,
           const int Hny,
           const int Hnxyt,
           const int Hnvar,
           const int slices, const int Hstep,
	   double *qxm,
	   double *qxp, double *qleft, double *qright) {
           //double qxm[Hnvar][Hstep][Hnxyt],
           //double qxp[Hnvar][Hstep][Hnxyt], double qleft[Hnvar][Hstep][Hnxyt], double qright[Hnvar][Hstep][Hnxyt]) {
  // #define IHVW(i,v) ((i) + (v) * Hnxyt)
  int nvar, i, s;
  int bmax;
  WHERE("qleftright");
  if (idim == 1) {
    bmax = Hnx + 1;
  } else {
    bmax = Hny + 1;
  }

#pragma acc parallel pcopyin(qxm[0:Hnvar*Hstep*Hnxyt], qxp[0:Hnvar*Hstep*Hnxyt]) pcopyout(qleft[0:Hnvar*Hstep*Hnxyt], qright[0:Hnvar*Hstep*Hnxyt]) 
#pragma acc loop gang collapse(2)
  for (nvar = 0; nvar < Hnvar; nvar++) {
    for (s = 0; s < slices; s++) {
#pragma acc loop vector
      for (i = 0; i < bmax; i++) {
        qleft[IDX(nvar,s,i)] = qxm[IDX(nvar,s,i + 1)];
        qright[IDX(nvar,s,i)] = qxp[IDX(nvar,s,i + 2)];
      }
    }
  }
}
开发者ID:HydroBench,项目名称:Hydro,代码行数:34,代码来源:qleftright.c


示例3: strspn

size_t
strspn(const char *s, const char *charset)
{
	/*
	 * NB: idx and bit are temporaries whose use causes gcc 3.4.2 to
	 * generate better code.  Without them, gcc gets a little confused.
	 */
	const char *s1;
	u_long bit;
	u_long tbl[(UCHAR_MAX + 1) / LONG_BIT];
	int idx;

	if(*s == '\0')
		return (0);

#if LONG_BIT == 64	/* always better to unroll on 64-bit architectures */
	tbl[3] = tbl[2] = tbl[1] = tbl[0] = 0;
#else
	for (idx = 0; idx < sizeof(tbl) / sizeof(tbl[0]); idx++)
		tbl[idx] = 0;
#endif
	for (; *charset != '\0'; charset++) {
		idx = IDX(*charset);
		bit = BIT(*charset);
		tbl[idx] |= bit;
	}

	for(s1 = s; ; s1++) {
		idx = IDX(*s1);
		bit = BIT(*s1);
		if ((tbl[idx] & bit) == 0)
			break;
	}
	return (s1 - s);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:35,代码来源:strspn.c


示例4: pickReps

// Chooses representatives at random from x and stores them in r.
void pickReps(matrix x, matrix *r){
  unint n = x.r;
  unint i, j;

  unint *shuf = (unint*)calloc(n, sizeof(*shuf));
  for(i=0; i<n; i++)
    shuf[i]=i;


  //generate a random permutation of 1..n
  struct timeval tv;
  gettimeofday(&tv,NULL);
  gsl_rng * rng;
  const gsl_rng_type *rngT;
  
  gsl_rng_env_setup();
  rngT = gsl_rng_default;
  rng = gsl_rng_alloc(rngT);
  gsl_rng_set(rng,tv.tv_usec);
  
  gsl_ran_shuffle(rng, shuf, n, sizeof(*shuf));
  gsl_rng_free(rng);
 
  for(i=0; i<r->r; i++){
    for(j=0; j<r->c; j++){
      r->mat[IDX( i, j, r->ld )] = x.mat[IDX( shuf[i], j, x.ld )];
    }
  }
  free(shuf);
}
开发者ID:sourekj,项目名称:Packages,代码行数:31,代码来源:rbc.cpp


示例5: write_wchars

static inline void
write_wchars(wchar_t buf[], size_t start, size_t end, bool escape,
             bool open_field, bool close_field) {
  size_t j;
  if (escape) {
    if (open_field)
      putwchar(L'"');
    for (j = start; j <= end; ++j) {
      if (buf[IDX(j)] == L'"')
        putwchar(L'"');
      if (putwchar(buf[IDX(j)]) == WEOF) {
        fprintf(stderr, "putwchar error");
        exit(1);
      }
    }
    if (close_field)
      putwchar(L'"');
  } else {
    for (j = start; j <= end; ++j) {
      if (putwchar(buf[IDX(j)]) == WEOF) {
        fprintf(stderr, "putwchar error");
        exit(1);
      }
    }
  }
}
开发者ID:Snazz2001,项目名称:data-tools,代码行数:26,代码来源:tab_to_csv.c


示例6: QString

void WSInfoDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& thisindex) const
{
	WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model);
	WSInfoModel *wsim = WSInfoModel::instance();
	QModelIndexList matches = wsim->match(wsim->index(0,0), Qt::DisplayRole, currCombo.activeText);
	int row;
	if (matches.isEmpty()) {
		// we need to add this puppy
		wsim->insertRows(wsim->rowCount(), 1);
		wsim->setData(wsim->index(wsim->rowCount() - 1, 0), currCombo.activeText);
		row = wsim->rowCount() - 1;
	} else {
		row = matches.first().row();
	}
	int grams = wsim->data(wsim->index(row, WSInfoModel::GR)).toInt();
	QVariant v = QString(currCombo.activeText);

	// don't set if it's the same as it was before setting.
	if (mymodel->data(thisindex, WeightModel::TYPE).toString() == currCombo.activeText){
		return;
	}
	mymodel->setData(IDX(WeightModel::TYPE), v, Qt::EditRole);
	mymodel->passInData(IDX(WeightModel::WEIGHT), grams);
	qDebug() << "Fixme, every weigth is 0.0 grams. see:" << grams;
}
开发者ID:JT5D,项目名称:subsurface,代码行数:25,代码来源:modeldelegates.cpp


示例7: bg_lower_ilevel

/**
 * bg_lower_ilevel - lower the index level
 */
void bg_lower_ilevel(ptst_t *ptst)
{
        unsigned long zero = sl_zero;
        node_t  *node = set->head;
        node_t  *node_next = node;

        ptst = ptst_critical_enter();

        if (node->level-2 <= sl_zero)
                return; /* no more room to lower */

        /* decrement the level of all nodes */

        while (node) {
                node_next = node->succs[IDX(0,zero)];
                if (!node->marker) {
                        if (node->level > 0) {
                                if (1 == node->level && node->raise_or_remove)
                                        node->raise_or_remove = 0;
                                //BARRIER();
                                /* null out the ptr for level being removed */
                                node->succs[IDX(0,zero)] = NULL;
                                --node->level;
                        }
                }
                node = node_next;
        }

        /* remove the lowest index level */
        BARRIER(); /* do all of the above first */
        ++sl_zero;

        ptst_critical_exit(ptst);
}
开发者ID:Comnir,项目名称:synchrobench,代码行数:37,代码来源:background.c


示例8: setModelData

void TankInfoDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& thisindex) const
{
	CylindersModel *mymodel = qobject_cast<CylindersModel *>(currCombo.model);
	TankInfoModel *tanks = TankInfoModel::instance();
	QModelIndexList matches = tanks->match(tanks->index(0,0), Qt::DisplayRole, currCombo.activeText);
	int row;
	if (matches.isEmpty()) {
		// we need to add this
		tanks->insertRows(tanks->rowCount(), 1);
		tanks->setData(tanks->index(tanks->rowCount() -1, 0), currCombo.activeText);
		row = tanks->rowCount() - 1;
	} else {
		row = matches.first().row();
	}
	int tankSize = tanks->data(tanks->index(row, TankInfoModel::ML)).toInt();
	int tankPressure = tanks->data(tanks->index(row, TankInfoModel::BAR)).toInt();

	// don't fuck the other data, jimmy.
	if ( mymodel->data(thisindex, CylindersModel::TYPE).toString() == currCombo.activeText){
		return;
	}

	mymodel->setData(IDX(CylindersModel::TYPE), currCombo.activeText, Qt::EditRole);
	mymodel->passInData(IDX(CylindersModel::WORKINGPRESS), tankPressure);
	mymodel->passInData(IDX(CylindersModel::SIZE), tankSize);
}
开发者ID:JT5D,项目名称:subsurface,代码行数:26,代码来源:modeldelegates.cpp


示例9: equation_of_state

void
equation_of_state(int imin,
                  int imax,
                  const int Hnxyt,
                  const int Hnvar,
                  const double Hsmallc,
                  const double Hgamma,
                  const int slices, const int Hstep,
                  double *eint, double *q, double *c) {
  //double eint[Hstep][Hnxyt], double q[Hnvar][Hstep][Hnxyt], double c[Hstep][Hnxyt]) {
  int k, s;
  double smallp;

  WHERE("equation_of_state");
  smallp = Square(Hsmallc) / Hgamma;
  CFLOPS(1);

#pragma acc parallel pcopyin(eint[0:Hstep*Hnxyt]) pcopy(q[0:Hnvar*Hstep*Hnxyt]) pcopyout(c[0:Hstep*Hnxyt])
#pragma acc loop gang
  for (s = 0; s < slices; s++) {
#pragma acc loop vector
    for (k = imin; k < imax; k++) {
      double rhok = q[IDX(ID,s,k)];
      double base = (Hgamma - one) * rhok * eint[IDXE(s,k)];
      base = MAX(base, (double) (rhok * smallp));

      q[IDX(IP,s,k)] = base;
      c[IDXE(s,k)] = sqrt(Hgamma * base / rhok);

      CFLOPS(7);
    }
  }
}                               // equation_of_state
开发者ID:HydroBench,项目名称:Hydro,代码行数:33,代码来源:equation_of_state.c


示例10: main

int main()
{
	freopen("t.in", "r", stdin);
	freopen("t.out", "w", stdout);
	int n;
	scanf("%d", &n);
	printf("%d", n);
	for(int i = 0; i < n; i ++)
		for(int j = 0; j < n; j ++)
			if(i + j > n)
				printf(" %d", IDX(i,j));
	printf("\n");
	printf("%d", nextOdd());
	for(int i = 0; i < n; i ++)
		for(int j = 0; j < n; j ++)
			if(i + j == n)
				printf(" %d", IDX(i,j));
	printf("\n");
	for(int i = n; i >= 2; i --)
	{
		printf("%d", nextOdd());
		for(int j = 0; j < i; j ++)
			printf(" %d", IDX(j, i - j - 1));
		printf("\n");
	}
}
开发者ID:alxsoares,项目名称:OI,代码行数:26,代码来源:p109.cpp


示例11: revertModelData

void WSInfoDelegate::revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint)
{
	if (hint == QAbstractItemDelegate::NoHint || hint == QAbstractItemDelegate::RevertModelCache){
		WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model);
		mymodel->setData(IDX(WeightModel::TYPE), currWeight.type, Qt::EditRole);
		mymodel->passInData(IDX(WeightModel::WEIGHT), currWeight.weight);
	}
}
开发者ID:LuisaDomingues,项目名称:subsurface,代码行数:8,代码来源:modeldelegates.cpp


示例12: i80286_selector_address

static UINT32 i80286_selector_address(i80286_state *cpustate,UINT16 sel)
{
	UINT32 base;
	UINT16 limit;
	if(TBL(sel)) { base = cpustate->ldtr.base; limit = cpustate->ldtr.limit; }
	else { base = cpustate->gdtr.base; limit = cpustate->gdtr.limit; }
	return ((IDX(sel)>=limit)||!IDXTBL(sel)?-1:base+IDX(sel));
}
开发者ID:NastyNoah,项目名称:groovyarcade.groovymame,代码行数:8,代码来源:instr286.c


示例13: _op_handler

static int _op_handler(double *lu, int i, double h2, hpx_addr_t u, hpx_addr_t f) {
  double left, right, lf;

  hpx_gas_memget_sync(&left, IDX(u,i-1), sizeof(left));
  hpx_gas_memget_sync(&right, IDX(u,i+1), sizeof(right));
  hpx_gas_memget_sync(&lf, IDX(f,i), sizeof(lf));
  *lu = left + right + h2*lf/2;
  return HPX_SUCCESS;
}
开发者ID:dkogler,项目名称:hpx5-measurement-tests,代码行数:9,代码来源:jacobi.c


示例14: qleftright

void
// qleftright(const int idim, const hydroparam_t H, hydrovarwork_t * Hvw)
qleftright (const int idim,
            const int Hnx,
            const int Hny,
            const int Hnxyt,
            const int Hnvar,
            const int slices, const int Hstep,
            hydro_real_t *qxm, hydro_real_t *qxp, hydro_real_t *qleft, hydro_real_t *qright)
{
    //double qxm[Hnvar][Hstep][Hnxyt],
    //double qxp[Hnvar][Hstep][Hnxyt], double qleft[Hnvar][Hstep][Hnxyt], double qright[Hnvar][Hstep][Hnxyt]) {
    // #define IHVW(i,v) ((i) + (v) * Hnxyt)
    //int nvar, i, s;
    int bmax;
    WHERE ("qleftright");
    if (idim == 1)
    {
        bmax = Hnx + 1;
    }
    else
    {
        bmax = Hny + 1;
    }

#pragma acc kernels present(qxm[0:Hnvar*Hstep*Hnxyt], qxp[0:Hnvar*Hstep*Hnxyt]) present(qleft[0:Hnvar*Hstep*Hnxyt], qright[0:Hnvar*Hstep*Hnxyt])
    {

#ifdef GRIDIFY
#ifndef GRIDIFY_TUNE_PHI
#pragma hmppcg gridify(nvar*s,i)
#else
#pragma hmppcg gridify(nvar*s,i), blocksize 512x1
#endif
#endif /* GRIDIFY */
#ifndef GRIDIFY
#pragma acc loop independent
#endif /* !GRIDIFY */
        for (int nvar = 0; nvar < Hnvar; nvar++)
        {
#ifndef GRIDIFY
#pragma acc loop independent
#endif /* !GRIDIFY */
            for (int s = 0; s < slices; s++)
            {
#ifndef GRIDIFY
#pragma acc loop independent
#endif /* !GRIDIFY */
                for (int i = 0; i < bmax; i++)
                {
                    qleft[IDX (nvar, s, i)] = qxm[IDX (nvar, s, i + 1)];
                    qright[IDX (nvar, s, i)] = qxp[IDX (nvar, s, i + 2)];
                }
            }
        }
    }//kernels region
}
开发者ID:RWTH-OS,项目名称:Hydro,代码行数:57,代码来源:qleftright.c


示例15: assert_matrix_equality

int assert_matrix_equality(double *A, double *B, int n){
    int i, j;
    double epsilon = 0.0001;
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
            if (fabs(A[IDX(i, j, n)] - B[IDX(i, j, n)]) > epsilon)
                return 1;
    return 0;
}
开发者ID:piotroramus,项目名称:OORA2015,代码行数:9,代码来源:chol_dense.c


示例16: switch

const glsl_type *
glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
{
   if (base_type == GLSL_TYPE_VOID)
      return void_type;

   if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4))
      return error_type;

   /* Treat GLSL vectors as Nx1 matrices.
    */
   if (columns == 1) {
      switch (base_type) {
      case GLSL_TYPE_UINT:
	 return uint_type + (rows - 1);
      case GLSL_TYPE_INT:
	 return int_type + (rows - 1);
      case GLSL_TYPE_FLOAT:
	 return float_type + (rows - 1);
      case GLSL_TYPE_BOOL:
	 return bool_type + (rows - 1);
      default:
	 return error_type;
      }
   } else {
      if ((base_type != GLSL_TYPE_FLOAT) || (rows == 1))
	 return error_type;

      /* GLSL matrix types are named mat{COLUMNS}x{ROWS}.  Only the following
       * combinations are valid:
       *
       *   1 2 3 4
       * 1
       * 2   x x x
       * 3   x x x
       * 4   x x x
       */
#define IDX(c,r) (((c-1)*3) + (r-1))

      switch (IDX(columns, rows)) {
      case IDX(2,2): return mat2_type;
      case IDX(2,3): return mat2x3_type;
      case IDX(2,4): return mat2x4_type;
      case IDX(3,2): return mat3x2_type;
      case IDX(3,3): return mat3_type;
      case IDX(3,4): return mat3x4_type;
      case IDX(4,2): return mat4x2_type;
      case IDX(4,3): return mat4x3_type;
      case IDX(4,4): return mat4_type;
      default: return error_type;
      }
   }

   assert(!"Should not get here.");
   return error_type;
}
开发者ID:DanMacDonald,项目名称:LoomSDK,代码行数:56,代码来源:glsl_types.cpp


示例17: copyMat

void copyMat(matrix *x, matrix *y){
  unint i,j;
  
  x->r=y->r; x->pr=y->pr; x->c=y->c; x->pc=y->pc; x->ld=y->ld;
  for(i=0; i<y->r; i++){
    for(j=0; j<y->c; j++){
      x->mat[IDX( i, j, x->ld )] = y->mat[IDX( i, j, y->ld )];
    }
  }
}
开发者ID:sourekj,项目名称:Packages,代码行数:10,代码来源:utils.cpp


示例18: Mat

// C = A^T
Mat Mat::T() {
  // create new Mat for output, and do operation
  Mat *C = new Mat(ncols,nrows);
  for (long int j=0; j<ncols; j++)
    for (long int i=0; i<nrows; i++)
      C->data[IDX(j,i,ncols)] = data[IDX(i,j,nrows)];

  // return result
  return *C;
}
开发者ID:TylerJackson,项目名称:SciCompRepo,代码行数:11,代码来源:Mat.cpp


示例19: pdf_jsimp_to_type

int pdf_jsimp_to_type(pdf_jsimp *imp, pdf_jsimp_obj *obj)
{
	js_State *J = imp->J;
	if (js_isnull(J, IDX(obj))) return JS_TYPE_NULL;
	if (js_isboolean(J, IDX(obj))) return JS_TYPE_BOOLEAN;
	if (js_isnumber(J, IDX(obj))) return JS_TYPE_NUMBER;
	if (js_isstring(J, IDX(obj))) return JS_TYPE_STRING;
	if (js_isarray(J, IDX(obj))) return JS_TYPE_ARRAY;
	return JS_TYPE_UNKNOWN;
}
开发者ID:BYogesh,项目名称:mupdf,代码行数:10,代码来源:pdf-jsimp-mu.c


示例20: transpose

static void transpose(real_t *A, uint_t dim)
{
    for (uint_t i = 0; i < dim; ++i) {
        for (uint_t j = 0; j < i; ++j) {
            real_t x = A[IDX(i, j, dim)];
            A[IDX(i, j, dim)] = A[IDX(j, i, dim)];
            A[IDX(j, i, dim)] = x;
        }
    }
}
开发者ID:romanz,项目名称:thesis,代码行数:10,代码来源:main.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ IDXBYTE函数代码示例发布时间:2022-05-30
下一篇:
C++ IDSetSwitch函数代码示例发布时间: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