cblas_zhpr2.c
Go to the documentation of this file.
00001 /*
00002  * cblas_zhpr2.c
00003  * The program is a C interface to zhpr2.
00004  * 
00005  * Keita Teranishi  5/20/98
00006  *
00007  */
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include "cblas.h"
00011 #include "cblas_f77.h"
00012 void cblas_zhpr2(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, incx=incX, incy=incY;
00032    double *x=(double *)X, *xx=(double *)X, *y=(double *)Y,
00033          *yy=(double *)Y, *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_zhpr2","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_zhpr2(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_zhpr2","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(double));
00076          y = malloc(n*sizeof(double));         
00077          stx = x + n;
00078          sty = y + n;
00079          if( incX > 0 )
00080             i = incX << 1;
00081          else
00082             i = incX *(-2);
00083  
00084          if( incY > 0 )
00085             j = incY << 1;
00086          else
00087             j = incY *(-2);
00088          do
00089          {
00090             *x = *xx;
00091             x[1] = -xx[1];
00092             x += 2;
00093             xx += i;
00094          } while (x != stx);
00095          do
00096          {
00097             *y = *yy;
00098             y[1] = -yy[1];
00099             y += 2;
00100             yy += j;
00101          }
00102          while (y != sty);
00103          x -= n;
00104          y -= n;
00105 
00106          #ifdef F77_INT
00107             if(incX > 0 )
00108                F77_incX = 1;
00109             else
00110                F77_incX = -1;
00111  
00112             if(incY > 0 )
00113                F77_incY = 1;
00114             else
00115                F77_incY = -1;
00116  
00117          #else
00118             if(incX > 0 )
00119                incx = 1;
00120             else
00121                incx = -1;
00122  
00123             if(incY > 0 )
00124                incy = 1;
00125             else
00126                incy = -1;
00127          #endif
00128 
00129       }  else 
00130       {
00131          x = (double *) X;
00132          y = (void  *) Y;
00133       }
00134       F77_zhpr2(F77_UL, &F77_N, alpha, y, &F77_incY, x, &F77_incX, Ap);
00135    } 
00136    else 
00137    {
00138       cblas_xerbla(1, "cblas_zhpr2","Illegal Order setting, %d\n", order);
00139       CBLAS_CallFromC = 0;
00140       RowMajorStrg = 0;
00141       return;
00142    }
00143    if(X!=x)
00144       free(x);
00145    if(Y!=y)
00146       free(y);
00147    CBLAS_CallFromC = 0;
00148    RowMajorStrg = 0;
00149    return;
00150 }


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:16