예제 #1
0
파일: Agg.cpp 프로젝트: alongwithyou/rnnlib
template <typename V, typename V1> void addVectors(V &a, const V1 &b) {
#ifdef FLOAT_REALS
  cblas_saxpy
#else
  cblas_daxpy
#endif
      (a.size(), 1, b.data(), 1, a.data(), 1);
#ifdef FLOAT_REALS
  cblas_sscal
#else
  cblas_dscal
#endif
      (a.size(), 0.5, a.data(), 1);
}
예제 #2
0
 template <class V1, class V2> double dot_impl(
     const V1 &v1, const V2 &v2) {
   assert(v1.size() == v2.size());
   if(v1.stride() > 0 && v2.stride() > 0){
     return ddot(v1.size(),
                 v1.data(), v1.stride(),
                 v2.data(), v2.stride());
   }else{
     double ans = 0;
     for(int i = 0; i < v1.size(); ++i){
       ans += v1[i] * v2[i];
     }
     return ans;
   }
 }