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


C++ Binary类代码示例

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


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

示例1: get_scan_dim_kernels

    static Kernel get_scan_dim_kernels(int kerIdx, int dim, bool isFinalPass, uint threads_y)
    {
        std::string ref_name =
            std::string("scan_") +
            std::to_string(dim) +
            std::string("_") +
            std::to_string(isFinalPass) +
            std::string("_") +
            std::string(dtype_traits<Ti>::getName()) +
            std::string("_") +
            std::string(dtype_traits<To>::getName()) +
            std::string("_") +
            std::to_string(op) +
            std::string("_") +
            std::to_string(threads_y) +
            std::string("_") +
            std::to_string(int(inclusive_scan));

        int device = getActiveDeviceId();

        kc_entry_t entry = kernelCache(device, ref_name);

        if (entry.prog==0 && entry.ker==0) {
            Binary<To, op> scan;
            ToNumStr<To> toNumStr;

            std::ostringstream options;
            options << " -D To=" << dtype_traits<To>::getName()
                    << " -D Ti=" << dtype_traits<Ti>::getName()
                    << " -D T=To"
                    << " -D dim=" << dim
                    << " -D DIMY=" << threads_y
                    << " -D THREADS_X=" << THREADS_X
                    << " -D init=" << toNumStr(scan.init())
                    << " -D " << binOpName<op>()
                    << " -D CPLX=" << af::iscplx<Ti>()
                    << " -D isFinalPass=" << (int)(isFinalPass)
                    << " -D inclusive_scan=" << inclusive_scan;
            if (std::is_same<Ti, double>::value ||
                std::is_same<Ti, cdouble>::value) {
                options << " -D USE_DOUBLE";
            }

            const char *ker_strs[] = {ops_cl, scan_dim_cl};
            const int   ker_lens[] = {ops_cl_len, scan_dim_cl_len};
            cl::Program prog;
            buildProgram(prog, 2, ker_strs, ker_lens, options.str());

            entry.prog = new Program(prog);
            entry.ker = new Kernel[2];

            entry.ker[0] = Kernel(*entry.prog, "scan_dim_kernel");
            entry.ker[1] = Kernel(*entry.prog, "bcast_dim_kernel");


            addKernelToCache(device, ref_name, entry);
        }

        return entry.ker[kerIdx];
    }
开发者ID:FilipeMaia,项目名称:arrayfire,代码行数:60,代码来源:scan_dim.hpp

示例2: sum

 Binary Binary::operator +(const Binary& B)
 {
   Binary sum(i+B.getInt());
   if(B.getBitSize() > sum.bitSize)
     sum.setBitSize(B.getBitSize());
   return sum;
 }
开发者ID:kd0kfo,项目名称:libdnstd,代码行数:7,代码来源:Binary.cpp

示例3: getDarwinDWARFResourceForPath

LLVMSymbolizer::BinaryPair
LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
  BinaryMapTy::iterator I = BinaryForPath.find(Path);
  if (I != BinaryForPath.end())
    return I->second;
  Binary *Bin = 0;
  Binary *DbgBin = 0;
  OwningPtr<Binary> ParsedBinary;
  OwningPtr<Binary> ParsedDbgBinary;
  if (!error(createBinary(Path, ParsedBinary))) {
    // Check if it's a universal binary.
    Bin = ParsedBinary.take();
    ParsedBinariesAndObjects.push_back(Bin);
    if (Bin->isMachO() || Bin->isMachOUniversalBinary()) {
      // On Darwin we may find DWARF in separate object file in
      // resource directory.
      const std::string &ResourcePath =
          getDarwinDWARFResourceForPath(Path);
      bool ResourceFileExists = false;
      if (!sys::fs::exists(ResourcePath, ResourceFileExists) &&
          ResourceFileExists &&
          !error(createBinary(ResourcePath, ParsedDbgBinary))) {
        DbgBin = ParsedDbgBinary.take();
        ParsedBinariesAndObjects.push_back(DbgBin);
      }
    }
  }
  if (DbgBin == 0)
    DbgBin = Bin;
  BinaryPair Res = std::make_pair(Bin, DbgBin);
  BinaryForPath[Path] = Res;
  return Res;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_llvm,代码行数:33,代码来源:LLVMSymbolize.cpp

