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

C++ shift函数代码示例

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

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



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

示例1: selected

/***
 When removing a set from the partial solution
 1. Indicate that the column is no longer selected (x)
 2. Remove cost of column from partial cost (fx)
 3. Increment # of un-used columns (un_cols)
 4. Decrement # of columns covering each row (ncol_cover)
 5. Remove column from all columns covering row i (col_cover)
 6. If a row is now uncovered, increment un_rows
 7. If a row is now uncovered, indicate it (y)
 **/
void removeSet(instance_t* inst, solution_t* sol, int colidx) {
    sol->x[colidx] = 0;
    sol->fx -= inst->cost[colidx];
    sol->un_cols += 1;
    for (int i = 0; i < inst->nrow[colidx]; i++) {
        int rowidx = inst->row[colidx][i];
        for (int j = 0; j < sol->ncol_cover[rowidx]; j++) {
            if (sol->col_cover[rowidx][j] == colidx) {
                sol->col_cover[rowidx][j] = -1;
                shift(sol, rowidx, j);
                break;
            }
        }
        sol->ncol_cover[rowidx] -= 1;
        if (sol->ncol_cover[rowidx] <= 0) {
            sol->un_rows += 1;
            sol->y[rowidx] = 0;
        }
    }
}
开发者ID:JensNevens,项目名称:set-covering-problem,代码行数:30,代码来源:utils.c


示例2: conv_flaw

void conv_flaw(const cv::Mat& imgOriginal, const cv::Mat& kernel, cv::Mat& out, const bool& corr)
{
  cv::Mat source;
  imgOriginal.copyTo(source);
  cv::Mat kernelPadded = cv::Mat::zeros(source.size(), source.type());
  if(kernel.size().height > kernelPadded.size().height || kernel.size().width > kernelPadded.size().width)
  {
    throw CustomException("Kernel padded bigger than image.");
  }
  kernel.copyTo(selectCentralROI(kernelPadded, kernel.size()));
  //Divided by 2.0 instead of 2 to consider the result as double instead of as an int
  //The +1 in the shift changes slightly the finest plane in the wavelet,
  shift(kernelPadded, kernelPadded, std::ceil(kernelPadded.cols/2.0), std::ceil(kernelPadded.rows/2.0));

  cv::Mat kernelPadded_ft, input_ft, output_ft;
  cv::dft(kernelPadded, kernelPadded_ft, cv::DFT_COMPLEX_OUTPUT + cv::DFT_SCALE);
  cv::dft(source, input_ft, cv::DFT_COMPLEX_OUTPUT + cv::DFT_SCALE);
  cv::mulSpectrums(input_ft, kernelPadded_ft.mul(kernelPadded.total()), output_ft, cv::DFT_COMPLEX_OUTPUT, corr);
  cv::idft(output_ft, out, cv::DFT_REAL_OUTPUT);
}
开发者ID:dguerra,项目名称:pdmaster,代码行数:20,代码来源:ToolBox.cpp


示例3: calculate_logR

Score::Score(Alignment& alg){
	PRECISION = 15.;	// the default value of PRECISION
	LAMBDA = .125;
	alignment = alg;
	alpha_exponent = 1.;
	logR = calculate_logR();
	std::vector <std::vector<double> > temp = shift(logR);
	alpha_exponent = find_alpha_exponent(temp);
	rescaled_R = re_scale(temp, alpha_exponent);

	laplacian_determinant = calculate_determinant(laplacian_of(rescaled_R), rescaled_R.size() - 1);

	tf = "TF-Unknown";

	ParameterFile p;
	parameters = p;

	BackgroundModel bg (parameters.give_background());
	background = bg;
}
开发者ID:omidi,项目名称:DWT-toolbox,代码行数:20,代码来源:Score.cpp


示例4: funcPLUS

bool funcPLUS(ParserParam &param, Token *tok){
	switch(param.stack.back()){
		case 78:
			shift(param,tok,81);
			break;
		case 83:
			if(!rule46(param)) return false;
			break;
		case 85:
			if(!rule45(param)) return false;
			break;
		case 86:
			if(!rule47(param)) return false;
			break;
		case 88:
			if(!rule48(param)) return false;
			break;
		case 91:
			if(!rule49(param)) return false;
			break;
		case 92:
			if(!rule50(param)) return false;
			break;
		case 95:
			if(!rule51(param)) return false;
			break;
		case 98:
			if(!rule52(param)) return false;
			break;
		case 99:
			if(!rule53(param)) return false;
			break;
		case 113:
			if(!rule68(param)) return false;
			break;
		default:
			return false;
		break;
	}
	return true;
}
开发者ID:LuisHsu,项目名称:Arc,代码行数:41,代码来源:parserFunc.cpp


