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


C++ Ex函数代码示例

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


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

示例1: while

void Assem_x86::assemLine( const string &line ) {

    int i=0;
    string name;
    vector<string> ops;

    //label?
    if( !isspace( line[i] ) ) {
        while( !isspace( line[i] ) ) ++i;
        string lab=line.substr( 0,i );
        if( !mod->addSymbol( lab.c_str(),mod->getPC() ) ) throw Ex( "duplicate label" );
    }

    //skip space
    while( isspace( line[i] ) && line[i]!='\n' ) ++i;
    if( line[i]=='\n' || line[i]==';' ) return;

    //fetch instruction name
    int from=i;
    for( ++i; !isspace( line[i] ); ++i ) {}
    name=line.substr( from,i-from );

    for(;;) {

        //skip space
        while( isspace( line[i] ) && line[i]!='\n' ) ++i;
        if( line[i]=='\n' || line[i]==';' ) break;

        int from=i;
        if( line[i]=='\"' ) {
            for( ++i; line[i]!='\"' && line[i]!='\n'; ++i ) {}
            if( line[i++]!='\"' ) throw Ex( "missing close quote" );
        } else {
            for( ++i; line[i]!=',' && line[i]!=';' && line[i]!='\n'; ++i ) {}
        }

        //back-up over space
        while( i && isspace( line[i-1] ) ) --i;
        ops.push_back( line.substr( from,i-from ) );

        //skip space
        while( isspace( line[i] ) && line[i]!='\n' ) ++i;
        if( line[i]=='\n' || line[i]==';' ) break;

        if( line[i++]!=',' ) throw Ex( "expecting ','" );
    }

    //pseudo op?
    if( name[0]=='.' ) {
        for( int k=0; k<ops.size(); ++k ) assemDir( name,ops[k] );
        return;
    }

    //normal instruction!
    if( ops.size()>2 ) throw Ex( "Too many operands" );
    ops.push_back( "" );
    ops.push_back( "" );
    assemInst( name,ops[0],ops[1] );
}
开发者ID:RubAlonso,项目名称:blitzplus,代码行数:59,代码来源:assem_x86.cpp

示例2: switch

char* GFolderSerializer::nextPiece(size_t* pOutSize)
{
	switch(m_state)
	{
	case 0: // uncompressed header
		memcpy(m_pPos, "ugfs", 4);
		m_pPos += 4;
		m_size -= 4;
		m_state = 4;
		break;
	case 1: // figure out what to do next
		if(m_dirStack.size() > 0)
			continueDir();
		else
			return NULL;
		break;
	case 2: // continue reading file
		continueFile();
		break;
	case 3: // continue reading dir
		continueDir();
		break;
	case 4: // get started
		{
			// Change to the directory with the file or folder
			string sPath = m_szPath;
			if(sPath.length() > 0 && (sPath[sPath.length() - 1] == '/' || sPath[sPath.length() - 1] == '\\'))
				sPath.erase(sPath.length() - 1);
			PathData pd;
			GFile::parsePath(sPath.c_str(), &pd);
			if(pd.fileStart > 0)
			{
				string s;
				s.assign(m_szPath, pd.fileStart);
				if(chdir(s.c_str()) != 0)
					throw Ex("Failed to change dir to ", s.c_str());
			}

			// Add the file or folder
			if(access(m_szPath, 0) != 0)
				throw Ex("The file or folder ", m_szPath, " does not seem to exist");
			struct stat status;
			stat(m_szPath, &status);
			if(status.st_mode & S_IFDIR)
				startDir(m_szPath + pd.fileStart);
			else
				startFile(m_szPath + pd.fileStart);
		}
		break;
	default:
		throw Ex("Unexpected state");
	}
	*pOutSize = (m_pPos - m_pBuf);
	m_pPos = m_pBuf;
	m_size = BUF_SIZE;
	return m_pBuf;
}
开发者ID:mikegashler,项目名称:waffles,代码行数:57,代码来源:GDirList.cpp

