Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_MeanBasedDivisionExpansionStrategy.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef STOKHOS_MEAN_BASED_DIVISION_EXPANSION_STRATEGY_HPP
11 #define STOKHOS_MEAN_BASED_DIVISION_EXPANSION_STRATEGY_HPP
12 
14 #include "Teuchos_TimeMonitor.hpp"
15 
16 namespace Stokhos {
17 
19 
22  template <typename ordinal_type, typename value_type, typename node_type>
24  public DivisionExpansionStrategy<ordinal_type,value_type,node_type> {
25  public:
26 
29 
32 
33  // Division operation: c = \alpha*(a/b) + beta*c
34  virtual void divide(
36  const value_type& alpha,
39  const value_type& beta);
40 
41  private:
42 
43  // Prohibit copying
46 
47  // Prohibit Assignment
50 
51  }; // class DivisionExpansionStrategy
52 
53 } // namespace Stokhos
54 
55 template <typename ordinal_type, typename value_type, typename node_type>
56 void
59  const value_type& alpha,
62  const value_type& beta)
63 {
64 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
65  TEUCHOS_FUNC_TIME_MONITOR("Stokhos::MeanBasedDivisionStrategy::divide()");
66 #endif
67  ordinal_type pc = a.size();
68  if (c.size() != pc)
69  c.resize(pc);
70 
71  const value_type* ca = a.coeff();
72  const value_type* cb = b.coeff();
73  value_type* cc = c.coeff();
74 
75  for (ordinal_type i=0; i<pc; i++)
76  cc[i] = alpha*ca[i]/cb[0] + beta*cc[i];
77 }
78 
79 #endif // STOKHOS_MEAN_BASED_DIVISION_EXPANSION_STRATEGY_HPP
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
void resize(ordinal_type sz)
Resize coefficient array (coefficients are preserved)
MeanBasedDivisionExpansionStrategy & operator=(const MeanBasedDivisionExpansionStrategy &b)
pointer coeff()
Return coefficient array.
Strategy interface for computing PCE of a/b.
virtual void divide(Stokhos::OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &alpha, const Stokhos::OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const Stokhos::OrthogPolyApprox< ordinal_type, value_type, node_type > &b, const value_type &beta)
Class to store coefficients of a projection onto an orthogonal polynomial basis.
ordinal_type size() const
Return size.
Strategy interface for computing PCE of a/b using only b[0].