42 #ifndef STOKHOS_STOCHASTICPRODUCTTENSOR_HPP
43 #define STOKHOS_STOCHASTICPRODUCTTENSOR_HPP
47 #include "Kokkos_Core.hpp"
78 template<
typename ValueType ,
typename TensorType,
class Device >
121 KOKKOS_INLINE_FUNCTION
127 KOKKOS_INLINE_FUNCTION
132 KOKKOS_INLINE_FUNCTION
135 #if defined( KOKKOS_ENABLE_CUDA )
136 std::is_same<execution_space,Kokkos::Cuda>::value;
140 const size_type AlignBytes = is_cuda ? 128 : 64;
142 return (
dimension() + NumAlign-1) & ~(NumAlign-1);
146 KOKKOS_INLINE_FUNCTION
150 template<
typename iType >
151 KOKKOS_INLINE_FUNCTION
159 template<
typename iType ,
typename jType >
160 KOKKOS_INLINE_FUNCTION
164 void print( std::ostream & s )
const
166 for (
unsigned i = 1 ; i <
m_degree_map.extent(0) ; ++i ) {
167 s <<
" bases[" << i - 1 <<
"] (" ;
171 s <<
" )" << std::endl ;
175 template <
typename OrdinalType,
typename CijkType>
178 const CijkType& Cijk,
185 typedef Kokkos::View< size_type** , execution_space > int_array_type ;
186 typedef typename int_array_type::HostMirror host_int_array_type ;
188 OrdinalType basis_sz = basis.
size();
189 OrdinalType basis_dim = basis.
dimension();
193 int_array_type(
"stochastic_tensor_degree_map" ,
200 host_int_array_type degree_map =
202 for ( OrdinalType
j = 0 ;
j < basis_dim ; ++
j )
203 degree_map(0,
j) = max_orders[
j];
204 for ( OrdinalType i = 0 ; i < basis_sz ; ++i ) {
206 for ( OrdinalType
j = 0 ;
j < basis_dim ; ++
j ) {
207 degree_map(i+1,
j) = term[
j];
213 spt.
m_tensor = tensor_type::create( basis, Cijk, params );
219 template<
typename TensorType,
typename OrdinalType ,
typename ValueType,
typename CijkType >
220 StochasticProductTensor<ValueType, TensorType, typename TensorType::execution_space>
223 const CijkType& Cijk,
228 basis, Cijk, params);
231 template <
typename ValueType ,
typename Device,
class TensorType >
239 template<
typename MatrixValue ,
typename VectorValue >
240 KOKKOS_INLINE_FUNCTION
242 const MatrixValue * a ,
243 const VectorValue *
const x ,
244 VectorValue *
const y )
248 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)