CEBL  2.1
cppR_operators.hpp
Go to the documentation of this file.
1 /*
2 * CEBL : CSU EEG Brain-Computer Interface Lab
3 *
4 * Author: Jeshua Bratman - jeshuabratman@gmail.com
5 *
6 * This file is part of CEBL.
7 *
8 * CEBL is free software; you can redistribute it and/or modify it.
9 * We only ask that if you use our code that you cite the source in
10 * your project or publication.
11 *
12 * EEG Group (www.cs.colostate.edu/eeg)
13 * Department of Computer Science
14 * Colorado State University
15 *
16 */
17 
18 
19 //--------------------------------------------------
20 // cppR_operators.hpp
21 // Matrix and Vector operators
22 
23 
24 #ifndef CPPR_OPERATORS_H //make sure this only gets included once
25 #define CPPR_OPERATORS_H
26 
27 //--------------------------------------------------
28 namespace cppR
29 {
30  //==============================
31  //operator/
32  template < typename T >
33  ublas::matrix<T> operator/(const T &value, ublas::matrix<T> &m1)
34  {
35  ublas::matrix<T> ret(m1.size1(), m1.size2());
36  for(unsigned int row=0;row<m1.size1();row++)
37  {
38  for(unsigned int col=0;col<m1.size2();col++)
39  {
40  ret(row,col) = value / m1(row,col);
41  }
42  }
43  return ret;
44  }
45 
46  //==============================
47  //operator/
48  template < typename T >
49  ublas::vector<T> operator/(const T &value, ublas::vector<T> &v1)
50  {
51  ublas::vector<T> ret(v1.size());
52  for(unsigned int row=0;row<v1.size();row++)
53  {
54  ret[row] = value / v1[row];
55  }
56  return ret;
57  }
58 
59 }//end of namespace
60 
61 
62 //--------------------------------------------------
63 
64 
65 
66 #endif