示例5: encrypt

/*
 * 加密
 *
 * @param key    密钥 { a, b }
 * @param src    待加密的字符串
 * @param dest   经过加密后的字符串
 */
char * encrypt(int* key, char* src, char* dest)
{
    char *pSrc  = src;
    char *pDest = dest;

    if (gcd(key[0], WIDTH) != 1)
    {
        printf("Error: a 与 m 不互素");
        exit(-1);
    }

    for (int i = 0; *pSrc; ++i, ++pSrc, ++pDest)
    {
        if (!isalpha(*pSrc))
            continue;

        *pDest = shift(key, toupper(*pSrc));
    }

    return dest;
}
开发者ID:BridgetCheng,项目名称:Cipher-examples,代码行数:28,代码来源:Affine.c


示例6: switch

	void StateItem::move(const int & action) {
		switch (decodeAction(action)) {
		case NO_ACTION:
			return;
		case SHIFT:
			shift();
			return;
		case REDUCE:
			reduce();
			return;
		case ARC_LEFT:
			arcLeft(action - AL_FIRST + 1);
			return;
		case ARC_RIGHT:
			arcRight(action - AR_FIRST + 1);
			return;
		case POP_ROOT:
			popRoot();
			return;
		}
	}
开发者ID:biug,项目名称:xParser,代码行数:21,代码来源:arceager_state.cpp


示例7: subst

dem subst (int n, dem y, dem z)
{
    if (y == NULL)
        return NULL;
    if (node(y) == node_var)
    {
        if (level(y) == n)
        	return z;
	if (level(y) > n)
		return mkdem (node_var, level(y)-1, NULL, NULL, NULL);
    }
    if (node(y) == node_ap)
	return ap (subst (n, sd0(y), z),
		   subst (n, sd1(y), z));
    if (node(y) == node_lambda)
	return lambda (subst (n+1, sd0(y), shift (0, 1, z)));
    /* return y; */
    return mkdem (node(y), level(y), name(y),
			subst (n, sd0(y), z),
			subst (n, sd1(y), z));
}
开发者ID:jbailhache,项目名称:log,代码行数:21,代码来源:NLCEI14.C


示例8: shift

bool LightColliderSphere::intersect(Vector3D start, Vector3D vec) {
    
    Vector3D shift(position - start);
    double a = vec.magnitudeSquared();
    double b = -2 * (vec * shift);
    double c = shift.magnitudeSquared() - radiusSquared;
    if(a == 0) {
        return false;
    }
    c = b * b - 4 * a * c;
    if(c < 0) {
        return false;
    }
    c = (-b - sqrt(c)) / (2 * a);

    if(c > 0 && c < 1) {
        
        return true;
    }
    return false;
}
开发者ID:evangambit,项目名称:Soft-Rastering-Program,代码行数:21,代码来源:LightCollider.cpp


示例9: lsm303_write8

/***************************************************************************
 PRIVATE FUNCTIONS
 ***************************************************************************/
uint8_t lsm303_write8(byte address, byte reg, byte value)
{

  int ret;
  byte buf[1];
 
  buf[0] = value;
  ret = 0;
  ret = i2c_writeReg(address, reg, buf, 1);

  if(ret!=0)
    {
#ifdef DEBUG
      shift(0x7777);
      _delay_ms(1000);
#endif
      return 1;
    }

  return 0;
}
开发者ID:knopancakes,项目名称:bike-lightbox,代码行数:24,代码来源:lsm303dlhc.c


示例10: crosscorrelation_direct

cv::Mat crosscorrelation_direct(const cv::Mat& A, const cv::Mat& B)
{  //For testing pourposes only
  cv::Mat aPadded, bPadded;
  cv::copyMakeBorder(A, aPadded, 0, A.rows, 0, A.cols, cv::BORDER_CONSTANT, cv::Scalar(0.0, 0.0));
  cv::copyMakeBorder(B, bPadded, 0, B.rows, 0, B.cols, cv::BORDER_CONSTANT, cv::Scalar(0.0, 0.0));

  cv::Mat C = cv::Mat::zeros(aPadded.size(), aPadded.type());
  cv::Mat conjA = conjComplex(aPadded);
  for(int i=0; i < aPadded.cols; ++i)              // rows
  {
    for(int j=0; j < aPadded.rows; ++j)          // columns
    {
      cv::Mat shifted, prod;
      shift(conjA,shifted,aPadded.cols-i,aPadded.rows-j);
      cv::mulSpectrums(shifted,bPadded,prod, cv::DFT_COMPLEX_OUTPUT);
      cv::Scalar s = cv::sum(prod);
      C.at<std::complex<float> >(i,j) = std::complex<float>(s.val[0],s.val[1]);
    }
  }
  return C;
}
开发者ID:dguerra,项目名称:pdmaster,代码行数:21,代码来源:ToolBox.cpp