示例3: GPNGWriter

	GPNGWriter()
	{
		m_pWriteStruct = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, error_handler, NULL);
		if(!m_pWriteStruct)
			throw Ex("Failed to create write struct. Out of mem?");
		m_pInfoStruct = png_create_info_struct(m_pWriteStruct);
		if(!m_pInfoStruct)
			throw Ex("Failed to create info struct. Out of mem?");
	}
开发者ID:admonkey,项目名称:snappybird,代码行数:9,代码来源:image.cpp

示例4: Ex

// virtual
void GNaiveBayes::trainInner(const GMatrix& features, const GMatrix& labels)
{
	if(!features.relation().areNominal())
		throw Ex("GNaiveBayes only supports nominal features. Perhaps you should wrap it in a GAutoFilter.");
	if(!labels.relation().areNominal())
		throw Ex("GNaiveBayes only supports nominal labels. Perhaps you should wrap it in a GAutoFilter.");
	beginIncrementalLearningInner(features.relation(), labels.relation());
	for(size_t n = 0; n < features.rows(); n++)
		trainIncremental(features[n], labels[n]);
}
开发者ID:BaskWind,项目名称:waffles,代码行数:11,代码来源:GNaiveBayes.cpp

示例5: Hz

void FDTD2D::updateH(){
  // Bulk update, Hz
  for( int ii=0; ii<Nx-1; ii++){
    for( int jj=0; jj<Ny-1; jj++){
      Hz(ii,jj) += HzC(ii,jj)*(Ex(ii,jj+1) - Ex(ii,jj)
                             - Ey(ii+1,jj) + Ey(ii,jj));
    }
  }
  // No need to account for boundary conditions here; they are included in the E update equations.
  return;
}
开发者ID:LiamPattinson,项目名称:MiniProject1,代码行数:11,代码来源:FDTD2D.hpp

示例6: Ex

// virtual
void GNaiveInstance::trainInner(const GMatrix& features, const GMatrix& labels)
{
	if(!features.relation().areContinuous())
		throw Ex("GNaiveInstance only supports continuous features. Perhaps you should wrap it in a GAutoFilter.");
	if(!labels.relation().areContinuous())
		throw Ex("GNaiveInstance only supports continuous labels. Perhaps you should wrap it in a GAutoFilter.");

	beginIncrementalLearningInner(features.relation(), labels.relation());
	for(size_t i = 0; i < features.rows(); i++)
		trainIncremental(features[i], labels[i]);
}
开发者ID:skn123,项目名称:waffles,代码行数:12,代码来源:GNaiveInstance.cpp

示例7: while

void GTokenizer::expect(const char* szString)
{
	while(*szString != '\0' && has_more())
	{
		char c = get();
		if(c != *szString)
			throw Ex("Expected \"", szString, "\" on line ", to_str(m_line), ", col ", to_str(col()));
		szString++;
	}
	if(*szString != '\0')
		throw Ex("Expected \", szString, \". Reached end-of-file instead.");
}
开发者ID:skn123,项目名称:waffles,代码行数:12,代码来源:GTokenizer.cpp

示例8: Ex

