libflame  revision_anchor
Functions
bli_hemv.c File Reference

(r)

Functions

void bli_shemv (uplo_t uplo, conj_t conj, int m, float *alpha, float *a, int a_rs, int a_cs, float *x, int incx, float *beta, float *y, int incy)
void bli_dhemv (uplo_t uplo, conj_t conj, int m, double *alpha, double *a, int a_rs, int a_cs, double *x, int incx, double *beta, double *y, int incy)
void bli_chemv (uplo_t uplo, conj_t conj, int m, scomplex *alpha, scomplex *a, int a_rs, int a_cs, scomplex *x, int incx, scomplex *beta, scomplex *y, int incy)
void bli_zhemv (uplo_t uplo, conj_t conj, int m, dcomplex *alpha, dcomplex *a, int a_rs, int a_cs, dcomplex *x, int incx, dcomplex *beta, dcomplex *y, int incy)
void bli_chemv_blas (uplo_t uplo, int m, scomplex *alpha, scomplex *a, int lda, scomplex *x, int incx, scomplex *beta, scomplex *y, int incy)
void bli_zhemv_blas (uplo_t uplo, int m, dcomplex *alpha, dcomplex *a, int lda, dcomplex *x, int incx, dcomplex *beta, dcomplex *y, int incy)

Function Documentation

void bli_chemv ( uplo_t  uplo,
conj_t  conj,
int  m,
scomplex alpha,
scomplex a,
int  a_rs,
int  a_cs,
scomplex x,
int  incx,
scomplex beta,
scomplex y,
int  incy 
)

References bli_c0(), bli_c1(), bli_callocv(), bli_caxpyv(), bli_ccopyv(), bli_ccreate_contigmr(), bli_cfree(), bli_cfree_contigm(), bli_chemv_blas(), bli_cscalv(), bli_is_conj(), bli_is_row_storage(), bli_zero_dim1(), BLIS_CONJUGATE, and BLIS_NO_CONJUGATE.

Referenced by FLA_Eig_gest_il_opc_var1(), FLA_Eig_gest_il_opc_var2(), FLA_Eig_gest_iu_opc_var1(), FLA_Eig_gest_iu_opc_var2(), FLA_Eig_gest_nl_opc_var1(), FLA_Eig_gest_nl_opc_var2(), FLA_Eig_gest_nu_opc_var1(), FLA_Eig_gest_nu_opc_var2(), FLA_Hemv_external(), FLA_Hemvc_external(), FLA_Lyap_h_opc_var1(), FLA_Lyap_n_opc_var1(), FLA_Tridiag_UT_l_step_ofc_var2(), FLA_Tridiag_UT_l_step_ofc_var3(), FLA_Tridiag_UT_l_step_opc_var1(), FLA_Tridiag_UT_l_step_opc_var2(), and FLA_Tridiag_UT_l_step_opc_var3().

