/algorithms_for_adolc/dot.hpp
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 4inline int fid(int row, int col, int ldim){ 5 return row + col*ldim; 6} 7 8template <class Tdouble> 9void dot(Tdouble *x, Tdouble *y, Tdouble *z, int N){ 10 for(int n = 0; n != N; ++n){ // iterate over all columns 11 for(int m = 0; m != N; ++m){ // iterate over all rows 12 z[fid(m,n,N)] = 0; 13 for(int k = 0; k != N; ++k){ 14 z[fid(m,n,N)] += x[fid(m,k,N)]*y[fid(k,n,N)]; 15 } 16 } 17 } 18} 19 20 21#endif