libflame revision_anchor
Functions
bli_trsmsx.c File Reference

(r)

Functions

void bli_strsmsx (char side, char uplo, char trans, char diag, int m, int n, float *alpha, float *a, int a_rs, int a_cs, float *b, int b_rs, int b_cs, float *beta, float *c, int c_rs, int c_cs)
void bli_dtrsmsx (char side, char uplo, char trans, char diag, int m, int n, double *alpha, double *a, int a_rs, int a_cs, double *b, int b_rs, int b_cs, double *beta, double *c, int c_rs, int c_cs)
void bli_ctrsmsx (char side, char uplo, char trans, char diag, int m, int n, scomplex *alpha, scomplex *a, int a_rs, int a_cs, scomplex *b, int b_rs, int b_cs, scomplex *beta, scomplex *c, int c_rs, int c_cs)
void bli_ztrsmsx (char side, char uplo, char trans, char diag, int m, int n, dcomplex *alpha, dcomplex *a, int a_rs, int a_cs, dcomplex *b, int b_rs, int b_cs, dcomplex *beta, dcomplex *c, int c_rs, int c_cs)

Function Documentation

void bli_ctrsmsx ( char  side,
char  uplo,
char  trans,
char  diag,
int  m,
int  n,
scomplex alpha,
scomplex a,
int  a_rs,
int  a_cs,
scomplex b,
int  b_rs,
int  b_cs,
scomplex beta,
scomplex c,
int  c_rs,
int  c_cs 
)

References bli_c1(), bli_callocm(), bli_caxpymt(), bli_ccopymt(), bli_ccreate_contigm(), bli_ccreate_contigmr(), bli_cfree(), bli_cfree_contigm(), bli_cfree_saved_contigm(), bli_cscalm(), bli_ctrsm(), bli_is_col_storage(), bli_set_dim_with_side(), and bli_zero_dim2().

Referenced by FLA_Trsmsx_external().

{
    int       m_save    = m;
    int       n_save    = n;
    scomplex* a_save    = a;
    scomplex* b_save    = b;
    scomplex* c_save    = c;
    int       a_rs_save = a_rs;
    int       a_cs_save = a_cs;
    int       b_rs_save = b_rs;
    int       b_cs_save = b_cs;
    int       c_rs_save = c_rs;
    int       c_cs_save = c_cs;
    scomplex  one = bli_c1();
    scomplex* b_copy;
    int       dim_a;
    int       b_copy_rs, b_copy_cs;

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

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

    bli_ccreate_contigm( m,
                         n,
                         b_save, b_rs_save, b_cs_save,
                         &b,     &b_rs,     &b_cs );

    bli_ccreate_contigm( m,
                         n,
                         c_save, c_rs_save, c_cs_save,
                         &c,     &c_rs,     &c_cs );

    // Create a copy of B to use in the computation so the original matrix is
    // left untouched.
    b_copy = bli_callocm( m, n );

    // Match the strides of B_copy to that of B.
    if ( bli_is_col_storage( b_rs, b_cs ) )
    {
        b_copy_rs = 1;
        b_copy_cs = m;
    }
    else // if ( bli_is_row_storage( b_rs, b_cs ) )
    {
        b_copy_rs = n;
        b_copy_cs = 1;
    }

    // Copy the contents of B to B_copy.
    bli_ccopymt( BLIS_NO_CONJUGATE,
                 m,
                 n,
                 b,      b_rs,      b_cs,
                 b_copy, b_copy_rs, b_copy_cs );
    
    // Perform the operation on B_copy.
    bli_ctrsm( side,
               uplo,
               trans,
               diag,
               m,
               n,
               alpha,
               a,      a_rs,      a_cs,
               b_copy, b_copy_rs, b_copy_cs );

    // Scale C by beta.
    bli_cscalm( BLIS_NO_CONJUGATE,
                m,
                n,
                beta,
                c, c_rs, c_cs );

    // Add B_copy into C.
    bli_caxpymt( BLIS_NO_TRANSPOSE,
                 m,
                 n,
                 &one,
                 b_copy, b_copy_rs, b_copy_cs,
                 c,      c_rs,      c_cs );

    // Free the copy of B.
    bli_cfree( b_copy );

    // Free any temporary contiguous matrices, copying the result back to
    // the original matrix.
    bli_cfree_contigm( a_save, a_rs_save, a_cs_save,
                       &a,     &a_rs,     &a_cs );

    bli_cfree_contigm( b_save, b_rs_save, b_cs_save,
                       &b,     &b_rs,     &b_cs );

    bli_cfree_saved_contigm( m_save,
                             n_save,
                             c_save, c_rs_save, c_cs_save,
                             &c,     &c_rs,     &c_cs );
}
void bli_dtrsmsx ( char  side,
char  uplo,
char  trans,
char  diag,
int  m,
int  n,
double *  alpha,
double *  a,
int  a_rs,
int  a_cs,
double *  b,
int  b_rs,
int  b_cs,
double *  beta,
double *  c,
int  c_rs,
int  c_cs 
)

