00001
00002
00003
00004
00005
00006
00007
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include "cblas.h"
00011 #include "cblas_f77.h"
00012 void cblas_chpr2(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00013 const int N,const void *alpha, const void *X,
00014 const int incX,const void *Y, const int incY, void *Ap)
00015
00016 {
00017 char UL;
00018 #ifdef F77_CHAR
00019 F77_CHAR F77_UL;
00020 #else
00021 #define F77_UL &UL
00022 #endif
00023
00024 #ifdef F77_INT
00025 F77_INT F77_N=N, F77_incX=incX, F77_incY=incY;
00026 #else
00027 #define F77_N N
00028 #define F77_incX incx
00029 #define F77_incY incy
00030 #endif
00031 int n, i, j, tincx, tincy, incx=incX, incy=incY;
00032 float *x=(float *)X, *xx=(float *)X, *y=(float *)Y,
00033 *yy=(float *)Y, *tx, *ty, *stx, *sty;
00034
00035 extern int CBLAS_CallFromC;
00036 extern int RowMajorStrg;
00037 RowMajorStrg = 0;
00038
00039 CBLAS_CallFromC = 1;
00040 if (order == CblasColMajor)
00041 {
00042 if (Uplo == CblasLower) UL = 'L';
00043 else if (Uplo == CblasUpper) UL = 'U';
00044 else
00045 {
00046 cblas_xerbla(2, "cblas_chpr2","Illegal Uplo setting, %d\n",Uplo );
00047 CBLAS_CallFromC = 0;
00048 RowMajorStrg = 0;
00049 return;
00050 }
00051 #ifdef F77_CHAR
00052 F77_UL = C2F_CHAR(&UL);
00053 #endif
00054
00055 F77_chpr2(F77_UL, &F77_N, alpha, X, &F77_incX, Y, &F77_incY, Ap);
00056
00057 } else if (order == CblasRowMajor)
00058 {
00059 RowMajorStrg = 1;
00060 if (Uplo == CblasUpper) UL = 'L';
00061 else if (Uplo == CblasLower) UL = 'U';
00062 else
00063 {
00064 cblas_xerbla(2, "cblas_chpr2","Illegal Uplo setting, %d\n", Uplo);
00065 CBLAS_CallFromC = 0;
00066 RowMajorStrg = 0;
00067 return;
00068 }
00069 #ifdef F77_CHAR
00070 F77_UL = C2F_CHAR(&UL);
00071 #endif
00072 if (N > 0)
00073 {
00074 n = N << 1;
00075 x = malloc(n*sizeof(float));
00076 y = malloc(n*sizeof(float));
00077 tx = x;
00078 ty = y;
00079 if( incX > 0 ) {
00080 i = incX << 1 ;
00081 tincx = 2;
00082 stx= x+n;
00083 } else {
00084 i = incX *(-2);
00085 tincx = -2;
00086 stx = x-2;
00087 x +=(n-2);
00088 }
00089
00090 if( incY > 0 ) {
00091 j = incY << 1;
00092 tincy = 2;
00093 sty= y+n;
00094 } else {
00095 j = incY *(-2);
00096 tincy = -2;
00097 sty = y-2;
00098 y +=(n-2);
00099 }
00100
00101 do
00102 {
00103 *x = *xx;
00104 x[1] = -xx[1];
00105 x += tincx ;
00106 xx += i;
00107 }
00108 while (x != stx);
00109 do
00110 {
00111 *y = *yy;
00112 y[1] = -yy[1];
00113 y += tincy ;
00114 yy += j;
00115 }
00116 while (y != sty);
00117
00118 x=tx;
00119 y=ty;
00120
00121 #ifdef F77_INT
00122 F77_incX = 1;
00123 F77_incY = 1;
00124 #else
00125 incx = 1;
00126 incy = 1;
00127 #endif
00128
00129 } else
00130 {
00131 x = (float *) X;
00132 y = (void *) Y;
00133 }
00134 F77_chpr2(F77_UL, &F77_N, alpha, y, &F77_incY, x, &F77_incX, Ap);
00135 } else
00136 {
00137 cblas_xerbla(1, "cblas_chpr2","Illegal Order setting, %d\n", order);
00138 CBLAS_CallFromC = 0;
00139 RowMajorStrg = 0;
00140 return;
00141 }
00142 if(X!=x)
00143 free(x);
00144 if(Y!=y)
00145 free(y);
00146 CBLAS_CallFromC = 0;
00147 RowMajorStrg = 0;
00148 return;
00149 }