rank_two_update [MTL Home] Programmers Guide
  Contents | Index |  Search 


Category:algorithms Component type:function
Prototype
template <class Matrix, class VecX, class VecY>
void rank_two_update(Matrix A, const VecX& x, const VecY& y) ;
Description
Definition
mtl.h
Requirements on types
  • Matrix::value_type, VecX::value_type, and VecY::value_type must be the same type.
  • The multiplication operator must be defined for Matrix::value_type.
  • The addition operator must be defined for Matrix::value_type.
Preconditions
  • A.nrows() == A.ncols()
  • A.nrows() == x.size()
  • x.size() == y.size()
  • A has rectangle shape and is dense.
Complexity
Example
In rank_2_symm_sparse.cc:
typedef matrix< double, 
                symmetric<lower>, 
                packed<>, 
                row_major>::type Matrix;
typedef dense1D<double> Vec;
  const int N = 3;
  const double alpha = 10;
  Matrix A(N,N);
  Vec y(N),x(N),ay(N),ax(N);
  //do the update
  rank_two_update(A, scaled(x, alpha), y);

  //print result
  cout << "axy^T + ayx^T + A:";
  print_all_matrix(A);

Notes
See also

[MTL Home] Copyright © 1998,1999 University of Notre Dame. All Rights Reserved.