libflame  revision_anchor
Functions
blis_prototypes_util.h File Reference

(r)

Go to the source code of this file.

Functions

float bli_s2 (void)
double bli_d2 (void)
scomplex bli_c2 (void)
dcomplex bli_z2 (void)
float bli_s1 (void)
double bli_d1 (void)
scomplex bli_c1 (void)
dcomplex bli_z1 (void)
float bli_s1h (void)
double bli_d1h (void)
scomplex bli_c1h (void)
dcomplex bli_z1h (void)
float bli_s0 (void)
double bli_d0 (void)
scomplex bli_c0 (void)
dcomplex bli_z0 (void)
float bli_sm1h (void)
double bli_dm1h (void)
scomplex bli_cm1h (void)
dcomplex bli_zm1h (void)
float bli_sm1 (void)
double bli_dm1 (void)
scomplex bli_cm1 (void)
dcomplex bli_zm1 (void)
float bli_sm2 (void)
double bli_dm2 (void)
scomplex bli_cm2 (void)
dcomplex bli_zm2 (void)
void * bli_vallocv (unsigned int n_elem, unsigned int elem_size)
int * bli_iallocv (unsigned int n_elem)
float * bli_sallocv (unsigned int n_elem)
double * bli_dallocv (unsigned int n_elem)
scomplexbli_callocv (unsigned int n_elem)
dcomplexbli_zallocv (unsigned int n_elem)
void * bli_vallocm (unsigned int m, unsigned int n, unsigned int elem_size)
int * bli_iallocm (unsigned int m, unsigned int n)
float * bli_sallocm (unsigned int m, unsigned int n)
double * bli_dallocm (unsigned int m, unsigned int n)
scomplexbli_callocm (unsigned int m, unsigned int n)
dcomplexbli_zallocm (unsigned int m, unsigned int n)
void bli_sapdiagmv (side_t side, conj_t conj, int m, int n, float *x, int incx, float *a, int a_rs, int a_cs)
void bli_dapdiagmv (side_t side, conj_t conj, int m, int n, double *x, int incx, double *a, int a_rs, int a_cs)
void bli_csapdiagmv (side_t side, conj_t conj, int m, int n, float *x, int incx, scomplex *a, int a_rs, int a_cs)
void bli_capdiagmv (side_t side, conj_t conj, int m, int n, scomplex *x, int incx, scomplex *a, int a_rs, int a_cs)
void bli_zdapdiagmv (side_t side, conj_t conj, int m, int n, double *x, int incx, dcomplex *a, int a_rs, int a_cs)
void bli_zapdiagmv (side_t side, conj_t conj, int m, int n, dcomplex *x, int incx, dcomplex *a, int a_rs, int a_cs)
void bli_screate_contigm (int m, int n, float *a_save, int a_rs_save, int a_cs_save, float **a, int *a_rs, int *a_cs)
void bli_dcreate_contigm (int m, int n, double *a_save, int a_rs_save, int a_cs_save, double **a, int *a_rs, int *a_cs)
void bli_ccreate_contigm (int m, int n, scomplex *a_save, int a_rs_save, int a_cs_save, scomplex **a, int *a_rs, int *a_cs)
void bli_zcreate_contigm (int m, int n, dcomplex *a_save, int a_rs_save, int a_cs_save, dcomplex **a, int *a_rs, int *a_cs)
void bli_screate_contigmt (trans_t trans_dims, int m, int n, float *a_save, int a_rs_save, int a_cs_save, float **a, int *a_rs, int *a_cs)
void bli_dcreate_contigmt (trans_t trans_dims, int m, int n, double *a_save, int a_rs_save, int a_cs_save, double **a, int *a_rs, int *a_cs)
void bli_ccreate_contigmt (trans_t trans_dims, int m, int n, scomplex *a_save, int a_rs_save, int a_cs_save, scomplex **a, int *a_rs, int *a_cs)
void bli_zcreate_contigmt (trans_t trans_dims, int m, int n, dcomplex *a_save, int a_rs_save, int a_cs_save, dcomplex **a, int *a_rs, int *a_cs)
void bli_screate_contigmr (uplo_t uplo, int m, int n, float *a_save, int a_rs_save, int a_cs_save, float **a, int *a_rs, int *a_cs)
void bli_dcreate_contigmr (uplo_t uplo, int m, int n, double *a_save, int a_rs_save, int a_cs_save, double **a, int *a_rs, int *a_cs)
void bli_ccreate_contigmr (uplo_t uplo, int m, int n, scomplex *a_save, int a_rs_save, int a_cs_save, scomplex **a, int *a_rs, int *a_cs)
void bli_zcreate_contigmr (uplo_t uplo, int m, int n, dcomplex *a_save, int a_rs_save, int a_cs_save, dcomplex **a, int *a_rs, int *a_cs)
void bli_screate_contigmsr (side_t side, uplo_t uplo, int m, int n, float *a_save, int a_rs_save, int a_cs_save, float **a, int *a_rs, int *a_cs)
void bli_dcreate_contigmsr (side_t side, uplo_t uplo, int m, int n, double *a_save, int a_rs_save, int a_cs_save, double **a, int *a_rs, int *a_cs)
void bli_ccreate_contigmsr (side_t side, uplo_t uplo, int m, int n, scomplex *a_save, int a_rs_save, int a_cs_save, scomplex **a, int *a_rs, int *a_cs)
void bli_zcreate_contigmsr (side_t side, uplo_t uplo, int m, int n, dcomplex *a_save, int a_rs_save, int a_cs_save, dcomplex **a, int *a_rs, int *a_cs)
void bli_sfree_contigm (float *a_save, int a_rs_save, int a_cs_save, float **a, int *a_rs, int *a_cs)
void bli_dfree_contigm (double *a_save, int a_rs_save, int a_cs_save, double **a, int *a_rs, int *a_cs)
void bli_cfree_contigm (scomplex *a_save, int a_rs_save, int a_cs_save, scomplex **a, int *a_rs, int *a_cs)
void bli_zfree_contigm (dcomplex *a_save, int a_rs_save, int a_cs_save, dcomplex **a, int *a_rs, int *a_cs)
void bli_sfree_saved_contigm (int m, int n, float *a_save, int a_rs_save, int a_cs_save, float **a, int *a_rs, int *a_cs)
void bli_dfree_saved_contigm (int m, int n, double *a_save, int a_rs_save, int a_cs_save, double **a, int *a_rs, int *a_cs)
void bli_cfree_saved_contigm (int m, int n, scomplex *a_save, int a_rs_save, int a_cs_save, scomplex **a, int *a_rs, int *a_cs)
void bli_zfree_saved_contigm (int m, int n, dcomplex *a_save, int a_rs_save, int a_cs_save, dcomplex **a, int *a_rs, int *a_cs)
void bli_sfree_saved_contigmr (uplo_t uplo, int m, int n, float *a_save, int a_rs_save, int a_cs_save, float **a, int *a_rs, int *a_cs)
void bli_dfree_saved_contigmr (uplo_t uplo, int m, int n, double *a_save, int a_rs_save, int a_cs_save, double **a, int *a_rs, int *a_cs)
void bli_cfree_saved_contigmr (uplo_t uplo, int m, int n, scomplex *a_save, int a_rs_save, int a_cs_save, scomplex **a, int *a_rs, int *a_cs)
void bli_zfree_saved_contigmr (uplo_t uplo, int m, int n, dcomplex *a_save, int a_rs_save, int a_cs_save, dcomplex **a, int *a_rs, int *a_cs)
void bli_sfree_saved_contigmsr (side_t side, uplo_t uplo, int m, int n, float *a_save, int a_rs_save, int a_cs_save, float **a, int *a_rs, int *a_cs)
void bli_dfree_saved_contigmsr (side_t side, uplo_t uplo, int m, int n, double *a_save, int a_rs_save, int a_cs_save, double **a, int *a_rs, int *a_cs)
void bli_cfree_saved_contigmsr (side_t side, uplo_t uplo, int m, int n, scomplex *a_save, int a_rs_save, int a_cs_save, scomplex **a, int *a_rs, int *a_cs)
void bli_zfree_saved_contigmsr (side_t side, uplo_t uplo, int m, int n, dcomplex *a_save, int a_rs_save, int a_cs_save, dcomplex **a, int *a_rs, int *a_cs)
void bli_sewinvscalv (conj_t conj, int n, float *x, int incx, float *y, int incy)
void bli_dewinvscalv (conj_t conj, int n, double *x, int incx, double *y, int incy)
void bli_csewinvscalv (conj_t conj, int n, float *x, int incx, scomplex *y, int incy)
void bli_cewinvscalv (conj_t conj, int n, scomplex *x, int incx, scomplex *y, int incy)
void bli_zdewinvscalv (conj_t conj, int n, double *x, int incx, dcomplex *y, int incy)
void bli_zewinvscalv (conj_t conj, int n, dcomplex *x, int incx, dcomplex *y, int incy)
void bli_sewinvscalmt (trans_t trans, int m, int n, float *a, int a_rs, int a_cs, float *b, int b_rs, int b_cs)
void bli_dewinvscalmt (trans_t trans, int m, int n, double *a, int a_rs, int a_cs, double *b, int b_rs, int b_cs)
void bli_csewinvscalmt (trans_t trans, int m, int n, float *a, int a_rs, int a_cs, scomplex *b, int b_rs, int b_cs)
void bli_cewinvscalmt (trans_t trans, int m, int n, scomplex *a, int a_rs, int a_cs, scomplex *b, int b_rs, int b_cs)
void bli_zdewinvscalmt (trans_t trans, int m, int n, double *a, int a_rs, int a_cs, dcomplex *b, int b_rs, int b_cs)
void bli_zewinvscalmt (trans_t trans, int m, int n, dcomplex *a, int a_rs, int a_cs, dcomplex *b, int b_rs, int b_cs)
void bli_sewscalv (conj_t conj, int n, float *x, int incx, float *y, int incy)
void bli_dewscalv (conj_t conj, int n, double *x, int incx, double *y, int incy)
void bli_csewscalv (conj_t conj, int n, float *x, int incx, scomplex *y, int incy)
void bli_cewscalv (conj_t conj, int n, scomplex *x, int incx, scomplex *y, int incy)
void bli_zdewscalv (conj_t conj, int n, double *x, int incx, dcomplex *y, int incy)
void bli_zewscalv (conj_t conj, int n, dcomplex *x, int incx, dcomplex *y, int incy)
void bli_sewscalmt (trans_t trans, int m, int n, float *a, int a_rs, int a_cs, float *b, int b_rs, int b_cs)
void bli_dewscalmt (trans_t trans, int m, int n, double *a, int a_rs, int a_cs, double *b, int b_rs, int b_cs)
void bli_csewscalmt (trans_t trans, int m, int n, float *a, int a_rs, int a_cs, scomplex *b, int b_rs, int b_cs)
void bli_cewscalmt (trans_t trans, int m, int n, scomplex *a, int a_rs, int a_cs, scomplex *b, int b_rs, int b_cs)
void bli_zdewscalmt (trans_t trans, int m, int n, double *a, int a_rs, int a_cs, dcomplex *b, int b_rs, int b_cs)
void bli_zewscalmt (trans_t trans, int m, int n, dcomplex *a, int a_rs, int a_cs, dcomplex *b, int b_rs, int b_cs)
void bli_vfree (void *p)
void bli_ifree (int *p)
void bli_sfree (float *p)
void bli_dfree (double *p)
void bli_cfree (scomplex *p)
void bli_zfree (dcomplex *p)
void bli_sinverts (conj_t conj, float *alpha)
void bli_dinverts (conj_t conj, double *alpha)
void bli_cinverts (conj_t conj, scomplex *alpha)
void bli_zinverts (conj_t conj, dcomplex *alpha)
void bli_sinvert2s (conj_t conj, float *alpha, float *beta)
void bli_dinvert2s (conj_t conj, double *alpha, double *beta)
void bli_cinvert2s (conj_t conj, scomplex *alpha, scomplex *beta)
void bli_zinvert2s (conj_t conj, dcomplex *alpha, dcomplex *beta)
void bli_sinvertv (conj_t conj, int n, float *x, int incx)
void bli_dinvertv (conj_t conj, int n, double *x, int incx)
void bli_cinvertv (conj_t conj, int n, scomplex *x, int incx)
void bli_zinvertv (conj_t conj, int n, dcomplex *x, int incx)
void bli_sident (int m, float *a, int a_rs, int a_cs)
void bli_dident (int m, double *a, int a_rs, int a_cs)
void bli_cident (int m, scomplex *a, int a_rs, int a_cs)
void bli_zident (int m, dcomplex *a, int a_rs, int a_cs)
void bli_smaxabsv (int n, float *x, int incx, float *maxabs)
void bli_dmaxabsv (int n, double *x, int incx, double *maxabs)
void bli_cmaxabsv (int n, scomplex *x, int incx, float *maxabs)
void bli_zmaxabsv (int n, dcomplex *x, int incx, double *maxabs)
void bli_smaxabsm (int m, int n, float *a, int a_rs, int a_cs, float *maxabs)
void bli_dmaxabsm (int m, int n, double *a, int a_rs, int a_cs, double *maxabs)
void bli_cmaxabsm (int m, int n, scomplex *a, int a_rs, int a_cs, float *maxabs)
void bli_zmaxabsm (int m, int n, dcomplex *a, int a_rs, int a_cs, double *maxabs)
void bli_smaxabsmr (uplo_t uplo, int m, int n, float *a, int a_rs, int a_cs, float *maxabs)
void bli_dmaxabsmr (uplo_t uplo, int m, int n, double *a, int a_rs, int a_cs, double *maxabs)
void bli_cmaxabsmr (uplo_t uplo, int m, int n, scomplex *a, int a_rs, int a_cs, float *maxabs)
void bli_zmaxabsmr (uplo_t uplo, int m, int n, dcomplex *a, int a_rs, int a_cs, double *maxabs)
void bli_srands (float *alpha)
void bli_drands (double *alpha)
void bli_crands (scomplex *alpha)
void bli_zrands (dcomplex *alpha)
void bli_srandv (int n, float *x, int incx)
void bli_drandv (int n, double *x, int incx)
void bli_crandv (int n, scomplex *x, int incx)
void bli_zrandv (int n, dcomplex *x, int incx)
void bli_srandm (int m, int n, float *a, int a_rs, int a_cs)
void bli_drandm (int m, int n, double *a, int a_rs, int a_cs)
void bli_crandm (int m, int n, scomplex *a, int a_rs, int a_cs)
void bli_zrandm (int m, int n, dcomplex *a, int a_rs, int a_cs)
void bli_srandmr (uplo_t uplo, diag_t diag, int m, int n, float *a, int a_rs, int a_cs)
void bli_drandmr (uplo_t uplo, diag_t diag, int m, int n, double *a, int a_rs, int a_cs)
void bli_crandmr (uplo_t uplo, diag_t diag, int m, int n, scomplex *a, int a_rs, int a_cs)
void bli_zrandmr (uplo_t uplo, diag_t diag, int m, int n, dcomplex *a, int a_rs, int a_cs)
void bli_set_contig_strides (int m, int n, int *rs, int *cs)
void bli_set_dim_with_side (side_t side, int m, int n, int *dim_new)
void bli_set_dims_with_trans (trans_t trans, int m, int n, int *m_new, int *n_new)
void bli_isetv (int m, int *sigma, int *x, int incx)
void bli_ssetv (int m, float *sigma, float *x, int incx)
void bli_dsetv (int m, double *sigma, double *x, int incx)
void bli_csetv (int m, scomplex *sigma, scomplex *x, int incx)
void bli_zsetv (int m, dcomplex *sigma, dcomplex *x, int incx)
void bli_isetm (int m, int n, int *sigma, int *a, int a_rs, int a_cs)
void bli_ssetm (int m, int n, float *sigma, float *a, int a_rs, int a_cs)
void bli_dsetm (int m, int n, double *sigma, double *a, int a_rs, int a_cs)
void bli_csetm (int m, int n, scomplex *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zsetm (int m, int n, dcomplex *sigma, dcomplex *a, int a_rs, int a_cs)
void bli_ssetmr (uplo_t uplo, int m, int n, float *sigma, float *a, int a_rs, int a_cs)
void bli_dsetmr (uplo_t uplo, int m, int n, double *sigma, double *a, int a_rs, int a_cs)
void bli_csetmr (uplo_t uplo, int m, int n, scomplex *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zsetmr (uplo_t uplo, int m, int n, dcomplex *sigma, dcomplex *a, int a_rs, int a_cs)
void bli_isetdiag (int offset, int m, int n, int *sigma, int *a, int a_rs, int a_cs)
void bli_ssetdiag (int offset, int m, int n, float *sigma, float *a, int a_rs, int a_cs)
void bli_dsetdiag (int offset, int m, int n, double *sigma, double *a, int a_rs, int a_cs)
void bli_csetdiag (int offset, int m, int n, scomplex *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zsetdiag (int offset, int m, int n, dcomplex *sigma, dcomplex *a, int a_rs, int a_cs)
void bli_sscalediag (conj_t conj, int offset, int m, int n, float *sigma, float *a, int a_rs, int a_cs)
void bli_dscalediag (conj_t conj, int offset, int m, int n, double *sigma, double *a, int a_rs, int a_cs)
void bli_cscalediag (conj_t conj, int offset, int m, int n, scomplex *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zscalediag (conj_t conj, int offset, int m, int n, dcomplex *sigma, dcomplex *a, int a_rs, int a_cs)
void bli_csscalediag (conj_t conj, int offset, int m, int n, float *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zdscalediag (conj_t conj, int offset, int m, int n, double *sigma, dcomplex *a, int a_rs, int a_cs)
void bli_sshiftdiag (conj_t conj, int offset, int m, int n, float *sigma, float *a, int a_rs, int a_cs)
void bli_dshiftdiag (conj_t conj, int offset, int m, int n, double *sigma, double *a, int a_rs, int a_cs)
void bli_cshiftdiag (conj_t conj, int offset, int m, int n, scomplex *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zshiftdiag (conj_t conj, int offset, int m, int n, dcomplex *sigma, dcomplex *a, int a_rs, int a_cs)
void bli_csshiftdiag (conj_t conj, int offset, int m, int n, float *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zdshiftdiag (conj_t conj, int offset, int m, int n, double *sigma, dcomplex *a, int a_rs, int a_cs)
void bli_ssymmize (conj_t conj, uplo_t uplo, int m, float *a, int a_rs, int a_cs)
void bli_dsymmize (conj_t conj, uplo_t uplo, int m, double *a, int a_rs, int a_cs)
void bli_csymmize (conj_t conj, uplo_t uplo, int m, scomplex *a, int a_rs, int a_cs)
void bli_zsymmize (conj_t conj, uplo_t uplo, int m, dcomplex *a, int a_rs, int a_cs)

Function Documentation

scomplex bli_c0 ( void  )
scomplex bli_c1 ( void  )
scomplex bli_c1h ( void  )

References bli_s0(), bli_s1h(), scomplex::imag, and scomplex::real.

{
    scomplex x;
    x.real = bli_s1h();
    x.imag = bli_s0();
    return x;
}
scomplex bli_c2 ( void  )

References bli_s0(), bli_s2(), scomplex::imag, and scomplex::real.

{
    scomplex x;
    x.real = bli_s2();
    x.imag = bli_s0();
    return x;
}
scomplex* bli_callocm ( unsigned int  m,
unsigned int  n 
)
scomplex* bli_callocv ( unsigned int  n_elem)
void bli_capdiagmv ( side_t  side,
conj_t  conj,
int  m,
int  n,
scomplex x,
int  incx,
scomplex a,
int  a_rs,
int  a_cs 
)

References bli_cewscalv(), bli_cscalv(), bli_is_left(), bli_is_row_storage(), and bli_zero_dim2().

Referenced by FLA_Apply_diag_matrix().

{
    scomplex* chi;
    scomplex* a_begin;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then we can proceed as if the
    // operation were transposed (applying the diagonal values in x from the
    // opposite side) for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
        bli_toggle_side( side );
    }

    if ( bli_is_left( side ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;

            bli_cewscalv( conj,
                          n_elem,
                          x,       incx,
                          a_begin, inca );
        }
    }
    else
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;
            chi     = x + j*incx;
    
            bli_cscalv( conj,
                        n_elem,
                        chi,
                        a_begin, inca );
        }
    }
}
void bli_ccreate_contigm ( int  m,
int  n,
scomplex a_save,
int  a_rs_save,
int  a_cs_save,
scomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_callocm(), bli_ccopymt(), bli_is_gen_storage(), bli_set_contig_strides(), and BLIS_NO_TRANSPOSE.

Referenced by bli_cgemm(), bli_cgemv(), bli_cger(), bli_chemm(), bli_csymm(), bli_ctrmm(), bli_ctrmmsx(), bli_ctrsm(), and bli_ctrsmsx().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;

/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/

        // Allocate temporary contiguous storage for the matrix.
        *a = bli_callocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_ccopymt( BLIS_NO_TRANSPOSE,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_ccreate_contigmr ( uplo_t  uplo,
int  m,
int  n,
scomplex a_save,
int  a_rs_save,
int  a_cs_save,
scomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_callocm(), bli_ccopymr(), bli_is_gen_storage(), and bli_set_contig_strides().

Referenced by bli_ccreate_contigmsr(), bli_chemm(), bli_chemv(), bli_cher(), bli_cher2(), bli_cher2k(), bli_cherk(), bli_csymm(), bli_csymv(), bli_csyr(), bli_csyr2(), bli_csyr2k(), bli_csyrk(), bli_ctrmm(), bli_ctrmmsx(), bli_ctrmv(), bli_ctrmvsx(), bli_ctrsm(), bli_ctrsmsx(), bli_ctrsv(), and bli_ctrsvsx().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;
/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/
        // Allocate temporary contiguous storage for the matrix.
        *a = bli_callocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_ccopymr( uplo,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_ccreate_contigmsr ( side_t  side,
uplo_t  uplo,
int  m,
int  n,
scomplex a_save,
int  a_rs_save,
int  a_cs_save,
scomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_ccreate_contigmr(), and bli_is_left().

{
    int dim_a;

    // Choose the dimension of the matrix based on the side parameter.
    if ( bli_is_left( side ) ) dim_a = m;
    else                       dim_a = n;

    // Call the simple version with chosen dimensions.
    bli_ccreate_contigmr( uplo,
                          dim_a,
                          dim_a,
                          a_save, a_rs_save, a_cs_save,
                          a,      a_rs,      a_cs );
}
void bli_ccreate_contigmt ( trans_t  trans_dims,
int  m,
int  n,
scomplex a_save,
int  a_rs_save,
int  a_cs_save,
scomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_callocm(), bli_ccopymt(), bli_does_trans(), bli_is_gen_storage(), bli_set_contig_strides(), and BLIS_NO_TRANSPOSE.

Referenced by bli_cgemm(), bli_cher2k(), bli_cherk(), bli_csyr2k(), and bli_csyrk().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Transpose the dimensions if requested.
        if ( bli_does_trans( trans_dims ) )
            bli_swap_ints( m, n );

        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;

/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/

        // Allocate temporary contiguous storage for the matrix.
        *a = bli_callocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_ccopymt( BLIS_NO_TRANSPOSE,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_cewinvscalmt ( trans_t  trans,
int  m,
int  n,
scomplex a,
int  a_rs,
int  a_cs,
scomplex b,
int  b_rs,
int  b_cs 
)

References bli_cewinvscalv(), bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_vector_dim(), bli_vector_inc(), bli_zero_dim2(), and BLIS_NO_TRANSPOSE.

Referenced by FLA_Inv_scal_elemwise().

{
    scomplex* a_begin;
    scomplex* b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewinvscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_cewinvscalv( conj,
                         n_elem,
                         a_begin, inca, 
                         b_begin, incb );
    }
}
void bli_cewinvscalv ( conj_t  conj,
int  n,
scomplex x,
int  incx,
scomplex y,
int  incy 
)

References bli_is_conj().

Referenced by bli_cewinvscalmt().

{
    scomplex* chi;
    scomplex* psi;
    scomplex  conjchi;
    int       i;

    if ( bli_is_conj( conj ) )
    {
        for ( i = 0; i < n; ++i )
        {
            chi = x + i*incx;
            psi = y + i*incy;

            bli_ccopyconj( chi, &conjchi );
            bli_cinvscals( &conjchi, psi );
        }
    }
    else
    {
        for ( i = 0; i < n; ++i )
        {
            chi = x + i*incx;
            psi = y + i*incy;
    
            bli_cinvscals( chi, psi );
        }
    }
}
void bli_cewscalmt ( trans_t  trans,
int  m,
int  n,
scomplex a,
int  a_rs,
int  a_cs,
scomplex b,
int  b_rs,
int  b_cs 
)

References bli_cewscalv(), bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_vector_dim(), bli_vector_inc(), bli_zero_dim2(), and BLIS_NO_TRANSPOSE.

Referenced by FLA_Scal_elemwise().

{
    scomplex* a_begin;
    scomplex* b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_cewscalv( conj,
                      n_elem,
                      a_begin, inca, 
                      b_begin, incb );
    }
}
void bli_cewscalv ( conj_t  conj,
int  n,
scomplex x,
int  incx,
scomplex y,
int  incy 
)

References bli_is_conj().

Referenced by bli_capdiagmv(), and bli_cewscalmt().

{
    scomplex* chi;
    scomplex* psi;
    scomplex  conjchi;
    int       i;

    if ( bli_is_conj( conj ) )
    {
        for ( i = 0; i < n; ++i )
        {
            chi = x + i*incx;
            psi = y + i*incy;

            bli_ccopyconj( chi, &conjchi );
            bli_cscals( &conjchi, psi );
        }
    }
    else
    {
        for ( i = 0; i < n; ++i )
        {
            chi = x + i*incx;
            psi = y + i*incy;
    
            bli_cscals( chi, psi );
        }
    }
}
void bli_cfree ( scomplex p)
void bli_cfree_contigm ( scomplex a_save,
int  a_rs_save,
int  a_cs_save,
scomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_cfree(), and bli_is_gen_storage().

Referenced by bli_cgemm(), bli_cgemv(), bli_chemm(), bli_chemv(), bli_cher2k(), bli_cherk(), bli_csymm(), bli_csymv(), bli_csyr2k(), bli_csyrk(), bli_ctrmm(), bli_ctrmmsx(), bli_ctrmv(), bli_ctrmvsx(), bli_ctrsm(), bli_ctrsmsx(), bli_ctrsv(), and bli_ctrsvsx().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Free the temporary contiguous storage for the matrix.
        bli_cfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_cfree_saved_contigm ( int  m,
int  n,
scomplex a_save,
int  a_rs_save,
int  a_cs_save,
scomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_ccopymt(), bli_cfree(), bli_is_gen_storage(), and BLIS_NO_TRANSPOSE.

Referenced by bli_cgemm(), bli_cger(), bli_chemm(), bli_cher(), bli_cher2(), bli_csymm(), bli_csyr(), bli_csyr2(), bli_ctrmm(), bli_ctrmmsx(), bli_ctrsm(), and bli_ctrsmsx().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_ccopymt( BLIS_NO_TRANSPOSE,
                     m,
                     n,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_cfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_cfree_saved_contigmr ( uplo_t  uplo,
int  m,
int  n,
scomplex a_save,
int  a_rs_save,
int  a_cs_save,
scomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_ccopymr(), bli_cfree(), and bli_is_gen_storage().

Referenced by bli_cher2k(), bli_cherk(), bli_csyr2k(), and bli_csyrk().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_ccopymr( uplo,
                     m,
                     n,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_cfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_cfree_saved_contigmsr ( side_t  side,
uplo_t  uplo,
int  m,
int  n,
scomplex a_save,
int  a_rs_save,
int  a_cs_save,
scomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_ccopymt(), bli_cfree(), bli_is_gen_storage(), and bli_is_left().

{
    int dim_a;

    // Choose the dimension of the matrix based on the side parameter.
    if ( bli_is_left( side ) ) dim_a = m;
    else                       dim_a = n;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_ccopymt( uplo,
                     dim_a,
                     dim_a,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_cfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_cident ( int  m,
scomplex a,
int  a_rs,
int  a_cs 
)

References scomplex::imag, and scomplex::real.

Referenced by FLA_UDdate_UT_opc_var1().

{
    scomplex* alpha;
    int       i, j;

    for ( j = 0; j < m; ++j )
    {
        for ( i = 0; i < m; ++i )
        {
            alpha = a + i*a_rs + j*a_cs;
    
            alpha->real = 0.0F;
            alpha->imag = 0.0F;

            if ( i == j )
                alpha->real = 1.0F;
        }
    }
}
void bli_cinvert2s ( conj_t  conj,
scomplex alpha,
scomplex beta 
)

References bli_is_conj(), scomplex::imag, and scomplex::real.

Referenced by bli_cinvscalm(), and bli_cinvscalv().

{
    float  one = 1.0F;
    float  temp;

    temp = one / ( alpha->real * alpha->real +
                   alpha->imag * alpha->imag );
    beta->real = alpha->real *  temp;
    beta->imag = alpha->imag * -temp;

    if ( bli_is_conj( conj ) )
        bli_cconjs( beta );
}
void bli_cinverts ( conj_t  conj,
scomplex alpha 
)

References bli_is_conj(), scomplex::imag, and scomplex::real.

Referenced by FLA_Trinv_ln_opc_var1(), FLA_Trinv_ln_opc_var2(), FLA_Trinv_ln_opc_var3(), FLA_Trinv_ln_opc_var4(), FLA_Trinv_un_opc_var1(), FLA_Trinv_un_opc_var2(), FLA_Trinv_un_opc_var3(), and FLA_Trinv_un_opc_var4().

{
    float  one = 1.0F;
    float  temp;

    temp = one / ( alpha->real * alpha->real +
                   alpha->imag * alpha->imag );
    alpha->real = alpha->real *  temp;
    alpha->imag = alpha->imag * -temp;

    if ( bli_is_conj( conj ) )
        bli_cconjs( alpha );
}
void bli_cinvertv ( conj_t  conj,
int  n,
scomplex x,
int  incx 
)

References bli_is_conj(), scomplex::imag, and scomplex::real.

Referenced by FLA_Invert().

{
    float     one = 1.0F;
    float     temp;
    float     conjsign;
    scomplex* chi;
    int       i;

    if ( bli_is_conj( conj ) ) conjsign =  one;
    else                       conjsign = -one;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        temp = one / ( chi->real * chi->real +
                       chi->imag * chi->imag );
        chi->real = chi->real *            temp;
        chi->imag = chi->imag * conjsign * temp;
    }
}
scomplex bli_cm1 ( void  )

References bli_s0(), bli_sm1(), scomplex::imag, and scomplex::real.

{
    scomplex x;
    x.real = bli_sm1();
    x.imag = bli_s0();
    return x;
}
scomplex bli_cm1h ( void  )

References bli_s0(), bli_sm1h(), scomplex::imag, and scomplex::real.

{
    scomplex x;
    x.real = bli_sm1h();
    x.imag = bli_s0();
    return x;
}
scomplex bli_cm2 ( void  )

References bli_s0(), bli_sm2(), scomplex::imag, and scomplex::real.

{
    scomplex x;
    x.real = bli_sm2();
    x.imag = bli_s0();
    return x;
}
void bli_cmaxabsm ( int  m,
int  n,
scomplex a,
int  a_rs,
int  a_cs,
float *  maxabs 
)

References bli_cmaxabsv(), bli_is_row_storage(), bli_s0(), and bli_zero_dim2().

Referenced by FLA_Max_abs_value().

{
    float     zero = bli_s0();
    scomplex* a_begin;
    float     maxabs_cand;
    float     maxabs_temp;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) { *maxabs = zero; return; }

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
    }

    // Initialize the maximum absolute value candidate to the first element.
    bli_csabsval2( a, &maxabs_cand );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;

        bli_cmaxabsv( n_elem,
                      a_begin, inca,
                      &maxabs_temp );

        if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
    }

    *maxabs = maxabs_cand;
}
void bli_cmaxabsmr ( uplo_t  uplo,
int  m,
int  n,
scomplex a,
int  a_rs,
int  a_cs,
float *  maxabs 
)

References bli_cmaxabsv(), bli_d0(), bli_is_row_storage(), bli_is_upper(), and bli_zero_dim2().

Referenced by FLA_Max_abs_value_herm().

{
    float     zero = bli_d0();
    scomplex* a_begin;
    float     maxabs_cand;
    float     maxabs_temp;
    int       inca, lda;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) { *maxabs = zero; return; }

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }

    // Initialize the maximum absolute value candidate to the first element.
    bli_csabsval2( a, &maxabs_cand );

    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j + 1, n_elem_max );
            a_begin = a + j*lda;

            bli_cmaxabsv( n_elem,
                          a_begin, inca,
                          &maxabs_temp );

            if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_max( 0, n_elem_max - j );
            a_begin = a + j*lda + j*inca;

            bli_cmaxabsv( n_elem,
                          a_begin, inca,
                          &maxabs_temp );

            if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
        }
    }

    *maxabs = maxabs_cand;
}
void bli_cmaxabsv ( int  n,
scomplex x,
int  incx,
float *  maxabs 
)

Referenced by bli_cmaxabsm(), and bli_cmaxabsmr().

{
    scomplex* chi;
    float     maxabs_cand;
    float     maxabs_temp;
    int       i;

    bli_csabsval2( x, &maxabs_cand );

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        bli_csabsval2( chi, &maxabs_temp );
        
        if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
    }

    *maxabs = maxabs_cand;
}
void bli_crandm ( int  m,
int  n,
scomplex a,
int  a_rs,
int  a_cs 
)

References bli_crandv(), bli_is_row_storage(), and bli_zero_dim2().

Referenced by FLA_Random_matrix().

{
    scomplex* a_begin;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
    }

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;

        bli_crandv( n_elem,
                    a_begin, inca );
    }
}
void bli_crandmr ( uplo_t  uplo,
diag_t  diag,
int  m,
int  n,
scomplex a,
int  a_rs,
int  a_cs 
)

References bli_c0(), bli_c1(), bli_cinvscalv(), bli_crands(), bli_crandv(), bli_csetv(), bli_is_nonunit_diag(), bli_is_row_storage(), bli_is_unit_diag(), bli_is_upper(), bli_is_zero_diag(), bli_zero_dim2(), BLIS_NO_CONJUGATE, and scomplex::real.

Referenced by FLA_Random_tri_matrix().

{
    scomplex* a_begin;
    scomplex* ajj;
    scomplex  one;
    scomplex  zero;
    scomplex  ord;
    int       lda, inca;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns to increase spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }

    // Initialize some scalars.
    one      = bli_c1();
    zero     = bli_c0();
    ord      = bli_c0();
    ord.real = ( float ) bli_max( m, n );

    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            // Randomize super-diagonal elements.
            bli_crandv( n_elem,
                        a_begin, inca );

            // Normalize super-diagonal elements by order of the matrix.
            bli_cinvscalv( BLIS_NO_CONJUGATE,
                           n_elem,
                           &ord,
                           a_begin, inca );

            // Initialize diagonal and sub-diagonal elements only if there are
            // elements left in the column (ie: j < n_elem_max).
            if ( j < n_elem_max )
            {
                ajj = a_begin + j*inca;

                // Initialize diagonal element.
                if      ( bli_is_unit_diag( diag ) )    *ajj = one;
                else if ( bli_is_zero_diag( diag ) )    *ajj = zero;
                else if ( bli_is_nonunit_diag( diag ) )
                {
                    // We want positive diagonal elements between 1 and 2.
                    bli_crands( ajj );
                    bli_cabsval2( ajj, ajj );
                    bli_cadd3( ajj, &one, ajj );
                }

                // Initialize sub-diagonal elements to zero.
                bli_csetv( n_elem_max - j - 1,
                           &zero,
                           ajj + inca, inca );
            }
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            // Initialize super-diagonal to zero.
            bli_csetv( n_elem,
                       &zero,
                       a_begin, inca );

            // Initialize diagonal and sub-diagonal elements only if there are
            // elements left in the column (ie: j < n_elem_max).
            if ( j < n_elem_max )
            {
                ajj = a_begin + j*inca;

                // Initialize diagonal element.
                if      ( bli_is_unit_diag( diag ) )    *ajj = one;
                else if ( bli_is_zero_diag( diag ) )    *ajj = zero;
                else if ( bli_is_nonunit_diag( diag ) )
                {
                    // We want positive diagonal elements between 1 and 2.
                    bli_crands( ajj );
                    bli_cabsval2( ajj, ajj );
                    bli_cadd3( ajj, &one, ajj );
                }

                // Randomize sub-diagonal elements.
                bli_crandv( n_elem_max - j - 1,
                            ajj + inca, inca );

                // Normalize sub-diagonal elements by order of the matrix.
                bli_cinvscalv( BLIS_NO_CONJUGATE,
                               n_elem_max - j - 1,
                               &ord,
                               ajj + inca, inca );

            }
        }
    }
}
void bli_crands ( scomplex alpha)

References bli_srands(), scomplex::imag, and scomplex::real.

Referenced by bli_crandmr(), and bli_crandv().

{
    bli_srands( &(alpha->real) );
    bli_srands( &(alpha->imag) );
}
void bli_crandv ( int  n,
scomplex x,
int  incx 
)

References bli_crands().

Referenced by bli_crandm(), and bli_crandmr().

{
    scomplex* chi;
    int       i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        bli_crands( chi );
    }
}
void bli_csapdiagmv ( side_t  side,
conj_t  conj,
int  m,
int  n,
float *  x,
int  incx,
scomplex a,
int  a_rs,
int  a_cs 
)

References bli_csewscalv(), bli_csscalv(), bli_is_left(), bli_is_row_storage(), and bli_zero_dim2().

Referenced by FLA_Apply_diag_matrix().

{
    float*    chi;
    scomplex* a_begin;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then we can proceed as if the
    // operation were transposed (applying the diagonal values in x from the
    // opposite side) for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
        bli_toggle_side( side );
    }

    if ( bli_is_left( side ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;

            bli_csewscalv( conj,
                           n_elem,
                           x,       incx,
                           a_begin, inca );
        }
    }
    else
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;
            chi     = x + j*incx;
    
            bli_csscalv( conj,
                         n_elem,
                         chi,
                         a_begin, inca );
        }
    }
}
void bli_cscalediag ( conj_t  conj,
int  offset,
int  m,
int  n,
scomplex sigma,
scomplex a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Scale_diag(), and FLA_UDdate_UT_opc_var1().

{
    scomplex* alpha;
    scomplex  sigma_conj;
    int       i, j;

    bli_ccopys( conj, sigma, &sigma_conj );

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        bli_cscals( &sigma_conj, alpha );

        ++i;
        ++j;
    }
}
void bli_csetdiag ( int  offset,
int  m,
int  n,
scomplex sigma,
scomplex a,
int  a_rs,
int  a_cs 
)