示例4: mate

/*
Step 1: Let zi := xi for i =1,2, ...,n (i.e., z is a copy of the
		primary parent x).
Step 2: Let zi := (1 - zi) with a probability PBF when xi = yi
		where PBF is a prespecified bit-flip probability.
Note:	Random primary parent selection
*/
bool BinaryCrsNonGeometric::mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child)
{
	Binary* p1 = (Binary*) (gen1.get());
	Binary* p2 = (Binary*) (gen2.get());
	Binary* ch = (Binary*) (child.get());
	
	double PBF = 0.5; //prespecified bit-flip probability

	//Step 1
	for (uint dimension = 0; dimension < p1->variables.size(); dimension++) {
		switch (state_->getRandomizer()->getRandomInteger(0, 1)) {
			case 0: for (uint i = 0; i < p1->getNumBits(); i++) {
						ch->variables[dimension][i] = p1->variables[dimension][i];
					}
					break;
			case 1: for (uint i = 0; i < p2->getNumBits(); i++) {
						ch->variables[dimension][i] = p2->variables[dimension][i];
					}
		}
		//Step 2
		for(uint i = 0; i < p1->getNumBits(); i++) {
			if (p1->variables[dimension][i] == p2->variables[dimension][i]) {
				double changeProbability = state_->getRandomizer()->getRandomDouble();
				if (changeProbability > PBF)
					ch->variables[dimension][i] =  ch->variables[dimension][i]  ? false:true;				
			}
		}
	}

	// update integer and real domain representation
	ch->update();

	return true;
}
开发者ID:llamallamaduck,项目名称:GP-crossover,代码行数:41,代码来源:BinaryCrsNonGeometric.cpp

示例5: diff

 Binary Binary::operator -(const Binary& B)
 {
   Binary diff(i-B.i);
   if(B.getBitSize() > diff.bitSize)
     diff.setBitSize(B.getBitSize());
   return diff;
 }
开发者ID:kd0kfo,项目名称:libdnstd,代码行数:7,代码来源:Binary.cpp

示例6: build_kernel

void build_kernel(Binary<expr::op::Sub, L, R> e, Kernel<T>& k)
{
  Kernel_builder<L, T>::apply(e.arg1(), k);
  Kernel<T> k2(k);
  Kernel_builder<R, T>::apply(e.arg2(), k2);
  k -= k2;
}
开发者ID:bambang,项目名称:vsipl,代码行数:7,代码来源:kernel_builder.hpp

示例7: reduce_all

    To reduce_all(const Array<Ti> &in)
    {
        Transform<Ti, To, op> transform;
        Binary<To, op> reduce;

        To out = reduce.init();

        // Decrement dimension of select dimension
        af::dim4 dims = in.dims();
        af::dim4 strides = in.strides();
        const Ti *inPtr = in.get();

        for(dim_t l = 0; l < dims[3]; l++) {
            dim_t off3 = l * strides[3];

            for(dim_t k = 0; k < dims[2]; k++) {
                dim_t off2 = k * strides[2];

                for(dim_t j = 0; j < dims[1]; j++) {
                    dim_t off1 = j * strides[1];

                    for(dim_t i = 0; i < dims[0]; i++) {
                        dim_t idx = i + off1 + off2 + off3;

                        To val = transform(inPtr[idx]);
                        out = reduce(val, out);
                    }
                }
            }
        }

        return out;
    }
开发者ID:PierreBizouard,项目名称:arrayfire,代码行数:33,代码来源:reduce.cpp

示例8: main

void main()
{
	randomize();

	Binary b;
	b.execute();
}
开发者ID:Dirker27,项目名称:DataStructures,代码行数:7,代码来源:BINTREE_.CPP