{
    scomplex* a_save    = a;
    int       a_rs_save = a_rs;
    int       a_cs_save = a_cs;
    scomplex  zero = bli_c0();
    scomplex  one  = bli_c1();
    scomplex* x_conj;
    scomplex* ax;
    int       lda, inca;
    int       incx_conj;
    int       incax;

    // Return early if possible.
    if ( bli_zero_dim1( m ) ) return;

    // If necessary, allocate, initialize, and use a temporary contiguous
    // copy of the matrix rather than the original matrix.
    bli_ccreate_contigmr( uplo,
                          m,
                          m,
                          a_save, a_rs_save, a_cs_save,
                          &a,     &a_rs,     &a_cs );

    // Initialize with values assuming column-major storage.
    lda  = a_cs;
    inca = a_rs;

    // If A is a row-major matrix, then we can use the underlying column-major
    // BLAS implementation by fiddling with the parameters.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
        bli_toggle_conj( conj );
    }

    // We want to handle the case where A is conjugated, but without
    // explicitly or conjugating A. To do so, we leverage the fact that
    // computing the product conj(A) * x is equivalent to computing
    // conj( A * conj(x) ).
    if ( bli_is_conj( conj ) )
    {
        // We need a temporary vector so we can create a conjugated copy of x.
        x_conj    = bli_callocv( m );
        incx_conj = 1;

        bli_ccopyv( BLIS_CONJUGATE,
                    m,
                    x,      incx,
                    x_conj, incx_conj );

        // We need a temporary vector for the product A * conj(x), which is
        // conformal to y (and x).
        ax    = bli_callocv( m );
        incax = 1;
        
        // Compute A * conj(x) where x is the temporary copy of x created above.
        bli_chemv_blas( uplo,
                        m,
                        &one,
                        a,      lda,
                        x_conj, incx_conj,
                        &zero,
                        ax,     incax );

        // Scale y by beta.
        bli_cscalv( BLIS_NO_CONJUGATE,
                    m,
                    beta,
                    y, incy );

        // And finally, accumulate alpha * conj( A * conj(x) ) into y.
        bli_caxpyv( BLIS_CONJUGATE,
                    m,
                    alpha,
                    ax, incax,
                    y,  incy);

        // Free the temporary vectors for x and Ax.
        bli_cfree( x_conj );
        bli_cfree( ax );
    }
    else // noconj
    {
        bli_chemv_blas( uplo,
                        m,
                        alpha,
                        a, lda,
                        x, incx,
                        beta,
                        y, incy );
    }

    // Free the temporary contiguous matrix.
    bli_cfree_contigm( a_save, a_rs_save, a_cs_save,
                       &a,     &a_rs,     &a_cs );
}
void bli_chemv_blas ( uplo_t  uplo,
int  m,
scomplex alpha,
scomplex a,
int  lda,
scomplex x,
int  incx,
scomplex beta,
scomplex y,
int  incy 
)

References bli_param_map_to_netlib_uplo(), cblas_chemv(), CblasColMajor, and F77_chemv().

Referenced by bli_chemv().

{
#ifdef BLIS_ENABLE_CBLAS_INTERFACES
    enum CBLAS_ORDER cblas_order = CblasColMajor;
    enum CBLAS_UPLO  cblas_uplo;

    bli_param_map_to_netlib_uplo( uplo, &cblas_uplo );

    cblas_chemv( cblas_order,
                 cblas_uplo,
                 m,
                 alpha,
                 a, lda,
                 x, incx,
                 beta,
                 y, incy );
#else
    char blas_uplo;

    bli_param_map_to_netlib_uplo( uplo, &blas_uplo );

    F77_chemv( &blas_uplo,
               &m,
               alpha,
               a, &lda,
               x, &incx,
               beta,
               y, &incy );
#endif
}
void bli_dhemv ( uplo_t  uplo,
conj_t  conj,
int  m,
double *  alpha,
double *  a,
int  a_rs,
int  a_cs,
double *  x,
int  incx,
double *  beta,
double *  y,
int  incy 
)
void bli_shemv ( uplo_t  uplo,
conj_t  conj,
int  m,
float *  alpha,
float *  a,
int  a_rs,
int  a_cs,
float *  x,
int  incx,
float *  beta,
float *  y,
int  incy 
)
void bli_zhemv ( uplo_t  uplo,
conj_t  conj,
int  m,
dcomplex alpha,
dcomplex a,
int  a_rs,
int  a_cs,
dcomplex x,
int  incx,
dcomplex beta,
dcomplex y,
int  incy 
)

References bli_is_conj(), bli_is_row_storage(), bli_z0(), bli_z1(), bli_zallocv(), bli_zaxpyv(), bli_zcopyv(), bli_zcreate_contigmr(), bli_zero_dim1(), bli_zfree(), bli_zfree_contigm(), bli_zhemv_blas(), bli_zscalv(), BLIS_CONJUGATE, and BLIS_NO_CONJUGATE.

Referenced by FLA_Eig_gest_il_opz_var1(), FLA_Eig_gest_il_opz_var2(), FLA_Eig_gest_iu_opz_var1(), FLA_Eig_gest_iu_opz_var2(), FLA_Eig_gest_nl_opz_var1(), FLA_Eig_gest_nl_opz_var2(), FLA_Eig_gest_nu_opz_var1(), FLA_Eig_gest_nu_opz_var2(), FLA_Hemv_external(), FLA_Hemvc_external(), FLA_Lyap_h_opz_var1(), FLA_Lyap_n_opz_var1(), FLA_Tridiag_UT_l_step_ofz_var2(), FLA_Tridiag_UT_l_step_ofz_var3(), FLA_Tridiag_UT_l_step_opz_var1(), FLA_Tridiag_UT_l_step_opz_var2(), and FLA_Tridiag_UT_l_step_opz_var3().