References scomplex::imag, and scomplex::real.

Referenced by FLA_Set_diag(), FLA_Set_offdiag(), and FLA_Triangularize().

{
    scomplex* alpha;
    int       i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        alpha->real = sigma->real;
        alpha->imag = sigma->imag;

        ++i;
        ++j;
    }
}
void bli_csetm ( int  m,
int  n,
scomplex sigma,
scomplex a,
int  a_rs,
int  a_cs 
)

References scomplex::imag, and scomplex::real.

Referenced by FLA_Bidiag_UT_u_step_ofc_var4(), FLA_Bidiag_UT_u_step_opc_var4(), FLA_Bidiag_UT_u_step_opc_var5(), FLA_Hess_UT_step_ofc_var4(), FLA_Hess_UT_step_opc_var4(), FLA_Hess_UT_step_opc_var5(), FLA_Set(), FLA_Tridiag_UT_l_step_ofc_var3(), and FLA_Tridiag_UT_l_step_opc_var3().

{
    scomplex* alpha;
    int       i, j;

    for ( j = 0; j < n; ++j )
    {
        for ( i = 0; i < m; ++i )
        {
            alpha = a + i*a_rs + j*a_cs;
    
            alpha->real = sigma->real;
            alpha->imag = sigma->imag;
        }
    }
}
void bli_csetmr ( uplo_t  uplo,
int  m,
int  n,
scomplex sigma,
scomplex a,
int  a_rs,
int  a_cs 
)

