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


C++ tensor类代码示例

本文整理汇总了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;
	}
}
开发者ID:cvejoski,项目名称:CUDALab,代码行数:7,代码来源:exercise_1.cpp

示例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);
};
开发者ID:matthew-ackerman,项目名称:Evolution_7,代码行数:8,代码来源:grapher.cpp

示例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()));
        }
开发者ID:20337112,项目名称:dlib,代码行数:10,代码来源:curand_dlibapi.cpp

示例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());
	}
开发者ID:boostorg,项目名称:ublas,代码行数:10,代码来源:tensor.hpp

示例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;
		}
	}
}
开发者ID:cvejoski,项目名称:CUDALab,代码行数:10,代码来源:exercise_1.cpp

示例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;
}
开发者ID:CFMS,项目名称:foam-extend-foam-extend-3.2,代码行数:28,代码来源:finiteRotation.C

示例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>());
  }
}
开发者ID:e-thereal,项目名称:capputils,代码行数:13,代码来源:entropy.hpp

示例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;
}
开发者ID:ctlee,项目名称:gamer,代码行数:13,代码来源:SurfaceMesh.cpp

示例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
    }
开发者ID:markpp,项目名称:MTB,代码行数:13,代码来源:tensor_tools.cpp

示例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));
        }
开发者ID:20337112,项目名称:dlib,代码行数:16,代码来源:curand_dlibapi.cpp

示例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_);
}
开发者ID:BarisCumhur,项目名称:OpenFOAM-dev,代码行数:13,代码来源:isoSurface.C

示例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
    }
开发者ID:markpp,项目名称:MTB,代码行数:19,代码来源:tensor_tools.cpp

示例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;
}
开发者ID:gravmath,项目名称:Projects,代码行数:18,代码来源:field.cpp

示例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
    }
开发者ID:markpp,项目名称:MTB,代码行数:20,代码来源:tensor_tools.cpp

示例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);

}
开发者ID:gravmath,项目名称:Projects,代码行数:18,代码来源:field.cpp


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