10 #ifndef STOKHOS_STOCHASTICPRODUCTTENSOR_HPP
11 #define STOKHOS_STOCHASTICPRODUCTTENSOR_HPP
15 #include "Kokkos_Core.hpp"
45 template<
typename ValueType ,
typename TensorType,
class Device >
88 KOKKOS_INLINE_FUNCTION
94 KOKKOS_INLINE_FUNCTION
99 KOKKOS_INLINE_FUNCTION
102 #if defined( KOKKOS_ENABLE_CUDA )
103 std::is_same<execution_space,Kokkos::Cuda>::value;
107 const size_type AlignBytes = is_cuda ? 128 : 64;
109 return (
dimension() + NumAlign-1) & ~(NumAlign-1);
113 KOKKOS_INLINE_FUNCTION
117 template<
typename iType >
118 KOKKOS_INLINE_FUNCTION
126 template<
typename iType ,
typename jType >
127 KOKKOS_INLINE_FUNCTION
131 void print( std::ostream & s )
const
133 for (
unsigned i = 1 ; i <
m_degree_map.extent(0) ; ++i ) {
134 s <<
" bases[" << i - 1 <<
"] (" ;
138 s <<
" )" << std::endl ;
142 template <
typename OrdinalType,
typename CijkType>
145 const CijkType& Cijk,
152 typedef Kokkos::View< size_type** , execution_space > int_array_type ;
153 typedef typename int_array_type::HostMirror host_int_array_type ;
155 OrdinalType basis_sz = basis.
size();
156 OrdinalType basis_dim = basis.
dimension();
160 int_array_type(
"stochastic_tensor_degree_map" ,
167 host_int_array_type degree_map =
169 for ( OrdinalType
j = 0 ;
j < basis_dim ; ++
j )
170 degree_map(0,
j) = max_orders[
j];
171 for ( OrdinalType i = 0 ; i < basis_sz ; ++i ) {
173 for ( OrdinalType
j = 0 ;
j < basis_dim ; ++
j ) {
174 degree_map(i+1,
j) = term[
j];
180 spt.
m_tensor = tensor_type::create( basis, Cijk, params );
186 template<
typename TensorType,
typename OrdinalType ,
typename ValueType,
typename CijkType >
187 StochasticProductTensor<ValueType, TensorType, typename TensorType::execution_space>
190 const CijkType& Cijk,
195 basis, Cijk, params);
198 template <
typename ValueType ,
typename Device,
class TensorType >
206 template<
typename MatrixValue ,
typename VectorValue >
207 KOKKOS_INLINE_FUNCTION
209 const MatrixValue * a ,
210 const VectorValue *
const x ,
211 VectorValue *
const y )
215 tensor_multiply::apply( block.
tensor() , a , x , y );
KOKKOS_INLINE_FUNCTION const tensor_type & tensor() const
StochasticProductTensor & operator=(const StochasticProductTensor &rhs)
KOKKOS_INLINE_FUNCTION size_type aligned_dimension() const
Aligned dimension: length of the vector block properly aligned.
Bases defined by combinatorial product of polynomial bases.
execution_space::size_type size_type
static KOKKOS_INLINE_FUNCTION void apply(const block_type &block, const MatrixValue *a, const VectorValue *const x, VectorValue *const y)
Kokkos::DefaultExecutionSpace execution_space
~StochasticProductTensor()
static StochasticProductTensor create(const Stokhos::ProductBasis< OrdinalType, ValueType > &basis, const CijkType &Cijk, const Teuchos::ParameterList ¶ms=Teuchos::ParameterList())
virtual ordinal_type dimension() const =0
Return dimension of basis.
A multidimensional index.
virtual const MultiIndex< ordinal_type > & term(ordinal_type i) const =0
Get orders of each coordinate polynomial given an index i.
KOKKOS_INLINE_FUNCTION size_type variable_count() const
How many variables are being expanded.
StochasticProductTensor(const StochasticProductTensor &rhs)
StochasticProductTensor< ValueType, TensorType, typename TensorType::execution_space > create_stochastic_product_tensor(const Stokhos::ProductBasis< OrdinalType, ValueType > &basis, const CijkType &Cijk, const Teuchos::ParameterList ¶ms=Teuchos::ParameterList())
KOKKOS_INLINE_FUNCTION size_type bases_degree(const iType &iBasis, const jType &iVariable) const
Basis function 'iBasis' is the product of 'variable_count()' polynomials. Return the polynomial degre...
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
KOKKOS_INLINE_FUNCTION size_type dimension() const
Dimension: number of bases and length of the vector block (and tensor).
tensor_type::size_type size_type
KOKKOS_INLINE_FUNCTION size_type variable_degree(const iType &iVariable) const
Polynomial degree of a given variable.
StochasticProductTensor()
void print(std::ostream &s) const
Kokkos::View< size_type **, execution_space > m_degree_map
StochasticProductTensor< ValueType, TensorType, execution_space > block_type
virtual ordinal_type size() const =0
Return total size of basis.
virtual MultiIndex< ordinal_type > getMaxOrders() const =0
Return maximum order allowable for each coordinate basis.
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)