本文整理汇总了C++中tensor类的典型用法代码示例。如果您正苦于以下问题:C++ tensor类的具体用法?C++ tensor怎么用?C++ tensor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tensor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_2D_view
void print_2D_view(tensor<T, M>& a) {
for (unsigned int i = 0; i<a.shape(0); i++){
for (unsigned int j = 0; j<a.shape(1); j++)
cout<<a(i, j)<<" ";
cout<<endl;
}
}
示例2: time_step
void time_step(){
reduce(&P_odd,even_to_odd);
P_odd.normalize();
drift(&P_odd, &N_tensor, 1000);
reduce(&P_even,odd_to_even);
P_even.normalize();
drift(&P_even, &N_tensor, 1000);
};
示例3: fill_uniform
void curand_generator::
fill_uniform (
tensor& data
)
{
if (data.size() == 0)
return;
CHECK_CURAND(curandGenerateUniform((curandGenerator_t)handle, data.device(), data.size()));
}
示例4: tensor
tensor (const tensor<value_type, other_layout> &other)
: tensor_expression_type<self_type> ()
, extents_ (other.extents())
, strides_ (other.extents())
, data_ (other.extents().product())
{
copy(this->rank(), this->extents().data(),
this->data(), this->strides().data(),
other.data(), other.strides().data());
}
示例5: print_3D_view
void print_3D_view(tensor<T, M>& a) {
for (unsigned int k = 0; k<a.shape(0); k++) {
cout<<"dimension 0: "<<k<<endl;
for (unsigned int i = 0; i<a.shape(1); i++){
for (unsigned int j = 0; j<a.shape(2); j++)
cout<<a(k, i, j)<<" ";
cout<<endl;
}
}
}
示例6: sqrt
Foam::vector Foam::finiteRotation::eulerAngles(const tensor& rotT)
{
// Create a vector containing euler angles (x = roll, y = pitch, z = yaw)
vector eulerAngles;
scalar& rollAngle = eulerAngles.x();
scalar& pitchAngle = eulerAngles.y();
scalar& yawAngle = eulerAngles.z();
// Calculate roll angle
rollAngle = atan2(rotT.yz(), rotT.zz());
// Use mag to avoid negative value due to round-off
// HJ, 24/Feb/2016
// Bugfix: sqr. SS, 18/Apr/2016
const scalar c2 = sqrt(sqr(rotT.xx()) + sqr(rotT.xy()));
// Calculate pitch angle
pitchAngle = atan2(-rotT.xz(), c2);
const scalar s1 = sin(rollAngle);
const scalar c1 = cos(rollAngle);
// Calculate yaw angle
yawAngle = atan2(s1*rotT.zx() - c1*rotT.yx(), c1*rotT.yy() - s1*rotT.zy());
return eulerAngles;
}
示例7: entropy
float entropy(const tensor<float, dim, device>& tensor, float totalSum = 1.f) {
if (totalSum == 1.f) {
return -tbblas::detail::transform_reduce(
typename tbblas::detail::select_system<device>::system(),
tensor.begin(), tensor.end(),
entropy_float(), 0.f, thrust::plus<float>());
} else {
return -tbblas::detail::transform_reduce(
typename tbblas::detail::select_system<device>::system(),
tensor.begin(), tensor.end(),
entropy_float_norm(totalSum), 0.f, thrust::plus<float>());
}
}
示例8: getNormalFromTangent
Vector getNormalFromTangent(const tensor<double, 3, 2> tangent)
{
Vector xp;
// upper right...
xp[0] = -tangent.get(1, 2); // x
xp[1] = tangent.get(0, 2); // y
xp[2] = -tangent.get(0, 1); // z
// lower left...
// xp[0] = tangent.get(2,1);
// xp[1] = -tangent.get(2,0);
// xp[2] = tangent.get(1,0);
return xp;
}
示例9: log10
void log10 (
tensor& dest,
const tensor& src
)
{
DLIB_CASSERT(dest.size() == src.size());
#ifdef DLIB_USE_CUDA
cuda::log10(dest,src);
#else
dest = log10(mat(src));
#endif
}
示例10: fill_gaussian
void curand_generator::
fill_gaussian (
tensor& data,
float mean,
float stddev
)
{
if (data.size() == 0)
return;
CHECK_CURAND(curandGenerateNormal((curandGenerator_t)handle,
data.device(),
data.size(),
mean,
stddev));
}
示例11:
bool Foam::isoSurface::noTransform(const tensor& tt) const
{
return
(mag(tt.xx()-1) < mergeDistance_)
&& (mag(tt.yy()-1) < mergeDistance_)
&& (mag(tt.zz()-1) < mergeDistance_)
&& (mag(tt.xy()) < mergeDistance_)
&& (mag(tt.xz()) < mergeDistance_)
&& (mag(tt.yx()) < mergeDistance_)
&& (mag(tt.yz()) < mergeDistance_)
&& (mag(tt.zx()) < mergeDistance_)
&& (mag(tt.zy()) < mergeDistance_);
}
示例12: scale_rows
void scale_rows (
tensor& out,
const tensor& m,
const tensor& v
)
{
DLIB_CASSERT(have_same_dimensions(out,m));
DLIB_CASSERT(is_vector(v));
if (m.size() == 0 && v.size() == 0)
return;
DLIB_CASSERT(m.size() != 0);
DLIB_CASSERT(m.num_samples() == v.size());
#ifdef DLIB_USE_CUDA
cuda::scale_rows(out, m, v);
#else
out = scale_rows(mat(m), mat(v));
#endif
}
示例13: GetInterpTensor
//******************************************************************************
//Name: GetInterpTensor *
// *
//Purpose: get the interpolated tensor at an arbitrary position *
// *
//Takes: pointer to the position as packed in a tensor *
//******************************************************************************
tensor field::GetInterpTensor(tensor &pos)
{
double position[3];
tensor ret_val;
for(int i = 0; i < 3; i++) position[i] = pos.Val(i);
ret_val <= GetInterpTensor(position);
return ret_val;
}
示例14: scale_columns
void scale_columns (
tensor& out,
const tensor& m,
const tensor& v
)
{
DLIB_CASSERT(have_same_dimensions(out,m));
DLIB_CASSERT(is_vector(v));
if (m.size() == 0 && v.size() == 0)
return;
DLIB_CASSERT(m.size() != 0);
DLIB_CASSERT(m.size()/m.num_samples() == v.size());
#ifdef DLIB_USE_CUDA
cuda::scale_columns(out, m, v);
#else
DLIB_CASSERT(false, "shouldn't be called right now");
out = scale_columns(mat(m), mat(v));
#endif
}
示例15: SetTensor
//******************************************************************************
//Name: SetTensor *
// *
//Purpose: Set the tensor portion of the field *
// *
//Takes: takes a position in tensor form and the address of the tensor *
//******************************************************************************
void field::SetTensor(const tensor &pos, const tensor &rval)
{
int i;
double position[3];
for( i = 0; i < 3; i++) position[i] = pos.Val(i);
SetTensor(position, rval);
}