Logo MTL4

rank_two_update(A, v, w)

Suppose matrix A have 2 triangle parts. L is the lower triangle and U the upper triangle part of A.

L -> $ L + lower(v*w' + w*v') $ U -> $ U + upper(v*w' + w*v') $

Details: mtl::matrix::rank_two_update

For example:

#include <iostream>
#include <boost/numeric/mtl/mtl.hpp>

int main(int, char**)
{
    using namespace mtl;
    typedef std::complex<double>  cdouble;
    
    const unsigned n= 8;
    dense2D<cdouble>              A(n, n);

    A= 3.0;

    dense_vector<cdouble>         v(n), w(n);
    for (unsigned i= 0; i < size(v); i++)
        v[i]= cdouble(i+1, n-i), w[i]= cdouble(i+n);

    rank_one_update(A, v, w);
    std::cout << "A after rank-one update is \n" 
              << with_format(A, 9, 3) << "\n";

    A= 3.0;
    rank_two_update(A, v, w);
    std::cout << "A after rank-two update is \n"
              << with_format(A, 9, 3) << "\n";

    return 0;
}

Return to Overview                                Table of Content                               


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