示例9: SpongeConstruction

void SpongeConstruction(string inputString, int outputLen)
{
	// Transform the input string into binary bits
	BinaryTransfer( inputString ) ;

	// Padding using Multirate
	vector< Binary > Message = Padding( inputString ) ;

	//Initialize the state variable
	Binary stateVar ;


	// Absorbing phase
	for(auto & block: Message){
		block<<=CAPACITY;
		//XOR with statevar
		stateVar^=block;
		stateVar=internalFun(stateVar);
	}
	// Squeezing phase
	string hashVal ; // The final output value
	if(outputLen <BITRATE){
		hashVal=stateVar.to_string().substr(0,outputLen);
	}else{
		hashVal+=stateVar.to_string().substr(0,BITRATE);
		while(hashVal.length() < outputLen){
			stateVar=internalFun(stateVar);
			hashVal+=stateVar.to_string().substr(0,BITRATE);
		}
	}


	// Print the hash value to the stdout
	PrintHex( hashVal.substr(0, outputLen) ) ;
}
开发者ID:daniel0076,项目名称:sha3,代码行数:35,代码来源:Sponge.cpp

示例10: _or

 Binary Binary::operator |(const Binary& B)
 {
   Binary _or(i | B.getInt());
   if(B.getBitSize() > _or.bitSize)
     _or.setBitSize(B.getBitSize());
   return _or;
 }
开发者ID:kd0kfo,项目名称:libdnstd,代码行数:7,代码来源:Binary.cpp

示例11: _and

 Binary Binary::operator &(const Binary& B)
 {
   Binary _and(i & B.getInt());
   if(B.getBitSize() > _and.bitSize)
     _and.setBitSize(B.getBitSize());
   return _and;
 }
开发者ID:kd0kfo,项目名称:libdnstd,代码行数:7,代码来源:Binary.cpp

示例12: GetEnv

void DataObserverAdapter::_Update(const Binary& arMeas, size_t aIndex)
{
	JNIEnv* pEnv = GetEnv();

	jboolean value = arMeas.GetValue();
	jbyte quality = arMeas.GetQuality();
	jlong timestamp = arMeas.GetTime();
	jlong index = aIndex;

	pEnv->CallVoidMethod(mProxy, mUpdateBinaryInput, value, quality, timestamp, index);
}
开发者ID:prakashnsm,项目名称:dnp3-1,代码行数:11,代码来源:DataObserverAdapter.cpp

示例13: evalV

double ZDT5::evalG(Solution * solution) {
  double res = 0.0;
  Binary * variable ;

  for (int i = 1; i < numberOfVariables_; i++) {
  	variable = (Binary *)(solution->getDecisionVariables()[i]) ;
    res += evalV(variable->cardinality());
  }

  return res;
}
开发者ID:Juanjdurillo,项目名称:jMetalCpp,代码行数:11,代码来源:ZDT5.cpp

示例14: rd_value

Status BinCommon::rd_value(CommandInitiator* thread, Binary& value)
{
  uint size;
  Status status = rd_value(thread, size);
  if (status == OK) {
    if (size > 0) { // protect from unrealistic size?
      value.reserve(size);
      status = rd_bytes(thread, size, (char*) value.data());
    }
  }
  return status;
}
开发者ID:nosilence,项目名称:jira-skype-app,代码行数:12,代码来源:SidProtocolBinCommon.cpp

示例15:

bool operator==(const Binary &left, const Binary &right) {
	unsigned char* leftBuffer = left.Buffer();
	unsigned char* rightBuffer = right.Buffer();
	size_t leftLen = left.BufferLength();
	size_t rightLen = right.BufferLength();

	if (leftLen != rightLen) return false;

	for (size_t i = 0; i < leftLen; i++) {
		if (leftBuffer[i] != rightBuffer[i]) return false;
	}
	return true;
}
开发者ID:Respublica,项目名称:mysqlwrap,代码行数:13,代码来源:Binary.cpp


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