Esempio n. 1
0
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;
}
Esempio n. 2
0
inline void orth(VVector& v, tag::vector)
{
    typedef typename mtl::Collection<VVector>::size_type  Size;
    using mtl::size1D;
    for (Size j= 0; j < size1D(v); ++j)
        orth(v, j, tag::vector());
}
Esempio n. 3
0
inline void orth(VVector& v, typename mtl::Collection<VVector>::size_type j, tag::vector)
{
    using mtl::two_norm;
    using mtl::size1D;
    MTL_DEBUG_THROW_IF(j < 0 || j >= size1D(v), index_out_of_range());

    typedef typename mtl::Collection<VVector>::size_type  Size;
    for (Size i= 0; i < j; ++i)
        entry1D(v, j)-= dot(entry1D(v, i), entry1D(v, j)) * entry1D(v, i);
    entry1D(v, j)/= two_norm(entry1D(v, j));
}