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)
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)
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 (char side, char conj, int m, int n, float *x, int incx, float *a, int a_rs, int a_cs)
void bli_dapdiagmv (char side, char conj, int m, int n, double *x, int incx, double *a, int a_rs, int a_cs)
void bli_capdiagmv (char side, char conj, int m, int n, scomplex *x, int incx, scomplex *a, int a_rs, int a_cs)
void bli_zapdiagmv (char side, char 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 (char 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 (char 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 (char 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 (char 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 (char 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 (char 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 (char 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 (char 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 (char side, char 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 (char side, char 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 (char side, char 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 (char side, char 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 (char 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 (char 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 (char 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 (char 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 (char side, char 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 (char side, char 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 (char side, char 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 (char side, char 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_sewscalv (char conj, int n, float *x, int incx, float *y, int incy)
void bli_dewscalv (char conj, int n, double *x, int incx, double *y, int incy)
void bli_cewscalv (char conj, int n, scomplex *x, int incx, scomplex *y, int incy)
void bli_zewscalv (char conj, int n, dcomplex *x, int incx, dcomplex *y, int incy)
void bli_sewscalmt (char trans, int m, int n, float *a, int a_rs, int a_cs, float *b, int b_rs, int b_cs)
void bli_dewscalmt (char trans, int m, int n, double *a, int a_rs, int a_cs, double *b, int b_rs, int b_cs)
void bli_cewscalmt (char trans, int m, int n, scomplex *a, int a_rs, int a_cs, scomplex *b, int b_rs, int b_cs)
void bli_zewscalmt (char trans, int m, int n, dcomplex *a, int a_rs, int a_cs, dcomplex *b, int b_rs, int b_cs)
void bli_sfree (float *p)
void bli_dfree (double *p)
void bli_cfree (scomplex *p)
void bli_zfree (dcomplex *p)
void bli_sinverts (char conj, float *alpha)
void bli_dinverts (char conj, double *alpha)
void bli_cinverts (char conj, scomplex *alpha)
void bli_zinverts (char conj, dcomplex *alpha)
void bli_sinvert2s (char conj, float *alpha, float *beta)
void bli_dinvert2s (char conj, double *alpha, double *beta)
void bli_cinvert2s (char conj, scomplex *alpha, scomplex *beta)
void bli_zinvert2s (char conj, dcomplex *alpha, dcomplex *beta)
void bli_sinvertv (char conj, int n, float *x, int incx)
void bli_dinvertv (char conj, int n, double *x, int incx)
void bli_cinvertv (char conj, int n, scomplex *x, int incx)
void bli_zinvertv (char 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_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 (char uplo, char diag, int m, int n, float *a, int a_rs, int a_cs)
void bli_drandmr (char uplo, char diag, int m, int n, double *a, int a_rs, int a_cs)
void bli_crandmr (char uplo, char diag, int m, int n, scomplex *a, int a_rs, int a_cs)
void bli_zrandmr (char uplo, char 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 (char side, int m, int n, int *dim_new)
void bli_set_dims_with_trans (char trans, int m, int n, int *m_new, int *n_new)
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_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 (char uplo, int m, int n, float *sigma, float *a, int a_rs, int a_cs)
void bli_dsetmr (char uplo, int m, int n, double *sigma, double *a, int a_rs, int a_cs)
void bli_csetmr (char uplo, int m, int n, scomplex *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zsetmr (char uplo, int m, int n, dcomplex *sigma, dcomplex *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 (char conj, int offset, int m, int n, float *sigma, float *a, int a_rs, int a_cs)
void bli_dscalediag (char conj, int offset, int m, int n, double *sigma, double *a, int a_rs, int a_cs)
void bli_cscalediag (char conj, int offset, int m, int n, scomplex *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zscalediag (char conj, int offset, int m, int n, dcomplex *sigma, dcomplex *a, int a_rs, int a_cs)
void bli_csscalediag (char conj, int offset, int m, int n, float *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zdscalediag (char conj, int offset, int m, int n, double *sigma, dcomplex *a, int a_rs, int a_cs)
void bli_sshiftdiag (char conj, int offset, int m, int n, float *sigma, float *a, int a_rs, int a_cs)
void bli_dshiftdiag (char conj, int offset, int m, int n, double *sigma, double *a, int a_rs, int a_cs)
void bli_cshiftdiag (char conj, int offset, int m, int n, scomplex *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zshiftdiag (char conj, int offset, int m, int n, dcomplex *sigma, dcomplex *a, int a_rs, int a_cs)
void bli_csshiftdiag (char conj, int offset, int m, int n, float *sigma, scomplex *a, int a_rs, int a_cs)
void bli_zdshiftdiag (char conj, int offset, int m, int n, double *sigma, dcomplex *a, int a_rs, int a_cs)
void bli_ssymmize (char conj, char uplo, int m, float *a, int a_rs, int a_cs)
void bli_dsymmize (char conj, char uplo, int m, double *a, int a_rs, int a_cs)
void bli_csymmize (char conj, char uplo, int m, scomplex *a, int a_rs, int a_cs)
void bli_zsymmize (char conj, char uplo, int m, dcomplex *a, int a_rs, int a_cs)

Function Documentation

scomplex bli_c0 ( void  )

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

Referenced by bli_cgemm(), bli_cgemv(), bli_chemm(), bli_chemv(), bli_crandmr(), and bli_csymm().

{
    scomplex x;
    x.real = bli_s0();
    x.imag = bli_s0();
    return x;
}
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 ( char  side,
char  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* a_begin;
    scomplex* chi;
    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(), and bli_set_contig_strides().

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 ( char  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 ( char  side,
char  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 ( char  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(), and bli_set_contig_strides().

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_cewscalmt ( char  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_vector_dim(), bli_vector_inc(), and bli_zero_dim2().

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;

    // 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 );
            }
        }
    }

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

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

References bli_does_conj().

Referenced by bli_capdiagmv(), and bli_cewscalmt().

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

    if ( bli_does_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(), and bli_is_gen_storage().

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 ( char  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 ( char  side,
char  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 ( char  conj,
scomplex alpha,
scomplex beta 
)

References bli_does_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_does_conj( conj ) )
        bli_cconjs( beta );
}
void bli_cinverts ( char  conj,
scomplex alpha 
)

References bli_does_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_does_conj( conj ) )
        bli_cconjs( alpha );
}
void bli_cinvertv ( char  conj,
int  n,
scomplex x,
int  incx 
)

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

Referenced by FLA_Invert().

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

    if ( bli_does_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_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 ( char  uplo,
char  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(), 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_cscalediag ( char  conj,
int  offset,
int  m,
int  n,
scomplex sigma,
scomplex a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Obj_scale_diagonal(), 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_Obj_set_diagonal_to_scalar(), 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_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 ( char  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_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_cshiftdiag ( char  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_Obj_shift_diagonal().

{
    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 ( char  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_Obj_scale_diagonal().

{
    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 ( char  conj,
int  offset,
int  m,
int  n,
float *  sigma,
scomplex a,
int  a_rs,
int  a_cs 
)

References scomplex::real.

Referenced by FLA_Obj_shift_diagonal().

{
    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 ( char  conj,
char  uplo,
int  m,
scomplex a,
int  a_rs,
int  a_cs 
)

References bli_ccopyv(), bli_does_conj(), bli_is_col_storage(), 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_does_conj( conj ) )
        {
            a_jj = a + j*a_rs + j*a_cs;
            a_jj->imag = bli_s0();
        }
    }
}
double bli_d0 ( void  )
double bli_d1 ( void  )

Referenced by bli_dgemm(), bli_drandmr(), bli_dsymm(), bli_dtrmmsx(), bli_dtrsmsx(), and bli_z1().

{
    double x;
    x = 1.0;
    return x;
}
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 ( char  side,
char  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*   a_begin;
    double*   chi;
    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(), and bli_set_contig_strides().

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 ( char  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 ( char  side,
char  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 ( char  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(), and bli_set_contig_strides().

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_dewscalmt ( char  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_vector_dim(), bli_vector_inc(), and bli_zero_dim2().

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;

    // 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 );
            }
        }
    }

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

        bli_dewscalv( trans,
                      n_elem,
                      a_begin, inca, 
                      b_begin, incb );
    }
}
void bli_dewscalv ( char  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(), and bli_is_gen_storage().

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 ( char  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 ( char  side,
char  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_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 ( char  conj,
double *  alpha,
double *  beta 
)

Referenced by bli_dinvscalm(), and bli_zdinvscalm().

{
    double one = 1.0;

    *beta = one / *alpha;
}
void bli_dinverts ( char  conj,
double *  alpha 
)
void bli_dinvertv ( char  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  )

Referenced by bli_zconjm(), bli_zconjmr(), bli_zconjv(), and bli_zm1().

{
    double x;
    x = -1.0;
    return x;
}
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_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 ( char  uplo,
char  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(), and bli_zero_dim2().

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 ( char  conj,
int  offset,
int  m,
int  n,
double *  sigma,
double *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Obj_scale_diagonal(), 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_Obj_set_diagonal_to_scalar(), 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_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 ( char  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_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 ( char  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_Obj_shift_diagonal().

{
    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 ( char  conj,
char  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 );
    }
}
float bli_s0 ( void  )
float bli_s1 ( void  )

Referenced by bli_c1(), bli_sgemm(), bli_srandmr(), bli_ssymm(), bli_strmmsx(), and bli_strsmsx().

{
    float x;
    x = 1.0F;
    return x;
}
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 ( char  side,
char  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*    a_begin;
    float*    chi;
    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(), and bli_set_contig_strides().

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 ( char  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 ( char  side,
char  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 ( char  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(), and bli_set_contig_strides().

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 ( char  side,
int  m,
int  n,
int *  dim_new 
)
void bli_set_dims_with_trans ( char  trans,
int  m,
int  n,
int *  m_new,
int *  n_new 
)

References bli_does_trans().

{
    if ( bli_does_trans( trans ) )
    {
        *m_new = n;
        *n_new = m;
    }
    else
    {
        *m_new = m;
        *n_new = n;
    }
}
void bli_sewscalmt ( char  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_sewscalv(), bli_vector_dim(), bli_vector_inc(), and bli_zero_dim2().

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;

    // 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 );
            }
        }
    }

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

        bli_sewscalv( trans,
                      n_elem,
                      a_begin, inca, 
                      b_begin, incb );
    }
}
void bli_sewscalv ( char  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(), and bli_sfree().

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 ( char  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 ( char  side,
char  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 ( char  conj,
float *  alpha,
float *  beta 
)

Referenced by bli_csinvscalm(), and bli_sinvscalm().

{
    float  one = 1.0F;

    *beta = one / *alpha;
}
void bli_sinverts ( char  conj,
float *  alpha 
)
void bli_sinvertv ( char  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_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 ( char  uplo,
char  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(), and bli_zero_dim2().

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 ( char  conj,
int  offset,
int  m,
int  n,
float *  sigma,
float *  a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Obj_scale_diagonal(), 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_Obj_set_diagonal_to_scalar(), 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_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 ( char  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_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 ( char  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_Obj_shift_diagonal().

{
    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 ( char  conj,
char  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 );
    }
}
dcomplex bli_z0 ( void  )

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

Referenced by bli_zgemm(), bli_zgemv(), bli_zhemm(), bli_zhemv(), bli_zrandmr(), and bli_zsymm().

{
    dcomplex x;
    x.real = bli_d0();
    x.imag = bli_d0();
    return x;
}
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 ( char  side,
char  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* a_begin;
    dcomplex* chi;
    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(), and bli_zcopymt().

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 ( char  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 ( char  side,
char  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 ( char  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(), and bli_zcopymt().

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_zdscalediag ( char  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_Obj_scale_diagonal().

{
    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 ( char  conj,
int  offset,
int  m,
int  n,
double *  sigma,
dcomplex a,
int  a_rs,
int  a_cs 
)

References dcomplex::real.

Referenced by FLA_Obj_shift_diagonal().

{
    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_zewscalmt ( char  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_vector_dim(), bli_vector_inc(), bli_zero_dim2(), and bli_zewscalv().

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;

    // 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 );
            }
        }
    }

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

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

References bli_does_conj().

Referenced by bli_zapdiagmv(), and bli_zewscalmt().

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

    if ( bli_does_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(), and bli_zfree().

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 ( char  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 ( char  side,
char  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 ( char  conj,
dcomplex alpha,
dcomplex beta 
)

References bli_does_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_does_conj( conj ) )
        bli_zconjs( beta );
}
void bli_zinverts ( char  conj,
dcomplex alpha 
)

References bli_does_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_does_conj( conj ) )
        bli_zconjs( alpha );
}
void bli_zinvertv ( char  conj,
int  n,
dcomplex x,
int  incx 
)

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

Referenced by FLA_Invert().

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

    if ( bli_does_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  )

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

{
    dcomplex x;
    x.real = bli_dm1();
    x.imag = bli_d0();
    return x;
}
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_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 ( char  uplo,
char  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(), 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 ( char  conj,
int  offset,
int  m,
int  n,
dcomplex sigma,
dcomplex a,
int  a_rs,
int  a_cs 
)

Referenced by FLA_Obj_scale_diagonal(), 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_Obj_set_diagonal_to_scalar(), 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 
)

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

Referenced by FLA_Bidiag_UT_u_step_ofz_var4(), FLA_Bidiag_UT_u_step_opz_var4(), FLA_Bidiag_UT_u_step_opz_var5(), FLA_Hess_UT_step_ofz_var4(), FLA_Hess_UT_step_opz_var4(), FLA_Hess_UT_step_opz_var5(), FLA_Tridiag_UT_l_step_ofz_var3(), and FLA_Tridiag_UT_l_step_opz_var3().

{
    dcomplex* 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_zsetmr ( char  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_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 ( char  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_Obj_shift_diagonal().

{
    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 ( char  conj,
char  uplo,
int  m,
dcomplex a,
int  a_rs,
int  a_cs 
)

References bli_d0(), bli_does_conj(), bli_is_col_storage(), 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_does_conj( conj ) )
        {
            a_jj = a + j*a_rs + j*a_cs;
            a_jj->imag = bli_d0();
        }
    }
}