void F77_cher(int *order, char *uplow, int *n, float *alpha, CBLAS_TEST_COMPLEX *x, int *incx, CBLAS_TEST_COMPLEX *a, int *lda) { CBLAS_TEST_COMPLEX *A; int i,j,LDA; enum CBLAS_UPLO uplo; get_uplo_type(uplow,&uplo); if (*order == TEST_ROW_MJR) { LDA = *n+1; A=(CBLAS_TEST_COMPLEX*)malloc((*n)*LDA*sizeof( CBLAS_TEST_COMPLEX )); for( i=0; i<*n; i++ ) for( j=0; j<*n; j++ ) { A[ LDA*i+j ].real=a[ (*lda)*j+i ].real; A[ LDA*i+j ].imag=a[ (*lda)*j+i ].imag; } cblas_cher(CblasRowMajor, uplo, *n, *alpha, x, *incx, A, LDA ); for( i=0; i<*n; i++ ) for( j=0; j<*n; j++ ) { a[ (*lda)*j+i ].real=A[ LDA*i+j ].real; a[ (*lda)*j+i ].imag=A[ LDA*i+j ].imag; } free(A); } else if (*order == TEST_COL_MJR) cblas_cher( CblasColMajor, uplo, *n, *alpha, x, *incx, a, *lda ); else cblas_cher( UNDEFINED, uplo, *n, *alpha, x, *incx, a, *lda ); }
inline void her (CBLAS_ORDER const Order, CBLAS_UPLO const Uplo, int const N, float const alpha, traits::complex_f const* X, int const incX, traits::complex_f* A, int const lda) { cblas_cher (Order, Uplo, N, alpha, static_cast<void const*> (X), incX, static_cast<void*> (A), lda); }
void phi_her(const int N, const Float alpha, const Complex *X, Complex *A){ #ifndef NOBLAS #ifdef SINGLEPRECISION cblas_cher(CblasRowMajor,CblasUpper,N,alpha,X,1,A,N); #else cblas_zher(CblasRowMajor,CblasUpper,N,alpha,X,1,A,N); #endif #else int i,j; for(i = 0; i < N; ++i){ for(j = 0; j < N; ++j){ A[i*N+j] = alpha*X[i]*conj(X[j]); } } #endif }
inline void her( const Order, const UpLo, const int n, const float alpha, const std::complex<float>* x, const int incx, std::complex<float>* a, const int lda ) { cblas_cher( cblas_option< Order >::value, cblas_option< UpLo >::value, n, alpha, x, incx, a, lda ); }
void test_her (void) { const double flteps = 1e-4, dbleps = 1e-6; { int order = 101; int uplo = 121; int N = 1; int lda = 1; float alpha = 1.0f; float A[] = { 0.188f, 0.856f }; float X[] = { -0.832f, -0.151f }; int incX = -1; float A_expected[] = { 0.903025f, 0.0f }; cblas_cher(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[2*i], A_expected[2*i], flteps, "cher(case 1410) real"); gsl_test_rel(A[2*i+1], A_expected[2*i+1], flteps, "cher(case 1410) imag"); }; }; }; { int order = 101; int uplo = 122; int N = 1; int lda = 1; float alpha = 1.0f; float A[] = { 0.188f, 0.856f }; float X[] = { -0.832f, -0.151f }; int incX = -1; float A_expected[] = { 0.903025f, 0.0f }; cblas_cher(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[2*i], A_expected[2*i], flteps, "cher(case 1411) real"); gsl_test_rel(A[2*i+1], A_expected[2*i+1], flteps, "cher(case 1411) imag"); }; }; }; { int order = 102; int uplo = 121; int N = 1; int lda = 1; float alpha = 1.0f; float A[] = { 0.188f, 0.856f }; float X[] = { -0.832f, -0.151f }; int incX = -1; float A_expected[] = { 0.903025f, 0.0f }; cblas_cher(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[2*i], A_expected[2*i], flteps, "cher(case 1412) real"); gsl_test_rel(A[2*i+1], A_expected[2*i+1], flteps, "cher(case 1412) imag"); }; }; }; { int order = 102; int uplo = 122; int N = 1; int lda = 1; float alpha = 1.0f; float A[] = { 0.188f, 0.856f }; float X[] = { -0.832f, -0.151f }; int incX = -1; float A_expected[] = { 0.903025f, 0.0f }; cblas_cher(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[2*i], A_expected[2*i], flteps, "cher(case 1413) real"); gsl_test_rel(A[2*i+1], A_expected[2*i+1], flteps, "cher(case 1413) imag"); }; }; }; { int order = 101; int uplo = 121; int N = 1; int lda = 1; double alpha = 0.1; double A[] = { 0.257, 0.326 }; double X[] = { 0.319, -0.009 }; int incX = -1; double A_expected[] = { 0.2671842, 0.0 }; cblas_zher(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[2*i], A_expected[2*i], dbleps, "zher(case 1414) real"); gsl_test_rel(A[2*i+1], A_expected[2*i+1], dbleps, "zher(case 1414) imag"); }; }; }; { int order = 101; int uplo = 122; int N = 1; int lda = 1; double alpha = 0.1; double A[] = { 0.257, 0.326 }; double X[] = { 0.319, -0.009 }; int incX = -1; double A_expected[] = { 0.2671842, 0.0 }; cblas_zher(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[2*i], A_expected[2*i], dbleps, "zher(case 1415) real"); gsl_test_rel(A[2*i+1], A_expected[2*i+1], dbleps, "zher(case 1415) imag"); }; }; }; { int order = 102; int uplo = 121; int N = 1; int lda = 1; double alpha = 0.1; double A[] = { 0.257, 0.326 }; double X[] = { 0.319, -0.009 }; int incX = -1; double A_expected[] = { 0.2671842, 0.0 }; cblas_zher(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[2*i], A_expected[2*i], dbleps, "zher(case 1416) real"); gsl_test_rel(A[2*i+1], A_expected[2*i+1], dbleps, "zher(case 1416) imag"); }; }; }; { int order = 102; int uplo = 122; int N = 1; int lda = 1; double alpha = 0.1; double A[] = { 0.257, 0.326 }; double X[] = { 0.319, -0.009 }; int incX = -1; double A_expected[] = { 0.2671842, 0.0 }; cblas_zher(order, uplo, N, alpha, X, incX, A, lda); { int i; for (i = 0; i < 1; i++) { gsl_test_rel(A[2*i], A_expected[2*i], dbleps, "zher(case 1417) real"); gsl_test_rel(A[2*i+1], A_expected[2*i+1], dbleps, "zher(case 1417) imag"); }; }; }; }