References bli_d1(), bli_dallocm(), bli_daxpymt(), bli_dcopymt(), bli_dcreate_contigm(), bli_dcreate_contigmr(), bli_dfree(), bli_dfree_contigm(), bli_dfree_saved_contigm(), bli_dscalm(), bli_dtrsm(), bli_is_col_storage(), bli_set_dim_with_side(), and bli_zero_dim2().

Referenced by FLA_Trsmsx_external().

{
    int       m_save    = m;
    int       n_save    = n;
    double*   a_save    = a;
    double*   b_save    = b;
    double*   c_save    = c;
    int       a_rs_save = a_rs;
    int       a_cs_save = a_cs;
    int       b_rs_save = b_rs;
    int       b_cs_save = b_cs;
    int       c_rs_save = c_rs;
    int       c_cs_save = c_cs;
    double    one = bli_d1();
    double*   b_copy;
    int       dim_a;
    int       b_copy_rs, b_copy_cs;

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

    // If necessary, allocate, initialize, and use a temporary contiguous
    // copy of each matrix rather than the original matrices.
    bli_set_dim_with_side( side, m, n, &dim_a );
    bli_dcreate_contigmr( uplo,
                          dim_a,
                          dim_a,
                          a_save, a_rs_save, a_cs_save,
                          &a,     &a_rs,     &a_cs );

    bli_dcreate_contigm( m,
                         n,
                         b_save, b_rs_save, b_cs_save,
                         &b,     &b_rs,     &b_cs );

    bli_dcreate_contigm( m,
                         n,
                         c_save, c_rs_save, c_cs_save,
                         &c,     &c_rs,     &c_cs );

    // Create a copy of B to use in the computation so the original matrix is
    // left untouched.
    b_copy = bli_dallocm( m, n );

    // Match the strides of B_copy to that of B.
    if ( bli_is_col_storage( b_rs, b_cs ) )
    {
        b_copy_rs = 1;
        b_copy_cs = m;
    }
    else // if ( bli_is_row_storage( b_rs, b_cs ) )
    {
        b_copy_rs = n;
        b_copy_cs = 1;
    }

    // Copy the contents of B to B_copy.
    bli_dcopymt( BLIS_NO_CONJUGATE,
                 m,
                 n,
                 b,      b_rs,      b_cs,
                 b_copy, b_copy_rs, b_copy_cs );
    
    // Perform the operation on B_copy.
    bli_dtrsm( side,
               uplo,
               trans,
               diag,
               m,
               n,
               alpha,
               a,      a_rs,      a_cs,
               b_copy, b_copy_rs, b_copy_cs );

    // Scale C by beta.
    bli_dscalm( BLIS_NO_CONJUGATE,
                m,
                n,
                beta,
                c, c_rs, c_cs );

    // Add B_copy into C.
    bli_daxpymt( BLIS_NO_TRANSPOSE,
                 m,
                 n,
                 &one,
                 b_copy, b_copy_rs, b_copy_cs,
                 c,      c_rs,      c_cs );

    // Free the copy of B.
    bli_dfree( b_copy );

    // Free any temporary contiguous matrices, copying the result back to
    // the original matrix.
    bli_dfree_contigm( a_save, a_rs_save, a_cs_save,
                       &a,     &a_rs,     &a_cs );

    bli_dfree_contigm( b_save, b_rs_save, b_cs_save,
                       &b,     &b_rs,     &b_cs );

    bli_dfree_saved_contigm( m_save,
                             n_save,
                             c_save, c_rs_save, c_cs_save,
                             &c,     &c_rs,     &c_cs );
}
void bli_strsmsx ( char  side,
char  uplo,
char  trans,
char  diag,
int  m,
int  n,
float *  alpha,
float *  a,
int  a_rs,
int  a_cs,
float *  b,
int  b_rs,
int  b_cs,
float *  beta,
float *  c,
int  c_rs,
int  c_cs 
)