References bli_csetv(), bli_is_row_storage(), bli_is_upper(), and bli_zero_dim2().

Referenced by FLA_Setr(), and FLA_Triangularize().

{
    scomplex* a_begin;
    int       lda, inca;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns to increase spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }
    
    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            bli_csetv( n_elem,
                       sigma,
                       a_begin, inca );
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_max( 0, n_elem_max - j - 1 );
            a_begin = a + j*lda + (j + 1)*inca;

            bli_csetv( n_elem,
                       sigma,
                       a_begin, inca );
        }
    }
}
void bli_csetv ( int  m,
scomplex sigma,
scomplex x,
int  incx 
)
void bli_csewinvscalmt ( trans_t  trans,
int  m,
int  n,
float *  a,
int  a_rs,
int  a_cs,
scomplex b,
int  b_rs,
int  b_cs 
)

References bli_csewinvscalv(), bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_vector_dim(), bli_vector_inc(), bli_zero_dim2(), and BLIS_NO_TRANSPOSE.

{
    float*    a_begin;
    scomplex* b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewinvscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_csewinvscalv( conj,
                          n_elem,
                          a_begin, inca, 
                          b_begin, incb );
    }
}
void bli_csewinvscalv ( conj_t  conj,
int  n,
float *  x,
int  incx,
scomplex y,
int  incy 
)

Referenced by bli_csewinvscalmt().

{
    float*    chi;
    scomplex* psi;
    int       i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;
        psi = y + i*incy;

        bli_csinvscals( chi, psi );
    }
}
void bli_csewscalmt ( trans_t  trans,
int  m,
int  n,
float *  a,
int  a_rs,
int  a_cs,
scomplex b,
int  b_rs,
int  b_cs 
)

References bli_csewscalv(), bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_vector_dim(), bli_vector_inc(), bli_zero_dim2(), and BLIS_NO_TRANSPOSE.

{
    float*    a_begin;
    scomplex* b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_csewscalv( conj,
                       n_elem,
                       a_begin, inca, 
                       b_begin, incb );
    }
}
void bli_csewscalv ( conj_t  conj,
int  n,
float *  x,
int  incx,
scomplex y,
int  incy 
)

Referenced by bli_csapdiagmv(), and bli_csewscalmt().

{
    float*    chi;
    scomplex* psi;
    int       i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;
        psi = y + i*incy;

        bli_csscals( chi, psi );
    }
}
void bli_cshiftdiag ( conj_t  conj,
int  offset,
int  m,
int  n,
scomplex sigma,
scomplex a,
int  a_rs,
int  a_cs 
)

References scomplex::imag, and scomplex::real.

Referenced by FLA_Lyap_h_opc_var1(), FLA_Lyap_h_opc_var2(), FLA_Lyap_h_opc_var3(), FLA_Lyap_h_opc_var4(), FLA_Lyap_n_opc_var1(), FLA_Lyap_n_opc_var2(), FLA_Lyap_n_opc_var3(), FLA_Lyap_n_opc_var4(), and FLA_Shift_diag().

{
    scomplex* alpha;
    scomplex  sigma_conj;
    int       i, j;

    bli_ccopys( conj, sigma, &sigma_conj );

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        alpha->real += sigma_conj.real;
        alpha->imag += sigma_conj.imag;

        ++i;
        ++j;
    }
}
void bli_csscalediag ( conj_t  conj,
int  offset,
int  m,
int  n,
float *  sigma,
scomplex a,
int  a_rs,
int  a_cs 
)

References scomplex::imag, and scomplex::real.

Referenced by FLA_Scale_diag().

{
    scomplex* alpha;
    int       i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        alpha->real *= *sigma;
        alpha->imag *= *sigma;

        ++i;
        ++j;
    }
}
void bli_csshiftdiag ( conj_t  conj,
int  offset,
int  m,
int  n,
float *  sigma,
scomplex a,
int  a_rs,
int  a_cs 
)

References scomplex::real.

Referenced by FLA_Shift_diag().

{
    scomplex* alpha;
    int       i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        alpha->real += *sigma;

        ++i;
        ++j;
    }
}
void bli_csymmize ( conj_t  conj,
uplo_t  uplo,
int  m,
scomplex a,
int  a_rs,
int  a_cs 
)

References bli_ccopyv(), bli_is_col_storage(), bli_is_conj(), bli_is_gen_storage(), bli_is_lower(), bli_is_row_storage(), bli_is_upper(), bli_s0(), bli_zero_dim1(), and scomplex::imag.

Referenced by FLA_Hermitianize(), and FLA_Symmetrize().

{
    scomplex* a_src;
    scomplex* a_dst;
    scomplex* a_jj;
    int       rs_src, cs_src, inc_src;
    int       rs_dst, cs_dst, inc_dst;
    int       n_iter;
    int       j;

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

    // Assume A is square.
    n_iter = m;

    // Initialize with appropriate values based on storage.
    if      ( bli_is_col_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        cs_src  = 1;
        rs_src  = 0;
        inc_src = a_cs;
        cs_dst  = a_cs;
        rs_dst  = 0;
        inc_dst = 1;
    }
    else if ( bli_is_col_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        cs_src  = a_cs;
        rs_src  = 0;
        inc_src = 1;
        cs_dst  = 1;
        rs_dst  = 0;
        inc_dst = a_cs;
    }
    else if ( bli_is_row_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        cs_src  = 0;
        rs_src  = a_rs;
        inc_src = 1;
        cs_dst  = 0;
        rs_dst  = 1;
        inc_dst = a_rs;
    }
    else if ( bli_is_row_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        cs_src  = 0;
        rs_src  = 1;
        inc_src = a_rs;
        cs_dst  = 0;
        rs_dst  = a_rs;
        inc_dst = 1;
    }
    else if ( bli_is_gen_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        // General stride with column-major tilt looks similar to column-major.
        // General stride with row-major tilt looks similar to row-major.
        if ( a_rs < a_cs )
        {
            cs_src  = 1 * a_rs;
            rs_src  = 0;
            inc_src = a_cs;
            cs_dst  = a_cs;
            rs_dst  = 0;
            inc_dst = 1 * a_rs;
        }
        else // if ( a_rs > a_cs )
        {
            cs_src  = 0;
            rs_src  = a_rs;
            inc_src = 1 * a_cs;
            cs_dst  = 0;
            rs_dst  = 1 * a_cs;
            inc_dst = a_rs;
        }
    }
    else // if ( bli_is_gen_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        // General stride with column-major tilt looks similar to column-major.
        // General stride with row-major tilt looks similar to row-major.
        if ( a_rs < a_cs )
        {
            cs_src  = a_cs;
            rs_src  = 0;
            inc_src = 1 * a_rs;
            cs_dst  = 1 * a_rs;
            rs_dst  = 0;
            inc_dst = a_cs;
        }
        else // if ( a_rs > a_cs )
        {
            cs_src  = 0;
            rs_src  = 1 * a_cs;
            inc_src = a_rs;
            cs_dst  = 0;
            rs_dst  = a_rs;
            inc_dst = 1 * a_cs;
        }
    }
    
    for ( j = 0; j < n_iter; j++ )
    {
        a_src = a + j*cs_src + j*rs_src;
        a_dst = a + j*cs_dst + j*rs_dst;

        bli_ccopyv( conj,
                    j,
                    a_src, inc_src,
                    a_dst, inc_dst );

        if ( bli_is_conj( conj ) )
        {
            a_jj = a + j*a_rs + j*a_cs;
            a_jj->imag = bli_s0();
        }
    }
}
double bli_d0 ( void  )

Referenced by bli_cmaxabsmr(), bli_dgemm(), bli_dmaxabsm(), bli_dmaxabsmr(), bli_drandmr(), bli_dsymm(), bli_z0(), bli_z1(), bli_z1h(), bli_z2(), bli_zher2k(), bli_zherk(), bli_zm1(), bli_zm1h(), bli_zm2(), bli_zmaxabsm(), bli_zmaxabsmr(), bli_zsymmize(), FLA_Apply_G_rf_asd_var1(), FLA_Apply_G_rf_asd_var2(), FLA_Apply_G_rf_asd_var3(), FLA_Apply_G_rf_asd_var3b(), FLA_Apply_G_rf_asd_var6(), FLA_Apply_G_rf_asd_var6b(), FLA_Apply_G_rf_asd_var9(), FLA_Apply_G_rf_asd_var9b(), FLA_Apply_G_rf_asz_var1(), FLA_Apply_G_rf_asz_var2(), FLA_Apply_G_rf_asz_var3(), FLA_Apply_G_rf_asz_var6(), FLA_Apply_G_rf_asz_var9(), FLA_Apply_G_rf_opd_var1(), FLA_Apply_G_rf_opd_var2(), FLA_Apply_G_rf_opd_var3(), FLA_Apply_G_rf_opd_var6(), FLA_Apply_G_rf_opd_var9(), FLA_Apply_G_rf_opz_var1(), FLA_Apply_G_rf_opz_var2(), FLA_Apply_G_rf_opz_var3(), FLA_Apply_G_rf_opz_var6(), FLA_Apply_G_rf_opz_var9(), FLA_Bsvd_compute_tol_thresh_opd(), FLA_Bsvd_find_submatrix_opd(), FLA_Bsvd_v_opd_var1(), FLA_Bsvd_v_opd_var2(), FLA_Bsvd_v_opz_var1(), FLA_Bsvd_v_opz_var2(), FLA_Fused_Ahx_Ax_opd_var1(), FLA_Fused_Ahx_Axpy_Ax_opd_var1(), FLA_Fused_Gerc2_Ahx_Ax_opd_var1(), FLA_Fused_Gerc2_Ahx_Axpy_Ax_opd_var1(), FLA_Fused_Uhu_Yhu_Zhu_opd_var1(), FLA_Fused_UYx_ZVx_opd_var1(), FLA_Fused_UZhu_ZUhu_opd_var1(), FLA_Pythag2_opd(), FLA_Pythag3_opd(), FLA_Tevd_find_submatrix_opd(), FLA_Tevd_v_opd_var2(), FLA_Tevd_v_opd_var4(), FLA_Tevd_v_opz_var2(), FLA_Tevd_v_opz_var4(), and FLA_Tridiag_UT_shift_U_l_opd().

