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_chpr.c 2.5 kB

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