// virtual
void GLinearDistribution::trainInner(const GMatrix& features, const GMatrix& labels)
{
	if(!features.relation().areContinuous())
		throw Ex("GLinearDistribution only supports continuous features. Perhaps you should wrap it in a GAutoFilter.");
	if(!labels.relation().areContinuous())
		throw Ex("GLinearDistribution only supports continuous labels. Perhaps you should wrap it in a GAutoFilter.");

	// Init A with the inverse of the weights prior covariance matrix
	size_t dims = features.cols();
	GMatrix a(dims, dims);
	a.setAll(0.0);

	// Init XY
	size_t labelDims = labels.cols();
	GMatrix xy(dims, labelDims);
	xy.setAll(0.0);

	// Train on each instance
	double w = 1.0 / (m_noiseDev * m_noiseDev);
	for(size_t i = 0; i < features.rows(); i++)
	{
		// Update A
		const GVec& feat = features[i];
		for(size_t j = 0; j < dims; j++)
		{
			GVec& el = a[j];
			for(size_t k = 0; k < dims; k++)
				el[k] += feat[j] * feat[k];
		}

		// Update XY
		const GVec& lab = labels[i];
		for(size_t j = 0; j < dims; j++)
		{
			GVec& el = xy[j];
			for(size_t k = 0; k < labelDims; k++)
				el[k] += feat[j] * lab[k];
		}
	}
	a.multiply(w);
	xy.multiply(w);

	// Compute final matrices
	clear();
	m_pAInv = a.pseudoInverse();
	GAssert(m_pAInv->cols() == dims);
	GAssert(m_pAInv->rows() == dims);
	m_pWBar = GMatrix::multiply(xy, *m_pAInv, true, true);
	GAssert(m_pWBar->cols() == dims);
	GAssert(m_pWBar->rows() == labelDims);
	m_buf.resize(dims);
}
开发者ID:b2020b,项目名称:waffles,代码行数:53,代码来源:GLinear.cpp

示例9: Ex

GDomNode* GKeyPair::serialize(GDom* pDoc, bool bIncludePrivateKey)
{
	GDomNode* pNode = pDoc->newObj();
	if(!n() || !publicKey())
		throw Ex("No key has been made yet");
	if(bIncludePrivateKey && !privateKey())
		throw Ex("This key-pair doesn't include the private key");
	pNode->addField(pDoc, "n", n()->serialize(pDoc));
	pNode->addField(pDoc, "public", publicKey()->serialize(pDoc));
	if(bIncludePrivateKey)
		pNode->addField(pDoc, "private", privateKey()->serialize(pDoc));
	return pNode;
}
开发者ID:har777,项目名称:tapkee_benchmarks,代码行数:13,代码来源:GKeyPair.cpp

示例10: GNaiveBayes_CheckResults

void GNaiveBayes_CheckResults(double yprior, double ycond, double nprior, double ncond, GPrediction* out)
{
	double py = yprior * ycond;
	double pn = nprior * ncond;
	double sum = py + pn;
	py /= sum;
	pn /= sum;
	GCategoricalDistribution* pCat = out->asCategorical();
	GVec& vals = pCat->values(2);
	if(std::abs(vals[0] - py) > 1e-8)
		throw Ex("wrong");
	if(std::abs(vals[1] - pn) > 1e-8)
		throw Ex("wrong");
}
开发者ID:BaskWind,项目名称:waffles,代码行数:14,代码来源:GNaiveBayes.cpp

示例11: SearchCProcs

bool SearchCProcs(var &result, var head, var body)
{
	stdext::hash_map<Var,CProc>::const_iterator
		iter = CProcs.find(head);
	if(iter != CProcs.end())
	{
		PushCProcSymbol pcs(head);
		if (Verbose >= 3) {
			wcerr << _W("Enter cproc for ");
			Println(Ex(head, body), wcerr);
		}
		try {
			result = iter->second(body);
		}
		catch (UserException&) {
			throw;
		}
// 		catch (std::exception& e) {
// 			wcerr << L"std::exception thrown: " << mbs2wcs(e.what()) << std::endl;
// 			wcerr << "CProc error while eval ";
// 			Println(Ex(head, body), wcerr);
// 			return false;
// 		}
		catch (...) {
			wcerr << "CProc error while eval ";
			Println(Ex(head, body), wcerr);
			throw;
		}
		if (result)
		{
			if (TraceRuleSymbols.count(head) != 0)
			{
				// FIXME: rewrite this after we implement the kernel message infrastructure
				Print(head);
				wcout << _W("::tracer : ");
				Print(Ex(head, body));
				wcout << _W(" :> ");
				Println(result);
			}
			if (Verbose >= 3) {
				wcerr << _W("Result is ");
				Println(result, wcerr);
			}
			return true;
		}
	}
	return false;
}
开发者ID:hyln9,项目名称:nV,代码行数:48,代码来源:eval.cpp