示例11: convolveDFT

void convolveDFT(const cv::Mat& imgOriginal, const cv::Mat& kernel, cv::Mat& out, const bool& corr, const bool& full)
{ //this method is also valid for complex image and kernel, set DFT_COMPLEX_OUTPUT then
  //convolution in fourier space, keep code for future use
  //CONVOLUTION_FULL: Return the full convolution, including border
  //to completeley emulate filter2D operation, image should be first double sized and then cut back to origianl size
  cv::Mat source, kernelPadded;
  const int marginSrcTop = corr ? std::ceil((kernel.rows-1)/2.0) : std::floor((kernel.rows-1)/2.0);
  const int marginSrcBottom = corr ? std::floor((kernel.rows-1)/2.0) : std::ceil((kernel.rows-1)/2.0);
  const int marginSrcLeft = corr ? std::ceil((kernel.cols-1)/2.0) : std::floor((kernel.cols-1)/2.0);
  const int marginSrcRight = corr ? std::floor((kernel.cols-1)/2.0) : std::ceil((kernel.cols-1)/2.0);
  cv::copyMakeBorder(imgOriginal, source, marginSrcTop, marginSrcBottom, marginSrcLeft, marginSrcRight, cv::BORDER_CONSTANT);

  const int marginKernelTop = std::ceil((source.rows-kernel.rows)/2.0);
  const int marginKernelBottom = std::floor((source.rows-kernel.rows)/2.0);
  const int marginKernelLeft = std::ceil((source.cols-kernel.cols)/2.0);
  const int marginKernelRight = std::floor((source.cols-kernel.cols)/2.0);
  cv::copyMakeBorder(kernel, kernelPadded, marginKernelTop, marginKernelBottom, marginKernelLeft, marginKernelRight, cv::BORDER_CONSTANT);

  //Divided by 2.0 instead of 2 to consider the result as double instead of as an int
  //The +1 in the shift changes slightly the finest plane in the wavelet,
  shift(kernelPadded, kernelPadded, std::ceil(kernelPadded.cols/2.0), std::ceil(kernelPadded.rows/2.0));

  cv::Mat kernelPadded_ft, input_ft, output_ft;
  cv::dft(kernelPadded, kernelPadded_ft, cv::DFT_COMPLEX_OUTPUT + cv::DFT_SCALE);
  cv::dft(source, input_ft, cv::DFT_COMPLEX_OUTPUT + cv::DFT_SCALE);
  cv::mulSpectrums(input_ft, kernelPadded_ft.mul(kernelPadded.total()), output_ft, cv::DFT_COMPLEX_OUTPUT, corr);
  
  if(imgOriginal.channels() == 1 && kernel.channels() == 1) cv::idft(output_ft, out, cv::DFT_REAL_OUTPUT);
  else cv::idft(output_ft, out, cv::DFT_COMPLEX_OUTPUT);
  
  if(!full)
  {
    //colRange and rowRange are semi-open intervals. first included, last is not
    //this frist option is what i think should be the correct one, but the next is what filter2D function gives for this inputs
//    out = out.colRange(marginSrcLeft, out.cols - marginSrcRight).
//              rowRange(marginSrcTop, out.rows - marginSrcBottom);
        out = out.colRange(marginSrcRight, out.cols - marginSrcLeft).
                  rowRange(marginSrcBottom, out.rows - marginSrcTop);
  }
}
开发者ID:dguerra,项目名称:pdmaster,代码行数:40,代码来源:ToolBox.cpp


示例12: shift

//---------------------------------------------------------------------------------------
void TableCellSizer::reposition_cells()
{
    //AWARE: row 0 is correctly positioned, so we start moving from row 1.
    //In horizontal cells are correctly positioned, so shift is only in vertical.

    int iH = m_iFirstRow * m_numColumns;
    USize shift(0.0f, 0.0f);
    for (int iRow=1; iRow < m_numRows; ++iRow)
    {
        shift.height += m_heights[iH];
        int iCell = (m_iFirstRow + iRow) * m_numColumns;
        for (int iCol=0; iCol < m_numColumns; ++iCol, ++iCell)
        {
            if (m_cellLayouters[iCell] != nullptr)
            {
                GmoBox* pCellBox = m_cellLayouters[iCell]->get_item_main_box();
                pCellBox->shift_origin(shift);
            }
        }
        iH += m_numColumns;
    }
}
开发者ID:kolewu,项目名称:lomse,代码行数:23,代码来源:lomse_table_layouter.cpp


