/* Example programs from the book Scientific and Engineering Programming in C++: An Introduction with Advanced Techniques and Examples, Addison-Wesley, 1994. (c) COPYRIGHT INTERNATIONAL BUSINESS MACHINES CORPORATION 1994. ALL RIGHTS RESERVED. See README file for further details. */ #include "LapackWrap/BlasSubroutines.h" template ConcreteBlas2d& ConcreteBlas2d::operator*=(const T& rhs) { Blas3Subroutines::xscal(numElts(), rhs, firstDatum(), 1); return *this; } template ConcreteBlas1d operator*(const ConcreteBlas2d& m, const ConcreteBlas1d& v) { ConcreteBlas1d result( m.shape(0) ); Blas3Subroutines::xgemv( Blas3Subroutines::no_trans, m.shape(0), m.shape(1), T(1), m.firstDatum(), m.shape(0), v.firstDatum(), 1, T(0), result.firstDatum(), 1 ); return result; } template ConcreteBlas2d& ConcreteBlas2d::operator/=(const T& rhs) { Blas3Subroutines::xscal(numElts(), T(1) / rhs, firstDatum(), 1); return *this; } template ConcreteBlas2d& ConcreteBlas2d::operator*=(const ConcreteBlas2d& rhs) { ConcreteBlas2d lhs(*this); // Copy out left operand reshape(SubscriptArray<2>(shape(0), rhs.shape(1))); // Make room for product Blas3Subroutines::xgemm( Blas3Subroutines::no_trans, Blas3Subroutines::no_trans, lhs.shape(0), rhs.shape(1), rhs.shape(0), T(1), lhs.firstDatum(), lhs.shape(0), rhs.firstDatum(), rhs.shape(0), T(0), firstDatum(), shape(0) ); return *this; } template ConcreteBlas2d& ConcreteBlas2d::setToOne() { *this = T(0); Subscript i = shape(0); T one(1); while (i-- > 0) (*this)(i, i) = one; return *this; } template ConcreteBlasProjection1d& ConcreteBlasProjection1d::operator*=(const T& rhs) { for (IteratorType i(*this); i.more(); i.advance()) i.current() *= rhs; return *this; } template ConcreteBlasProjection1d& ConcreteBlasProjection1d::operator/=(const T& rhs) { for (IteratorType i(*this); i.more(); i.advance()) i.current() /= rhs; return *this; } template double ConcreteBlasProjection1d::dot(const ConcreteBlasProjection1d& rhs) const { if ( shape(0) != rhs.shape(0) ) throw ArrayErr::Shape(); return Blas1Subroutines::xdot(shape(0), firstDatum(), offset(1), rhs.firstDatum(), rhs.offset(1)); } template ConcreteBlas1d operator*(const ConcreteBlasProjection1d& lhs, const T& rhs) { ConcreteBlas1d result(lhs); return result *= rhs; } template ConcreteBlas1d operator/(const ConcreteBlasProjection1d& lhs, const T& rhs) { ConcreteBlas1d result(lhs); return result /= rhs; } template ostream& operator<<(ostream& os, const ConstConcreteBlasProjection1d& p) { ConcreteArray1dConstRef::ConstProjectionT::SubscriptorT, T> pr = p; return os << pr; } template double ConstConcreteBlasProjection1d::dot(const ConstConcreteBlasProjection1d& rhs) const { if ( shape(0) != rhs.shape(0) ) throw ArrayErr::Shape(); return Blas1Subroutines::xdot(shape(0), firstDatum(), offset(1), rhs.firstDatum(), rhs.offset(1)); } template ConcreteBlas1d operator*(const ConstConcreteBlasProjection1d& lhs, const T& rhs) { ConcreteBlas1d result(lhs); return result *= rhs; } template ConcreteBlas1d operator/(const ConstConcreteBlasProjection1d& lhs, const T& rhs) { ConcreteBlas1d result(lhs); return result /= rhs; } template ConstConcreteBlasProjection1d ConcreteBlas2d::project(Subscript i, Dimension d) const { return ConcreteFortranArray2d::project(i, d); } template ConcreteBlas2d::ProjectionT ConcreteBlas2d::project(Subscript i, Dimension d) { return ConcreteFortranArray2d::project(i, d); }