Logo MTL4

orth(v)

returns orthogonal and normalized all vectors of vector v.

Details: mtl::vector::orth

For example:

#include <iostream>
#include <cmath>
#include <vector>
#include <boost/test/minimal.hpp>
#include <boost/numeric/mtl/mtl.hpp>

int test_main(int, char**)
{
    using namespace mtl;
    dense_vector<double>                                        cd(5, 1.0);
    std::vector<dense_vector<double> >                          v(5, cd);
 
    for (unsigned i= 0, c= 1; i < size(v); ++i)
        for (unsigned j= 0; j < size(v[i]); ++j, c++)
            v[i][j]= double((i + j) % 5);

    std::cout << "w initially\n";
    std::vector<dense_vector<double> >                          w(v),x(v);
    for (unsigned i= 0; i < size(w); ++i)
        std::cout << w[i] << "\n";
 
    orth(w);
    std::cout << "\nw orthogonalized\n";
    for (unsigned i= 0; i < size(w); ++i)
        std::cout << w[i] << "\n";
    
    std::cout << "\nTest: dot product of orthogonalized w\n";
    for (unsigned i= 0, c= 1; i < size(w); ++i) {
        for (unsigned j= 0; j < size(w); ++j, ++c)
            std::cout << (dot(w[i], w[j])<1.e-8 ? 0 : dot(w[i], w[j]) )<< " " ;
        std::cout << "\n";
    }   
    std::cout << "\nThe according factors are: \n" << orthogonalize_factors(v) << '\n';
    
    orth(x,0); orth(x,1);
    std::cout << "\nw(0), w(1) orthogonalized\n";
    for (unsigned i= 0; i < size(w); ++i)
        std::cout << x[i] << "\n";
    

    return 0;
}

Return to Overview                                Table of Content                               


orth(v) -- MTL 4 -- Peter Gottschling and Andrew Lumsdaine -- Gen. with rev. 7542 on 7 Apr 2011 by doxygen 1.5.9 -- © 2010 by SimuNova UG.