当前位置: 首页>>代码示例>>C++>>正文


C++ conv函数代码示例

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


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

示例1: vhd_print_bitmap_extents

static int
vhd_print_bitmap_extents(vhd_context_t *vhd, uint64_t sector, int count,
			 int hex)
{
	char *buf;
	uint64_t cur;
	int i, err, bit;
	uint32_t blk, bm_blk, sec;
	int64_t s, r;

	if (vhd_sectors_to_bytes(sector + count) > vhd->footer.curr_size) {
		printf("sector %s past end of file\n", conv(hex, sector));
		return -ERANGE;
	}

	bm_blk = -1;
	buf    = NULL;
	s = -1;
	r = 0;

	for (i = 0; i < count; i++) {
		cur = sector + i;
		blk = cur / vhd->spb;
		sec = cur % vhd->spb;

		if (blk != bm_blk) {
			bm_blk = blk;
			free(buf);
			buf = NULL;

			if (vhd->bat.bat[blk] != DD_BLK_UNUSED) {
				err = vhd_read_bitmap(vhd, blk, &buf);
				if (err)
					goto out;
			}
		}

		if (vhd->bat.bat[blk] == DD_BLK_UNUSED)
			bit = 0;
		else
			bit = vhd_bitmap_test(vhd, buf, sec);

		if (bit) {
			if (r == 0)
				s = cur;
			r++;
		} else {
			if (r > 0) {
				printf("%s ", conv(hex, s));
				printf("%s\n", conv(hex, r));
			}
			r = 0;
		}
	}
	if (r > 0) {
		printf("%s ", conv(hex, s));
		printf("%s\n", conv(hex, r));
	}

	err = 0;
 out:
	free(buf);
	return err;
}
开发者ID:borland667,项目名称:blktap,代码行数:64,代码来源:vhd-util-read.c

示例2: get_key_info

void CCellView::HandleDrop(BMessage *inMessage)
{
	long l;
	void * p;
	BPoint dp = inMessage->DropPoint();
	
	fDragIsAcceptable = false;
	
	if (inMessage->FindPointer("container", &p) == B_NO_ERROR)
	{
		key_info ki;
		get_key_info(&ki);
		
		CContainer *srcContainer;
		range srcRange, dstRange;
		CCellView *srcView;
		int action;
		
		srcContainer = (CContainer *)p;
		FailOSErr(inMessage->FindData("range", 'rang', (const void**)&p, &l), errMessageMissing);
		srcRange = *(range *)p;
		FailOSErr(inMessage->FindPointer("cellview", &p), errMessageMissing);
		srcView = (CCellView *)p;
		
		if (srcView != this)
			action = dragCopy;
		else
			action = dragMove;
		
		inMessage->FindBool("dragacopy", &fDragACopy);
		
		if (srcView == this &&
		    (ki.modifiers & B_CONTROL_KEY ||
			fDragACopy))
		{
			BPopUpMenu popup("dragpopup", false);
			popup.SetFont(be_plain_font);
			popup.AddItem(new BMenuItem(GetMessage(msgLinkHere), NULL));
			popup.AddItem(new BMenuItem(GetMessage(msgMoveHere), NULL));
			popup.AddItem(new BMenuItem(GetMessage(msgCopyHere), NULL));
			popup.AddSeparatorItem();
			popup.AddItem(new BMenuItem(GetMessage(msgCancel), NULL));
			
			BMenuItem *item = popup.Go(dp, false, true);
			int result = item ? popup.IndexOf(item) : -1;
			switch (result)
			{
				case 0: action = dragLink; break;
				case 1: action = dragMove; break;
				case 2: action = dragCopy; break;
				default:
					ClearAnts();
					fCurCell = fSelection.TopLeft();
					return;
			}
		}
	
		dstRange = srcRange;
		dstRange.OffsetBy(fCurCell.h - dstRange.left,
			fCurCell.v - dstRange.top);
		
		((CCellWindow *)Window())->
			RegisterCommand(new CDragCommand(this, srcContainer,
				fContainer, &srcRange, &dstRange, action));
	}
	else if (inMessage->FindData("text/plain", B_MIME_DATA, (const void **)&p, &l) == B_NO_ERROR)
	{
		cell dc;
		
		ConvertFromScreen(&dp);
		GetCellHitBy(dp, dc);
		
		BMemoryIO buf(p, l);
		CContainer *srcContainer = new CContainer;
		range srcRange, dstRange;
		
		CTextConverter conv(buf, srcContainer);
		conv.ConvertFromText(srcRange);
		
		dstRange = srcRange;
		dstRange.OffsetBy(dc.h - srcRange.left, dc.v - srcRange.top);
		
		((CCellWindow *)Window())->
			RegisterCommand(new CDragCommand(this, srcContainer,
				fContainer, &srcRange, &dstRange, dragMove));

		srcContainer->Release();
	}
	else
	{
		beep();
		ClearAnts();
		fCurCell = fSelection.TopLeft();
	}
} /* CCellView::HandleDrop */
开发者ID:ModeenF,项目名称:OpenSumIt,代码行数:95,代码来源:CellView.drag.cpp

