1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
#ifndef HPC_ULMBLAS_TRUSM_H
#define HPC_ULMBLAS_TRUSM_H 1

namespace hpc { namespace ulmblas {

template <typename Index, typename Alpha, typename TA, typename TB>
void
trusm(Index         m,
      Index         n,
      const Alpha   &alpha,
      bool          unitDiag,
      const TA      *A,
      Index         incRowA,
      Index         incColA,
      TB            *B,
      Index         incRowB,
      Index         incColB)
{
    for (Index j=0; j<n; ++j) {
        if (alpha!=Alpha(1)) {
            for (Index i=0; i<m; ++i) {
                B[i*incRowB+j*incColB] *= alpha;
            }
        }
        for (Index i_=m; i_>=1; --i_) {
            Index i = i_ - 1;
            if (!unitDiag) {
                B[i*incRowB+j*incColB] /= A[i*(incRowA+incColA)];
            }
            for (Index l=0; l<i; ++l) {
                B[l*incRowB+j*incColB] -= A[l*incRowA+i*incColA]
                                         *B[i*incRowB+j*incColB];
            }
        }
    }
}


} } // namespace ulmblas, hpc

#endif // HPC_ULMBLAS_TRUSM_H 1