00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __BLASOPERATORS_H
00021 #define __BLASOPERATORS_H
00022
00023 extern "C" {
00024 void dgemm_(const char* TRANSA, const char* TRANSB, int* width, int* height, int* inter,
00025 double* alpha, const double* A, int *lda, const double* B, int *ldb,
00026 double* beta, double* C, int *ldc);
00027 }
00028
00029
00030
00031
00032 template <class RET, class LHS, class RHS>
00033 inline void blasmmmult(RET& ret, const LHS& lhs, const RHS& rhs){
00034
00035
00036
00037 typedef typename RET::layout retlayout;
00038 typedef typename LHS::layout lhslayout;
00039 typedef typename RHS::layout rhslayout;
00040
00041 const bool CM = !retlayout::is_rowmajor();
00042 const bool LCM = !lhslayout::is_rowmajor();
00043 const bool RCM = !rhslayout::is_rowmajor();
00044
00045 int width = CM ? ret.num_cols():ret.num_rows();
00046 int height = CM ? ret.num_rows():ret.num_cols();
00047 int inter = lhs.num_cols();
00048 double alpha = 1;
00049 int lda = CM ? lhs.num_skip() : rhs.num_skip();
00050 int ldb = CM ? rhs.num_skip() : lhs.num_skip();
00051 double beta = 0;
00052 int ldc = ret.num_skip();
00053 const char* TrA = CM ? (LCM ? "N" : "T") : (RCM ? "T" : "N");
00054 const char* TrB = CM ? (RCM ? "N" : "T") : (LCM ? "T" : "N");
00055
00056 dgemm_(TrA,TrB,&width,&height,&inter,&alpha,
00057 CM ? lhs.get_data_ptr() : rhs.get_data_ptr(),&lda,
00058 CM ? rhs.get_data_ptr() : lhs.get_data_ptr(),&ldb,
00059 &beta, ret.get_data_ptr(), &ldc);
00060 }
00061
00062
00063
00064 #endif