References bli_is_col_storage(), bli_s1(), bli_sallocm(), bli_saxpymt(), bli_scopymt(), bli_screate_contigm(), bli_screate_contigmr(), bli_set_dim_with_side(), bli_sfree(), bli_sfree_contigm(), bli_sfree_saved_contigm(), bli_sscalm(), bli_strsm(), and bli_zero_dim2().

Referenced by FLA_Trsmsx_external().

{
    int       m_save    = m;
    int       n_save    = n;
    float*    a_save    = a;
    float*    b_save    = b;
    float*    c_save    = c;
    int       a_rs_save = a_rs;
    int       a_cs_save = a_cs;
    int       b_rs_save = b_rs;
    int       b_cs_save = b_cs;
    int       c_rs_save = c_rs;
    int       c_cs_save = c_cs;
    float     one = bli_s1();
    float*    b_copy;
    int       dim_a;
    int       b_copy_rs, b_copy_cs;

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

    // If necessary, allocate, initialize, and use a temporary contiguous
    // copy of each matrix rather than the original matrices.
    bli_set_dim_with_side( side, m, n, &dim_a );
    bli_screate_contigmr( uplo,
                          dim_a,
                          dim_a,
                          a_save, a_rs_save, a_cs_save,
                          &a,     &a_rs,     &a_cs );

    bli_screate_contigm( m,
                         n,
                         b_save, b_rs_save, b_cs_save,
                         &b,     &b_rs,     &b_cs );

    bli_screate_contigm( m,
                         n,
                         c_save, c_rs_save, c_cs_save,
                         &c,     &c_rs,     &c_cs );

    // Create a copy of B to use in the computation so the original matrix is
    // left untouched.
    b_copy = bli_sallocm( m, n );

    // Match the strides of B_copy to that of B.
    if ( bli_is_col_storage( b_rs, b_cs ) )
    {
        b_copy_rs = 1;
        b_copy_cs = m;
    }
    else // if ( bli_is_row_storage( b_rs, b_cs ) )
    {
        b_copy_rs = n;
        b_copy_cs = 1;
    }

    // Copy the contents of B to B_copy.
    bli_scopymt( BLIS_NO_CONJUGATE,
                 m,
                 n,
                 b,      b_rs,      b_cs,
                 b_copy, b_copy_rs, b_copy_cs );
    
    // Perform the operation on B_copy.
    bli_strsm( side,
               uplo,
               trans,
               diag,
               m,
               n,
               alpha,
               a,      a_rs,      a_cs,
               b_copy, b_copy_rs, b_copy_cs );

    // Scale C by beta.
    bli_sscalm( BLIS_NO_CONJUGATE,
                m,
                n,
                beta,
                c, c_rs, c_cs );

    // Add B_copy into C.
    bli_saxpymt( BLIS_NO_TRANSPOSE,
                 m,
                 n,
                 &one,
                 b_copy, b_copy_rs, b_copy_cs,
                 c,      c_rs,      c_cs );

    // Free the copy of B.
    bli_sfree( b_copy );

    // Free any temporary contiguous matrices, copying the result back to
    // the original matrix.
    bli_sfree_contigm( a_save, a_rs_save, a_cs_save,
                       &a,     &a_rs,     &a_cs );

    bli_sfree_contigm( b_save, b_rs_save, b_cs_save,
                       &b,     &b_rs,     &b_cs );

    bli_sfree_saved_contigm( m_save,
                             n_save,
                             c_save, c_rs_save, c_cs_save,
                             &c,     &c_rs,     &c_cs );
}
void bli_ztrsmsx ( char  side,
char  uplo,
char  trans,
char  diag,
int  m,
int  n,
dcomplex alpha,
dcomplex a,
int  a_rs,
int  a_cs,
dcomplex b,
int  b_rs,
int  b_cs,
dcomplex beta,
dcomplex c,
int  c_rs,
int  c_cs 
)

