// @HEADER // ***************************************************************************** // Stokhos Package // // Copyright 2009 NTESS and the Stokhos contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #include "Stokhos_ProductBasis.hpp" template Stokhos::VectorOrthogPoly:: VectorOrthogPoly() : ProductContainer(), basis_() { } template Stokhos::VectorOrthogPoly:: VectorOrthogPoly( const Teuchos::RCP >& theBasis, const Teuchos::RCP& theMap) : ProductContainer(theMap), basis_(theBasis) { } template Stokhos::VectorOrthogPoly:: VectorOrthogPoly( const Teuchos::RCP >& theBasis, const Teuchos::RCP& theMap, const typename traits_type::cloner_type& cloner) : ProductContainer(theMap, cloner), basis_(theBasis) { } template Stokhos::VectorOrthogPoly:: VectorOrthogPoly(const Stokhos::VectorOrthogPoly& v) : ProductContainer(v), basis_(v.basis_) { } template Stokhos::VectorOrthogPoly:: ~VectorOrthogPoly() { } template Stokhos::VectorOrthogPoly& Stokhos::VectorOrthogPoly:: operator=(const Stokhos::VectorOrthogPoly& v) { if (this != &v) { ProductContainer::operator=(v); basis_ = v.basis_; } return *this; } template void Stokhos::VectorOrthogPoly:: reset( const Teuchos::RCP >& new_basis, const Teuchos::RCP& new_map, const typename traits_type::cloner_type& cloner) { basis_ = new_basis; ProductContainer::reset(new_map, cloner); } template Teuchos::RCP::ordinal_type, typename Stokhos::VectorOrthogPoly::value_type> > Stokhos::VectorOrthogPoly:: basis() const { return basis_; } template coeff_type& Stokhos::VectorOrthogPoly:: term(ordinal_type dimension, ordinal_type order) { Teuchos::RCP< const Stokhos::ProductBasis > product_basis = Teuchos::rcp_dynamic_cast< const Stokhos::ProductBasis >(basis_, true); ordinal_type d = product_basis->dimension(); MultiIndex theTerm(d); theTerm[dimension] = order; ordinal_type index = product_basis->index(theTerm); return *(this->coeff_[this->map_->LID(index)]); } template const coeff_type& Stokhos::VectorOrthogPoly:: term(ordinal_type dimension, ordinal_type order) const { Teuchos::RCP< const Stokhos::ProductBasis > product_basis = Teuchos::rcp_dynamic_cast< const Stokhos::ProductBasis >(basis_, true); ordinal_type d = product_basis->dimension(); MultiIndex theTerm(d); theTerm[dimension] = order; ordinal_type index = product_basis->index(theTerm); return *(this->coeff_[this->map_->LID(index)]); } template void Stokhos::VectorOrthogPoly:: evaluate(const Teuchos::Array& basis_values, coeff_type& result) const { traits_type::init(result, value_type(0)); ordinal_type sz = this->coeff_.size(); for (ordinal_type i=0; icoeff_[i])); } template void Stokhos::VectorOrthogPoly:: sumIntoAllTerms(const value_type& weight, const Teuchos::Array& basis_values, const Teuchos::Array& basis_norms, const coeff_type& vec) { ordinal_type sz = this->coeff_.size(); int i_gid; for (ordinal_type i=0; imap_->GID(i); traits_type::update(*(this->coeff_[i]), weight*basis_values[i_gid]/basis_norms[i_gid], vec); } } template std::ostream& Stokhos::VectorOrthogPoly:: print(std::ostream& os) const { ordinal_type sz = this->coeff_.size(); os << "Stokhos::VectorOrthogPoly of global size " << this->map_->NumGlobalElements() << ", local size " << sz << " in basis " << "\n" << basis_->getName() << ":" << std::endl; Teuchos::RCP< const Stokhos::ProductBasis > product_basis = Teuchos::rcp_dynamic_cast< const Stokhos::ProductBasis >(basis_); if (product_basis != Teuchos::null) { for (ordinal_type i=0; i& trm = product_basis->term(i); os << "Term " << i << " ("; for (ordinal_type j=0; j(trm.size())-1; j++) os << trm[j] << ", "; os << trm[trm.size()-1] << "):" << std::endl; traits_type::print(os, *(this->coeff_[this->map_->LID(i)])); } } else { for (ordinal_type i=0; imap_->GID(i) << ":" << std::endl; traits_type::print(os, *(this->coeff_[i])); } } return os; }