{
    double x;
    x = 0.0;
    return x;
}
double bli_d1 ( void  )
double bli_d1h ( void  )

Referenced by bli_z1h().

{
    double x;
    x = 0.5;
    return x;
}
double bli_d2 ( void  )

Referenced by bli_z2().

{
    double x;
    x = 2.0;
    return x;
}
double* bli_dallocm ( unsigned int  m,
unsigned int  n 
)

Referenced by bli_dcreate_contigm(), bli_dcreate_contigmr(), bli_dcreate_contigmt(), bli_dgemm(), bli_dsymm(), bli_dsyr2k(), bli_dtrmmsx(), and bli_dtrsmsx().

{
    return ( double* ) BLIS_MALLOC( m * n * sizeof( double ) );
}
double* bli_dallocv ( unsigned int  n_elem)

Referenced by bli_dtrmvsx(), and bli_dtrsvsx().

{
    return ( double* ) BLIS_MALLOC( n_elem * sizeof( double ) );
}
void bli_dapdiagmv ( side_t  side,
conj_t  conj,
int  m,
int  n,
double *  x,
int  incx,
double *  a,
int  a_rs,
int  a_cs 
)

References bli_dewscalv(), bli_dscalv(), bli_is_left(), bli_is_row_storage(), and bli_zero_dim2().

Referenced by FLA_Apply_diag_matrix().

{
    double*   chi;
    double*   a_begin;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then we can proceed as if the
    // operation were transposed (applying the diagonal values in x from the
    // opposite side) for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
        bli_toggle_side( side );
    }

    if ( bli_is_left( side ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;

            bli_dewscalv( conj,
                          n_elem,
                          x,       incx,
                          a_begin, inca );
        }
    }
    else
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;
            chi     = x + j*incx;
    
            bli_dscalv( conj,
                        n_elem,
                        chi,
                        a_begin, inca );
        }
    }
}
void bli_dcreate_contigm ( int  m,
int  n,
double *  a_save,
int  a_rs_save,
int  a_cs_save,
double **  a,
int *  a_rs,
int *  a_cs 
)

References bli_dallocm(), bli_dcopymt(), bli_is_gen_storage(), bli_set_contig_strides(), and BLIS_NO_TRANSPOSE.

Referenced by bli_dgemm(), bli_dgemv(), bli_dger(), bli_dsymm(), bli_dtrmm(), bli_dtrmmsx(), bli_dtrsm(), and bli_dtrsmsx().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;

/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/

        // Allocate temporary contiguous storage for the matrix.
        *a = bli_dallocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_dcopymt( BLIS_NO_TRANSPOSE,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_dcreate_contigmr ( uplo_t  uplo,
int  m,
int  n,
double *  a_save,
int  a_rs_save,
int  a_cs_save,
double **  a,
int *  a_rs,
int *  a_cs 
)

References bli_dallocm(), bli_dcopymr(), bli_is_gen_storage(), and bli_set_contig_strides().

Referenced by bli_dcreate_contigmsr(), bli_dsymm(), bli_dsymv(), bli_dsyr(), bli_dsyr2(), bli_dsyr2k(), bli_dsyrk(), bli_dtrmm(), bli_dtrmmsx(), bli_dtrmv(), bli_dtrmvsx(), bli_dtrsm(), bli_dtrsmsx(), bli_dtrsv(), and bli_dtrsvsx().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;
/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/
        // Allocate temporary contiguous storage for the matrix.
        *a = bli_dallocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_dcopymr( uplo,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_dcreate_contigmsr ( side_t  side,
uplo_t  uplo,
int  m,
int  n,
double *  a_save,
int  a_rs_save,
int  a_cs_save,
double **  a,
int *  a_rs,
int *  a_cs 
)

References bli_dcreate_contigmr(), and bli_is_left().

{
    int dim_a;

    // Choose the dimension of the matrix based on the side parameter.
    if ( bli_is_left( side ) ) dim_a = m;
    else                       dim_a = n;

    // Call the simple version with chosen dimensions.
    bli_dcreate_contigmr( uplo,
                          dim_a,
                          dim_a,
                          a_save, a_rs_save, a_cs_save,
                          a,      a_rs,      a_cs );
}
void bli_dcreate_contigmt ( trans_t  trans_dims,
int  m,
int  n,
double *  a_save,
int  a_rs_save,
int  a_cs_save,
double **  a,
int *  a_rs,
int *  a_cs 
)

References bli_dallocm(), bli_dcopymt(), bli_does_trans(), bli_is_gen_storage(), bli_set_contig_strides(), and BLIS_NO_TRANSPOSE.

Referenced by bli_dgemm(), bli_dsyr2k(), and bli_dsyrk().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Transpose the dimensions if requested.
        if ( bli_does_trans( trans_dims ) )
            bli_swap_ints( m, n );

        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;

/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/

        // Allocate temporary contiguous storage for the matrix.
        *a = bli_dallocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_dcopymt( BLIS_NO_TRANSPOSE,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_dewinvscalmt ( trans_t  trans,
int  m,
int  n,
double *  a,
int  a_rs,
int  a_cs,
double *  b,
int  b_rs,
int  b_cs 
)

References bli_dewinvscalv(), bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_vector_dim(), bli_vector_inc(), bli_zero_dim2(), and BLIS_NO_TRANSPOSE.

Referenced by FLA_Inv_scal_elemwise().

{
    double*   a_begin;
    double*   b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewinvscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_dewinvscalv( conj,
                         n_elem,
                         a_begin, inca, 
                         b_begin, incb );
    }
}
void bli_dewinvscalv ( conj_t  conj,
int  n,
double *  x,
int  incx,
double *  y,
int  incy 
)

Referenced by bli_dewinvscalmt().

{
    double*   chi;
    double*   psi;
    int       i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;
        psi = y + i*incy;

        bli_dinvscals( chi, psi );
    }
}
void bli_dewscalmt ( trans_t  trans,
int  m,
int  n,
double *  a,
int  a_rs,
int  a_cs,
double *  b,
int  b_rs,
int  b_cs 
)

References bli_dewscalv(), bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_vector_dim(), bli_vector_inc(), bli_zero_dim2(), and BLIS_NO_TRANSPOSE.

Referenced by FLA_Scal_elemwise().

{
    double*   a_begin;
    double*   b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_dewscalv( conj,
                      n_elem,
                      a_begin, inca, 
                      b_begin, incb );
    }
}
void bli_dewscalv ( conj_t  conj,
int  n,
double *  x,
int  incx,
double *  y,
int  incy 
)

Referenced by bli_dapdiagmv(), and bli_dewscalmt().

{
    double*   chi;
    double*   psi;
    int       i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;
        psi = y + i*incy;

        bli_dscals( chi, psi );
    }
}
void bli_dfree ( double *  p)
void bli_dfree_contigm ( double *  a_save,
int  a_rs_save,
int  a_cs_save,
double **  a,
int *  a_rs,
int *  a_cs 
)

References bli_dfree(), and bli_is_gen_storage().

Referenced by bli_dgemm(), bli_dgemv(), bli_dsymm(), bli_dsymv(), bli_dsyr2k(), bli_dsyrk(), bli_dtrmm(), bli_dtrmmsx(), bli_dtrmv(), bli_dtrmvsx(), bli_dtrsm(), bli_dtrsmsx(), bli_dtrsv(), and bli_dtrsvsx().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Free the temporary contiguous storage for the matrix.
        bli_dfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_dfree_saved_contigm ( int  m,
int  n,
double *  a_save,
int  a_rs_save,
int  a_cs_save,
double **  a,
int *  a_rs,
int *  a_cs 
)

References bli_dcopymt(), bli_dfree(), bli_is_gen_storage(), and BLIS_NO_TRANSPOSE.

Referenced by bli_dgemm(), bli_dger(), bli_dsymm(), bli_dsyr(), bli_dsyr2(), bli_dtrmm(), bli_dtrmmsx(), bli_dtrsm(), and bli_dtrsmsx().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_dcopymt( BLIS_NO_TRANSPOSE,
                     m,
                     n,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_dfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_dfree_saved_contigmr ( uplo_t  uplo,
int  m,
int  n,
double *  a_save,
int  a_rs_save,
int  a_cs_save,
double **  a,
int *  a_rs,
int *  a_cs 
)

References bli_dcopymr(), bli_dfree(), and bli_is_gen_storage().

Referenced by bli_dsyr2k(), and bli_dsyrk().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_dcopymr( uplo,
                     m,
                     n,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_dfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_dfree_saved_contigmsr ( side_t  side,
uplo_t  uplo,
int  m,
int  n,
double *  a_save,
int  a_rs_save,
int  a_cs_save,
double **  a,
int *  a_rs,
int *  a_cs 
)

References bli_dcopymt(), bli_dfree(), bli_is_gen_storage(), and bli_is_left().

{
    int dim_a;

    // Choose the dimension of the matrix based on the side parameter.
    if ( bli_is_left( side ) ) dim_a = m;
    else                       dim_a = n;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_dcopymt( uplo,
                     dim_a,
                     dim_a,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_dfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_dident ( int  m,
double *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Bsvd_v_opd_var2(), FLA_Bsvd_v_opz_var2(), FLA_Tevd_v_opd_var2(), FLA_Tevd_v_opd_var4(), FLA_Tevd_v_opz_var2(), FLA_Tevd_v_opz_var4(), and FLA_UDdate_UT_opd_var1().

{
    double* alpha;
    int     i, j;

    for ( j = 0; j < m; ++j )
    {
        for ( i = 0; i < m; ++i )
        {
            alpha = a + i*a_rs + j*a_cs;
    
            *alpha = 0.0;

            if ( i == j )
                *alpha = 1.0;
        }
    }
}
void bli_dinvert2s ( conj_t  conj,
double *  alpha,
double *  beta 
)

Referenced by bli_dinvscalm(), and bli_zdinvscalm().

{
    double one = 1.0;

    *beta = one / *alpha;
}
void bli_dinverts ( conj_t  conj,
double *  alpha 
)
void bli_dinvertv ( conj_t  conj,
int  n,
double *  x,
int  incx 
)

Referenced by FLA_Invert().

{
    double  one = 1.0;
    double* chi;
    int     i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        *chi = one / *chi;
    }
}
double bli_dm1 ( void  )
double bli_dm1h ( void  )

Referenced by bli_zm1h().

{
    double x;
    x = -0.5;
    return x;
}
double bli_dm2 ( void  )

Referenced by bli_zm2().

{
    double x;
    x = -2.0;
    return x;
}
void bli_dmaxabsm ( int  m,
int  n,
double *  a,
int  a_rs,
int  a_cs,
double *  maxabs 
)

References bli_d0(), bli_dmaxabsv(), bli_is_row_storage(), and bli_zero_dim2().

Referenced by FLA_Max_abs_value().

{
    double    zero = bli_d0();
    double*   a_begin;
    double    maxabs_cand;
    double    maxabs_temp;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) { *maxabs = zero; return; }

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
    }

    // Initialize the maximum absolute value candidate to the first element.
    bli_dabsval2( a, &maxabs_cand );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;

        bli_dmaxabsv( n_elem,
                      a_begin, inca,
                      &maxabs_temp );

        if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
    }

    *maxabs = maxabs_cand;
}
void bli_dmaxabsmr ( uplo_t  uplo,
int  m,
int  n,
double *  a,
int  a_rs,
int  a_cs,
double *  maxabs 
)

References bli_d0(), bli_dmaxabsv(), bli_is_row_storage(), bli_is_upper(), and bli_zero_dim2().

Referenced by FLA_Max_abs_value_herm().

{
    double    zero = bli_d0();
    double*   a_begin;
    double    maxabs_cand;
    double    maxabs_temp;
    int       inca, lda;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) { *maxabs = zero; return; }

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }

    // Initialize the maximum absolute value candidate to the first element.
    bli_dabsval2( a, &maxabs_cand );

    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j + 1, n_elem_max );
            a_begin = a + j*lda;

            bli_dmaxabsv( n_elem,
                          a_begin, inca,
                          &maxabs_temp );

            if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_max( 0, n_elem_max - j );
            a_begin = a + j*lda + j*inca;

            bli_dmaxabsv( n_elem,
                          a_begin, inca,
                          &maxabs_temp );

            if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
        }
    }

    *maxabs = maxabs_cand;
}
void bli_dmaxabsv ( int  n,
double *  x,
int  incx,
double *  maxabs 
)

Referenced by bli_dmaxabsm(), and bli_dmaxabsmr().

{
    double*   chi;
    double    maxabs_cand;
    double    maxabs_temp;
    int       i;

    bli_dabsval2( x, &maxabs_cand );

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        bli_dabsval2( chi, &maxabs_temp );
        
        if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
    }

    *maxabs = maxabs_cand;
}
void bli_drandm ( int  m,
int  n,
double *  a,
int  a_rs,
int  a_cs 
)

References bli_drandv(), bli_is_row_storage(), and bli_zero_dim2().

Referenced by FLA_Random_matrix().

{
    double*   a_begin;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
    }

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;

        bli_drandv( n_elem,
                    a_begin, inca );
    }
}
void bli_drandmr ( uplo_t  uplo,
diag_t  diag,
int  m,
int  n,
double *  a,
int  a_rs,
int  a_cs 
)

References bli_d0(), bli_d1(), bli_dinvscalv(), bli_drands(), bli_drandv(), bli_dsetv(), bli_is_nonunit_diag(), bli_is_row_storage(), bli_is_unit_diag(), bli_is_upper(), bli_is_zero_diag(), bli_zero_dim2(), and BLIS_NO_CONJUGATE.

Referenced by FLA_Random_tri_matrix().

{
    double*   a_begin;
    double*   ajj;
    double    one;
    double    zero;
    double    ord;
    int       lda, inca;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns to increase spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }

    // Initialize some scalars.
    one      = bli_d1();
    zero     = bli_d0();
    ord      = ( double ) bli_max( m, n );

    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            // Randomize super-diagonal elements.
            bli_drandv( n_elem,
                        a_begin, inca );

            // Normalize super-diagonal elements by order of the matrix.
            bli_dinvscalv( BLIS_NO_CONJUGATE,
                           n_elem,
                           &ord,
                           a_begin, inca );

            // Initialize diagonal and sub-diagonal elements only if there are
            // elements left in the column (ie: j < n_elem_max).
            if ( j < n_elem_max )
            {
                ajj = a_begin + j*inca;

                // Initialize diagonal element.
                if      ( bli_is_unit_diag( diag ) )    *ajj = one;
                else if ( bli_is_zero_diag( diag ) )    *ajj = zero;
                else if ( bli_is_nonunit_diag( diag ) )
                {
                    // We want positive diagonal elements between 1 and 2.
                    bli_drands( ajj );
                    bli_dabsval2( ajj, ajj );
                    bli_dadd3( ajj, &one, ajj );
                }

                // Initialize sub-diagonal elements to zero.
                bli_dsetv( n_elem_max - j - 1,
                           &zero,
                           ajj + inca, inca );
            }
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            // Initialize super-diagonal to zero.
            bli_dsetv( n_elem,
                       &zero,
                       a_begin, inca );

            // Initialize diagonal and sub-diagonal elements only if there are
            // elements left in the column (ie: j < n_elem_max).
            if ( j < n_elem_max )
            {
                ajj = a_begin + j*inca;

                // Initialize diagonal element.
                if      ( bli_is_unit_diag( diag ) )    *ajj = one;
                else if ( bli_is_zero_diag( diag ) )    *ajj = zero;
                else if ( bli_is_nonunit_diag( diag ) )
                {
                    // We want positive diagonal elements between 1 and 2.
                    bli_drands( ajj );
                    bli_dabsval2( ajj, ajj );
                    bli_dadd3( ajj, &one, ajj );
                }

                // Randomize sub-diagonal elements.
                bli_drandv( n_elem_max - j - 1,
                            ajj + inca, inca );

                // Normalize sub-diagonal elements by order of the matrix.
                bli_dinvscalv( BLIS_NO_CONJUGATE,
                               n_elem_max - j - 1,
                               &ord,
                               ajj + inca, inca );

            }
        }
    }
}
void bli_drands ( double *  alpha)

