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


Category:algorithms Component type:function
Prototype
template <class VecX, class VecY, class VecZ>
void add(const VecX& x, const VecY& y, VecZ z) ;
Description
Add the elements of x and y and assign into z.
Definition
mtl.h
Requirements on types
  • VecX::value_type, VecY::value_type, and VecZ::value_type should be the same type
  • The addition operator must be defined for the value_type.
Preconditions
Complexity
linear time
Example
In y_ax_y.cc:
  typedef matrix< double, 
                  rectangle<>, 
                  dense<>, 
                  row_major>::type Matrix; 
  Matrix A(3,3);
  double SCALE = - A(2,1) / A(1,1);
  add(scaled(A[0], SCALE), A[1], A[1]);  

More examples can be found in vecvec_add.cc

Notes
See also

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