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


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