Changeset 734 for trunk/yat


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

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

Location:
trunk/yat/utility
Files:
3 edited

Legend:

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

    r732 r734  
    359359
    360360
    361   const vector matrix::operator*(const vector&) const
    362   {
    363     std::cerr << "Not implemented:" << std::endl
    364               << "   const vector matrix::operator*(const vector&) const"
    365               << std::endl;
    366     return vector(0);
    367   }
    368 
    369 
    370361  bool matrix::operator==(const matrix& other) const
    371362  {
  • 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
  • trunk/yat/utility/utility.h

    r687 r734  
    77  Copyright (C) 2005 Jari Häkkinen, Peter Johansson, Markus Ringnér
    88  Copyright (C) 2006 Jari Häkkinen
     9  Copyright (C) 2007 Peter Johansson
    910
    1011  This file is part of the yat library, http://lev.thep.lu.se/trac/yat
     
    3233///
    3334
     35#include "vector.h"
     36
    3437#include <string>
    3538#include <utility>
     
    4043namespace utility {
    4144
    42   class vector;
     45  class matrix;
    4346
    4447  ///
     
    8285  void shuffle(vector& invec);
    8386
     87
     88  /**
     89     @brief matrix vector multiplication
     90   */
     91  vector operator*(const matrix&, const vector&);
     92
     93
     94  /**
     95     @brief matrix vector multiplication
     96   */
     97  vector operator*(const vector&, const matrix&);
     98
    8499}}} // of namespace utility, yat, and theplu
    85100
Note: See TracChangeset for help on using the changeset viewer.