本文整理汇总了C++中ValueType函数的典型用法代码示例。如果您正苦于以下问题:C++ ValueType函数的具体用法?C++ ValueType怎么用?C++ ValueType使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValueType函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValueType
inline ValueType spatialaggregate::OcTreeNode< CoordType, ValueType >::getValueInVolume( const spatialaggregate::OcTreePosition< CoordType >& minPosition, const spatialaggregate::OcTreePosition< CoordType >& maxPosition, CoordType minimumSearchVolumeSize ) {
if( type == OCTREE_LEAF_NODE ) {
if( inRegion( minPosition, maxPosition ) )
return value;
return ValueType(0);
}
else {
if( !overlap( minPosition, maxPosition ) )
return ValueType(0);
if( containedInRegion( minPosition, maxPosition ) )
return value;
if( (this->maxPosition[0] - this->minPosition[0]) - minimumSearchVolumeSize <= -OCTREE_EPSILON*minimumSearchVolumeSize ) {
return value;
}
ValueType value = ValueType(0);
for( unsigned int i = 0; i < 8; i++ ) {
if(!siblings[i])
continue;
value += siblings[i]->getValueInVolume( minPosition, maxPosition, minimumSearchVolumeSize );
}
return value;
}
}
示例2: controlExpression
static bool controlExpression(char relOp, expADT expL, expADT expR, environmentADT env){
valueADT leftV, rightV;
leftV = Eval(expL, env);
rightV = Eval(expR, env);
if(ValueType(leftV) == IntValue && ValueType(rightV) == IntValue ){
switch(relOp){
case '<':
return (GetIntValue(leftV) < GetIntValue(rightV));
case '>':
return (GetIntValue(leftV) > GetIntValue(rightV));
case '=':
return (GetIntValue(leftV) == GetIntValue(rightV));
default:
Error("Reloperator %c is not valid.\n", relOp);
break;
}
}
else
Error("\nCompared expressions is not Integers\n");
}
示例3: result
void Quaternion::setAsSlerp(Quaternion const& from, Quaternion const& to, Real const t)
{
Real64 omega, cosomega, sinomega, scale_from, scale_to;
Quaternion result(to);
cosomega = from.x() * to.x() + from.y() * to.y() + from.z() * to.z() + from.w() * to.w();
if (cosomega < ValueType(0.0))
{
cosomega = -cosomega;
result = -to;
}
if((ValueType(1.0) - cosomega) > rengine::epsilon)
{
omega = acos(cosomega);
sinomega = sin(omega);
scale_from = sin((ValueType(1.0) - t) * omega) / sinomega;
scale_to = sin(t * omega) / sinomega;
}
else // Quaternions are very close, so we can linear interpolate
{
scale_from = ValueType(1.0) - t;
scale_to = t;
}
*this = (from * scale_from) + (result * scale_to);
}
示例4: kernel_csr_replace_column_vector_offset
__global__ void kernel_csr_replace_column_vector_offset(const IndexType *row_offset, const IndexType *col,
const IndexType nrow, const IndexType idx,
const ValueType *vec, IndexType *offset) {
IndexType ai = blockIdx.x*blockDim.x+threadIdx.x;
IndexType aj;
IndexType add = 1;
if (ai < nrow) {
offset[ai+1] = row_offset[ai+1] - row_offset[ai];
for (aj=row_offset[ai]; aj<row_offset[ai+1]; ++aj) {
if (col[aj] == idx) {
add = 0;
break;
}
}
if (add == 1 && vec[ai] != ValueType(0.0))
++offset[ai+1];
if (add == 0 && vec[ai] == ValueType(0.0))
--offset[ai+1];
}
}
示例5: SpecialSymbols
/*
* SpecialSymbols
*/
bool SpecialSymbols(const char *name, ValueType &out)
{
if (strcmp(name, "__PMAS__") == 0) out = ValueType(VERSIONN);
else if (strcmp(name, "__LINE__") == 0) out = ValueType(file->line_num);
else if (strcmp(name, "__FILE__") == 0) out = ValueType(file->filename);
else if (strcmp(name, "__RAMBASE__") == 0) out = ValueType(option_ram_base);
else return false;
return true;
}
示例6: parallel_reduce
KOKKOS_INLINE_FUNCTION
void parallel_reduce(const Impl::ThreadVectorRangeBoundariesStruct<iType,Impl::OpenMPTargetExecTeamMember >&
loop_boundaries, const Lambda & lambda, ValueType& result) {
result = ValueType();
for( iType i = loop_boundaries.start; i < loop_boundaries.end; i+=loop_boundaries.increment) {
ValueType tmp = ValueType();
lambda(i,tmp);
result+=tmp;
}
}
示例7: extendTo
inline void extendTo(KeyType x) {
Int i;
if(Graph1d<ValueType, KeyType, Int>::N<1)
{
Graph1d<ValueType, KeyType, Int>::N=1;
Graph1d<ValueType, KeyType, Int>::minX=x-0.5*Graph1d<ValueType, KeyType, Int>::delta;
Graph1d<ValueType, KeyType, Int>::maxX=Graph1d<ValueType, KeyType, Int>::minX+Graph1d<ValueType, KeyType, Int>::delta;
Graph1d<ValueType, KeyType, Int>::y.resize(Graph1d<ValueType, KeyType, Int>::N);
if(k>0)
{
M.resize(Graph1d<ValueType, KeyType, Int>::N);
for(int i=0; i<k; i++) m[i].resize(Graph1d<ValueType, KeyType, Int>::N);
}
} else
{
i=this->idx(x);
if(i<0)
{
Graph1d<ValueType, KeyType, Int>::y.resize(Graph1d<ValueType, KeyType, Int>::N-i);
if(k>0)
{
M.resize(Graph1d<ValueType, KeyType, Int>::N-i);
for(int ii=0; ii<k; ii++) m[ii].resize(Graph1d<ValueType, KeyType, Int>::N-i);
}
for(Int j=Graph1d<ValueType, KeyType, Int>::N-1; j>=0; j--)
{
Graph1d<ValueType, KeyType, Int>::y[j-i]=Graph1d<ValueType, KeyType, Int>::y[j];
Graph1d<ValueType, KeyType, Int>::y[j]=ValueType(0);
if(k>0)
{
M[j-i]=M[j];
M[j]=0;
for(int ii=0; ii<k; ii++)
{
m[ii][j-i]=m[ii][j];
m[ii][j]=ValueType(0);
}
}
}
Graph1d<ValueType, KeyType, Int>::N=Graph1d<ValueType, KeyType, Int>::N-i; Graph1d<ValueType, KeyType, Int>::minX+=KeyType(i)*Graph1d<ValueType, KeyType, Int>::delta;
i=0;
} else if(i>=Graph1d<ValueType, KeyType, Int>::N)
{
Int n=i-Graph1d<ValueType, KeyType, Int>::N+1;
Graph1d<ValueType, KeyType, Int>::y.resize(i+1,ValueType(0));
if(k>0)
{
M.resize(i+1,0);
for(int ii=0; ii<k; ii++) m[ii].resize(i+1,ValueType(0));
}
Graph1d<ValueType, KeyType, Int>::N=i+1;
Graph1d<ValueType, KeyType, Int>::maxX+=KeyType(n)*Graph1d<ValueType, KeyType, Int>::delta;
}
} }
示例8: assert
void MultiColoredSGS<OperatorType, VectorType, ValueType>::SolveD_(void) {
assert(this->build_ == true);
for (int i=0; i<this->num_blocks_; ++i) {
this->x_block_[i]->PointWiseMult(*this->diag_block_[i]);
// SSOR
if (this->omega_ != ValueType(1.0))
this->x_block_[i]->Scale(this->omega_/(ValueType(2.0) - this->omega_));
}
}
示例9: assert
void MultiElimination<OperatorType, VectorType, ValueType>::Solve(const VectorType &rhs,
VectorType *x) {
assert(this->build_ == true);
// LOG_INFO("Level = " << this->get_level() << " with size=" << this->get_size_diag_block() );
this->rhs_.CopyFromPermute(rhs,
this->permutation_);
this->x_1_.CopyFrom(this->rhs_,
0,
0,
this->size_);
this->rhs_2_.CopyFrom(this->rhs_,
this->size_,
0,
this->rhs_.get_size() - this->size_);
// Solve L
this->E_.ApplyAdd(this->x_1_, ValueType(-1.0), &this->rhs_2_);
// Solve R
this->AA_solver_->Solve(this->rhs_2_,
&this->x_2_);
this->F_.ApplyAdd(this->x_2_, ValueType(-1.0), &this->x_1_);
this->x_1_.PointWiseMult(this->inv_vec_D_);
this->x_.CopyFrom(this->x_1_,
0,
0,
this->size_);
this->x_.CopyFrom(this->x_2_,
0,
this->size_,
this->rhs_.get_size() - this->size_);
x->CopyFromPermuteBackward(this->x_,
this->permutation_);
}
示例10: assert
void HostMatrixCOO<ValueType>::Apply(const BaseVector<ValueType> &in, BaseVector<ValueType> *out) const {
assert(in. get_size() >= 0);
assert(out->get_size() >= 0);
assert(in. get_size() == this->ncol_);
assert(out->get_size() == this->nrow_);
const HostVector<ValueType> *cast_in = dynamic_cast<const HostVector<ValueType>*> (&in) ;
HostVector<ValueType> *cast_out = dynamic_cast< HostVector<ValueType>*> (out) ;
assert(cast_in != NULL);
assert(cast_out!= NULL);
_set_omp_backend_threads(this->local_backend_, this->nnz_);
#pragma omp parallel for
for (int i=0; i<this->nrow_; ++i) {
cast_out->vec_[i] = ValueType(0.0);
if (i == 0) {
int nthreads = omp_get_num_threads();
std::cout << "variable nthreads IN COO is " << nthreads << std::endl;
}
}
for (int i=0; i<this->nnz_; ++i)
cast_out->vec_[this->mat_.row[i] ] += this->mat_.val[i] * cast_in->vec_[ this->mat_.col[i] ];
}
示例11: ValueType
KOKKOS_INLINE_FUNCTION
void parallel_reduce
(const Impl::ThreadVectorRangeBoundariesStruct<iType,Impl::TaskExec< Kokkos::Serial > >& loop_boundaries,
const Lambda & lambda,
ValueType& initialized_result)
{
initialized_result = ValueType();
#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
#pragma ivdep
#endif
for( iType i = loop_boundaries.start; i < loop_boundaries.end; i+=loop_boundaries.increment) {
ValueType tmp = ValueType();
lambda(i,tmp);
initialized_result+=tmp;
}
}
示例12: _DumpItems
static void
_DumpItems(
ValueStruct *value)
{
int i;
if ( value == NULL ) return;
switch (ValueType(value)) {
case GL_TYPE_INT:
printf("int");
break;
case GL_TYPE_BOOL:
printf("bool");
break;
case GL_TYPE_BYTE:
printf("byte");
break;
case GL_TYPE_CHAR:
printf("char(%d)",(int)ValueStringLength(value));
break;
case GL_TYPE_VARCHAR:
printf("varchar(%d)",(int)ValueStringLength(value));
break;
case GL_TYPE_DBCODE:
printf("dbcode(%d)",(int)ValueStringLength(value));
break;
case GL_TYPE_NUMBER:
if ( ValueFixedSlen(value) == 0 ) {
printf("number(%d)",(int)ValueFixedLength(value));
} else {
printf("number(%d,%d)",
(int)ValueFixedLength(value),
(int)ValueFixedSlen(value));
}
break;
case GL_TYPE_TEXT:
printf("text");
break;
case GL_TYPE_ARRAY:
_DumpItems(ValueArrayItem(value,0));
printf("[%d]",(int)ValueArraySize(value));
break;
case GL_TYPE_RECORD:
printf("{\n");
nTab ++;
for ( i = 0 ; i < ValueRecordSize(value) ; i ++ ) {
PutTab(nTab);
printf("%s\t",ValueRecordName(value,i));
_DumpItems(ValueRecordItem(value,i));
printf(";\n");
}
nTab --;
PutTab(nTab);
printf("}");
break;
default:
break;
}
fflush(stdout);
}
示例13: kernel_reduce
__global__ void kernel_reduce(const IndexType n, const ValueType *data, ValueType *out,
const IndexType GROUP_SIZE, const IndexType LOCAL_SIZE) {
IndexType tid = threadIdx.x;
__shared__ ValueType sdata[BLOCK_SIZE];
sdata[tid] = ValueType(0.0);
// get global id
IndexType gid = GROUP_SIZE * blockIdx.x + tid;
for (IndexType i = 0; i < LOCAL_SIZE; ++i, gid += BLOCK_SIZE)
if ( gid < n )
sdata[tid] += data[gid];
__syncthreads();
#pragma unroll
for (IndexType i = BLOCK_SIZE/2; i > 0; i /= 2) {
if (tid < i)
sdata[tid] += sdata[tid + i];
__syncthreads();
}
if (tid == 0)
out[blockIdx.x] = sdata[tid];
}
示例14: find
T& HashMap<Key, T, Hasher, EqualKey, Alloc>::operator[](const Key& k){
iterator i = find(k);
if(i != end() )
return i->second;
i = addNode(ValueType(k) );
return i->second;
}
示例15: kernel_ell_add_spmv
__global__ void kernel_ell_add_spmv(const IndexType num_rows,
const IndexType num_cols,
const IndexType num_cols_per_row,
const IndexType *Acol,
const ValueType *Aval,
const ValueType scalar,
const ValueType *x,
ValueType *y) {
int row = blockDim.x * blockIdx.x + threadIdx.x;
if (row < num_rows) {
ValueType sum = ValueType(0.0);
for (IndexType n=0; n<num_cols_per_row; ++n) {
const IndexType ind = ELL_IND(row, n, num_rows, num_cols_per_row);
const IndexType col = Acol[ind];
if ((col >= 0) && (col < num_cols)) {
sum += Aval[ind] * x[col];
}
}
y[row] += scalar*sum;
}
}