References bli_is_col_storage(), bli_set_dim_with_side(), bli_z1(), bli_zallocm(), bli_zaxpymt(), bli_zcopymt(), bli_zcreate_contigm(), bli_zcreate_contigmr(), bli_zero_dim2(), bli_zfree(), bli_zfree_contigm(), bli_zfree_saved_contigm(), bli_zscalm(), and bli_ztrsm().

Referenced by FLA_Trsmsx_external().

{
    int       m_save    = m;
    int       n_save    = n;
    dcomplex* a_save    = a;
    dcomplex* b_save    = b;
    dcomplex* c_save    = c;
    int       a_rs_save = a_rs;
    int       a_cs_save = a_cs;
    int       b_rs_save = b_rs;
    int       b_cs_save = b_cs;
    int       c_rs_save = c_rs;
    int       c_cs_save = c_cs;
    dcomplex  one = bli_z1();
    dcomplex* b_copy;
    int       dim_a;
    int       b_copy_rs, b_copy_cs;

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

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

    bli_zcreate_contigm( m,
                         n,
                         b_save, b_rs_save, b_cs_save,
                         &b,     &b_rs,     &b_cs );

    bli_zcreate_contigm( m,
                         n,
                         c_save, c_rs_save, c_cs_save,
                         &c,     &c_rs,     &c_cs );

    // Create a copy of B to use in the computation so the original matrix is
    // left untouched.
    b_copy = bli_zallocm( m, n );

    // Match the strides of B_copy to that of B.
    if ( bli_is_col_storage( b_rs, b_cs ) )
    {
        b_copy_rs = 1;
        b_copy_cs = m;
    }
    else // if ( bli_is_row_storage( b_rs, b_cs ) )
    {
        b_copy_rs = n;
        b_copy_cs = 1;
    }

    // Copy the contents of B to B_copy.
    bli_zcopymt( BLIS_NO_CONJUGATE,
                 m,
                 n,
                 b,      b_rs,      b_cs,
                 b_copy, b_copy_rs, b_copy_cs );
    
    // Perform the operation on B_copy.
    bli_ztrsm( side,
               uplo,
               trans,
               diag,
               m,
               n,
               alpha,
               a,      a_rs,      a_cs,
               b_copy, b_copy_rs, b_copy_cs );

    // Scale C by beta.
    bli_zscalm( BLIS_NO_CONJUGATE,
                m,
                n,
                beta,
                c, c_rs, c_cs );

    // Add B_copy into C.
    bli_zaxpymt( BLIS_NO_TRANSPOSE,
                 m,
                 n,
                 &one,
                 b_copy, b_copy_rs, b_copy_cs,
                 c,      c_rs,      c_cs );

    // Free the copy of B.
    bli_zfree( b_copy );

    // Free any temporary contiguous matrices, copying the result back to
    // the original matrix.
    bli_zfree_contigm( a_save, a_rs_save, a_cs_save,
                       &a,     &a_rs,     &a_cs );

    bli_zfree_contigm( b_save, b_rs_save, b_cs_save,
                       &b,     &b_rs,     &b_cs );

    bli_zfree_saved_contigm( m_save,
                             n_save,
                             c_save, c_rs_save, c_cs_save,
                             &c,     &c_rs,     &c_cs );
}