inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/vops
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_vops
00005 #define inlib_vops
00006 
00007 #include "vmanip"
00008 
00009 // global operators over std::vectors.
00010 // They had not been put in vmanip due
00011 // to potential clash with similar operators
00012 // coming from another source (and being also
00013 // in the global namespace).
00014 
00015 // Note that the below operators induces an intermediate vector
00016 // and then copy of data. So it would be better to consider
00017 // the usage of inlib::[add,sub,mul,div] that induces no copy.
00018 
00019 template <class T>
00020 inline std::vector<T> operator+(const std::vector<T>& a1,const std::vector<T>& a2) {
00021   std::vector<T> res(a1);
00022   inlib::add(res,a2);
00023   return res;
00024 }
00025 
00026 template <class T>
00027 inline std::vector<T> operator-(const std::vector<T>& a1,const std::vector<T>& a2) {
00028   std::vector<T> res(a1);
00029   inlib::sub(res,a2);
00030   return res;
00031 }
00032 
00033 template <class T>
00034 inline std::vector<T> operator*(const std::vector<T>& a1,const std::vector<T>& a2) {
00035   std::vector<T> res(a1);
00036   inlib::mul(res,a2);
00037   return res;
00038 }
00039 
00040 template <class T>
00041 inline std::vector<T> operator/(const std::vector<T>& a1,const std::vector<T>& a2) {
00042   std::vector<T> res(a1);
00043   inlib::div(res,a2); //WARNING : could have /0 errors !
00044   return res;
00045 }
00046 
00047 template <class T>
00048 inline std::vector<T> operator*(const std::vector<T>& a1,const T& a2) {
00049   std::vector<T> res(a1);
00050   inlib::mul(res,a2);
00051   return res;
00052 }
00053 
00054 template <class T>
00055 inline std::vector<T> operator*(const T& a2,const std::vector<T>& a1) {
00056   std::vector<T> res(a1);
00057   inlib::mul(res,a2);
00058   return res;
00059 }
00060 
00061 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines