Ignore:
Timestamp:
Jan 6, 2007, 6:04:54 PM (16 years ago)
Author:
Peter
Message:

added vector*matrix and matrix*vector operators. fixes #18

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/utility.cc

    r680 r734  
    44  Copyright (C) 2005 Jari Häkkinen, Markus Ringnér
    55  Copyright (C) 2006 Jari Häkkinen
     6  Copyright (C) 2007 Peter Johansson
    67
    78  This file is part of the yat library, http://lev.thep.lu.se/trac/yat
     
    2425
    2526#include "utility.h"
     27
     28#include "matrix.h"
    2629#include "stl_utility.h"
    2730#include "vector.h"
     
    116119
    117120
     121  vector operator*(const matrix& m, const vector& v)
     122  {
     123    utility::vector res(m.rows());
     124    for (size_t i=0; i<res.size(); ++i)
     125      res(i) = vector(m,i) * v;
     126    return res;
     127  }
     128
     129
     130  vector operator*(const vector& v, const matrix& m)
     131  {
     132    utility::vector res(m.columns());
     133    for (size_t i=0; i<res.size(); ++i)
     134      res(i) = v * vector(m,i,false);
     135    return res;
     136  }
     137
    118138}}} // end of namespace utility, yat and thep
Note: See TracChangeset for help on using the changeset viewer.