{
    dcomplex* a_save    = a;
    int       a_rs_save = a_rs;
    int       a_cs_save = a_cs;
    dcomplex  zero = bli_z0();
    dcomplex  one  = bli_z1();
    dcomplex* x_conj;
    dcomplex* ax;
    int       lda, inca;
    int       incx_conj;
    int       incax;

    // Return early if possible.
    if ( bli_zero_dim1( m ) ) return;

    // If necessary, allocate, initialize, and use a temporary contiguous
    // copy of the matrix rather than the original matrix.
    bli_zcreate_contigmr( uplo,
                          m,
                          m,
                          a_save, a_rs_save, a_cs_save,
                          &a,     &a_rs,     &a_cs );

    // Initialize with values assuming column-major storage.
    lda  = a_cs;
    inca = a_rs;

    // If A is a row-major matrix, then we can use the underlying column-major
    // BLAS implementation by fiddling with the parameters.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
        bli_toggle_conj( conj );
    }

    // We want to handle the case where A is conjugated, but without
    // explicitly or conjugating A. To do so, we leverage the fact that
    // computing the product conj(A) * x is equivalent to computing
    // conj( A * conj(x) ).
    if ( bli_is_conj( conj ) )
    {
        // We need a temporary vector so we can create a conjugated copy of x.
        x_conj    = bli_zallocv( m );
        incx_conj = 1;

        bli_zcopyv( BLIS_CONJUGATE,
                    m,
                    x,      incx,
                    x_conj, incx_conj );

        // We need a temporary vector for the product A * conj(x), which is
        // conformal to y (and x).
        ax    = bli_zallocv( m );
        incax = 1;
        
        // Compute A * conj(x) where x is the temporary copy of x created above.
        bli_zhemv_blas( uplo,
                        m,
                        &one,
                        a,      lda,
                        x_conj, incx_conj,
                        &zero,
                        ax,     incax );

        // Scale y by beta.
        bli_zscalv( BLIS_NO_CONJUGATE,
                    m,
                    beta,
                    y, incy );

        // And finally, accumulate alpha * conj( A * conj(x) ) into y.
        bli_zaxpyv( BLIS_CONJUGATE,
                    m,
                    alpha,
                    ax, incax,
                    y,  incy);

        // Free the temporary vectors for x and Ax.
        bli_zfree( x_conj );
        bli_zfree( ax );
    }
    else // noconj
    {
        bli_zhemv_blas( uplo,
                        m,
                        alpha,
                        a, lda,
                        x, incx,
                        beta,
                        y, incy );
    }

    // Free the temporary contiguous matrix.
    bli_zfree_contigm( a_save, a_rs_save, a_cs_save,
                       &a,     &a_rs,     &a_cs );
}
void bli_zhemv_blas ( uplo_t  uplo,
int  m,
dcomplex alpha,
dcomplex a,
int  lda,
dcomplex x,
int  incx,
dcomplex beta,
dcomplex y,
int  incy 
)

References bli_param_map_to_netlib_uplo(), cblas_zhemv(), CblasColMajor, and F77_zhemv().

Referenced by bli_zhemv().

{
#ifdef BLIS_ENABLE_CBLAS_INTERFACES
    enum CBLAS_ORDER cblas_order = CblasColMajor;
    enum CBLAS_UPLO  cblas_uplo;

    bli_param_map_to_netlib_uplo( uplo, &cblas_uplo );

    cblas_zhemv( cblas_order,
                 cblas_uplo,
                 m,
                 alpha,
                 a, lda,
                 x, incx,
                 beta,
                 y, incy );
#else
    char blas_uplo;

    bli_param_map_to_netlib_uplo( uplo, &blas_uplo );

    F77_zhemv( &blas_uplo,
               &m,
               alpha,
               a, &lda,
               x, &incx,
               beta,
               y, &incy );
#endif
}