Referenced by bli_drandmr(), bli_drandv(), and bli_zrands().

{
    *alpha = ( ( double ) rand() / ( ( double ) RAND_MAX / 2.0 ) ) - 1.0;
}
void bli_drandv ( int  n,
double *  x,
int  incx 
)

References bli_drands().

Referenced by bli_drandm(), and bli_drandmr().

{
    double* chi;
    int     i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        bli_drands( chi );
    }
}
void bli_dscalediag ( conj_t  conj,
int  offset,
int  m,
int  n,
double *  sigma,
double *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Scale_diag(), and FLA_UDdate_UT_opd_var1().

{
    double* alpha;
    int     i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        *alpha *= *sigma;

        ++i;
        ++j;
    }
}
void bli_dsetdiag ( int  offset,
int  m,
int  n,
double *  sigma,
double *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Set_diag(), FLA_Set_offdiag(), and FLA_Triangularize().

{
    double* alpha;
    int     i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        *alpha = *sigma;

        ++i;
        ++j;
    }
}
void bli_dsetm ( int  m,
int  n,
double *  sigma,
double *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Bidiag_UT_u_step_ofd_var4(), FLA_Bidiag_UT_u_step_opd_var4(), FLA_Bidiag_UT_u_step_opd_var5(), FLA_Hess_UT_step_ofd_var4(), FLA_Hess_UT_step_opd_var4(), FLA_Hess_UT_step_opd_var5(), FLA_Set(), FLA_Tridiag_UT_l_step_ofd_var3(), and FLA_Tridiag_UT_l_step_opd_var3().

{
    double* alpha;
    int     i, j;

    for ( j = 0; j < n; ++j )
    {
        for ( i = 0; i < m; ++i )
        {
            alpha = a + i*a_rs + j*a_cs;
    
            *alpha = *sigma;
        }
    }
}
void bli_dsetmr ( uplo_t  uplo,
int  m,
int  n,
double *  sigma,
double *  a,
int  a_rs,
int  a_cs 
)

References bli_dsetv(), bli_is_row_storage(), bli_is_upper(), and bli_zero_dim2().

Referenced by FLA_Setr(), and FLA_Triangularize().

{
    double*   a_begin;
    int       lda, inca;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns to increase spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }
    
    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            bli_dsetv( n_elem,
                       sigma,
                       a_begin, inca );
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_max( 0, n_elem_max - j - 1 );
            a_begin = a + j*lda + (j + 1)*inca;

            bli_dsetv( n_elem,
                       sigma,
                       a_begin, inca );
        }
    }
}
void bli_dsetv ( int  m,
double *  sigma,
double *  x,
int  incx 
)
void bli_dshiftdiag ( conj_t  conj,
int  offset,
int  m,
int  n,
double *  sigma,
double *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Lyap_h_opd_var1(), FLA_Lyap_h_opd_var2(), FLA_Lyap_h_opd_var3(), FLA_Lyap_h_opd_var4(), FLA_Lyap_n_opd_var1(), FLA_Lyap_n_opd_var2(), FLA_Lyap_n_opd_var3(), FLA_Lyap_n_opd_var4(), and FLA_Shift_diag().

{
    double* alpha;
    int     i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        *alpha += *sigma;

        ++i;
        ++j;
    }
}
void bli_dsymmize ( conj_t  conj,
uplo_t  uplo,
int  m,
double *  a,
int  a_rs,
int  a_cs 
)

References bli_dcopyv(), bli_is_col_storage(), bli_is_gen_storage(), bli_is_lower(), bli_is_row_storage(), bli_is_upper(), and bli_zero_dim1().

Referenced by FLA_Hermitianize(), and FLA_Symmetrize().

{
    double*   a_src;
    double*   a_dst;
    int       rs_src, cs_src, inc_src;
    int       rs_dst, cs_dst, inc_dst;
    int       n_iter;
    int       j;

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

    // Assume A is square.
    n_iter = m;

    // Initialize with appropriate values based on storage.
    if      ( bli_is_col_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        cs_src  = 1;
        rs_src  = 0;
        inc_src = a_cs;
        cs_dst  = a_cs;
        rs_dst  = 0;
        inc_dst = 1;
    }
    else if ( bli_is_col_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        cs_src  = a_cs;
        rs_src  = 0;
        inc_src = 1;
        cs_dst  = 1;
        rs_dst  = 0;
        inc_dst = a_cs;
    }
    else if ( bli_is_row_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        cs_src  = 0;
        rs_src  = a_rs;
        inc_src = 1;
        cs_dst  = 0;
        rs_dst  = 1;
        inc_dst = a_rs;
    }
    else if ( bli_is_row_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        cs_src  = 0;
        rs_src  = 1;
        inc_src = a_rs;
        cs_dst  = 0;
        rs_dst  = a_rs;
        inc_dst = 1;
    }
    else if ( bli_is_gen_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        // General stride with column-major tilt looks similar to column-major.
        // General stride with row-major tilt looks similar to row-major.
        if ( a_rs < a_cs )
        {
            cs_src  = 1 * a_rs;
            rs_src  = 0;
            inc_src = a_cs;
            cs_dst  = a_cs;
            rs_dst  = 0;
            inc_dst = 1 * a_rs;
        }
        else // if ( a_rs > a_cs )
        {
            cs_src  = 0;
            rs_src  = a_rs;
            inc_src = 1 * a_cs;
            cs_dst  = 0;
            rs_dst  = 1 * a_cs;
            inc_dst = a_rs;
        }
    }
    else // if ( bli_is_gen_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        // General stride with column-major tilt looks similar to column-major.
        // General stride with row-major tilt looks similar to row-major.
        if ( a_rs < a_cs )
        {
            cs_src  = a_cs;
            rs_src  = 0;
            inc_src = 1 * a_rs;
            cs_dst  = 1 * a_rs;
            rs_dst  = 0;
            inc_dst = a_cs;
        }
        else // if ( a_rs > a_cs )
        {
            cs_src  = 0;
            rs_src  = 1 * a_cs;
            inc_src = a_rs;
            cs_dst  = 0;
            rs_dst  = a_rs;
            inc_dst = 1 * a_cs;
        }
    }
    
    for ( j = 0; j < n_iter; j++ )
    {
        a_src = a + j*cs_src + j*rs_src;
        a_dst = a + j*cs_dst + j*rs_dst;

        bli_dcopyv( conj,
                    j,
                    a_src, inc_src,
                    a_dst, inc_dst );
    }
}
int* bli_iallocm ( unsigned int  m,
unsigned int  n 
)
{
    return ( int* ) BLIS_MALLOC( m * n * sizeof( int ) );
}
int* bli_iallocv ( unsigned int  n_elem)
{
    return ( int*   ) BLIS_MALLOC( n_elem * sizeof( int ) );
}
void bli_ifree ( int *  p)
{
    free( ( int* ) p );
}
void bli_isetdiag ( int  offset,
int  m,
int  n,
int *  sigma,
int *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Set_diag(), and FLA_Set_offdiag().

{
    int*   alpha;
    int    i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        *alpha = *sigma;

        ++i;
        ++j;
    }
}
void bli_isetm ( int  m,
int  n,
int *  sigma,
int *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Set().

{
    int*   alpha;
    int    i, j;

    for ( j = 0; j < n; ++j )
    {
        for ( i = 0; i < m; ++i )
        {
            alpha = a + i*a_rs + j*a_cs;
    
            *alpha = *sigma;
        }
    }
}
void bli_isetv ( int  m,
int *  sigma,
int *  x,
int  incx 
)
{
    int*   chi;
    int    i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        *chi = *sigma;
    }
}
float bli_s0 ( void  )
float bli_s1 ( void  )
float bli_s1h ( void  )

Referenced by bli_c1h().

{
    float x;
    x = 0.5F;
    return x;
}
float bli_s2 ( void  )

Referenced by bli_c2().

{
    float x;
    x = 2.0F;
    return x;
}
float* bli_sallocm ( unsigned int  m,
unsigned int  n 
)

Referenced by bli_screate_contigm(), bli_screate_contigmr(), bli_screate_contigmt(), bli_sgemm(), bli_ssymm(), bli_ssyr2k(), bli_strmmsx(), and bli_strsmsx().

{
    return ( float* ) BLIS_MALLOC( m * n * sizeof( float ) );
}
float* bli_sallocv ( unsigned int  n_elem)

Referenced by bli_strmvsx(), and bli_strsvsx().

{
    return ( float* ) BLIS_MALLOC( n_elem * sizeof( float ) );
}
void bli_sapdiagmv ( side_t  side,
conj_t  conj,
int  m,
int  n,
float *  x,
int  incx,
float *  a,
int  a_rs,
int  a_cs 
)

References bli_is_left(), bli_is_row_storage(), bli_sewscalv(), bli_sscalv(), and bli_zero_dim2().

Referenced by FLA_Apply_diag_matrix().

{
    float*    chi;
    float*    a_begin;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then we can proceed as if the
    // operation were transposed (applying the diagonal values in x from the
    // opposite side) for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
        bli_toggle_side( side );
    }

    if ( bli_is_left( side ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;

            bli_sewscalv( conj,
                          n_elem,
                          x,       incx,
                          a_begin, inca );
        }
    }
    else
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;
            chi     = x + j*incx;
    
            bli_sscalv( conj,
                        n_elem,
                        chi,
                        a_begin, inca );
        }
    }
}
void bli_screate_contigm ( int  m,
int  n,
float *  a_save,
int  a_rs_save,
int  a_cs_save,
float **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), bli_sallocm(), bli_scopymt(), bli_set_contig_strides(), and BLIS_NO_TRANSPOSE.

Referenced by bli_sgemm(), bli_sgemv(), bli_sger(), bli_ssymm(), bli_strmm(), bli_strmmsx(), bli_strsm(), and bli_strsmsx().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;

/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/

        // Allocate temporary contiguous storage for the matrix.
        *a = bli_sallocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_scopymt( BLIS_NO_TRANSPOSE,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_screate_contigmr ( uplo_t  uplo,
int  m,
int  n,
float *  a_save,
int  a_rs_save,
int  a_cs_save,
float **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), bli_sallocm(), bli_scopymr(), and bli_set_contig_strides().

Referenced by bli_screate_contigmsr(), bli_ssymm(), bli_ssymv(), bli_ssyr(), bli_ssyr2(), bli_ssyr2k(), bli_ssyrk(), bli_strmm(), bli_strmmsx(), bli_strmv(), bli_strmvsx(), bli_strsm(), bli_strsmsx(), bli_strsv(), and bli_strsvsx().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;
/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/
        // Allocate temporary contiguous storage for the matrix.
        *a = bli_sallocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_scopymr( uplo,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_screate_contigmsr ( side_t  side,
uplo_t  uplo,
int  m,
int  n,
float *  a_save,
int  a_rs_save,
int  a_cs_save,
float **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_left(), and bli_screate_contigmr().

{
    int dim_a;

    // Choose the dimension of the matrix based on the side parameter.
    if ( bli_is_left( side ) ) dim_a = m;
    else                       dim_a = n;

    // Call the simple version with chosen dimensions.
    bli_screate_contigmr( uplo,
                          dim_a,
                          dim_a,
                          a_save, a_rs_save, a_cs_save,
                          a,      a_rs,      a_cs );
}
void bli_screate_contigmt ( trans_t  trans_dims,
int  m,
int  n,
float *  a_save,
int  a_rs_save,
int  a_cs_save,
float **  a,
int *  a_rs,
int *  a_cs 
)

References bli_does_trans(), bli_is_gen_storage(), bli_sallocm(), bli_scopymt(), bli_set_contig_strides(), and BLIS_NO_TRANSPOSE.

Referenced by bli_sgemm(), bli_ssyr2k(), and bli_ssyrk().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Transpose the dimensions if requested.
        if ( bli_does_trans( trans_dims ) )
            bli_swap_ints( m, n );

        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;

/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/

        // Allocate temporary contiguous storage for the matrix.
        *a = bli_sallocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_scopymt( BLIS_NO_TRANSPOSE,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_set_contig_strides ( int  m,
int  n,
int *  rs,
int *  cs 
)

Referenced by bli_ccreate_contigm(), bli_ccreate_contigmr(), bli_ccreate_contigmt(), bli_dcreate_contigm(), bli_dcreate_contigmr(), bli_dcreate_contigmt(), bli_screate_contigm(), bli_screate_contigmr(), bli_screate_contigmt(), bli_zcreate_contigm(), bli_zcreate_contigmr(), and bli_zcreate_contigmt().

{
    // Default to column-major order.
    *rs = 1;
    *cs = m;

    // Handle special cases first.
    // Check the strides, and modify them if needed.
    if ( *rs == 1 && *cs == 1 )
    {
        // If both strides are unit, we are probably trying to create a
        // 1-by-n matrix in column-major order, or an m-by-1 matrix in
        // row-major order. We have decided to "reserve" the case where
        // rs == cs == 1 for scalars only, as having unit strides can
        // upset the BLAS error checking when attempting to induce a
        // row-major operation.
        if ( m > 1 && n == 1 )
        {
            // Set the column stride to indicate that this is an m-by-1
            // matrix (or vector) stored in column-major order. This is
            // necessary because, in some cases, we have to satisfy error
            // checking in the underlying BLAS library, which expects the
            // leading dimension to be set to at least m, even if it will
            // never be used for indexing since there is only one column
            // of data. Note that rs is already set to 1.
            *cs = m;
        }
        else if ( m == 1 && 1 < n )
        {
            // Set the row stride to indicate that this is a 1-by-n matrix
            // stored in row-major order. Note that cs is already set to 1.
            *rs = n;
        }
        else
        {
            // If m == n == 1, then we are dealing with a scalar. Since rs
            // and cs do not exceed m and n, we don't have to do anything.
        }
    }
}
void bli_set_dim_with_side ( side_t  side,
int  m,
int  n,
int *  dim_new 
)
void bli_set_dims_with_trans ( trans_t  trans,
int  m,
int  n,
int *  m_new,
int *  n_new 
)

References bli_does_trans().

Referenced by bli_cher2k(), bli_csyr2k(), bli_dsyr2k(), bli_ssyr2k(), bli_zher2k(), and bli_zsyr2k().

{
    if ( bli_does_trans( trans ) )
    {
        *m_new = n;
        *n_new = m;
    }
    else
    {
        *m_new = m;
        *n_new = n;
    }
}
void bli_sewinvscalmt ( trans_t  trans,
int  m,
int  n,
float *  a,
int  a_rs,
int  a_cs,
float *  b,
int  b_rs,
int  b_cs 
)

References bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_sewinvscalv(), bli_vector_dim(), bli_vector_inc(), bli_zero_dim2(), and BLIS_NO_TRANSPOSE.

Referenced by FLA_Inv_scal_elemwise().

{
    float*    a_begin;
    float*    b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewinvscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_sewinvscalv( conj,
                         n_elem,
                         a_begin, inca, 
                         b_begin, incb );
    }
}
void bli_sewinvscalv ( conj_t  conj,
int  n,
float *  x,
int  incx,
float *  y,
int  incy 
)

Referenced by bli_sewinvscalmt().

{
    float*    chi;
    float*    psi;
    int       i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;
        psi = y + i*incy;

        bli_sinvscals( chi, psi );
    }
}
void bli_sewscalmt ( trans_t  trans,
int  m,
int  n,
float *  a,
int  a_rs,
int  a_cs,
float *  b,
int  b_rs,
int  b_cs 
)

References bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_sewscalv(), bli_vector_dim(), bli_vector_inc(), bli_zero_dim2(), and BLIS_NO_TRANSPOSE.

Referenced by FLA_Scal_elemwise().

{
    float*    a_begin;
    float*    b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_sewscalv( conj,
                      n_elem,
                      a_begin, inca, 
                      b_begin, incb );
    }
}
void bli_sewscalv ( conj_t  conj,
int  n,
float *  x,
int  incx,
float *  y,
int  incy 
)

Referenced by bli_sapdiagmv(), and bli_sewscalmt().

{
    float*    chi;
    float*    psi;
    int       i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;
        psi = y + i*incy;

        bli_sscals( chi, psi );
    }
}
void bli_sfree ( float *  p)
void bli_sfree_contigm ( float *  a_save,
int  a_rs_save,
int  a_cs_save,
float **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), and bli_sfree().

