cblas_chpr.c
Go to the documentation of this file.
00001 /*
00002  * cblas_chpr.c
00003  * The program is a C interface to chpr.
00004  * 
00005  * Keita Teranishi  3/23/98
00006  *
00007  */
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include "cblas.h"
00011 #include "cblas_f77.h"
00012 void cblas_chpr(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo,
00013                 const int N, const float alpha, const void *X,
00014                 const int incX, void *A)
00015 {
00016    char UL;
00017 #ifdef F77_CHAR
00018    F77_CHAR F77_UL;
00019 #else
00020    #define F77_UL &UL
00021 #endif
00022 
00023 #ifdef F77_INT
00024    F77_INT F77_N=N, F77_incX=incX;
00025 #else
00026    #define F77_N N
00027    #define F77_incX incx
00028 #endif
00029    int n, i, tincx, incx=incX;
00030    float *x=(float *)X, *xx=(float *)X, *tx, *st;
00031 
00032    extern int CBLAS_CallFromC;
00033    extern int RowMajorStrg;
00034    RowMajorStrg = 0;
00035  
00036    CBLAS_CallFromC = 1;
00037    if (order == CblasColMajor)
00038    {
00039       if (Uplo == CblasLower) UL = 'L';
00040       else if (Uplo == CblasUpper) UL = 'U';
00041       else 
00042       {
00043          cblas_xerbla(2, "cblas_chpr","Illegal Uplo setting, %d\n",Uplo );
00044          CBLAS_CallFromC = 0;
00045          RowMajorStrg = 0;
00046          return;
00047       }
00048       #ifdef F77_CHAR
00049          F77_UL = C2F_CHAR(&UL);
00050       #endif
00051 
00052       F77_chpr(F77_UL, &F77_N, &alpha, X, &F77_incX, A);
00053 
00054    }  else if (order == CblasRowMajor)
00055    {
00056       RowMajorStrg = 1;
00057       if (Uplo == CblasUpper) UL = 'L';
00058       else if (Uplo == CblasLower) UL = 'U';
00059       else 
00060       {
00061          cblas_xerbla(2, "cblas_chpr","Illegal Uplo setting, %d\n", Uplo);
00062          CBLAS_CallFromC = 0;
00063          RowMajorStrg = 0;
00064          return;
00065       }
00066       #ifdef F77_CHAR
00067          F77_UL = C2F_CHAR(&UL);
00068       #endif
00069       if (N > 0)
00070       {
00071          n = N << 1;
00072          x = malloc(n*sizeof(float));
00073          tx = x;
00074          if( incX > 0 ) {
00075             i = incX << 1;
00076             tincx = 2;
00077             st= x+n;
00078          } else { 
00079             i = incX *(-2);
00080             tincx = -2;
00081             st = x-2; 
00082             x +=(n-2); 
00083          }
00084          do
00085          {
00086             *x = *xx;
00087             x[1] = -xx[1];
00088             x += tincx ;
00089             xx += i;
00090          }
00091          while (x != st);
00092          x=tx;
00093          #ifdef F77_INT
00094             F77_incX = 1;
00095          #else
00096             incx = 1;
00097          #endif
00098       }
00099       else x = (float *) X;
00100 
00101       F77_chpr(F77_UL, &F77_N, &alpha, x, &F77_incX, A);
00102 
00103    } else 
00104    {
00105       cblas_xerbla(1, "cblas_chpr","Illegal Order setting, %d\n", order);
00106       CBLAS_CallFromC = 0;
00107       RowMajorStrg = 0;
00108       return;
00109    }
00110    if(X!=x)
00111      free(x);
00112    CBLAS_CallFromC = 0;
00113    RowMajorStrg = 0;
00114    return;
00115 }


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