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


Category:algorithms Component type:function
Prototype
template <class Matrix, class VecX, class VecY>
void __mult_dim(const Matrix& A, const VecX& x, VecY y, oned_tag) ;
Description
Multiplies matrix A times vector x and stores the result in vector y.

Note: ignore the oned_tag parameter and the underscores in the name of this function.

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() <= y.size()
  • A.ncols() <= x.size()
  • x and y not same vector
Complexity
Example
In general_matvec_mult.cc:
  typedef matrix< double, 
                  rectangle<2,2>, 
                  dense<external>, 
                  column_major>::type Matrix; 
  typedef dense1D<double> Vector;
  double pi, theta;
  double dA[4];
  Matrix rot(dA);
  Vector vec1(Matrix::N),vec2(Matrix::N);

  pi = 4.0 * atan (1.0);
  theta = pi / 2.0;

  rot(0,0) = cos(theta);
  rot(1,0) = sin(theta);
  rot(0,1) = -sin(theta);
  rot(1,1) = cos(theta);

  vec1[0] = 3.0;
  vec1[1] = 4.0;
  mult(rot, scaled(vec1, 0.5), vec2);

More examples can be found in banded_matvec_mult.cc, symm_matvec_mult.ccsymm_matvec_mult.cc

Notes
See also

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