Referenced by bli_sgemm(), bli_sgemv(), bli_ssymm(), bli_ssymv(), bli_ssyr2k(), bli_ssyrk(), bli_strmm(), bli_strmmsx(), bli_strmv(), bli_strmvsx(), bli_strsm(), bli_strsmsx(), bli_strsv(), and bli_strsvsx().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Free the temporary contiguous storage for the matrix.
        bli_sfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_sfree_saved_contigm ( int  m,
int  n,
float *  a_save,
int  a_rs_save,
int  a_cs_save,
float **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), bli_scopymt(), bli_sfree(), and BLIS_NO_TRANSPOSE.

Referenced by bli_sgemm(), bli_sger(), bli_ssymm(), bli_ssyr(), bli_ssyr2(), bli_strmm(), bli_strmmsx(), bli_strsm(), and bli_strsmsx().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_scopymt( BLIS_NO_TRANSPOSE,
                     m,
                     n,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_sfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_sfree_saved_contigmr ( uplo_t  uplo,
int  m,
int  n,
float *  a_save,
int  a_rs_save,
int  a_cs_save,
float **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), bli_scopymr(), and bli_sfree().

Referenced by bli_ssyr2k(), and bli_ssyrk().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_scopymr( uplo,
                     m,
                     n,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_sfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_sfree_saved_contigmsr ( side_t  side,
uplo_t  uplo,
int  m,
int  n,
float *  a_save,
int  a_rs_save,
int  a_cs_save,
float **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), bli_is_left(), bli_scopymt(), and bli_sfree().

{
    int dim_a;

    // Choose the dimension of the matrix based on the side parameter.
    if ( bli_is_left( side ) ) dim_a = m;
    else                       dim_a = n;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_scopymt( uplo,
                     dim_a,
                     dim_a,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_sfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_sident ( int  m,
float *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_UDdate_UT_ops_var1().

{
    float* alpha;
    int    i, j;

    for ( j = 0; j < m; ++j )
    {
        for ( i = 0; i < m; ++i )
        {
            alpha = a + i*a_rs + j*a_cs;
    
            *alpha = 0.0F;

            if ( i == j )
                *alpha = 1.0F;
        }
    }
}
void bli_sinvert2s ( conj_t  conj,
float *  alpha,
float *  beta 
)

Referenced by bli_csinvscalm(), and bli_sinvscalm().

{
    float  one = 1.0F;

    *beta = one / *alpha;
}
void bli_sinverts ( conj_t  conj,
float *  alpha 
)
void bli_sinvertv ( conj_t  conj,
int  n,
float *  x,
int  incx 
)

Referenced by FLA_Invert().

{
    float  one = 1.0F;
    float* chi;
    int    i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        *chi = one / *chi;
    }
}
float bli_sm1 ( void  )

Referenced by bli_cconjm(), bli_cconjmr(), bli_cconjv(), and bli_cm1().

{
    float x;
    x = -1.0F;
    return x;
}
float bli_sm1h ( void  )

Referenced by bli_cm1h().

{
    float x;
    x = -0.5F;
    return x;
}
float bli_sm2 ( void  )

Referenced by bli_cm2().

{
    float x;
    x = -2.0F;
    return x;
}
void bli_smaxabsm ( int  m,
int  n,
float *  a,
int  a_rs,
int  a_cs,
float *  maxabs 
)

References bli_is_row_storage(), bli_s0(), bli_smaxabsv(), and bli_zero_dim2().

Referenced by FLA_Max_abs_value().

{
    float     zero = bli_s0();
    float*    a_begin;
    float     maxabs_cand;
    float     maxabs_temp;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) { *maxabs = zero; return; }

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
    }

    // Initialize the maximum absolute value candidate to the first element.
    bli_sabsval2( a, &maxabs_cand );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;

        bli_smaxabsv( n_elem,
                      a_begin, inca,
                      &maxabs_temp );

        if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
    }

    *maxabs = maxabs_cand;
}
void bli_smaxabsmr ( uplo_t  uplo,
int  m,
int  n,
float *  a,
int  a_rs,
int  a_cs,
float *  maxabs 
)

References bli_is_row_storage(), bli_is_upper(), bli_s0(), bli_smaxabsv(), and bli_zero_dim2().

Referenced by FLA_Max_abs_value_herm().

{
    float     zero = bli_s0();
    float*    a_begin;
    float     maxabs_cand;
    float     maxabs_temp;
    int       inca, lda;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) { *maxabs = zero; return; }

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }

    // Initialize the maximum absolute value candidate to the first element.
    bli_sabsval2( a, &maxabs_cand );

    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j + 1, n_elem_max );
            a_begin = a + j*lda;

            bli_smaxabsv( n_elem,
                          a_begin, inca,
                          &maxabs_temp );

            if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_max( 0, n_elem_max - j );
            a_begin = a + j*lda + j*inca;

            bli_smaxabsv( n_elem,
                          a_begin, inca,
                          &maxabs_temp );

            if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
        }
    }

    *maxabs = maxabs_cand;
}
void bli_smaxabsv ( int  n,
float *  x,
int  incx,
float *  maxabs 
)

Referenced by bli_smaxabsm(), and bli_smaxabsmr().

{
    float*    chi;
    float     maxabs_cand;
    float     maxabs_temp;
    int       i;

    bli_sabsval2( x, &maxabs_cand );

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        bli_sabsval2( chi, &maxabs_temp );
        
        if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
    }

    *maxabs = maxabs_cand;
}
void bli_srandm ( int  m,
int  n,
float *  a,
int  a_rs,
int  a_cs 
)

References bli_is_row_storage(), bli_srandv(), and bli_zero_dim2().

Referenced by FLA_Random_matrix().

{
    float*    a_begin;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
    }

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;

        bli_srandv( n_elem,
                    a_begin, inca );
    }
}
void bli_srandmr ( uplo_t  uplo,
diag_t  diag,
int  m,
int  n,
float *  a,
int  a_rs,
int  a_cs 
)

References bli_is_nonunit_diag(), bli_is_row_storage(), bli_is_unit_diag(), bli_is_upper(), bli_is_zero_diag(), bli_s0(), bli_s1(), bli_sinvscalv(), bli_srands(), bli_srandv(), bli_ssetv(), bli_zero_dim2(), and BLIS_NO_CONJUGATE.

Referenced by FLA_Random_tri_matrix().

{
    float*    a_begin;
    float*    ajj;
    float     one;
    float     zero;
    float     ord;
    int       lda, inca;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns to increase spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }

    // Initialize some scalars.
    one      = bli_s1();
    zero     = bli_s0();
    ord      = ( float ) bli_max( m, n );

    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            // Randomize super-diagonal elements.
            bli_srandv( n_elem,
                        a_begin, inca );

            // Normalize super-diagonal elements by order of the matrix.
            bli_sinvscalv( BLIS_NO_CONJUGATE,
                           n_elem,
                           &ord,
                           a_begin, inca );

            // Initialize diagonal and sub-diagonal elements only if there are
            // elements left in the column (ie: j < n_elem_max).
            if ( j < n_elem_max )
            {
                ajj = a_begin + j*inca;

                // Initialize diagonal element.
                if      ( bli_is_unit_diag( diag ) )    *ajj = one;
                else if ( bli_is_zero_diag( diag ) )    *ajj = zero;
                else if ( bli_is_nonunit_diag( diag ) )
                {
                    // We want positive diagonal elements between 1 and 2.
                    bli_srands( ajj );
                    bli_sabsval2( ajj, ajj );
                    bli_sadd3( ajj, &one, ajj );
                }

                // Initialize sub-diagonal elements to zero.
                bli_ssetv( n_elem_max - j - 1,
                           &zero,
                           ajj + inca, inca );
            }
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            // Initialize super-diagonal to zero.
            bli_ssetv( n_elem,
                       &zero,
                       a_begin, inca );

            // Initialize diagonal and sub-diagonal elements only if there are
            // elements left in the column (ie: j < n_elem_max).
            if ( j < n_elem_max )
            {
                ajj = a_begin + j*inca;

                // Initialize diagonal element.
                if      ( bli_is_unit_diag( diag ) )    *ajj = one;
                else if ( bli_is_zero_diag( diag ) )    *ajj = zero;
                else if ( bli_is_nonunit_diag( diag ) )
                {
                    // We want positive diagonal elements between 1 and 2.
                    bli_srands( ajj );
                    bli_sabsval2( ajj, ajj );
                    bli_sadd3( ajj, &one, ajj );
                }

                // Randomize sub-diagonal elements.
                bli_srandv( n_elem_max - j - 1,
                            ajj + inca, inca );

                // Normalize sub-diagonal elements by order of the matrix.
                bli_sinvscalv( BLIS_NO_CONJUGATE,
                               n_elem_max - j - 1,
                               &ord,
                               ajj + inca, inca );

            }
        }
    }
}
void bli_srands ( float *  alpha)

Referenced by bli_crands(), bli_srandmr(), and bli_srandv().

{
    *alpha = ( float ) ( ( double ) rand() / ( ( double ) RAND_MAX / 2.0F ) ) - 1.0F;
}
void bli_srandv ( int  n,
float *  x,
int  incx 
)

References bli_srands().

Referenced by bli_srandm(), and bli_srandmr().

{
    float* chi;
    int    i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        bli_srands( chi );
    }
}
void bli_sscalediag ( conj_t  conj,
int  offset,
int  m,
int  n,
float *  sigma,
float *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Scale_diag(), and FLA_UDdate_UT_ops_var1().

{
    float* alpha;
    int    i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        *alpha *= *sigma;

        ++i;
        ++j;
    }
}
void bli_ssetdiag ( int  offset,
int  m,
int  n,
float *  sigma,
float *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Set_diag(), FLA_Set_offdiag(), and FLA_Triangularize().

{
    float* alpha;
    int    i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        *alpha = *sigma;

        ++i;
        ++j;
    }
}
void bli_ssetm ( int  m,
int  n,
float *  sigma,
float *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Bidiag_UT_u_step_ofs_var4(), FLA_Bidiag_UT_u_step_ops_var4(), FLA_Bidiag_UT_u_step_ops_var5(), FLA_Hess_UT_step_ofs_var4(), FLA_Hess_UT_step_ops_var4(), FLA_Hess_UT_step_ops_var5(), FLA_Set(), FLA_Tridiag_UT_l_step_ofs_var3(), and FLA_Tridiag_UT_l_step_ops_var3().

{
    float* alpha;
    int    i, j;

    for ( j = 0; j < n; ++j )
    {
        for ( i = 0; i < m; ++i )
        {
            alpha = a + i*a_rs + j*a_cs;
    
            *alpha = *sigma;
        }
    }
}
void bli_ssetmr ( uplo_t  uplo,
int  m,
int  n,
float *  sigma,
float *  a,
int  a_rs,
int  a_cs 
)

References bli_is_row_storage(), bli_is_upper(), bli_ssetv(), and bli_zero_dim2().

Referenced by FLA_Setr(), and FLA_Triangularize().

{
    float*    a_begin;
    int       lda, inca;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns to increase spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }
    
    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            bli_ssetv( n_elem,
                       sigma,
                       a_begin, inca );
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_max( 0, n_elem_max - j - 1 );
            a_begin = a + j*lda + (j + 1)*inca;

            bli_ssetv( n_elem,
                       sigma,
                       a_begin, inca );
        }
    }
}
void bli_ssetv ( int  m,
float *  sigma,
float *  x,
int  incx 
)
void bli_sshiftdiag ( conj_t  conj,
int  offset,
int  m,
int  n,
float *  sigma,
float *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Lyap_h_ops_var1(), FLA_Lyap_h_ops_var2(), FLA_Lyap_h_ops_var3(), FLA_Lyap_h_ops_var4(), FLA_Lyap_n_ops_var1(), FLA_Lyap_n_ops_var2(), FLA_Lyap_n_ops_var3(), FLA_Lyap_n_ops_var4(), and FLA_Shift_diag().

{
    float* alpha;
    int    i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        *alpha += *sigma;

        ++i;
        ++j;
    }
}
void bli_ssymmize ( conj_t  conj,
uplo_t  uplo,
int  m,
float *  a,
int  a_rs,
int  a_cs 
)

References bli_is_col_storage(), bli_is_gen_storage(), bli_is_lower(), bli_is_row_storage(), bli_is_upper(), bli_scopyv(), and bli_zero_dim1().

Referenced by FLA_Hermitianize(), and FLA_Symmetrize().

{
    float*    a_src;
    float*    a_dst;
    int       rs_src, cs_src, inc_src;
    int       rs_dst, cs_dst, inc_dst;
    int       n_iter;
    int       j;

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

    // Assume A is square.
    n_iter = m;

    // Initialize with appropriate values based on storage.
    if      ( bli_is_col_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        cs_src  = 1;
        rs_src  = 0;
        inc_src = a_cs;
        cs_dst  = a_cs;
        rs_dst  = 0;
        inc_dst = 1;
    }
    else if ( bli_is_col_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        cs_src  = a_cs;
        rs_src  = 0;
        inc_src = 1;
        cs_dst  = 1;
        rs_dst  = 0;
        inc_dst = a_cs;
    }
    else if ( bli_is_row_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        cs_src  = 0;
        rs_src  = a_rs;
        inc_src = 1;
        cs_dst  = 0;
        rs_dst  = 1;
        inc_dst = a_rs;
    }
    else if ( bli_is_row_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        cs_src  = 0;
        rs_src  = 1;
        inc_src = a_rs;
        cs_dst  = 0;
        rs_dst  = a_rs;
        inc_dst = 1;
    }
    else if ( bli_is_gen_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        // General stride with column-major tilt looks similar to column-major.
        // General stride with row-major tilt looks similar to row-major.
        if ( a_rs < a_cs )
        {
            cs_src  = 1 * a_rs;
            rs_src  = 0;
            inc_src = a_cs;
            cs_dst  = a_cs;
            rs_dst  = 0;
            inc_dst = 1 * a_rs;
        }
        else // if ( a_rs > a_cs )
        {
            cs_src  = 0;
            rs_src  = a_rs;
            inc_src = 1 * a_cs;
            cs_dst  = 0;
            rs_dst  = 1 * a_cs;
            inc_dst = a_rs;
        }
    }
    else // if ( bli_is_gen_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        // General stride with column-major tilt looks similar to column-major.
        // General stride with row-major tilt looks similar to row-major.
        if ( a_rs < a_cs )
        {
            cs_src  = a_cs;
            rs_src  = 0;
            inc_src = 1 * a_rs;
            cs_dst  = 1 * a_rs;
            rs_dst  = 0;
            inc_dst = a_cs;
        }
        else // if ( a_rs > a_cs )
        {
            cs_src  = 0;
            rs_src  = 1 * a_cs;
            inc_src = a_rs;
            cs_dst  = 0;
            rs_dst  = a_rs;
            inc_dst = 1 * a_cs;
        }
    }

    for ( j = 0; j < n_iter; j++ )
    {
        a_src = a + j*cs_src + j*rs_src;
        a_dst = a + j*cs_dst + j*rs_dst;

        bli_scopyv( conj,
                    j,
                    a_src, inc_src,
                    a_dst, inc_dst );
    }
}
void* bli_vallocm ( unsigned int  m,
unsigned int  n,
unsigned int  elem_size 
)
{
    return ( void* ) BLIS_MALLOC( m * n * elem_size );
}
void* bli_vallocv ( unsigned int  n_elem,
unsigned int  elem_size 
)
{
    return ( void*  ) BLIS_MALLOC( n_elem * elem_size );
}
void bli_vfree ( void *  p)
{
    free( ( void* ) p );
}
dcomplex bli_z0 ( void  )
dcomplex bli_z1 ( void  )
dcomplex bli_z1h ( void  )

References bli_d0(), bli_d1h(), dcomplex::imag, and dcomplex::real.

{
    dcomplex x;
    x.real = bli_d1h();
    x.imag = bli_d0();
    return x;
}
dcomplex bli_z2 ( void  )

References bli_d0(), bli_d2(), dcomplex::imag, and dcomplex::real.