示例13: turn

void turn() //обработка ходов
{
	int direction = 0;
	bool moved;
	while (true)
	{
		direction = controls();
		moved = shift(direction);
		int number = cells_check();
		if (!move_check() && !number)
		{
			lose();
			return;
		}
		if (moved)
		{
			add_2(number);
			printfield();
			Sleep(50);
		}
	}
}
开发者ID:shaeredal,项目名称:2048console,代码行数:22,代码来源:Logic.cpp


示例14: maybe_autolink

/* autolinking means that all inline html is <a href'ified>.   A
 * autolink url is alphanumerics, slashes, periods, underscores,
 * the at sign, colon, and the % character.
 */
static int
maybe_autolink(MMIOT *f)
{
    register int c;
    int size;

    /* greedily scan forward for the end of a legitimate link.
     */
    for ( size=0; (c=peek(f, size+1)) != EOF; size++ )
	if ( c == '\\' ) {
	     if ( peek(f, size+2) != EOF )
		++size;
	}
	else if ( isspace(c) || strchr("'\"()[]{}<>`", c) )
	    break;

    if ( (size > 1) && process_possible_link(f, size) ) {
	shift(f, size);
	return 1;
    }
    return 0;
}
开发者ID:gensym,项目名称:markdownlive,代码行数:26,代码来源:generate.c


示例15: WHERE

vector<Shift> ShiftRepo::getWeeklyShifts(string start_date, string end_date, int type_selected)
{
    db.open();

    stringstream sqlQuery;

    sqlQuery << "SELECT * FROM Shifts WHERE (date BETWEEN '" << start_date << "'";
    sqlQuery << " AND '" << end_date << "') AND (shiftID BETWEEN 1 AND 13) AND type = " << type_selected;
    sqlQuery << " ORDER BY date ASC";

    QSqlQuery query(db);

    bool success = query.exec(QString::fromStdString(sqlQuery.str()));
    qDebug() << query.lastQuery();
    if(!success)
    {
        qDebug() << "Error in getting weekly shifts";
        qDebug() << query.lastError().text();
    }

    vector<Shift> shifts;

    while(query.next())
    {
        QString raw_date = query.value("date").toString();
        QDate date = stringToDate(raw_date);
        int id = query.value("shiftID").toInt();
        bool type = query.value("type").toBool();
        QString name = query.value("name").toString();
        double hours = query.value("hours").toDouble();
        double wages = query.value("wages").toDouble();

        Shift shift(date, id, type, name, hours, wages);
        shifts.push_back(shift);
    }

    return shifts;
}
开发者ID:gummigun,项目名称:Shifty,代码行数:38,代码来源:shiftrepo.cpp


示例16: _bucketsort_q

inline _queue_t _bucketsort_q(_queue_t src, size_t depth,
			      keyaccessor_t key, indexer_t idx,
			      comparator_t cmp)
{
    list_t head = src.head;
    if (!head)
	return src;
    if (!key)
	key = identity;
    if (!idx)
	idx = charAt;
    if (!cmp)
	cmp = stringcmp;
    if (depth > BUCKETSORT_DEPTH) {
	src.head = mergesort_l(head, cmp);
	for (src.tail = src.head; src.tail->cdr; src.tail = src.tail->cdr);
	return src;
    }
    _queue_t buckets[BUCKETSIZ];
    size_t i;
    for (i = 0; i < BUCKETSIZ; i++)
	buckets[i].head = NULL;
    while (head) {
	list_t l = shift(&head);
	int c = idx(key(l->car), depth);
	enqueue(&buckets[c], l, NULL);
    }
    _queue_t dst = { NULL, NULL };
    for (i = 0; i < BUCKETSIZ; i++) {
	_queue_t b = buckets[i];
	if (b.head) {
	    if (!allthesame(b, cmp))
		b = _bucketsort_q(b, depth + 1, key, idx, cmp);
	    enqueue(&dst, b.head, b.tail);
	}
    }
    return dst;
};
开发者ID:dankogai,项目名称:c-bucketsort,代码行数:38,代码来源:bucketsort.c


示例17: main