示例12: memcpy

void GImage::loadPng(const char* szFilename)
{
	size_t nSize;
	std::ifstream s;
	char* pBuf;
	s.exceptions(std::ios::badbit);
	try
	{
		// NB: we double copy the content of the file!
		// Once in a std::string and then to final destination
		// We do this so it will work with named pipes, which
		// do not permit seeking to the end of the file to determine
		// the file length.
		s.open(szFilename, std::ios::binary);
		std::stringstream buffer;
		buffer << s.rdbuf();
		std::string content = buffer.str();
		nSize = content.size();
		pBuf = new char[nSize];
		memcpy(pBuf, content.data(), nSize);
		s.close();
	}
	catch(const std::exception&)
	{
		throw Ex("Error while trying to open the file, ", szFilename, ". ", strerror(errno));
	}
	readPng(this, (const unsigned char*)pBuf, nSize);
	delete[] pBuf;
}
开发者ID:admonkey,项目名称:snappybird,代码行数:29,代码来源:image.cpp

示例13: startDir

void GFolderSerializer::continueDir()
{
	GDirList* pDL = m_dirStack.top();
	if(pDL->m_folders.size() > 0)
	{
		startDir(pDL->m_folders.back().c_str());
		pDL->m_folders.pop_back();
	}
	else if(pDL->m_files.size() > 0)
	{
		startFile(pDL->m_files.back().c_str());
		pDL->m_files.pop_back();
	}
	else
	{
		// End of dir indicator
		*m_pPos = 'e';
		m_pPos++;
		m_size--;

		// Move out of the dir
		delete(pDL);
		m_dirStack.pop();
		if(chdir("..") != 0)
			throw Ex("Failed to chdir to ..");
		m_state = 1;
	}
}
开发者ID:mikegashler,项目名称:waffles,代码行数:28,代码来源:GDirList.cpp

示例14: addName

void GFolderSerializer::startFile(const char* szFilename)
{
	// File indicator
	*m_pPos = 'f';
	m_pPos++;
	m_size--;
	addName(szFilename);

	// The file size
	m_pInStream = new std::ifstream();
	unsigned long long size = 0;
	try
	{
		m_pInStream->exceptions(std::ios::badbit | std::ios::failbit);
		m_pInStream->open(szFilename, std::ios::binary);
		m_pInStream->seekg(0, std::ios::end);
		size = m_pInStream->tellg();
		m_pInStream->seekg(0, std::ios::beg);
	}
	catch(const std::exception e)
	{
		throw Ex("Error opening file: ", szFilename);
	}
	memcpy(m_pPos, &size, sizeof(unsigned long long));
	m_pPos += sizeof(unsigned long long);
	m_size -= sizeof(unsigned long long);
	m_remaining = (size_t)size;

	// The file
	continueFile();
}
开发者ID:mikegashler,项目名称:waffles,代码行数:31,代码来源:GDirList.cpp

示例15: Ex

GPlotLabelSpacer::GPlotLabelSpacer(double min, double max, int maxLabels)
{
	if(max <= min)
		throw Ex("invalid range");
	int p = (int)ceil(log((max - min) / maxLabels) * M_LOG10E);

	// Every 10
	m_spacing = pow(10.0, p);
	m_start = (int)ceil(min / m_spacing);
	m_count = (int)floor(max / m_spacing) - m_start + 1;

	if(m_count * 5 + 4 < maxLabels)
	{
		// Every 2
		m_spacing *= 0.2;
		m_start = (int)ceil(min / m_spacing);
		m_count = (int)floor(max / m_spacing) - m_start + 1;
	}
	else if(m_count * 2 + 1 < maxLabels)
	{
		// Every 5
		m_spacing *= 0.5;
		m_start = (int)ceil(min / m_spacing);
		m_count = (int)floor(max / m_spacing) - m_start + 1;
	}
}
开发者ID:har777,项目名称:tapkee_benchmarks,代码行数:26,代码来源:GPlot.cpp


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