{
    dcomplex x;
    x.real = bli_d2();
    x.imag = bli_d0();
    return x;
}
dcomplex* bli_zallocm ( unsigned int  m,
unsigned int  n 
)
dcomplex* bli_zallocv ( unsigned int  n_elem)
void bli_zapdiagmv ( side_t  side,
conj_t  conj,
int  m,
int  n,
dcomplex x,
int  incx,
dcomplex a,
int  a_rs,
int  a_cs 
)

References bli_is_left(), bli_is_row_storage(), bli_zero_dim2(), bli_zewscalv(), and bli_zscalv().

Referenced by FLA_Apply_diag_matrix().

{
    dcomplex* chi;
    dcomplex* a_begin;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then we can proceed as if the
    // operation were transposed (applying the diagonal values in x from the
    // opposite side) for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
        bli_toggle_side( side );
    }

    if ( bli_is_left( side ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;

            bli_zewscalv( conj,
                          n_elem,
                          x,       incx,
                          a_begin, inca );
        }
    }
    else
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;
            chi     = x + j*incx;
    
            bli_zscalv( conj,
                        n_elem,
                        chi,
                        a_begin, inca );
        }
    }
}
void bli_zcreate_contigm ( int  m,
int  n,
dcomplex a_save,
int  a_rs_save,
int  a_cs_save,
dcomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), bli_set_contig_strides(), bli_zallocm(), bli_zcopymt(), and BLIS_NO_TRANSPOSE.

Referenced by bli_zgemm(), bli_zgemv(), bli_zger(), bli_zhemm(), bli_zsymm(), bli_ztrmm(), bli_ztrmmsx(), bli_ztrsm(), and bli_ztrsmsx().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;

/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/

        // Allocate temporary contiguous storage for the matrix.
        *a = bli_zallocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_zcopymt( BLIS_NO_TRANSPOSE,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_zcreate_contigmr ( uplo_t  uplo,
int  m,
int  n,
dcomplex a_save,
int  a_rs_save,
int  a_cs_save,
dcomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), bli_set_contig_strides(), bli_zallocm(), and bli_zcopymr().

Referenced by bli_zcreate_contigmsr(), bli_zhemm(), bli_zhemv(), bli_zher(), bli_zher2(), bli_zher2k(), bli_zherk(), bli_zsymm(), bli_zsymv(), bli_zsyr(), bli_zsyr2(), bli_zsyr2k(), bli_zsyrk(), bli_ztrmm(), bli_ztrmmsx(), bli_ztrmv(), bli_ztrmvsx(), bli_ztrsm(), bli_ztrsmsx(), bli_ztrsv(), and bli_ztrsvsx().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;
/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/
        // Allocate temporary contiguous storage for the matrix.
        *a = bli_zallocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_zcopymr( uplo,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_zcreate_contigmsr ( side_t  side,
uplo_t  uplo,
int  m,
int  n,
dcomplex a_save,
int  a_rs_save,
int  a_cs_save,
dcomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_left(), and bli_zcreate_contigmr().

{
    int dim_a;

    // Choose the dimension of the matrix based on the side parameter.
    if ( bli_is_left( side ) ) dim_a = m;
    else                       dim_a = n;

    // Call the simple version with chosen dimensions.
    bli_zcreate_contigmr( uplo,
                          dim_a,
                          dim_a,
                          a_save, a_rs_save, a_cs_save,
                          a,      a_rs,      a_cs );
}
void bli_zcreate_contigmt ( trans_t  trans_dims,
int  m,
int  n,
dcomplex a_save,
int  a_rs_save,
int  a_cs_save,
dcomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_does_trans(), bli_is_gen_storage(), bli_set_contig_strides(), bli_zallocm(), bli_zcopymt(), and BLIS_NO_TRANSPOSE.

Referenced by bli_zgemm(), bli_zher2k(), bli_zherk(), bli_zsyr2k(), and bli_zsyrk().

{
    int m_contig, n_contig;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Transpose the dimensions if requested.
        if ( bli_does_trans( trans_dims ) )
            bli_swap_ints( m, n );

        // Initialize dimensions assuming no transposition needed during copy.
        m_contig = m;
        n_contig = n;

/*
        // Transpose the dimensions of the contiguous matrix, if requested.
        if ( bli_does_trans( trans_copy ) )
        {
            m_contig = n;
            n_contig = m;
        }
*/

        // Allocate temporary contiguous storage for the matrix.
        *a = bli_zallocm( m_contig, n_contig );

        // Set the row and column strides for the temporary matrix.
        bli_set_contig_strides( m_contig, n_contig, a_rs, a_cs );

        // Initialize the contiguous matrix with the contents of the original.
        bli_zcopymt( BLIS_NO_TRANSPOSE,
                     m_contig,
                     n_contig,
                     a_save, a_rs_save, a_cs_save,
                     *a,     *a_rs,     *a_cs );
    }
}
void bli_zdapdiagmv ( side_t  side,
conj_t  conj,
int  m,
int  n,
double *  x,
int  incx,
dcomplex a,
int  a_rs,
int  a_cs 
)

References bli_is_left(), bli_is_row_storage(), bli_zdewscalv(), bli_zdscalv(), and bli_zero_dim2().

Referenced by FLA_Apply_diag_matrix().

{
    double*   chi;
    dcomplex* a_begin;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then we can proceed as if the
    // operation were transposed (applying the diagonal values in x from the
    // opposite side) for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
        bli_toggle_side( side );
    }

    if ( bli_is_left( side ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;

            bli_zdewscalv( conj,
                           n_elem,
                           x,       incx,
                           a_begin, inca );
        }
    }
    else
    {
        for ( j = 0; j < n_iter; j++ )
        {
            a_begin = a + j*lda;
            chi     = x + j*incx;
    
            bli_zdscalv( conj,
                         n_elem,
                         chi,
                         a_begin, inca );
        }
    }
}
void bli_zdewinvscalmt ( trans_t  trans,
int  m,
int  n,
double *  a,
int  a_rs,
int  a_cs,
dcomplex b,
int  b_rs,
int  b_cs 
)

References bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_vector_dim(), bli_vector_inc(), bli_zdewinvscalv(), bli_zero_dim2(), and BLIS_NO_TRANSPOSE.

{
    double*   a_begin;
    dcomplex* b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewinvscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_zdewinvscalv( conj,
                          n_elem,
                          a_begin, inca, 
                          b_begin, incb );
    }
}
void bli_zdewinvscalv ( conj_t  conj,
int  n,
double *  x,
int  incx,
dcomplex y,
int  incy 
)

Referenced by bli_zdewinvscalmt().

{
    double*   chi;
    dcomplex* psi;
    int       i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;
        psi = y + i*incy;

        bli_zdinvscals( chi, psi );
    }
}
void bli_zdewscalmt ( trans_t  trans,
int  m,
int  n,
double *  a,
int  a_rs,
int  a_cs,
dcomplex b,
int  b_rs,
int  b_cs 
)

References bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_vector_dim(), bli_vector_inc(), bli_zdewscalv(), bli_zero_dim2(), and BLIS_NO_TRANSPOSE.

{
    double*   a_begin;
    dcomplex* b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_zdewscalv( conj,
                       n_elem,
                       a_begin, inca, 
                       b_begin, incb );
    }
}
void bli_zdewscalv ( conj_t  conj,
int  n,
double *  x,
int  incx,
dcomplex y,
int  incy 
)

Referenced by bli_zdapdiagmv(), and bli_zdewscalmt().

{
    double*   chi;
    dcomplex* psi;
    int       i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;
        psi = y + i*incy;

        bli_zdscals( chi, psi );
    }
}
void bli_zdscalediag ( conj_t  conj,
int  offset,
int  m,
int  n,
double *  sigma,
dcomplex a,
int  a_rs,
int  a_cs 
)

References dcomplex::imag, and dcomplex::real.

Referenced by FLA_Scale_diag().

{
    dcomplex* alpha;
    int       i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        alpha->real *= *sigma;
        alpha->imag *= *sigma;

        ++i;
        ++j;
    }
}
void bli_zdshiftdiag ( conj_t  conj,
int  offset,
int  m,
int  n,
double *  sigma,
dcomplex a,
int  a_rs,
int  a_cs 
)

References dcomplex::real.

Referenced by FLA_Shift_diag().

{
    dcomplex* alpha;
    int       i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        alpha->real += *sigma;

        ++i;
        ++j;
    }
}
void bli_zewinvscalmt ( trans_t  trans,
int  m,
int  n,
dcomplex a,
int  a_rs,
int  a_cs,
dcomplex b,
int  b_rs,
int  b_cs 
)

References bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_vector_dim(), bli_vector_inc(), bli_zero_dim2(), bli_zewinvscalv(), and BLIS_NO_TRANSPOSE.

Referenced by FLA_Inv_scal_elemwise().

{
    dcomplex* a_begin;
    dcomplex* b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewinvscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_zewinvscalv( conj,
                         n_elem,
                         a_begin, inca, 
                         b_begin, incb );
    }
}
void bli_zewinvscalv ( conj_t  conj,
int  n,
dcomplex x,
int  incx,
dcomplex y,
int  incy 
)

References bli_is_conj().

Referenced by bli_zewinvscalmt().

{
    dcomplex* chi;
    dcomplex* psi;
    dcomplex  conjchi;
    int       i;

    if ( bli_is_conj( conj ) )
    {
        for ( i = 0; i < n; ++i )
        {
            chi = x + i*incx;
            psi = y + i*incy;

            bli_zcopyconj( chi, &conjchi );
            bli_zinvscals( &conjchi, psi );
        }
    }
    else
    {
        for ( i = 0; i < n; ++i )
        {
            chi = x + i*incx;
            psi = y + i*incy;
    
            bli_zinvscals( chi, psi );
        }
    }
}
void bli_zewscalmt ( trans_t  trans,
int  m,
int  n,
dcomplex a,
int  a_rs,
int  a_cs,
dcomplex b,
int  b_rs,
int  b_cs 
)

References bli_does_notrans(), bli_does_trans(), bli_is_col_storage(), bli_is_row_storage(), bli_is_vector(), bli_proj_trans_to_conj(), bli_vector_dim(), bli_vector_inc(), bli_zero_dim2(), bli_zewscalv(), and BLIS_NO_TRANSPOSE.

Referenced by FLA_Scal_elemwise().

{
    dcomplex* a_begin;
    dcomplex* b_begin;
    int       lda, inca;
    int       ldb, incb;
    int       n_iter;
    int       n_elem;
    int       j;
    conj_t    conj;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Handle cases where A and B are vectors to ensure that the underlying ewscal
    // gets invoked only once.
    if ( bli_is_vector( m, n ) )
    {
        // Initialize with values appropriate for vectors.
        n_iter = 1;
        n_elem = bli_vector_dim( m, n );
        lda    = 1; // multiplied by zero when n_iter == 1; not needed.
        inca   = bli_vector_inc( trans,             m, n, a_rs, a_cs );
        ldb    = 1; // multiplied by zero when n_iter == 1; not needed.
        incb   = bli_vector_inc( BLIS_NO_TRANSPOSE, m, n, b_rs, b_cs );
    }
    else // matrix case
    {
        // Initialize with optimal values for column-major storage.
        n_iter = n;
        n_elem = m;
        lda    = a_cs;
        inca   = a_rs;
        ldb    = b_cs;
        incb   = b_rs;
        
        // Handle the transposition of A.
        if ( bli_does_trans( trans ) )
        {
            bli_swap_ints( lda, inca );
        }

        // An optimization: if B is row-major and if A is effectively row-major
        // after a possible transposition, then let's access the matrices by rows
        // instead of by columns for increased spatial locality.
        if ( bli_is_row_storage( b_rs, b_cs ) )
        {
            if ( ( bli_is_col_storage( a_rs, a_cs ) && bli_does_trans( trans ) ) ||
                 ( bli_is_row_storage( a_rs, a_cs ) && bli_does_notrans( trans ) ) )
            {
                bli_swap_ints( n_iter, n_elem );
                bli_swap_ints( lda, inca );
                bli_swap_ints( ldb, incb );
            }
        }
    }

    // Extract conj component from trans parameter.
    conj = bli_proj_trans_to_conj( trans );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;
        b_begin = b + j*ldb;

        bli_zewscalv( conj,
                      n_elem,
                      a_begin, inca, 
                      b_begin, incb );
    }
}
void bli_zewscalv ( conj_t  conj,
int  n,
dcomplex x,
int  incx,
dcomplex y,
int  incy 
)

References bli_is_conj().

Referenced by bli_zapdiagmv(), and bli_zewscalmt().

{
    dcomplex* chi;
    dcomplex* psi;
    dcomplex  conjchi;
    int       i;

    if ( bli_is_conj( conj ) )
    {
        for ( i = 0; i < n; ++i )
        {
            chi = x + i*incx;
            psi = y + i*incy;

            bli_zcopyconj( chi, &conjchi );
            bli_zscals( &conjchi, psi );
        }
    }
    else
    {
        for ( i = 0; i < n; ++i )
        {
            chi = x + i*incx;
            psi = y + i*incy;
    
            bli_zscals( chi, psi );
        }
    }
}
void bli_zfree ( dcomplex p)
void bli_zfree_contigm ( dcomplex a_save,
int  a_rs_save,
int  a_cs_save,
dcomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), and bli_zfree().

Referenced by bli_zgemm(), bli_zgemv(), bli_zhemm(), bli_zhemv(), bli_zher2k(), bli_zherk(), bli_zsymm(), bli_zsymv(), bli_zsyr2k(), bli_zsyrk(), bli_ztrmm(), bli_ztrmmsx(), bli_ztrmv(), bli_ztrmvsx(), bli_ztrsm(), bli_ztrsmsx(), bli_ztrsv(), and bli_ztrsvsx().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Free the temporary contiguous storage for the matrix.
        bli_zfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_zfree_saved_contigm ( int  m,
int  n,
dcomplex a_save,
int  a_rs_save,
int  a_cs_save,
dcomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), bli_zcopymt(), bli_zfree(), and BLIS_NO_TRANSPOSE.