int main()
{
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		char a[1000],b[1000];
		int k;
		scanf("%s %d",a,&k);
		int len=strlen(a);
		int j,h=0;
		for(j=0;j<len;j++)
		{
			if(a[j]!='a'&&a[j]!='e'&&a[j]!='i'&&a[j]!='o'&&a[j]!='u')
			{
				b[h]=a[j];
				h++;
			}
		}	
		for(j=0;j<k;j++)
		{
			shift(b,len);
			printf("%s heel\n",b);
		}
		printf("hello\n");
		int x=0;
		for(j=0;j<len;j++)
		{
			if(a[j]!='a'&&a[j]!='e'&&a[j]!='i'&&a[j]!='o'&&a[j]!='u')
			{
				a[j]=b[x];
				x++;
			}
		}
	//	printf("%s\n",a);
	}
	return 0;
}
开发者ID:RitikaTanwani,项目名称:College_Documents,代码行数:38,代码来源:5p1.c


示例18: maybe_tag_or_link

/* a < may be just a regular character, the start of an embedded html
 * tag, or the start of an <automatic link>.    If it's an automatic
 * link, we also need to know if it's an email address because if it
 * is we need to mangle it in our futile attempt to cut down on the
 * spaminess of the rendered page.
 */
static int
maybe_tag_or_link(MMIOT *f)
{
    int c, size;
    int maybetag = 1;

    if ( f->flags & INSIDE_TAG )
	return 0;

    for ( size=0; (c = peek(f, size+1)) != '>'; size++) {
	if ( c == EOF )
	    return 0;
	else if ( c == '\\' ) {
	    maybetag=0;
	    if ( peek(f, size+2) != EOF )
		size++;
	}
	else if ( isspace(c) )
	    break;
	else if ( ! (c == '/' || isalnum(c) ) )
	    maybetag=0;
    }

    if ( size ) {
	if ( maybetag || (size >= 3 && strncmp(cursor(f), "!--", 3) == 0) ) {
	    Qstring(forbidden_tag(f) ? "&lt;" : "<", f);
	    while ( ((c = peek(f, 1)) != EOF) && (c != '>') )
		cputc(pull(f), f);
	    return 1;
	}
	else if ( !isspace(c) && process_possible_link(f, size) ) {
	    shift(f, size+1);
	    return 1;
	}
    }
    
    return 0;
}
开发者ID:gensym,项目名称:markdownlive,代码行数:44,代码来源:generate.c


示例19: send_all

int send_all(Buffer &b) {
   int len = send(conn, (const char*)b.get_buf(), b.size(), 0);
   if (len == SOCKET_ERROR) {
      int error = WSAGetLastError();
      if (error == WSAEWOULDBLOCK) {
         sendBuf << b;
         return 0;
      }
      else {
         cleanup();
         killWindow();
         msg(PLUGIN_NAME": Failed to send requested data. %d != %d. Error: %x, %d\n", len, b.size(), error, error);
         return -1;
      }
   }
   else if (len != b.size()) {
      //move the remainder into sendBuf
      shift(b, len);
      sendBuf << b;
      //msg(PLUGIN_NAME": Short send. %d != %d.", len, out.size());
   }
   return len;
}
开发者ID:FlankerZ,项目名称:collabREate,代码行数:23,代码来源:idanet.cpp


示例20: get_translational_alignment_no_preprocessing

ResultAlign2D get_translational_alignment_no_preprocessing(const cv::Mat &M1,
                                                           const cv::Mat &M2) {
  IMP_LOG_TERSE("starting 2D translational alignment with no preprocessing"
                << std::endl);
  IMP_USAGE_CHECK(((M1.rows == M2.rows) && (M1.cols == M2.cols)),
                  "get_translational_alignment_no_preprocessing: "
                  "Matrices have different size.");

  cv::Mat corr;
  corr.create(M1.rows, M1.cols, CV_64FC1);
  get_correlation2d_no_preprocessing(M1, M2, corr);  // corr must be allocated!
  // Find the peak of the cross_correlation
  double max_cc;
  algebra::Vector2D peak = internal::get_peak(corr, &max_cc);

  // Convert the pixel with the maximum to a shift respect to the center
  algebra::Vector2D shift(peak[0] - static_cast<double>(corr.cols) / 2.,
                          peak[1] - static_cast<double>(corr.rows) / 2.);
  algebra::Transformation2D t(shift);
  IMP_LOG_VERBOSE(" Translational Transformation = "
                  << t << " cross_correlation = " << max_cc << std::endl);
  return ResultAlign2D(t, max_cc);
}
开发者ID:salilab,项目名称:imp,代码行数:23,代码来源:align2D.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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