示例3: conv

		void SofaHAPIHapticsDevice::onBeginAnimationStep(const double /*dt*/)
		{
			if (!device.get()) return;
			sofa::helper::AdvancedTimer::stepBegin("SofaHAPIHapticsDevice");

			sofa::helper::AdvancedTimer::stepBegin("DeviceValues");
			HAPI::HAPIHapticsDevice::DeviceValues dv = device->getDeviceValues();
			sofa::helper::AdvancedTimer::stepEnd("DeviceValues");

			sofa::helper::AdvancedTimer::stepBegin("XForm");
			/// COMPUTATION OF THE virtualTool 6D POSITION IN THE World COORDINATES
			Vec3d pos = conv(dv.position);
			Quat quat = conv(dv.orientation);
			Transform baseDevice_H_endDevice(pos*data.scale, quat);
			Transform world_H_virtualTool = data.world_H_baseDevice * baseDevice_H_endDevice * data.endDevice_H_virtualTool;
			lastToolPosition = world_H_virtualTool;
			/*
				Transform baseDevice_H_endDevice2 = data.world_H_baseDevice.inversed() * world_H_virtualTool * data.endDevice_H_virtualTool.inversed();
				sout << "bHe = " << baseDevice_H_endDevice << sendl;
				sout << "wHb = " << data.world_H_baseDevice << sendl;
				sout << "dHt = " << data.endDevice_H_virtualTool << sendl;
				sout << "wHv = " << world_H_virtualTool << sendl;
				sout << "bHe2 = " << baseDevice_H_endDevice2 << sendl;
				sout << sendl;
			*/
			sofa::helper::AdvancedTimer::stepEnd("XForm");


			sofa::helper::AdvancedTimer::stepBegin("Button");

			int buttonState = fakeButtonState | device->getButtonStatus();

			int buttonChanged = buttonState ^ lastButtonState;
			// special case: btn2 is mapped to tool selection if "toolSelector" is used
			if (toolSelector.getValue() && (buttonChanged & HapticDeviceEvent::Button2StateMask))
			{
				if ((buttonState & HapticDeviceEvent::Button2StateMask) != 0)
				{
					// start tool switch : disable feedback on previous instrument
					int currentToolIndex = toolIndex.getValue();
					int newToolIndex = ((currentToolIndex+1)%toolCount.getValue());
					toolIndex.setValue(newToolIndex);
					if (toolTransitionSpringStiffness.getValue() != 0.0 && mState)
					{
						sout << "Enabling tool transition spring" << sendl;

						sofa::helper::ReadAccessor<Data<sofa::helper::vector<sofa::defaulttype::RigidCoord<3,double> > > > x = *this->mState->read(sofa::core::VecCoordId::position());
						Transform world_H_virtualTool(x[newToolIndex].getCenter(), x[newToolIndex].getOrientation());
						Transform baseDevice_H_endDevice2 = data.world_H_baseDevice.inversed() * world_H_virtualTool * data.endDevice_H_virtualTool.inversed();
						transitionEffect.reset(
							new HAPI::HapticSpring( conv(baseDevice_H_endDevice2.getOrigin()*(1/data.scale)),
									toolTransitionSpringStiffness.getValue()));
						device->addEffect(transitionEffect.get(), 1.0);
					}
					setToolFeedback(currentToolIndex, false);
					isToolControlled = false; // we disable update of the tool position and feedback until the button is released
				}
				else
				{
					if (transitionEffect.get())
					{
						sout << "Disabling tool transition spring" << sendl;
						device->removeEffect(transitionEffect.get());
						transitionEffect.reset();
					}
					setToolFeedback(toolIndex.getValue(), true);
					isToolControlled = true;
				}
			}
			sofa::helper::AdvancedTimer::stepNext("Button", "Event");

			if (buttonState != lastButtonState)
			{
				lastButtonState = buttonState;
				sendHapticDeviceEvent();
			}
			sofa::helper::AdvancedTimer::stepEnd("Event");

			if (isToolControlled) // ignore haptic device if tool is unselected
			{
				const int currentToolIndex = toolIndex.getValue();
				sofa::helper::AdvancedTimer::stepBegin("FFB");
				// store actual position of interface for the forcefeedback (as it will be used as soon as new LCP will be computed)
				for (unsigned int i=0; i < feedbackEffects.size(); ++i)
				{
					SofaHAPIForceFeedbackEffect::SPtr ffe = feedbackEffects[i];
					if (ffe->getIndice() != currentToolIndex) continue;
					if (ffe->getForceFeedback())
						ffe->getForceFeedback()->setReferencePosition(world_H_virtualTool);
				}
				sofa::helper::AdvancedTimer::stepEnd("FFB");
				if (mState)
				{
					sofa::helper::AdvancedTimer::stepBegin("SetState");
					/// TODO : SHOULD INCLUDE VELOCITY !!

					sofa::helper::WriteAccessor<Data<sofa::helper::vector<sofa::defaulttype::RigidCoord<3,double> > > > x = *this->mState->write(sofa::core::VecCoordId::position());
					sofa::helper::WriteAccessor<Data<sofa::helper::vector<sofa::defaulttype::RigidCoord<3,double> > > > xfree = *this->mState->write(sofa::core::VecCoordId::freePosition());

					xfree[currentToolIndex].getCenter() = world_H_virtualTool.getOrigin();
//.........这里部分代码省略.........
开发者ID:david-cazier,项目名称:sofa,代码行数:101,代码来源:SofaHAPIHapticsDevice.cpp

示例4: conv

void conv(ZZ& a,bkzfloat& b) {
    conv(a,to_stdstring(b).c_str());
}
开发者ID:tell,项目名称:pbkz,代码行数:3,代码来源:misc.cpp

示例5: main

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    int res = 0;
    QString appIni;
    QMap<QString, QString> args = convertArgs(QCoreApplication::arguments());

    if (!args.value("-f").isEmpty()) {
        appIni = args.value("-f");
        devIni = QFileInfo(appIni).dir().path() + QDir::separator() + "development.ini";
    } else {
        QString dir = QLatin1String("..") + QDir::separator() + QLatin1String("..") + QDir::separator() + "config" +  QDir::separator();
        appIni = dir + "application.ini";
        devIni = dir + "development.ini";
    }

    if (!QFile::exists(appIni)) {
        usage();
        return 1;
    }

    QSettings appSetting(appIni, QSettings::IniFormat);
    QSettings devSetting(devIni, QSettings::IniFormat);

    // Default codec
    QTextCodec *codec = QTextCodec::codecForName("UTF-8");
    QString codecName = appSetting.value("InternalEncoding").toString();
    if (!codecName.isEmpty()) {
        QTextCodec *c = QTextCodec::codecForName(codecName.toLatin1().constData());
        if (c) {
            codec = c;
        }
    }
    QTextCodec::setCodecForLocale(codec);

    defaultTrimMode = devSetting.value("Erb.DefaultTrimMode", "1").toInt();
    printf("Erb.DefaultTrimMode: %d\n", defaultTrimMode);

    QDir viewDir(".");
    if (!args.value("-v").isEmpty()) {
        viewDir.setPath(args.value("-v"));
    }
    if (!viewDir.exists()) {
        usage();
        return 1;
    }

    QDir outputDir(DEFAULT_OUTPUT_DIR);
    if (!args.value("-d").isEmpty()) {
        outputDir.setPath(args.value("-d"));
    }

    if (outputDir.exists()) {
        if (outputDir.path() != ".") {
            printf("  exists   %s\n", qPrintable(outputDir.path()));
        }
    } else {
        if (outputDir.mkpath(".")) {
            printf("  created  %s\n", qPrintable(outputDir.path()));
        } else {
            usage();
            return 1;
        }
    }

    bool createProFile = (args.contains("-p") || !args.contains("-P"));
    ViewConverter conv(viewDir, outputDir, createProFile);
    QString templateSystem = devSetting.value("TemplateSystem").toString();
    if (templateSystem.isEmpty()) {
        templateSystem = appSetting.value("TemplateSystem", "Erb").toString();
    }

    res = conv.convertView(templateSystem);
    return res;
}  
开发者ID:CasyWang,项目名称:treefrog-framework,代码行数:75,代码来源:main.cpp

示例6: rgbToRgbWrapper

/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
static int rgbToRgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
                           int srcSliceH, uint8_t* dst[], int dstStride[])
{
    const enum PixelFormat srcFormat= c->srcFormat;
    const enum PixelFormat dstFormat= c->dstFormat;
    const int srcBpp= (c->srcFormatBpp + 7) >> 3;
    const int dstBpp= (c->dstFormatBpp + 7) >> 3;
    const int srcId= c->srcFormatBpp >> 2; /* 1:0, 4:1, 8:2, 15:3, 16:4, 24:6, 32:8 */
    const int dstId= c->dstFormatBpp >> 2;
    void (*conv)(const uint8_t *src, uint8_t *dst, int src_size)=NULL;

#define CONV_IS(src, dst) (srcFormat == PIX_FMT_##src && dstFormat == PIX_FMT_##dst)

    if (isRGBA32(srcFormat) && isRGBA32(dstFormat)) {
        if (     CONV_IS(ABGR, RGBA)
              || CONV_IS(ARGB, BGRA)
              || CONV_IS(BGRA, ARGB)
              || CONV_IS(RGBA, ABGR)) conv = shuffle_bytes_3210;
        else if (CONV_IS(ABGR, ARGB)
              || CONV_IS(ARGB, ABGR)) conv = shuffle_bytes_0321;
        else if (CONV_IS(ABGR, BGRA)
              || CONV_IS(ARGB, RGBA)) conv = shuffle_bytes_1230;
        else if (CONV_IS(BGRA, RGBA)
              || CONV_IS(RGBA, BGRA)) conv = shuffle_bytes_2103;
        else if (CONV_IS(BGRA, ABGR)
              || CONV_IS(RGBA, ARGB)) conv = shuffle_bytes_3012;
    } else
    /* BGR -> BGR */
    if (  (isBGRinInt(srcFormat) && isBGRinInt(dstFormat))
       || (isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
        switch(srcId | (dstId<<4)) {
        case 0x34: conv= rgb16to15; break;
        case 0x36: conv= rgb24to15; break;
        case 0x38: conv= rgb32to15; break;
        case 0x43: conv= rgb15to16; break;
        case 0x46: conv= rgb24to16; break;
        case 0x48: conv= rgb32to16; break;
        case 0x63: conv= rgb15to24; break;
        case 0x64: conv= rgb16to24; break;
        case 0x68: conv= rgb32to24; break;
        case 0x83: conv= rgb15to32; break;
        case 0x84: conv= rgb16to32; break;
        case 0x86: conv= rgb24to32; break;
        }
    } else if (  (isBGRinInt(srcFormat) && isRGBinInt(dstFormat))
             || (isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
        switch(srcId | (dstId<<4)) {
        case 0x33: conv= rgb15tobgr15; break;
        case 0x34: conv= rgb16tobgr15; break;
        case 0x36: conv= rgb24tobgr15; break;
        case 0x38: conv= rgb32tobgr15; break;
        case 0x43: conv= rgb15tobgr16; break;
        case 0x44: conv= rgb16tobgr16; break;
        case 0x46: conv= rgb24tobgr16; break;
        case 0x48: conv= rgb32tobgr16; break;
        case 0x63: conv= rgb15tobgr24; break;
        case 0x64: conv= rgb16tobgr24; break;
        case 0x66: conv= rgb24tobgr24; break;
        case 0x68: conv= rgb32tobgr24; break;
        case 0x83: conv= rgb15tobgr32; break;
        case 0x84: conv= rgb16tobgr32; break;
        case 0x86: conv= rgb24tobgr32; break;
        }
    }

    if (!conv) {
        av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
               av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
    } else {
        const uint8_t *srcPtr= src[0];
              uint8_t *dstPtr= dst[0];
        if ((srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1) && !isRGBA32(dstFormat))
            srcPtr += ALT32_CORR;

        if ((dstFormat == PIX_FMT_RGB32_1 || dstFormat == PIX_FMT_BGR32_1) && !isRGBA32(srcFormat))
            dstPtr += ALT32_CORR;

        if (dstStride[0]*srcBpp == srcStride[0]*dstBpp && srcStride[0] > 0 && !(srcStride[0] % srcBpp))
            conv(srcPtr, dstPtr + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]);
        else {
            int i;
            dstPtr += dstStride[0]*srcSliceY;

            for (i=0; i<srcSliceH; i++) {
                conv(srcPtr, dstPtr, c->srcW*srcBpp);
                srcPtr+= srcStride[0];
                dstPtr+= dstStride[0];
            }
        }
    }
    return srcSliceH;
}
开发者ID:Tjoppen,项目名称:FFmpeg,代码行数:93,代码来源:swscale_unscaled.c

示例7: ProcessVerify

void ProcessVerify(HWND hWnd,CMyList *m_list,int Type)
{
	CString PidNum;
	CString FilePath;
	DWORD dwReadByte;

	POSITION pos = m_list->GetFirstSelectedItemPosition(); //判断列表框中是否有选择项
	int Item = m_list->GetNextSelectedItem(pos); //将列表中被选择的下一项索引值保存到数组中

	FilePath.Format(L"%s",m_list->GetItemText(Item,3));

	WCHAR lpwzNum[50];
	WCHAR lpwzFilePath[260];
	WCHAR lpwzTrue[260];
	CHAR lpszFilePath[5024];

	memset(lpwzNum,0,sizeof(lpwzNum));
	memset(lpszFilePath,0,sizeof(lpszFilePath));
	memset(lpwzFilePath,0,sizeof(lpwzFilePath));

	wcscat(lpwzFilePath,FilePath);
	if (!wcslen(lpwzFilePath))
	{
		return;
	}
	if (GetFileAttributes(lpwzFilePath) == INVALID_FILE_ATTRIBUTES)
	{
		MessageBoxW(hWnd,L"文件无法访问!",L"A盾电脑防护",0);
		return;
	}
	//1为验证数字签名
	if (Type == 1){
		if (VerifyEmbeddedSignature(lpwzFilePath)){
			AfxMessageBox(L"通过数字签名验证");
		}else
			AfxMessageBox(L"没有通过数字签名验证");
		return;
	}
	WideCharToMultiByte (CP_OEMCP,NULL,lpwzFilePath,-1,lpszFilePath,wcslen(lpwzFilePath)*2,NULL,FALSE);

	FILE * fp=fopen(lpszFilePath,"rb");
	if(fp)
	{
		MD5VAL val;
		val = md5File(fp);
		wsprintfW(lpwzNum,L"%08x%08x%08x%08x",conv(val.a),conv(val.b),conv(val.c),conv(val.d));
		fclose(fp);
	}
	FileVerify(lpszFilePath,lpwzNum,lpwzTrue);

	WCHAR lpwzMessageBox[256] = {0};
	WCHAR lpszSuccess[256];

	memset(lpszSuccess,0,sizeof(lpszSuccess));
	memset(lpwzMessageBox,0,sizeof(lpwzMessageBox));

	if (_wcsnicmp(lpwzTrue,L"不支持当前系统",wcslen(L"不支持当前系统")) == 0)
	{
		wsprintfW(lpwzMessageBox,L"%s\r\n\r\n是否允许\"A盾电脑防护\"收集您的计算机版本以便作为后续版本更新?",L"不支持当前系统");
		if (MessageBoxW(hWnd,lpwzMessageBox,L"A盾电脑防护",MB_YESNO | MB_ICONWARNING) == IDYES)
		{
			//开始收集系统信息
		}
	}
	else if (_wcsnicmp(lpwzTrue,L"MD5(√)/签名(-)",wcslen(L"MD5(√)/签名(-)")) == 0)
	{
		wsprintfW(lpszSuccess,L"文件:%ws\r\nMD5值:%ws\r\n\r\n已经通过验证,属于系统原生文件!\r\n",lpwzFilePath,lpwzNum);
		AfxMessageBox(lpszSuccess);
	}
	else
	{
		wsprintfW(lpszSuccess,L"文件:%ws\r\nMD5值:%ws\r\n\r\n%ws!\r\n",lpwzFilePath,lpwzNum,lpwzTrue);
		AfxMessageBox(lpszSuccess);
	}
}
开发者ID:AmesianX,项目名称:A-Protect,代码行数:75,代码来源:Process.cpp

示例8: determinant

void determinant(GF2E& d, const mat_GF2E& M_in)
{
   long k, n;
   long i, j;
   long pos;
   GF2X t1, t2;
   GF2X *x, *y;

   const GF2XModulus& p = GF2E::modulus();

   n = M_in.NumRows();

   if (M_in.NumCols() != n)
      LogicError("determinant: nonsquare matrix");

   if (n == 0) {
      set(d);
      return;
   }

   vec_GF2XVec M;

   M.SetLength(n);
   for (i = 0; i < n; i++) {
      M[i].SetSize(n, 2*GF2E::WordLength());
      for (j = 0; j < n; j++)
         M[i][j] = rep(M_in[i][j]);
   }

   GF2X det;
   set(det);

   for (k = 0; k < n; k++) {
      pos = -1;
      for (i = k; i < n; i++) {
         rem(t1, M[i][k], p);
         M[i][k] = t1;
         if (pos == -1 && !IsZero(t1))
            pos = i;
      }

      if (pos != -1) {
         if (k != pos) {
            swap(M[pos], M[k]);
         }

         MulMod(det, det, M[k][k], p);

         // make M[k, k] == -1 mod p, and make row k reduced

         InvMod(t1, M[k][k], p);
         for (j = k+1; j < n; j++) {
            rem(t2, M[k][j], p);
            MulMod(M[k][j], t2, t1, p);
         }

         for (i = k+1; i < n; i++) {
            // M[i] = M[i] + M[k]*M[i,k]

            t1 = M[i][k];   // this is already reduced

            x = M[i].elts() + (k+1);
            y = M[k].elts() + (k+1);

            for (j = k+1; j < n; j++, x++, y++) {
               // *x = *x + (*y)*t1

               mul(t2, *y, t1);
               add(*x, *x, t2);
            }
         }
      }
      else {
         clear(d);
         return;
      }
   }

   conv(d, det);
}
开发者ID:95krasovsky,项目名称:SecretSharingSchemes,代码行数:80,代码来源:mat_GF2E.c

示例9: solve_impl

static
void solve_impl(GF2E& d, vec_GF2E& X, const mat_GF2E& A, const vec_GF2E& b, bool trans)

{
   long n = A.NumRows();
   if (A.NumCols() != n)
      LogicError("solve: nonsquare matrix");

   if (b.length() != n)
      LogicError("solve: dimension mismatch");

   if (n == 0) {
      set(d);
      X.SetLength(0);
      return;
   }

   long i, j, k, pos;
   GF2X t1, t2;
   GF2X *x, *y;

   const GF2XModulus& p = GF2E::modulus();

   vec_GF2XVec M;

   M.SetLength(n);

   for (i = 0; i < n; i++) {
      M[i].SetSize(n+1, 2*GF2E::WordLength());

      if (trans) 
         for (j = 0; j < n; j++) M[i][j] = rep(A[j][i]);
      else
         for (j = 0; j < n; j++) M[i][j] = rep(A[i][j]);

      M[i][n] = rep(b[i]);
   }

   GF2X det;
   set(det);

   for (k = 0; k < n; k++) {
      pos = -1;
      for (i = k; i < n; i++) {
         rem(t1, M[i][k], p);
         M[i][k] = t1;
         if (pos == -1 && !IsZero(t1)) {
            pos = i;
         }
      }

      if (pos != -1) {
         if (k != pos) {
            swap(M[pos], M[k]);
         }

         MulMod(det, det, M[k][k], p);

         // make M[k, k] == -1 mod p, and make row k reduced

         InvMod(t1, M[k][k], p);
         for (j = k+1; j <= n; j++) {
            rem(t2, M[k][j], p);
            MulMod(M[k][j], t2, t1, p);
         }

         for (i = k+1; i < n; i++) {
            // M[i] = M[i] + M[k]*M[i,k]

            t1 = M[i][k];   // this is already reduced

            x = M[i].elts() + (k+1);
            y = M[k].elts() + (k+1);

            for (j = k+1; j <= n; j++, x++, y++) {
               // *x = *x + (*y)*t1

               mul(t2, *y, t1);
               add(*x, *x, t2);
            }
         }
      }
      else {
         clear(d);
         return;
      }
   }

   X.SetLength(n);
   for (i = n-1; i >= 0; i--) {
      clear(t1);
      for (j = i+1; j < n; j++) {
         mul(t2, rep(X[j]), M[i][j]);
         add(t1, t1, t2);
      }
      add(t1, t1, M[i][n]);
      conv(X[i], t1);
   }

   conv(d, det);
//.........这里部分代码省略.........
开发者ID:95krasovsky,项目名称:SecretSharingSchemes,代码行数:101,代码来源:mat_GF2E.c

示例10: main

void main()
{

TRISC=0;
// Variables para controlador
int16 valor;     
float control;                //valor del PWM
float a1,b1,c1;                  //constantes del PID
float ref;            //temperatura a alcanzar
float rT,eT,iT,dT,yT,uT,iT0,eT0,iT_1,eT_1;     //variables de ecuaciones            
float max,min;               //límites máximo y mínimo de control.
float T ,Kp1, Ti1,Td1;  


setup_adc_ports(RA0_ANALOG);//entrada del LM35
setup_adc(ADC_CLOCK_INTERNAL);
setup_COUNTERS(RTCC_internal.rtcc_div_1);
set_adc_channel(0);

  setup_timer_2(t2_div_by_4,500,1);     //periodo de la señal PWM a 1ms
setup_ccp1(ccp_pwm);                  //Módulo CCP a modo PWM
setup_adc(ADC_CLOCK_INTERNAL);       //reloj convertidor AD interno
set_adc_channel(0);

setup_timer_0(rtcc_ext_l_to_h|RTCC_DIV_2);   //Configuración TMR0
setup_timer_1(T1_internal|T1_DIV_BY_8);     //Configuración TMR1

  float Temp;
  int c;
  char k;
  char Kp[6];
  char Ki[6];
  char Kd[6];
  char Sp[6];
  int v;
  
   port_b_pullups(true),
   lcd_init();
   kbd_init();
   
   
   inicio:
   
   for (v=0;v<=5;v++){
   Kp[v]=0; Ki[v]=0; Kd[v]=0; Sp[v]=0;
   }
   
   lcd_gotoxy(1,1);
   lcd_putc("\f");
   lcd_putc("Kp:");
   lcd_gotoxy(9,1);
   lcd_putc("Ki:");
   lcd_gotoxy(1,2);
   lcd_putc("Kd:");
   lcd_gotoxy(9,2);
   lcd_putc("Sp:");
   
   while(true){
      K_p:
      lcd_gotoxy(4,1);
      lcd_send_byte(0,0x0f);
      c=0;
      k=0;
      while(c<=4){
      
      k=kbd_getc();
      if(k!=0){
      
         
        
         if(k!='A' && k!='*' && k!='C'){
            
            if(k=='B'){
               printf(lcd_putc,".");
               Kp[c]=k;
               lcd_gotoxy(4+c,1);      
            }
            else
            printf(lcd_putc,"%c",k);
            Kp[c]=k;
            lcd_gotoxy(4+c,1);            
                
         }
         
         if(k=='A'){
               c++;
               Kp[c]=-92;                
               lcd_gotoxy(4+c,1);
                  
          }
               
          
      }
      if(k=='D'){
         int j=0;
         for(;;){
            Kp[j]=0;
            if(j==5) break;
            j++;
         }
//.........这里部分代码省略.........
开发者ID:aldajo92,项目名称:Procesadores,代码行数:101,代码来源:codigo.c

示例11: conv

		void Canvas::move(double x, double y){current = conv(x, y);}
开发者ID:zarath8128,项目名称:NumericalAnalysis,代码行数:1,代码来源:Canvas.cpp

示例12: string_to_double

//convert method from string to double
bool string_to_double(std::string & convert, double * result)
{
	std::istringstream conv(convert);
	return conv >> *result ? true : false ;
}
开发者ID:petrmiko,项目名称:Uni_PPR,代码行数:6,代码来源:Tools.cpp

示例13: rp

void *NavigatePlugin::processEvent(Event *e)
{
#ifdef WIN32
    if (e->type() == EventGetURL){
        string *url = (string*)(e->param());
        *url = getCurrentUrl();
        return e->param();
    }
#endif
    if (e->type() == EventGoURL){
        string url = (const char*)(e->param());
        string proto;
        if (url.length() == 0)
            return NULL;
        int n = url.find(':');
        /* in textshow.cpp file:// is deleted because it seems on some
           Qt-version it is appended and on some not - so if no : is found,
           append file:// */
        if (n < 0){
            proto = "file";
            url = proto + "://" + url;
        }else{
            proto = url.substr(0, n);
            if ((proto != "http") &&
                    (proto != "https") &&
                    (proto != "ftp") &&
                    (proto != "file") &&
                    (proto != "mailto"))
                return NULL;
        }
#ifdef WIN32
        bool bExec = false;
        if (getNewWindow()){
            string key_name = proto;
            key_name += "\\Shell\\Open";
            RegEntry rp(HKEY_CLASSES_ROOT, key_name.c_str());
            string prg    = rp.value("command");
            string action = rp.value("ddeexec");
            string topic  = rp.value("ddeexec\\Topic");
            string server = rp.value("ddeexec\\Application");
            if (!action.empty()){
                int pos = action.find("%1");
                if (pos >= 0)
                    action = action.substr(0, pos) + url + action.substr(pos + 2);
                pos = prg.find("%1");
                if (pos >= 0)
                    prg = prg.substr(0, pos) + url + prg.substr(pos + 2);
                if (!prg.empty()){
                    STARTUPINFOA si;
                    PROCESS_INFORMATION pi;
                    ZeroMemory(&si, sizeof(si));
                    si.cb = sizeof(si);
                    ZeroMemory(&pi, sizeof(pi));
                    if (CreateProcessA(NULL, (char*)prg.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)){
                        WaitForInputIdle(pi.hProcess, INFINITE);
                        CloseHandle(pi.hProcess);
                        CloseHandle(pi.hThread);
                    }
                }
                DDEbase b;
                DDEconversation conv(server.c_str(), topic.c_str());
                if (conv.Execute(action.c_str()))
                    bExec = true;
            }
        }
        if (!bExec){
            if (proto == "file")
                url = url.substr(5);
            ShellExecuteA(NULL, NULL, url.c_str(), NULL, NULL, SW_SHOWNORMAL);
        }
#else
#ifdef USE_KDE
        if (getUseKDE())
        {
            if (proto == "mailto")
                kapp->invokeMailer(url.substr(proto.length() + 1), QString::null);
            else
                kapp->invokeBrowser(url);
            return e->param();
        }
#endif // USE_KDE
        ExecParam execParam;
        if (proto == "mailto"){
            execParam.cmd = getMailer();
            url = url.substr(proto.length() + 1);
        }else{
            execParam.cmd = getBrowser();
	    QUrl qurl(url);
	    QString encodedUrl = qurl.toString(true, false);
	    url = encodedUrl.latin1();
        }
        execParam.arg = url.c_str();
        Event eExec(EventExec, &execParam);
        eExec.process();
#endif // WIN32
        return e->param();
    }
    if (e->type() == EventEncodeText){
        QString *text = (QString*)(e->param());
        *text = parseUrl(*text);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:sim-im-svn,代码行数:101,代码来源:navigate.cpp

示例14: vhd_print_footer

static void
vhd_print_footer(vhd_footer_t *f, int hex)
{
	uint64_t  c, h, s;
	uint32_t  ff_maj, ff_min, cr_maj, cr_min, cksm;
	char      time_str[26], creator[5], uuid[37], cookie[9];

	printf("VHD Footer Summary:\n-------------------\n");

	snprintf(cookie, 9, "%s", f->cookie);
	printf("Cookie              : %s\n", cookie);

	printf("Features            : (0x%08x) %s%s\n", f->features,
		(f->features & HD_TEMPORARY) ? "<TEMP>" : "",
		(f->features & HD_RESERVED)  ? "<RESV>" : "");

	ff_maj = f->ff_version >> 16;
	ff_min = f->ff_version & 0xffff;
	printf("File format version : Major: %d, Minor: %d\n", 
		ff_maj, ff_min);

	printf("Data offset         : %s\n", conv(hex, f->data_offset));

	vhd_time_to_string(f->timestamp, time_str);
	printf("Timestamp           : %s\n", time_str);

	memcpy(creator, f->crtr_app, 4);
	creator[4] = '\0';
	printf("Creator Application : '%s'\n", creator);

	cr_maj = f->crtr_ver >> 16;
	cr_min = f->crtr_ver & 0xffff;
	printf("Creator version     : Major: %d, Minor: %d\n",
		cr_maj, cr_min);

	printf("Creator OS          : %s\n",
		((f->crtr_os == HD_CR_OS_WINDOWS) ? "Windows" :
		 ((f->crtr_os == HD_CR_OS_MACINTOSH) ? "Macintosh" : 
		  "Unknown!")));

	printf("Original disk size  : %s MB ", conv(hex, f->orig_size >> 20));
	printf("(%s Bytes)\n", conv(hex, f->orig_size));

	printf("Current disk size   : %s MB ", conv(hex, f->curr_size >> 20));
	printf("(%s Bytes)\n", conv(hex, f->curr_size));

	c = f->geometry >> 16;
	h = (f->geometry & 0x0000FF00) >> 8;
	s = f->geometry & 0x000000FF;
	printf("Geometry            : Cyl: %s, ", conv(hex, c));
	printf("Hds: %s, ", conv(hex, h));
	printf("Sctrs: %s\n", conv(hex, s));
	printf("                    : = %s MB ", conv(hex, (c * h * s) >> 11));
	printf("(%s Bytes)\n", conv(hex, c * h * s << 9));

	printf("Disk type           : %s\n", 
	       f->type <= HD_TYPE_MAX ? 
	       hd_type_str[f->type] : "Unknown type!\n");

	cksm = vhd_checksum_footer(f);
	printf("Checksum            : 0x%x|0x%x (%s)\n", f->checksum, cksm,
		f->checksum == cksm ? "Good!" : "Bad!");

	uuid_unparse(f->uuid, uuid);
	printf("UUID                : %s\n", uuid);

	printf("Saved state         : %s\n", f->saved == 0 ? "No" : "Yes");
	printf("Hidden              : %d\n", f->hidden);
	printf("\n");
}
开发者ID:borland667,项目名称:blktap,代码行数:70,代码来源:vhd-util-read.c

示例15: str2int

int str2int(String str) {
    std::istringstream conv(str);
    int res;
    conv >> res;
    return res;
}
开发者ID:gentryx,项目名称:rockNroll,代码行数:6,代码来源:misc.cpp


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