cblas_zher.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * cblas_zher.c
  3. * The program is a C interface to zher.
  4. *
  5. * Keita Teranishi 5/20/98
  6. *
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include "cblas.h"
  11. #include "cblas_f77.h"
  12. void cblas_zher(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
  13. const int N, const double alpha, const void *X, const int incX
  14. ,void *A, const int lda)
  15. {
  16. char UL;
  17. #ifdef F77_CHAR
  18. F77_CHAR F77_UL;
  19. #else
  20. #define F77_UL &UL
  21. #endif
  22. #ifdef F77_INT
  23. F77_INT F77_N=N, F77_lda=lda, F77_incX=incX;
  24. #else
  25. #define F77_N N
  26. #define F77_lda lda
  27. #define F77_incX incx
  28. #endif
  29. int n, i, tincx, incx=incX;
  30. double *x=(double *)X, *xx=(double *)X, *tx, *st;
  31. extern int CBLAS_CallFromC;
  32. extern int RowMajorStrg;
  33. RowMajorStrg = 0;
  34. CBLAS_CallFromC = 1;
  35. if (order == CblasColMajor)
  36. {
  37. if (Uplo == CblasLower) UL = 'L';
  38. else if (Uplo == CblasUpper) UL = 'U';
  39. else
  40. {
  41. cblas_xerbla(2, "cblas_zher","Illegal Uplo setting, %d\n",Uplo );
  42. CBLAS_CallFromC = 0;
  43. RowMajorStrg = 0;
  44. return;
  45. }
  46. #ifdef F77_CHAR
  47. F77_UL = C2F_CHAR(&UL);
  48. #endif
  49. F77_zher(F77_UL, &F77_N, &alpha, X, &F77_incX, A, &F77_lda);
  50. } else if (order == CblasRowMajor)
  51. {
  52. RowMajorStrg = 1;
  53. if (Uplo == CblasUpper) UL = 'L';
  54. else if (Uplo == CblasLower) UL = 'U';
  55. else
  56. {
  57. cblas_xerbla(2, "cblas_zher","Illegal Uplo setting, %d\n", Uplo);
  58. CBLAS_CallFromC = 0;
  59. RowMajorStrg = 0;
  60. return;
  61. }
  62. #ifdef F77_CHAR
  63. F77_UL = C2F_CHAR(&UL);
  64. #endif
  65. if (N > 0)
  66. {
  67. n = N << 1;
  68. x = malloc(n*sizeof(double));
  69. tx = x;
  70. if( incX > 0 ) {
  71. i = incX << 1 ;
  72. tincx = 2;
  73. st= x+n;
  74. } else {
  75. i = incX *(-2);
  76. tincx = -2;
  77. st = x-2;
  78. x +=(n-2);
  79. }
  80. do
  81. {
  82. *x = *xx;
  83. x[1] = -xx[1];
  84. x += tincx ;
  85. xx += i;
  86. }
  87. while (x != st);
  88. x=tx;
  89. #ifdef F77_INT
  90. F77_incX = 1;
  91. #else
  92. incx = 1;
  93. #endif
  94. }
  95. else x = (double *) X;
  96. F77_zher(F77_UL, &F77_N, &alpha, x, &F77_incX, A, &F77_lda);
  97. } else cblas_xerbla(1, "cblas_zher", "Illegal Order setting, %d\n", order);
  98. if(X!=x)
  99. free(x);
  100. CBLAS_CallFromC = 0;
  101. RowMajorStrg = 0;
  102. return;
  103. }