inline void Trmv ( UpperOrLower uplo, Orientation orientation, UnitOrNonUnit diag, const Matrix<T>& A, Matrix<T>& x ) { #ifndef RELEASE PushCallStack("Trmv"); if( x.Height() != 1 && x.Width() != 1 ) throw std::logic_error("x must be a vector"); if( A.Height() != A.Width() ) throw std::logic_error("A must be square"); const int xLength = ( x.Width()==1 ? x.Height() : x.Width() ); if( xLength != A.Height() ) throw std::logic_error("x must conform with A"); #endif const char uploChar = UpperOrLowerToChar( uplo ); const char transChar = OrientationToChar( orientation ); const char diagChar = UnitOrNonUnitToChar( diag ); const int m = A.Height(); const int incx = ( x.Width()==1 ? 1 : x.LDim() ); blas::Trmv ( uploChar, transChar, diagChar, m, A.LockedBuffer(), A.LDim(), x.Buffer(), incx ); #ifndef RELEASE PopCallStack(); #endif }
inline void Trmm ( LeftOrRight side, UpperOrLower uplo, Orientation orientation, UnitOrNonUnit diag, T alpha, const Matrix<T>& A, Matrix<T>& B ) { #ifndef RELEASE CallStackEntry entry("Trmm"); if( A.Height() != A.Width() ) LogicError("Triangular matrix must be square"); if( side == LEFT ) { if( A.Height() != B.Height() ) LogicError("Nonconformal Trmm"); } else { if( A.Height() != B.Width() ) LogicError("Nonconformal Trmm"); } #endif const char sideChar = LeftOrRightToChar( side ); const char uploChar = UpperOrLowerToChar( uplo ); const char transChar = OrientationToChar( orientation ); const char diagChar = UnitOrNonUnitToChar( diag ); blas::Trmm ( sideChar, uploChar, transChar, diagChar, B.Height(), B.Width(), alpha, A.LockedBuffer(), A.LDim(), B.Buffer(), B.LDim() ); }
inline void Syrk ( UpperOrLower uplo, Orientation orientation, T alpha, const Matrix<T>& A, T beta, Matrix<T>& C ) { #ifndef RELEASE PushCallStack("Syrk"); if( orientation == NORMAL ) { if( A.Height() != C.Height() || A.Height() != C.Width() ) throw std::logic_error("Nonconformal Syrk"); } else if( orientation == TRANSPOSE ) { if( A.Width() != C.Height() || A.Width() != C.Width() ) throw std::logic_error("Nonconformal Syrk"); } else throw std::logic_error ("Syrk only accepts NORMAL and TRANSPOSE options"); #endif const char uploChar = UpperOrLowerToChar( uplo ); const char transChar = OrientationToChar( orientation ); const int k = ( orientation == NORMAL ? A.Width() : A.Height() ); blas::Syrk ( uploChar, transChar, C.Height(), k, alpha, A.LockedBuffer(), A.LDim(), beta, C.Buffer(), C.LDim() ); #ifndef RELEASE PopCallStack(); #endif }
void imatcopy ( Orientation orientation, BlasInt m, BlasInt n, dcomplex alpha, dcomplex* A, BlasInt lda, BlasInt ldb ) { if( m < 1 || n < 1 ) return; char ordering = 'C'; char trans = OrientationToChar( orientation ); EL_BLAS(zimatcopy)( &ordering, &trans, &m, &n, &alpha, A, &lda, &ldb ); }
void TrrkMKL ( UpperOrLower uplo, Orientation orientA, Orientation orientB, T alpha, const Matrix<T>& A, const Matrix<T>& B, T beta, Matrix<T>& C ) { EL_DEBUG_CSE const char uploChar = UpperOrLowerToChar( uplo ); const char orientAChar = OrientationToChar( orientA ); const char orientBChar = OrientationToChar( orientB ); const auto n = C.Height(); const auto k = orientA == NORMAL ? A.Width() : A.Height(); mkl::Trrk ( uploChar, orientAChar, orientBChar, n, k, alpha, A.LockedBuffer(), A.LDim(), B.LockedBuffer(), B.LDim(), beta, C.Buffer(), C.LDim() ); }
void omatcopy ( Orientation orientation, BlasInt m, BlasInt n, double alpha, const double* A, BlasInt lda, double* B, BlasInt ldb ) { if( m < 1 || n < 1 ) return; char ordering = 'C'; char trans = OrientationToChar( orientation ); EL_BLAS(domatcopy)( &ordering, &trans, &m, &n, &alpha, A, &lda, B, &ldb ); }
inline void Trsm ( LeftOrRight side, UpperOrLower uplo, Orientation orientation, UnitOrNonUnit diag, F alpha, const Matrix<F>& A, Matrix<F>& B, bool checkIfSingular ) { #ifndef RELEASE PushCallStack("Trsm"); if( A.Height() != A.Width() ) throw std::logic_error("Triangular matrix must be square"); if( side == LEFT ) { if( A.Height() != B.Height() ) throw std::logic_error("Nonconformal Trsm"); } else { if( A.Height() != B.Width() ) throw std::logic_error("Nonconformal Trsm"); } #endif const char sideChar = LeftOrRightToChar( side ); const char uploChar = UpperOrLowerToChar( uplo ); const char transChar = OrientationToChar( orientation ); const char diagChar = UnitOrNonUnitToChar( diag ); if( checkIfSingular && diag != UNIT ) { const int n = A.Height(); for( int j=0; j<n; ++j ) if( A.Get(j,j) == F(0) ) throw SingularMatrixException(); } blas::Trsm ( sideChar, uploChar, transChar, diagChar, B.Height(), B.Width(), alpha, A.LockedBuffer(), A.LDim(), B.Buffer(), B.LDim() ); #ifndef RELEASE PopCallStack(); #endif }
inline void Gemv ( Orientation orientation, T alpha, const Matrix<T>& A, const Matrix<T>& x, T beta, Matrix<T>& y ) { #ifndef RELEASE PushCallStack("Gemv"); if( ( x.Height() != 1 && x.Width() != 1 ) || ( y.Height() != 1 && y.Width() != 1 ) ) { std::ostringstream msg; msg << "x and y must be vectors:\n" << " x ~ " << x.Height() << " x " << x.Width() << "\n" << " y ~ " << y.Height() << " x " << y.Width(); throw std::logic_error( msg.str().c_str() ); } const int xLength = ( x.Width()==1 ? x.Height() : x.Width() ); const int yLength = ( y.Width()==1 ? y.Height() : y.Width() ); if( orientation == NORMAL ) { if( A.Height() != yLength || A.Width() != xLength ) { std::ostringstream msg; msg << "A must conform with x and y:\n" << " A ~ " << A.Height() << " x " << A.Width() << "\n" << " x ~ " << x.Height() << " x " << x.Width() << "\n" << " y ~ " << y.Height() << " x " << y.Width(); throw std::logic_error( msg.str().c_str() ); } } else { if( A.Width() != yLength || A.Height() != xLength ) { std::ostringstream msg; msg << "A must conform with x and y:\n" << " A ~ " << A.Height() << " x " << A.Width() << "\n" << " x ~ " << x.Height() << " x " << x.Width() << "\n" << " y ~ " << y.Height() << " x " << y.Width(); throw std::logic_error( msg.str().c_str() ); } } #endif const char transChar = OrientationToChar( orientation ); const int m = A.Height(); const int n = A.Width(); const int k = ( transChar == 'N' ? n : m ); const int incx = ( x.Width()==1 ? 1 : x.LDim() ); const int incy = ( y.Width()==1 ? 1 : y.LDim() ); if( k != 0 ) { blas::Gemv ( transChar, m, n, alpha, A.LockedBuffer(), A.LDim(), x.LockedBuffer(), incx, beta, y.Buffer(), incy ); } else { Scale( beta, y ); } #ifndef RELEASE PopCallStack(); #endif }