10 #ifndef STOKHOS_LINEAR_SPARSE_3_TENSOR_HPP 
   11 #define STOKHOS_LINEAR_SPARSE_3_TENSOR_HPP 
   13 #include "Kokkos_Core.hpp" 
   29 template< 
typename ValueType , 
class ExecutionSpace , 
int BlockSize >
 
   34   typedef typename execution_space::size_type  
size_type ;
 
   86   KOKKOS_INLINE_FUNCTION
 
   90   KOKKOS_INLINE_FUNCTION
 
   94   KOKKOS_INLINE_FUNCTION
 
   99    KOKKOS_INLINE_FUNCTION
 
  104   KOKKOS_INLINE_FUNCTION
 
  109   KOKKOS_INLINE_FUNCTION
 
  114   KOKKOS_INLINE_FUNCTION
 
  118   template <
typename OrdinalType>
 
  134     tensor.
m_nnz = symmetric ? 2 : 3 ;
 
  138     typename value_array_type::host_mirror_type
 
  144       bases[0]->computeTripleProductTensor();
 
  146     host_value(0) = (*cijk)(0,0,0);
 
  147     host_value(1) = (*cijk)(0,1,1);
 
  149       host_value(2) = (*cijk)(1,1,1);
 
  162 template< 
class Device , 
typename OrdinalType , 
typename ValueType , 
int BlockSize >
 
  163 LinearSparse3Tensor<ValueType, Device,BlockSize>
 
  170     basis, Cijk, params );
 
  173 template < 
typename ValueType, 
typename Device, 
int BlockSize >
 
  181   template< 
typename MatrixValue , 
typename VectorValue >
 
  182   KOKKOS_INLINE_FUNCTION
 
  184                      const MatrixValue * 
const a ,
 
  185                      const VectorValue * 
const x ,
 
  186                            VectorValue * 
const y )
 
  188     const size_type block_size = tensor_type::block_size;
 
  192     const ValueType c0 = tensor.
value(0);
 
  193     const ValueType c1 = tensor.
value(1);
 
  194     const ValueType a0 = a[0];
 
  195     const ValueType x0 = x[0];
 
  197     if (block_size > 1) {
 
  199       TV vc0(c0), vc1(c1), va0(a0), vx0(x0), vy0;
 
  202       const MatrixValue *aa = a;
 
  203       const VectorValue *xx = x;
 
  207       const size_type nBlock = dim / block_size;
 
  208       const size_type iEnd = nBlock * block_size;
 
  213         for ( ; i < iEnd; i+=block_size,aa+=block_size,xx+=block_size,yy+=block_size) {
 
  226           yi.aligned_scatter(yy);
 
  229           ai2.times_equal(vc1);
 
  232         ValueType y0 = vy0.sum();
 
  235         for ( ; i < dim; ++i) {
 
  236           const ValueType ai3 = *aa++;
 
  237           const ValueType xi2 = *xx++;
 
  238           *yy++ += c1*(a0*xi2 + ai3*x0);
 
  241         y[0] += y0 + (c0-3.0*c1)*a0*x0;
 
  245         const ValueType c2 = tensor.
value(2);
 
  248         for ( ; i < iEnd; i+=block_size,aa+=block_size,xx+=block_size,yy+=block_size) {
 
  264           yi.aligned_scatter(yy);
 
  267           ai2.times_equal(vc1);
 
  270         ValueType y0 = vy0.sum();
 
  273         for ( ; i < dim; ++i) {
 
  274           const ValueType ai3 = *aa++;
 
  275           const ValueType xi2 = *xx++;
 
  276           const ValueType aixi = ai3*xi2;
 
  277           *yy++ += c1*(a0*xi2 + ai3*x0) + c2*aixi;
 
  280         y[0] += y0 + (c0-3.0*c1-c2)*a0*x0;
 
  288       ValueType y0 = c0*a0*x0;
 
  293           const ValueType ai = a[i];
 
  294           const ValueType xi = x[i];
 
  295           y[i] += c1*(a0*xi + ai*x0);
 
  303         const ValueType c2 = tensor.
value(2);
 
  305           const ValueType ai = a[i];
 
  306           const ValueType xi = x[i];
 
  307           const ValueType aixi = ai*xi;
 
  308           y[i] += c1*(a0*xi + ai*x0) + c2*aixi;
 
  319   KOKKOS_INLINE_FUNCTION
 
  323   KOKKOS_INLINE_FUNCTION
 
KOKKOS_INLINE_FUNCTION size_type entry_count() const 
Number of sparse entries. 
 
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format. 
 
T & get(ParameterList &l, const std::string &name)
 
static LinearSparse3Tensor create(const Stokhos::ProductBasis< OrdinalType, ValueType > &basis, const Stokhos::Sparse3Tensor< OrdinalType, ValueType > &Cijk, const Teuchos::ParameterList ¶ms)
 
KOKKOS_INLINE_FUNCTION size_type num_non_zeros() const 
Number of non-zero's. 
 
Kokkos::View< value_type[], execution_space > value_array_type
 
Stokhos::CrsMatrix< ValueType, Device, Layout >::host_mirror_type create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)
 
Device::size_type size_type
 
static KOKKOS_INLINE_FUNCTION size_type matrix_size(const tensor_type &tensor)
 
KOKKOS_INLINE_FUNCTION size_type dimension() const 
Dimension of the tensor. 
 
KOKKOS_INLINE_FUNCTION bool symmetric() const 
Is tensor built from symmetric PDFs. 
 
ExecutionSpace execution_space
 
Sparse product tensor with replicated entries to provide subsets with a given coordinate. 
 
execution_space::size_type size_type
 
static KOKKOS_INLINE_FUNCTION void apply(const tensor_type &tensor, const MatrixValue *const a, const VectorValue *const x, VectorValue *const y)
 
LinearSparse3Tensor< ValueType, Device, BlockSize > tensor_type
 
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
 
LinearSparse3Tensor & operator=(const LinearSparse3Tensor &rhs)
 
virtual Teuchos::Array< Teuchos::RCP< const OneDOrthogPolyBasis< ordinal_type, value_type > > > getCoordinateBases() const =0
Return array of coordinate bases. 
 
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< view_type >::value, typename CijkType< view_type >::type >::type cijk(const view_type &view)
 
KOKKOS_INLINE_FUNCTION size_type aligned_dimension() const 
Dimension of the tensor. 
 
LinearSparse3Tensor(const LinearSparse3Tensor &rhs)
 
KOKKOS_INLINE_FUNCTION const value_type & value(const size_type entry) const 
Value for entry 'entry'. 
 
static const int block_size
 
KOKKOS_INLINE_FUNCTION size_type num_flops() const 
Number flop's per multiply-add. 
 
static KOKKOS_INLINE_FUNCTION size_type vector_size(const tensor_type &tensor)
 
LinearSparse3Tensor< ValueType, Device, BlockSize > create_linear_sparse_3_tensor(const Stokhos::ProductBasis< OrdinalType, ValueType > &basis, const Stokhos::Sparse3Tensor< OrdinalType, ValueType > &Cijk, const Teuchos::ParameterList ¶ms)
 
virtual ordinal_type size() const =0
Return total size of basis.