/algorithms_for_adolc/dot.hpp

http://github.com/b45ch1/hpsc_hanoi_2009_walter · C++ Header · 21 lines · 17 code · 4 blank · 0 comment · 6 complexity · 7499e7df39c8e033523c02c11be33a9d MD5 · raw file

  1. #ifndef DOT_HPP
  2. #define DOT_HPP
  3. inline int fid(int row, int col, int ldim){
  4. return row + col*ldim;
  5. }
  6. template <class Tdouble>
  7. void dot(Tdouble *x, Tdouble *y, Tdouble *z, int N){
  8. for(int n = 0; n != N; ++n){ // iterate over all columns
  9. for(int m = 0; m != N; ++m){ // iterate over all rows
  10. z[fid(m,n,N)] = 0;
  11. for(int k = 0; k != N; ++k){
  12. z[fid(m,n,N)] += x[fid(m,k,N)]*y[fid(k,n,N)];
  13. }
  14. }
  15. }
  16. }
  17. #endif