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


C++ math::zero方法代码示例

本文整理汇总了C++中math::zero方法的典型用法代码示例。如果您正苦于以下问题:C++ math::zero方法的具体用法?C++ math::zero怎么用?C++ math::zero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在math的用法示例。


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

示例1: orthogonalize_factors

dense2D<typename mtl::Collection
<typename mtl::Collection<VVector>::value_type
>::value_type, parameters<> >
inline orthogonalize_factors(VVector& v, tag::vector)
{
    using ::mtl::two_norm;
    using math::zero;
    using mtl::size1D;
    typedef typename mtl::Collection<VVector>::size_type  Size;
    typedef typename mtl::Collection<VVector>::value_type Vector;
    typedef typename mtl::Collection<Vector>::value_type  Scalar;

    dense2D<Scalar, parameters<> > tau(size1D(v), size1D(v));
    tau= zero(Scalar());

    for (Size j= 0; j < size1D(v); ++j) {
        for (Size i= 0; i < j; ++i) {
            Scalar t= dot(entry1D(v, i), entry1D(v, j)) / tau[i][i];
            tau[i][j]= t;
            entry1D(v, j)-= t * entry1D(v, i);
        }
        tau[j][j]= dot(entry1D(v, j), entry1D(v, j));
    }
    return tau;
}
开发者ID:masteroftime,项目名称:viennamesh-dev,代码行数:25,代码来源:orth.hpp

示例2: unit_vector

    typename traits::unit_vector<Value>::type
    inline unit_vector(std::size_t k, std::size_t n)
    {
	using math::zero; using math::one;
	dense_vector<Value> v(n, zero(Value()));
	v[k]= one(Value());
	return v;
    }
开发者ID:guolisen,项目名称:DLStudy,代码行数:8,代码来源:unit_vector.hpp

示例3: operator

    // To prevent that cout << A * B prints the element-wise product, suggestion by Hui Li
    // It is rather inefficient, esp. for multiple products (complexity increases with the number of arguments :-!)
    //    or sparse matrices. 
    // Better compute your product first and print it then when compute time is an issue,
    // this is ONLY for convenience.
    result_value_type
    operator()(std::size_t r, std::size_t c) const
    {
	using math::zero;
	MTL_THROW_IF(num_cols(first) != num_rows(second), incompatible_size());

	result_value_type ref, sum(zero(ref));
	for (std::size_t i= 0; i < num_cols(first); i++)
	    sum+= first(r, i) * second(i, c);
	return sum;
    }
开发者ID:guolisen,项目名称:DLStudy,代码行数:16,代码来源:mat_mat_times_expr.hpp

示例4: trace

typename Collection<Matrix>::value_type
inline trace(const Matrix& matrix)
{
    using math::zero;
    typedef typename Collection<Matrix>::value_type value_type;

    MTL_THROW_IF(num_rows(matrix) != num_cols(matrix), matrix_not_square());

    // If matrix is empty then the result is the identity from the default-constructed value
    if (num_rows(matrix) == 0) {
	value_type ref;
	return zero(ref);
    }

    value_type value= matrix[0][0];
    for (unsigned i= 1; i < num_rows(matrix); i++)
	value+= matrix[i][i];	
    return value;
}
开发者ID:AlexanderToifl,项目名称:viennamesh-dev,代码行数:19,代码来源:trace.hpp

示例5: init

    static inline void init(Value& value)
    {
	using math::zero;
	value= zero(value);
    }
开发者ID:,项目名称:,代码行数:5,代码来源:

示例6: operator

    /// Value of matrix entry
    value_type operator()(size_type r, size_type c) const
    {
	using math::zero;
	utilities::maybe<size_type> o= offset(r, c);
	return o ? data[o.value()] : zero(value_type());
    }
开发者ID:FaceMixer,项目名称:FaceMixer,代码行数:7,代码来源:sparse_banded.hpp

示例7: operator

	result_type operator()(const Value& v) const
	{
	    using math::zero;
	    return zero(v);
	}
开发者ID:guolisen,项目名称:DLStudy,代码行数:5,代码来源:imag.hpp

示例8: apply

	static inline result_type apply(const Value& v)
	{
	    using math::zero;
	    return zero(v);
	}
开发者ID:guolisen,项目名称:DLStudy,代码行数:5,代码来源:imag.hpp

示例9: apply

	static inline Value apply(const Value& v)
	{
	    using math::zero; using math::one;
	    return v == zero(v) ? zero(v) : ( v < zero(v) ? -one(v) : one(v) );
	}
开发者ID:FaceMixer,项目名称:FaceMixer,代码行数:5,代码来源:signum.hpp


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