Referenced by bli_zgemm(), bli_zger(), bli_zhemm(), bli_zher(), bli_zher2(), bli_zsymm(), bli_zsyr(), bli_zsyr2(), bli_ztrmm(), bli_ztrmmsx(), bli_ztrsm(), and bli_ztrsmsx().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_zcopymt( BLIS_NO_TRANSPOSE,
                     m,
                     n,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_zfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_zfree_saved_contigmr ( uplo_t  uplo,
int  m,
int  n,
dcomplex a_save,
int  a_rs_save,
int  a_cs_save,
dcomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), bli_zcopymr(), and bli_zfree().

Referenced by bli_zher2k(), bli_zherk(), bli_zsyr2k(), and bli_zsyrk().

{
    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_zcopymr( uplo,
                     m,
                     n,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_zfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_zfree_saved_contigmsr ( side_t  side,
uplo_t  uplo,
int  m,
int  n,
dcomplex a_save,
int  a_rs_save,
int  a_cs_save,
dcomplex **  a,
int *  a_rs,
int *  a_cs 
)

References bli_is_gen_storage(), bli_is_left(), bli_zcopymr(), and bli_zfree().

{
    int dim_a;

    // Choose the dimension of the matrix based on the side parameter.
    if ( bli_is_left( side ) ) dim_a = m;
    else                       dim_a = n;

    if ( bli_is_gen_storage( a_rs_save, a_cs_save ) )
    {
        // Copy the contents of the temporary matrix back to the original.
        bli_zcopymr( uplo,
                     dim_a,
                     dim_a,
                     *a,     *a_rs,     *a_cs,
                     a_save, a_rs_save, a_cs_save );

        // Free the temporary contiguous storage for the matrix.
        bli_zfree( *a );

        // Restore the original matrix address.
        *a = a_save;

        // Restore the original row and column strides.
        *a_rs = a_rs_save;
        *a_cs = a_cs_save;
    }
}
void bli_zident ( int  m,
dcomplex a,
int  a_rs,
int  a_cs 
)

References dcomplex::imag, and dcomplex::real.

Referenced by FLA_UDdate_UT_opz_var1().

{
    dcomplex* alpha;
    int       i, j;

    for ( j = 0; j < m; ++j )
    {
        for ( i = 0; i < m; ++i )
        {
            alpha = a + i*a_rs + j*a_cs;
    
            alpha->real = 0.0;
            alpha->imag = 0.0;

            if ( i == j )
                alpha->real = 1.0;
        }
    }
}
void bli_zinvert2s ( conj_t  conj,
dcomplex alpha,
dcomplex beta 
)

References bli_is_conj(), dcomplex::imag, and dcomplex::real.

Referenced by bli_zinvscalm(), and bli_zinvscalv().

{
    double one = 1.0;
    double temp;

    temp = one / ( alpha->real * alpha->real +
                   alpha->imag * alpha->imag );
    beta->real = alpha->real *  temp;
    beta->imag = alpha->imag * -temp;

    if ( bli_is_conj( conj ) )
        bli_zconjs( beta );
}
void bli_zinverts ( conj_t  conj,
dcomplex alpha 
)

References bli_is_conj(), dcomplex::imag, and dcomplex::real.

Referenced by FLA_Trinv_ln_opz_var1(), FLA_Trinv_ln_opz_var2(), FLA_Trinv_ln_opz_var3(), FLA_Trinv_ln_opz_var4(), FLA_Trinv_un_opz_var1(), FLA_Trinv_un_opz_var2(), FLA_Trinv_un_opz_var3(), and FLA_Trinv_un_opz_var4().

{
    double one = 1.0;
    double temp;

    temp = one / ( alpha->real * alpha->real +
                   alpha->imag * alpha->imag );
    alpha->real = alpha->real *  temp;
    alpha->imag = alpha->imag * -temp;

    if ( bli_is_conj( conj ) )
        bli_zconjs( alpha );
}
void bli_zinvertv ( conj_t  conj,
int  n,
dcomplex x,
int  incx 
)

References bli_is_conj(), dcomplex::imag, and dcomplex::real.

Referenced by FLA_Invert().

{
    double    one = 1.0;
    double    temp;
    double    conjsign;
    dcomplex* chi;
    int       i;

    if ( bli_is_conj( conj ) ) conjsign =  one;
    else                       conjsign = -one;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        temp = one / ( chi->real * chi->real +
                       chi->imag * chi->imag );
        chi->real = chi->real *            temp;
        chi->imag = chi->imag * conjsign * temp;
    }
}
dcomplex bli_zm1 ( void  )
dcomplex bli_zm1h ( void  )

References bli_d0(), bli_dm1h(), dcomplex::imag, and dcomplex::real.

{
    dcomplex x;
    x.real = bli_dm1h();
    x.imag = bli_d0();
    return x;
}
dcomplex bli_zm2 ( void  )

References bli_d0(), bli_dm2(), dcomplex::imag, and dcomplex::real.

{
    dcomplex x;
    x.real = bli_dm2();
    x.imag = bli_d0();
    return x;
}
void bli_zmaxabsm ( int  m,
int  n,
dcomplex a,
int  a_rs,
int  a_cs,
double *  maxabs 
)

References bli_d0(), bli_is_row_storage(), bli_zero_dim2(), and bli_zmaxabsv().

Referenced by FLA_Max_abs_value().

{
    double    zero = bli_d0();
    dcomplex* a_begin;
    double    maxabs_cand;
    double    maxabs_temp;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) { *maxabs = zero; return; }

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
    }

    // Initialize the maximum absolute value candidate to the first element.
    bli_zdabsval2( a, &maxabs_cand );

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;

        bli_zmaxabsv( n_elem,
                      a_begin, inca,
                      &maxabs_temp );

        if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
    }

    *maxabs = maxabs_cand;
}
void bli_zmaxabsmr ( uplo_t  uplo,
int  m,
int  n,
dcomplex a,
int  a_rs,
int  a_cs,
double *  maxabs 
)

References bli_d0(), bli_is_row_storage(), bli_is_upper(), bli_zero_dim2(), and bli_zmaxabsv().

Referenced by FLA_Max_abs_value_herm().

{
    double    zero = bli_d0();
    dcomplex* a_begin;
    double    maxabs_cand;
    double    maxabs_temp;
    int       inca, lda;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) { *maxabs = zero; return; }

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }

    // Initialize the maximum absolute value candidate to the first element.
    bli_zdabsval2( a, &maxabs_cand );

    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j + 1, n_elem_max );
            a_begin = a + j*lda;

            bli_zmaxabsv( n_elem,
                          a_begin, inca,
                          &maxabs_temp );

            if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_max( 0, n_elem_max - j );
            a_begin = a + j*lda + j*inca;

            bli_zmaxabsv( n_elem,
                          a_begin, inca,
                          &maxabs_temp );

            if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
        }
    }

    *maxabs = maxabs_cand;
}
void bli_zmaxabsv ( int  n,
dcomplex x,
int  incx,
double *  maxabs 
)

Referenced by bli_zmaxabsm(), and bli_zmaxabsmr().

{
    dcomplex* chi;
    double    maxabs_cand;
    double    maxabs_temp;
    int       i;

    bli_zdabsval2( x, &maxabs_cand );

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        bli_zdabsval2( chi, &maxabs_temp );
        
        if ( maxabs_temp > maxabs_cand ) maxabs_cand = maxabs_temp;
    }

    *maxabs = maxabs_cand;
}
void bli_zrandm ( int  m,
int  n,
dcomplex a,
int  a_rs,
int  a_cs 
)

References bli_is_row_storage(), bli_zero_dim2(), and bli_zrandv().

Referenced by FLA_Random_matrix().

{
    dcomplex* a_begin;
    int       inca, lda;
    int       n_iter;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    inca   = a_rs;
    lda    = a_cs;
    n_iter = n;
    n_elem = m;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns for increased spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem );
        bli_swap_ints( lda, inca );
    }

    for ( j = 0; j < n_iter; j++ )
    {
        a_begin = a + j*lda;

        bli_zrandv( n_elem,
                    a_begin, inca );
    }
}
void bli_zrandmr ( uplo_t  uplo,
diag_t  diag,
int  m,
int  n,
dcomplex a,
int  a_rs,
int  a_cs 
)

References bli_is_nonunit_diag(), bli_is_row_storage(), bli_is_unit_diag(), bli_is_upper(), bli_is_zero_diag(), bli_z0(), bli_z1(), bli_zero_dim2(), bli_zinvscalv(), bli_zrands(), bli_zrandv(), bli_zsetv(), BLIS_NO_CONJUGATE, and dcomplex::real.

Referenced by FLA_Random_tri_matrix().

{
    dcomplex* a_begin;
    dcomplex* ajj;
    dcomplex  one;
    dcomplex  zero;
    dcomplex  ord;
    int       lda, inca;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns to increase spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }

    // Initialize some scalars.
    one      = bli_z1();
    zero     = bli_z0();
    ord      = bli_z0();
    ord.real = ( double ) bli_max( m, n );

    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            // Randomize super-diagonal elements.
            bli_zrandv( n_elem,
                        a_begin, inca );

            // Normalize super-diagonal elements by order of the matrix.
            bli_zinvscalv( BLIS_NO_CONJUGATE,
                           n_elem,
                           &ord,
                           a_begin, inca );

            // Initialize diagonal and sub-diagonal elements only if there are
            // elements left in the column (ie: j < n_elem_max).
            if ( j < n_elem_max )
            {
                ajj = a_begin + j*inca;

                // Initialize diagonal element.
                if      ( bli_is_unit_diag( diag ) )    *ajj = one;
                else if ( bli_is_zero_diag( diag ) )    *ajj = zero;
                else if ( bli_is_nonunit_diag( diag ) )
                {
                    // We want positive diagonal elements between 1 and 2.
                    bli_zrands( ajj );
                    bli_zabsval2( ajj, ajj );
                    bli_zadd3( ajj, &one, ajj );
                }

                // Initialize sub-diagonal elements to zero.
                bli_zsetv( n_elem_max - j - 1,
                           &zero,
                           ajj + inca, inca );
            }
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            // Initialize super-diagonal to zero.
            bli_zsetv( n_elem,
                       &zero,
                       a_begin, inca );

            // Initialize diagonal and sub-diagonal elements only if there are
            // elements left in the column (ie: j < n_elem_max).
            if ( j < n_elem_max )
            {
                ajj = a_begin + j*inca;

                // Initialize diagonal element.
                if      ( bli_is_unit_diag( diag ) )    *ajj = one;
                else if ( bli_is_zero_diag( diag ) )    *ajj = zero;
                else if ( bli_is_nonunit_diag( diag ) )
                {
                    // We want positive diagonal elements between 1 and 2.
                    bli_zrands( ajj );
                    bli_zabsval2( ajj, ajj );
                    bli_zadd3( ajj, &one, ajj );
                }

                // Randomize sub-diagonal elements.
                bli_zrandv( n_elem_max - j - 1,
                            ajj + inca, inca );

                // Normalize sub-diagonal elements by order of the matrix.
                bli_zinvscalv( BLIS_NO_CONJUGATE,
                               n_elem_max - j - 1,
                               &ord,
                               ajj + inca, inca );

            }
        }
    }
}
void bli_zrands ( dcomplex alpha)

References bli_drands(), dcomplex::imag, and dcomplex::real.

Referenced by bli_zrandmr(), and bli_zrandv().

{
    bli_drands( &(alpha->real) );
    bli_drands( &(alpha->imag) );
}
void bli_zrandv ( int  n,
dcomplex x,
int  incx 
)

References bli_zrands().

Referenced by bli_zrandm(), and bli_zrandmr().

{
    dcomplex* chi;
    int       i;

    for ( i = 0; i < n; ++i )
    {
        chi = x + i*incx;

        bli_zrands( chi );
    }
}
void bli_zscalediag ( conj_t  conj,
int  offset,
int  m,
int  n,
dcomplex sigma,
dcomplex a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Scale_diag(), and FLA_UDdate_UT_opz_var1().

{
    dcomplex* alpha;
    dcomplex  sigma_conj;
    int       i, j;

    bli_zcopys( conj, sigma, &sigma_conj );

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        bli_zscals( &sigma_conj, alpha );

        ++i;
        ++j;
    }
}
void bli_zsetdiag ( int  offset,
int  m,
int  n,
dcomplex sigma,
dcomplex a,
int  a_rs,
int  a_cs 
)

References dcomplex::imag, and dcomplex::real.

Referenced by FLA_Set_diag(), FLA_Set_offdiag(), and FLA_Triangularize().

{
    dcomplex* alpha;
    int       i, j;

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        alpha->real = sigma->real;
        alpha->imag = sigma->imag;

        ++i;
        ++j;
    }
}
void bli_zsetm ( int  m,
int  n,
dcomplex sigma,
dcomplex a,
int  a_rs,
int  a_cs 
)
void bli_zsetmr ( uplo_t  uplo,
int  m,
int  n,
dcomplex sigma,
dcomplex a,
int  a_rs,
int  a_cs 
)

References bli_is_row_storage(), bli_is_upper(), bli_zero_dim2(), and bli_zsetv().

Referenced by FLA_Setr(), and FLA_Triangularize().

{
    dcomplex* a_begin;
    int       lda, inca;
    int       n_iter;
    int       n_elem_max;
    int       n_elem;
    int       j;

    // Return early if possible.
    if ( bli_zero_dim2( m, n ) ) return;

    // Initialize with optimal values for column-major storage.
    n_iter     = n;
    n_elem_max = m;
    lda        = a_cs;
    inca       = a_rs;

    // An optimization: if A is row-major, then let's access the matrix by
    // rows instead of by columns to increase spatial locality.
    if ( bli_is_row_storage( a_rs, a_cs ) )
    {
        bli_swap_ints( n_iter, n_elem_max );
        bli_swap_ints( lda, inca );
        bli_toggle_uplo( uplo );
    }
    
    if ( bli_is_upper( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_min( j, n_elem_max );
            a_begin = a + j*lda;

            bli_zsetv( n_elem,
                       sigma,
                       a_begin, inca );
        }
    }
    else // if ( bli_is_lower( uplo ) )
    {
        for ( j = 0; j < n_iter; j++ )
        {
            n_elem  = bli_max( 0, n_elem_max - j - 1 );
            a_begin = a + j*lda + (j + 1)*inca;

            bli_zsetv( n_elem,
                       sigma,
                       a_begin, inca );
        }
    }
}
void bli_zsetv ( int  m,
dcomplex sigma,
dcomplex x,
int  incx 
)
void bli_zshiftdiag ( conj_t  conj,
int  offset,
int  m,
int  n,
dcomplex sigma,
dcomplex a,
int  a_rs,
int  a_cs 
)

References dcomplex::imag, and dcomplex::real.

Referenced by FLA_Lyap_h_opz_var1(), FLA_Lyap_h_opz_var2(), FLA_Lyap_h_opz_var3(), FLA_Lyap_h_opz_var4(), FLA_Lyap_n_opz_var1(), FLA_Lyap_n_opz_var2(), FLA_Lyap_n_opz_var3(), FLA_Lyap_n_opz_var4(), and FLA_Shift_diag().

{
    dcomplex* alpha;
    dcomplex  sigma_conj;
    int       i, j;

    bli_zcopys( conj, sigma, &sigma_conj );

    i = j = 0;

    if      ( offset < 0 ) i = -offset;
    else if ( offset > 0 ) j =  offset;
    
    while ( i < m && j < n )
    {
        alpha = a + i*a_rs + j*a_cs;
    
        alpha->real += sigma_conj.real;
        alpha->imag += sigma_conj.imag;

        ++i;
        ++j;
    }
}
void bli_zsymmize ( conj_t  conj,
uplo_t  uplo,
int  m,
dcomplex a,
int  a_rs,
int  a_cs 
)

References bli_d0(), bli_is_col_storage(), bli_is_conj(), bli_is_gen_storage(), bli_is_lower(), bli_is_row_storage(), bli_is_upper(), bli_zcopyv(), bli_zero_dim1(), and dcomplex::imag.

Referenced by FLA_Hermitianize(), and FLA_Symmetrize().

{
    dcomplex* a_src;
    dcomplex* a_dst;
    dcomplex* a_jj;
    int       rs_src, cs_src, inc_src;
    int       rs_dst, cs_dst, inc_dst;
    int       n_iter;
    int       j;

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

    // Assume A is square.
    n_iter = m;

    // Initialize with appropriate values based on storage.
    if      ( bli_is_col_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        cs_src  = 1;
        rs_src  = 0;
        inc_src = a_cs;
        cs_dst  = a_cs;
        rs_dst  = 0;
        inc_dst = 1;
    }
    else if ( bli_is_col_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        cs_src  = a_cs;
        rs_src  = 0;
        inc_src = 1;
        cs_dst  = 1;
        rs_dst  = 0;
        inc_dst = a_cs;
    }
    else if ( bli_is_row_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        cs_src  = 0;
        rs_src  = a_rs;
        inc_src = 1;
        cs_dst  = 0;
        rs_dst  = 1;
        inc_dst = a_rs;
    }
    else if ( bli_is_row_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        cs_src  = 0;
        rs_src  = 1;
        inc_src = a_rs;
        cs_dst  = 0;
        rs_dst  = a_rs;
        inc_dst = 1;
    }
    else if ( bli_is_gen_storage( a_rs, a_cs ) && bli_is_lower( uplo ) )
    {
        // General stride with column-major tilt looks similar to column-major.
        // General stride with row-major tilt looks similar to row-major.
        if ( a_rs < a_cs )
        {
            cs_src  = 1 * a_rs;
            rs_src  = 0;
            inc_src = a_cs;
            cs_dst  = a_cs;
            rs_dst  = 0;
            inc_dst = 1 * a_rs;
        }
        else // if ( a_rs > a_cs )
        {
            cs_src  = 0;
            rs_src  = a_rs;
            inc_src = 1 * a_cs;
            cs_dst  = 0;
            rs_dst  = 1 * a_cs;
            inc_dst = a_rs;
        }
    }
    else // if ( bli_is_gen_storage( a_rs, a_cs ) && bli_is_upper( uplo ) )
    {
        // General stride with column-major tilt looks similar to column-major.
        // General stride with row-major tilt looks similar to row-major.
        if ( a_rs < a_cs )
        {
            cs_src  = a_cs;
            rs_src  = 0;
            inc_src = 1 * a_rs;
            cs_dst  = 1 * a_rs;
            rs_dst  = 0;
            inc_dst = a_cs;
        }
        else // if ( a_rs > a_cs )
        {
            cs_src  = 0;
            rs_src  = 1 * a_cs;
            inc_src = a_rs;
            cs_dst  = 0;
            rs_dst  = a_rs;
            inc_dst = 1 * a_cs;
        }
    }
    
    for ( j = 0; j < n_iter; j++ )
    {
        a_src = a + j*cs_src + j*rs_src;
        a_dst = a + j*cs_dst + j*rs_dst;

        bli_zcopyv( conj,
                    j,
                    a_src, inc_src,
                    a_dst, inc_dst );

        if ( bli_is_conj( conj ) )
        {
            a_jj = a + j*a_rs + j*a_cs;
            a_jj->imag = bli_d0();
        }
    }
}