You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cblas_dgemm.c 3.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. *
  3. * cblas_dgemm.c
  4. * This program is a C interface to dgemm.
  5. * Written by Keita Teranishi
  6. * 4/8/1998
  7. *
  8. */
  9. #include "cblas.h"
  10. #include "cblas_f77.h"
  11. void cblas_dgemm(const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE TransA,
  12. const CBLAS_TRANSPOSE TransB, const int M, const int N,
  13. const int K, const double alpha, const double *A,
  14. const int lda, const double *B, const int ldb,
  15. const double beta, double *C, const int ldc)
  16. {
  17. char TA, TB;
  18. #ifdef F77_CHAR
  19. F77_CHAR F77_TA, F77_TB;
  20. #else
  21. #define F77_TA &TA
  22. #define F77_TB &TB
  23. #endif
  24. #ifdef F77_INT
  25. F77_INT F77_M=M, F77_N=N, F77_K=K, F77_lda=lda, F77_ldb=ldb;
  26. F77_INT F77_ldc=ldc;
  27. #else
  28. #define F77_M M
  29. #define F77_N N
  30. #define F77_K K
  31. #define F77_lda lda
  32. #define F77_ldb ldb
  33. #define F77_ldc ldc
  34. #endif
  35. extern int CBLAS_CallFromC;
  36. extern int RowMajorStrg;
  37. RowMajorStrg = 0;
  38. CBLAS_CallFromC = 1;
  39. if( layout == CblasColMajor )
  40. {
  41. if(TransA == CblasTrans) TA='T';
  42. else if ( TransA == CblasConjTrans ) TA='C';
  43. else if ( TransA == CblasNoTrans ) TA='N';
  44. else
  45. {
  46. cblas_xerbla(2, "cblas_dgemm","Illegal TransA setting, %d\n", TransA);
  47. CBLAS_CallFromC = 0;
  48. RowMajorStrg = 0;
  49. return;
  50. }
  51. if(TransB == CblasTrans) TB='T';
  52. else if ( TransB == CblasConjTrans ) TB='C';
  53. else if ( TransB == CblasNoTrans ) TB='N';
  54. else
  55. {
  56. cblas_xerbla(3, "cblas_dgemm","Illegal TransB setting, %d\n", TransB);
  57. CBLAS_CallFromC = 0;
  58. RowMajorStrg = 0;
  59. return;
  60. }
  61. #ifdef F77_CHAR
  62. F77_TA = C2F_CHAR(&TA);
  63. F77_TB = C2F_CHAR(&TB);
  64. #endif
  65. F77_dgemm(F77_TA, F77_TB, &F77_M, &F77_N, &F77_K, &alpha, A,
  66. &F77_lda, B, &F77_ldb, &beta, C, &F77_ldc);
  67. } else if (layout == CblasRowMajor)
  68. {
  69. RowMajorStrg = 1;
  70. if(TransA == CblasTrans) TB='T';
  71. else if ( TransA == CblasConjTrans ) TB='C';
  72. else if ( TransA == CblasNoTrans ) TB='N';
  73. else
  74. {
  75. cblas_xerbla(2, "cblas_dgemm","Illegal TransA setting, %d\n", TransA);
  76. CBLAS_CallFromC = 0;
  77. RowMajorStrg = 0;
  78. return;
  79. }
  80. if(TransB == CblasTrans) TA='T';
  81. else if ( TransB == CblasConjTrans ) TA='C';
  82. else if ( TransB == CblasNoTrans ) TA='N';
  83. else
  84. {
  85. cblas_xerbla(2, "cblas_dgemm","Illegal TransB setting, %d\n", TransB);
  86. CBLAS_CallFromC = 0;
  87. RowMajorStrg = 0;
  88. return;
  89. }
  90. #ifdef F77_CHAR
  91. F77_TA = C2F_CHAR(&TA);
  92. F77_TB = C2F_CHAR(&TB);
  93. #endif
  94. F77_dgemm(F77_TA, F77_TB, &F77_N, &F77_M, &F77_K, &alpha, B,
  95. &F77_ldb, A, &F77_lda, &beta, C, &F77_ldc);
  96. }
  97. else cblas_xerbla(1, "cblas_dgemm", "Illegal layout setting, %d\n", layout);
  98. CBLAS_CallFromC = 0;
  99. RowMajorStrg = 0;
  100. return;
  101. }