本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: init
static inline void init(Value& value)
{
using math::zero;
value= zero(value);
}
示例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());
}
示例7: operator
result_type operator()(const Value& v) const
{
using math::zero;
return zero(v);
}
示例8: apply
static inline result_type apply(const Value& v)
{
using math::zero;
return zero(v);
}
示例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) );
}