Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_Update.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_UPDATE_HPP
11 #define STOKHOS_UPDATE_HPP
12 
13 namespace Stokhos {
14 
15 template< typename ValueType, typename VectorType >
16 class Update
17 {
18 public:
19  typedef VectorType vector_type;
20  typedef ValueType value_type;
22  typedef typename execution_space::size_type size_type;
23 
24 
29 
30  Update(const value_type& alpha, vector_type& x,
31  const value_type& beta, const vector_type& y)
32  : m_x( x )
33  , m_y( y )
34  , m_alpha( alpha )
35  , m_beta( beta )
36  {}
37 
38  //--------------------------------------------------------------------------
39 
40  KOKKOS_INLINE_FUNCTION
41  void operator()( const size_type iRow ) const
42  {
43  m_x(iRow) = m_alpha * m_x(iRow) + m_beta * m_y(iRow) ;
44  }
45 
46  static void apply(const value_type& alpha, vector_type& x,
47  const value_type& beta, const vector_type& y)
48  {
49  const size_t row_count = x.extent(0);
50  Kokkos::parallel_for( row_count , Update(alpha,x,beta,y) );
51  }
52 };
53 
54 template <typename ValueType, typename VectorType>
55 void update(const ValueType& alpha, VectorType& x,
56  const ValueType& beta, const VectorType& y)
57 {
58  Update<ValueType,VectorType>::apply( alpha , x , beta, y );
59 }
60 
61 } // namespace Stokhos
62 
63 #endif
VectorType vector_type
Kokkos::DefaultExecutionSpace execution_space
const value_type m_beta
const vector_type m_y
static void apply(const value_type &alpha, vector_type &x, const value_type &beta, const vector_type &y)
ValueType value_type
const value_type m_alpha
KOKKOS_INLINE_FUNCTION void operator()(const size_type iRow) const
vector_type::execution_space execution_space
execution_space::size_type size_type
Update(const value_type &alpha, vector_type &x, const value_type &beta, const vector_type &y)
void update(const ValueType &alpha, VectorType &x, const ValueType &beta, const VectorType &y)