#include #include #include #include #include //------------------------------------------------------------------------------ #define MY_ABS(x) ((x)<0 ? -(x) : (x)) //------------------------------------------------------------------------------ void initMatrix(size_t m, size_t n, double *A, ptrdiff_t incRowA, ptrdiff_t incColA, bool withNan) { // if A is row major initialize A^T if (MY_ABS(incRowA) > MY_ABS(incColA)) { initMatrix(n, m, A, incColA, incRowA, withNan); return; } // if A is col major if (withNan) { for (size_t j=0; j MY_ABS(incColB)) { dgeaxpy(n, m, alpha, A, incColA, incRowA, B, incColB, incRowB); return; } // B is col major: for (size_t j=0; j MY_ABS(incColB)) { dgecopy(n, m, A, incColA, incRowA, B, incColB, incRowB); return; } // B is col major: for (size_t j=0; j MY_ABS(incColA)) { dgescal(n, m, alpha, A, incColA, incRowA); return; } // A is col major: if (alpha!=0) { for (size_t j=0; jres) { res = asum; } } return res; } //------------------------------------------------------------------------------ #ifndef DIM_M #define DIM_M 4 #endif #ifndef DIM_N #define DIM_N 5 #endif double A[DIM_M*DIM_N]; double B[DIM_M*DIM_N]; const int rowMajorA[] = {0, 1, 0, 1}; const int rowMajorB[] = {0, 0, 1, 1}; const int numTests = sizeof(rowMajorA)/sizeof(int); int main() { for (int test=0; test