14 #include "KokkosSparse_CrsMatrix.hpp"
15 #include "KokkosSparse_spmv.hpp"
23 #include "Kokkos_Core.hpp"
26 template<
typename IntType >
33 return k + N * ( j + N * i );
36 template <
typename ordinal >
39 std::vector< std::vector<ordinal> >& graph )
41 graph.resize( N * N * N, std::vector<ordinal>() );
45 for (
int i = 0; i < (int) N; ++i ) {
46 for (
int j = 0;
j < (int) N; ++
j ) {
47 for (
int k = 0; k < (int) N; ++k ) {
51 graph[row].reserve(27);
53 for (
int ii = -1; ii < 2; ++ii ) {
54 for (
int jj = -1; jj < 2; ++jj ) {
55 for (
int kk = -1; kk < 2; ++kk ) {
56 if ( 0 <= i + ii && i + ii < (
int) N &&
57 0 <=
j + jj &&
j + jj < (
int) N &&
58 0 <= k + kk && k + kk < (
int) N ) {
61 graph[row].push_back(col);
64 total += graph[row].size();
70 template <
typename scalar,
typename ordinal>
74 const ordinal iRowFEM,
75 const ordinal iColFEM,
76 const ordinal iStoch )
78 const scalar A_fem = ( 10.0 + scalar(iRowFEM) / scalar(nFEM) ) +
79 ( 5.0 + scalar(iColFEM) / scalar(nFEM) );
81 const scalar A_stoch = ( 1.0 + scalar(iStoch) / scalar(nStoch) );
83 return A_fem + A_stoch;
87 template <
typename scalar,
typename ordinal>
91 const ordinal iColFEM,
92 const ordinal iStoch )
94 const scalar X_fem = 100.0 + scalar(iColFEM) / scalar(nFEM);
95 const scalar X_stoch = 1.0 + scalar(iStoch) / scalar(nStoch);
96 return X_fem + X_stoch;
100 template <
typename kokkos_cijk_type,
typename ordinal_type>
116 Array< RCP<const one_d_basis> > bases(stoch_dim);
118 bases[i] =
rcp(
new legendre_basis(poly_ord,
true));
119 RCP<const product_basis> basis =
rcp(
new product_basis(bases));
122 RCP<Cijk>
cijk = basis->computeTripleProductTensor();
125 kokkos_cijk_type kokkos_cijk =
126 Stokhos::create_product_tensor<execution_space>(*basis, *
cijk);
132 template <
typename Scalar>
struct ScalarTol {};
133 template <>
struct ScalarTol<float> {
static float tol() {
return 1e-4; } };
137 template <
typename array_type,
typename scalar_type>
139 const array_type& y_exp,
144 typedef typename array_type::size_type size_type;
150 size_type num_rows = y.extent(0);
151 size_type num_cols = y.extent(1);
153 for (size_type i=0; i<num_rows; ++i) {
154 for (size_type
j=0;
j<num_cols; ++
j) {
158 out <<
"y_expected(" << i <<
"," <<
j <<
") - "
159 <<
"y(" << i <<
"," <<
j <<
") = " << hy_exp(i,
j)
160 <<
" - " << hy(i,
j) <<
" == "
161 << diff <<
" < " << tol <<
" : ";
167 success = success && s;
174 template <
typename vector_type,
typename scalar_type>
176 const vector_type& y_exp,
181 typedef typename vector_type::size_type size_type;
187 size_type num_rows = y.extent(0);
189 for (size_type i=0; i<num_rows; ++i) {
194 out <<
"y_expected(" << i <<
").coeff(" <<
j <<
") - "
195 <<
"y(" << i <<
").coeff(" <<
j <<
") = " << hy_exp(i).fastAccessCoeff(
j)
196 <<
" - " << hy(i).fastAccessCoeff(
j) <<
" == "
197 << diff <<
" < " << tol <<
" : ";
203 success = success && s;
209 template <
typename vector_type,
typename scalar_type>
211 const vector_type& y_exp,
216 typedef typename vector_type::size_type size_type;
222 size_type num_rows = y.extent(0);
223 size_type num_cols = y.extent(1);
226 for (size_type col = 0; col < num_cols; ++col){
227 for (size_type i=0; i<num_rows; ++i) {
232 out <<
"y_expected(" << i <<
").coeff(" <<
j <<
") - "
233 <<
"y(" << i <<
").coeff(" <<
j <<
") = " << hy_exp(i,col).fastAccessCoeff(
j)
234 <<
" - " << hy(i,col).fastAccessCoeff(
j) <<
" == "
235 << diff <<
" < " << tol <<
" : ";
241 success = success && s;
252 template <
typename MatrixType,
typename CijkType>
256 const CijkType&
cijk) {
258 typedef typename MatrixType::StaticCrsGraphType matrix_graph_type;
259 typedef typename MatrixType::values_type matrix_values_type;
261 std::vector< std::vector<ordinal_type> > graph(nrow);
262 for (ordinal_type i=0; i<nrow; ++i)
263 graph[i] = std::vector<ordinal_type>(1, i);
264 ordinal_type graph_length = nrow;
266 matrix_graph_type matrix_graph =
267 Kokkos::create_staticcrsgraph<matrix_graph_type>(
"graph", graph);
268 matrix_values_type matrix_values =
269 Kokkos::make_view<matrix_values_type>(
"values",
cijk, graph_length, pce_size);
271 MatrixType matrix(
"matrix", nrow, matrix_values, matrix_graph);
280 template <
typename MatrixType>
291 KOKKOS_INLINE_FUNCTION
296 m_matrix.replaceValues(row, &col, 1, &val,
false,
true);
300 static void apply(
const MatrixType matrix) {
306 static bool check(
const MatrixType matrix,
308 typedef typename MatrixType::values_type matrix_values_type;
309 typename matrix_values_type::HostMirror host_matrix_values =
318 "matrix_values(row)",
322 success = success && s;
329 template <
typename MatrixType>
340 KOKKOS_INLINE_FUNCTION
345 m_matrix.sumIntoValues(row, &col, 1, &val,
false,
true);
349 static void apply(
const MatrixType matrix) {
355 static bool check(
const MatrixType matrix,
357 typedef typename MatrixType::values_type matrix_values_type;
358 typename matrix_values_type::HostMirror host_matrix_values =
367 "matrix_values(row)",
371 success = success && s;
379 template <
typename MatrixType>
390 KOKKOS_INLINE_FUNCTION
395 m_matrix.sumIntoValues(row, &col, 1, &val,
false,
true);
399 static void apply(
const MatrixType matrix) {
405 static bool check(
const MatrixType matrix,
407 typedef typename MatrixType::values_type matrix_values_type;
408 typename matrix_values_type::HostMirror host_matrix_values =
417 val_expected = nrow*(nrow-1)/2;
421 "matrix_values(row)",
425 success = success && s;
432 Kokkos_CrsMatrix_PCE, ReplaceValues, MatrixScalar )
436 typedef typename MatrixScalar::cijk_type Cijk;
437 typedef KokkosSparse::CrsMatrix<MatrixScalar,Ordinal,Device> Matrix;
445 const Ordinal nrow = 10;
446 const Ordinal pce_size = cijk.dimension();
447 Matrix matrix = buildDiagonalMatrix<Matrix>(nrow, pce_size,
cijk);
451 kernel::apply(matrix);
454 success = kernel::check(matrix, out);
458 Kokkos_CrsMatrix_PCE, SumIntoValues, MatrixScalar )
462 typedef typename MatrixScalar::cijk_type Cijk;
463 typedef KokkosSparse::CrsMatrix<MatrixScalar,Ordinal,Device> Matrix;
471 const Ordinal nrow = 10;
472 const Ordinal pce_size = cijk.dimension();
473 Matrix matrix = buildDiagonalMatrix<Matrix>(nrow, pce_size,
cijk);
477 kernel::apply(matrix);
480 success = kernel::check(matrix, out);
484 Kokkos_CrsMatrix_PCE, SumIntoValuesAtomic, MatrixScalar )
488 typedef typename MatrixScalar::cijk_type Cijk;
489 typedef KokkosSparse::CrsMatrix<MatrixScalar,Ordinal,Device> Matrix;
497 const Ordinal nrow = 10;
498 const Ordinal pce_size = cijk.dimension();
499 Matrix matrix = buildDiagonalMatrix<Matrix>(nrow, pce_size,
cijk);
503 kernel::apply(matrix);
506 success = kernel::check(matrix, out);
509 template <
typename PCEType,
typename Multiply>
513 KokkosSparse::DeviceConfig dev_config,
514 Multiply multiply_op,
520 typedef typename PCEType::cijk_type cijk_type;
522 typedef Kokkos::LayoutLeft Layout;
523 typedef Kokkos::View< PCEType*, Layout, execution_space > block_vector_type;
524 typedef KokkosSparse::CrsMatrix< PCEType, ordinal_type, execution_space > block_matrix_type;
525 typedef typename block_matrix_type::StaticCrsGraphType matrix_graph_type;
526 typedef typename block_matrix_type::values_type matrix_values_type;
530 const ordinal_type stoch_length = cijk.dimension();
533 const ordinal_type stoch_length_aligned = stoch_length;
537 storage_type::is_static && storage_type::static_size != stoch_length,
539 "Static storage size must equal pce size");
542 const ordinal_type fem_length = nGrid * nGrid * nGrid;
543 std::vector< std::vector<ordinal_type> > fem_graph;
550 block_vector_type x =
551 Kokkos::make_view<block_vector_type>(
"x",
cijk, fem_length, stoch_length_aligned);
552 block_vector_type y =
553 Kokkos::make_view<block_vector_type>(
"y",
cijk, fem_length, stoch_length_aligned);
559 typename block_vector_type::HostMirror::array_type hax = hx ;
560 typename block_vector_type::HostMirror::array_type hay = hy ;
562 for (ordinal_type iRowFEM=0; iRowFEM<fem_length; ++iRowFEM) {
563 for (ordinal_type iRowStoch=0; iRowStoch<stoch_length; ++iRowStoch) {
564 hax(iRowStoch, iRowFEM) =
565 generate_vector_coefficient<scalar_type>(
566 fem_length, stoch_length, iRowFEM, iRowStoch );
567 hay(iRowStoch, iRowFEM) = 0.0;
577 matrix_graph_type matrix_graph =
578 Kokkos::create_staticcrsgraph<matrix_graph_type>(
579 std::string(
"test crs graph"), fem_graph);
580 matrix_values_type matrix_values =
581 Kokkos::make_view<matrix_values_type>(
582 Kokkos::ViewAllocateWithoutInitializing(
"matrix"),
cijk, fem_graph_length, stoch_length_aligned);
583 block_matrix_type matrix(
584 "block_matrix", fem_length, matrix_values, matrix_graph);
585 matrix.dev_config = dev_config;
587 typename matrix_values_type::HostMirror hM =
590 typename matrix_values_type::HostMirror::array_type haM = hM ;
592 for (ordinal_type iRowFEM=0, iEntryFEM=0; iRowFEM<fem_length; ++iRowFEM) {
593 const ordinal_type row_size = fem_graph[iRowFEM].size();
594 for (ordinal_type iRowEntryFEM=0; iRowEntryFEM<row_size;
595 ++iRowEntryFEM, ++iEntryFEM) {
596 const ordinal_type iColFEM = fem_graph[iRowFEM][iRowEntryFEM];
598 for (ordinal_type k=0; k<stoch_length; ++k) {
600 generate_matrix_coefficient<scalar_type>(
601 fem_length, stoch_length, iRowFEM, iColFEM, k);
611 multiply_op( matrix, x, y );
616 typedef typename block_vector_type::array_type array_type;
617 array_type ay_expected =
618 array_type(
"ay_expected", stoch_length_aligned, fem_length);
619 typename array_type::HostMirror hay_expected =
621 typename cijk_type::HostMirror host_cijk =
624 for (ordinal_type iRowFEM=0, iEntryFEM=0; iRowFEM<fem_length; ++iRowFEM) {
625 const ordinal_type row_size = fem_graph[iRowFEM].size();
626 for (ordinal_type iRowEntryFEM=0; iRowEntryFEM<row_size;
627 ++iRowEntryFEM, ++iEntryFEM) {
628 const ordinal_type iColFEM = fem_graph[iRowFEM][iRowEntryFEM];
629 for (ordinal_type i=0; i<stoch_length; ++i) {
630 const ordinal_type num_entry = host_cijk.num_entry(i);
631 const ordinal_type entry_beg = host_cijk.entry_begin(i);
632 const ordinal_type entry_end = entry_beg + num_entry;
634 for (ordinal_type entry = entry_beg; entry < entry_end; ++entry) {
635 const ordinal_type
j = host_cijk.coord(entry,0);
636 const ordinal_type k = host_cijk.coord(entry,1);
637 const scalar_type a_j =
638 generate_matrix_coefficient<scalar_type>(
639 fem_length, stoch_length, iRowFEM, iColFEM,
j);
640 const scalar_type a_k =
641 generate_matrix_coefficient<scalar_type>(
642 fem_length, stoch_length, iRowFEM, iColFEM, k);
643 const scalar_type x_j =
644 generate_vector_coefficient<scalar_type>(
645 fem_length, stoch_length, iColFEM,
j);
646 const scalar_type x_k =
647 generate_vector_coefficient<scalar_type>(
648 fem_length, stoch_length, iColFEM, k);
649 tmp += host_cijk.value(entry) * ( a_j * x_k + a_k * x_j );
651 hay_expected(i, iRowFEM) += tmp;
660 typename block_vector_type::array_type ay = y;
669 Kokkos_CrsMatrix_PCE, Multiply,
Scalar, MultiplyOp )
673 const Ordinal nGrid = 5;
676 KokkosSparse::DeviceConfig dev_config;
678 success = test_embedded_pce<Scalar>(
683 template <
typename Matrix,
typename InputVector,
typename OutputVector>
685 const InputVector& x,
686 OutputVector& y)
const {
691 template <
typename Tag>
696 template <
typename Matrix,
typename InputVector,
typename OutputVector>
698 const InputVector& x,
699 OutputVector& y)
const {
705 Kokkos_CrsMatrix_PCE, MeanMultiplyRank1,
Scalar )
709 const Ordinal nGrid = 5;
712 KokkosSparse::DeviceConfig dev_config;
717 typedef typename Scalar::cijk_type cijk_type;
719 typedef Kokkos::LayoutLeft Layout;
720 typedef Kokkos::View< Scalar*, Layout, execution_space > block_vector_type;
721 typedef KokkosSparse::CrsMatrix< Scalar, ordinal_type, execution_space > block_matrix_type;
722 typedef typename block_matrix_type::StaticCrsGraphType matrix_graph_type;
723 typedef typename block_matrix_type::values_type matrix_values_type;
727 cijk_type mean_cijk =
728 Stokhos::create_mean_based_product_tensor<execution_space, ordinal_type, scalar_type>();
729 const ordinal_type stoch_length = cijk.dimension();
730 const ordinal_type align = 8;
731 const ordinal_type stoch_length_aligned = (stoch_length+align-1) & ~(align-1);
734 const ordinal_type fem_length = nGrid * nGrid * nGrid;
735 std::vector< std::vector<ordinal_type> > fem_graph;
738 block_vector_type x =
739 Kokkos::make_view<block_vector_type>(
"x",
cijk, fem_length, stoch_length_aligned);
740 block_vector_type y =
741 Kokkos::make_view<block_vector_type>(
"y",
cijk, fem_length, stoch_length_aligned);
743 block_vector_type y_expected =
744 Kokkos::make_view<block_vector_type>(
"y",
cijk, fem_length, stoch_length_aligned);
748 typename block_vector_type::HostMirror hy_expected =
752 typename block_vector_type::HostMirror::array_type hax = hx ;
753 typename block_vector_type::HostMirror::array_type hay = hy ;
754 typename block_vector_type::HostMirror::array_type hay_expected =
757 for (ordinal_type iRowFEM=0; iRowFEM<fem_length; ++iRowFEM) {
758 for (ordinal_type iRowStoch=0; iRowStoch<stoch_length; ++iRowStoch) {
759 hax(iRowStoch,iRowFEM) =
760 generate_vector_coefficient<scalar_type>(
761 fem_length, stoch_length, iRowFEM, iRowStoch );
762 hay(iRowStoch,iRowFEM) = 0.0;
763 hay_expected(iRowStoch,iRowFEM) = 0.0;
772 matrix_graph_type matrix_graph =
773 Kokkos::create_staticcrsgraph<matrix_graph_type>(
774 std::string(
"test crs graph"), fem_graph);
775 matrix_values_type matrix_values =
776 Kokkos::make_view<matrix_values_type>(
777 Kokkos::ViewAllocateWithoutInitializing(
"matrix"), mean_cijk, fem_graph_length,
ordinal_type(1));
778 block_matrix_type matrix(
779 "block_matrix", fem_length, matrix_values, matrix_graph);
780 matrix.dev_config = dev_config;
782 typename matrix_values_type::HostMirror hM =
784 typename matrix_values_type::HostMirror::array_type haM = hM ;
786 for (ordinal_type iRowFEM=0, iEntryFEM=0; iRowFEM<fem_length; ++iRowFEM) {
787 const ordinal_type row_size = fem_graph[iRowFEM].size();
788 for (ordinal_type iRowEntryFEM=0; iRowEntryFEM<row_size;
789 ++iRowEntryFEM, ++iEntryFEM) {
790 const ordinal_type iColFEM = fem_graph[iRowFEM][iRowEntryFEM];
793 generate_matrix_coefficient<scalar_type>(
794 fem_length, 1, iRowFEM, iColFEM, 0);
795 for (ordinal_type iRowStoch=0; iRowStoch<stoch_length; ++iRowStoch) {
796 hay_expected(iRowStoch,iRowFEM) +=
797 haM(iEntryFEM, 0) * hax(iRowStoch,iColFEM);
851 success =
compareRank1(y, y_expected, rel_tol, abs_tol, out);
856 Kokkos_CrsMatrix_PCE, MeanMultiplyRank2,
Scalar )
861 typedef typename Scalar::cijk_type cijk_type;
863 typedef Kokkos::LayoutLeft Layout;
864 typedef Kokkos::View< Scalar**, Layout, execution_space > block_vector_type;
865 typedef KokkosSparse::CrsMatrix< Scalar, ordinal_type, execution_space > block_matrix_type;
866 typedef typename block_matrix_type::StaticCrsGraphType matrix_graph_type;
867 typedef typename block_matrix_type::values_type matrix_values_type;
870 const ordinal_type nGrid = 5;
873 KokkosSparse::DeviceConfig dev_config;
877 cijk_type mean_cijk =
878 Stokhos::create_mean_based_product_tensor<execution_space, ordinal_type, scalar_type>();
879 const ordinal_type stoch_length = cijk.dimension();
880 const ordinal_type align = 8;
881 const ordinal_type stoch_length_aligned = (stoch_length+align-1) & ~(align-1);
882 const ordinal_type num_cols = 2;
884 const ordinal_type fem_length = nGrid * nGrid * nGrid;
885 std::vector< std::vector<ordinal_type> > fem_graph;
888 block_vector_type x =
889 Kokkos::make_view<block_vector_type>(
"x",
cijk, fem_length, num_cols, stoch_length_aligned);
890 block_vector_type y =
891 Kokkos::make_view<block_vector_type>(
"y",
cijk, fem_length, num_cols, stoch_length_aligned);
893 block_vector_type y_expected =
894 Kokkos::make_view<block_vector_type>(
"y_expected",
cijk, fem_length, num_cols, stoch_length_aligned);
898 typename block_vector_type::HostMirror hy_expected =
901 for (ordinal_type i=0; i<num_cols; ++i){
902 for (ordinal_type iRowFEM=0; iRowFEM<fem_length; ++iRowFEM) {
903 for (ordinal_type iRowStoch=0; iRowStoch<stoch_length; ++iRowStoch) {
904 hx(iRowFEM,i).fastAccessCoeff(iRowStoch) =
905 generate_vector_coefficient<scalar_type>(
906 fem_length, stoch_length, iRowFEM, iRowStoch );
907 hy(iRowFEM,i).fastAccessCoeff(iRowStoch) = 0.0;
908 hy_expected(iRowFEM,i).fastAccessCoeff(iRowStoch) = 0.0;
918 matrix_graph_type matrix_graph =
919 Kokkos::create_staticcrsgraph<matrix_graph_type>(
920 std::string(
"test crs graph"), fem_graph);
921 matrix_values_type matrix_values =
922 Kokkos::make_view<matrix_values_type>(
923 Kokkos::ViewAllocateWithoutInitializing(
"matrix"), mean_cijk, fem_graph_length,
ordinal_type(1));
924 block_matrix_type matrix(
925 "block_matrix", fem_length, matrix_values, matrix_graph);
926 matrix.dev_config = dev_config;
928 typename matrix_values_type::HostMirror hM =
931 typename matrix_values_type::HostMirror::array_type haM = hM ;
933 for (ordinal_type iRowFEM=0, iEntryFEM=0; iRowFEM<fem_length; ++iRowFEM) {
934 const ordinal_type row_size = fem_graph[iRowFEM].size();
935 for (ordinal_type iRowEntryFEM=0; iRowEntryFEM<row_size;
936 ++iRowEntryFEM, ++iEntryFEM) {
937 const ordinal_type iColFEM = fem_graph[iRowFEM][iRowEntryFEM];
940 generate_matrix_coefficient<scalar_type>(
941 fem_length, 1, iRowFEM, iColFEM, 0);
942 for (ordinal_type i=0; i<num_cols; ++i){
943 for (ordinal_type iRowStoch=0; iRowStoch<stoch_length; ++iRowStoch) {
944 hy_expected(iRowFEM,i).fastAccessCoeff(iRowStoch) +=
945 haM(iEntryFEM, 0) * hx(iColFEM,i).fastAccessCoeff(iRowStoch);
1003 success =
compareRank2(y, y_expected, rel_tol, abs_tol, out);
1009 #define CRSMATRIX_UQ_PCE_TESTS_MATRIXSCALAR( SCALAR ) \
1010 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
1011 Kokkos_CrsMatrix_PCE, ReplaceValues, SCALAR ) \
1012 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
1013 Kokkos_CrsMatrix_PCE, SumIntoValues, SCALAR ) \
1014 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
1015 Kokkos_CrsMatrix_PCE, SumIntoValuesAtomic, SCALAR )
1016 #define CRSMATRIX_UQ_PCE_MEAN_MULTIPLY_TESTS( SCALAR ) \
1017 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
1018 Kokkos_CrsMatrix_PCE, MeanMultiplyRank1, SCALAR ) \
1019 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \
1020 Kokkos_CrsMatrix_PCE, MeanMultiplyRank2, SCALAR )
1021 #define CRS_MATRIX_UQ_PCE_MULTIPLY_TESTS_SCALAR_OP( SCALAR, OP ) \
1022 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( \
1023 Kokkos_CrsMatrix_PCE, Multiply, SCALAR, OP )
1025 #define CRS_MATRIX_UQ_PCE_MULTIPLY_TESTS_SCALAR( SCALAR ) \
1026 CRS_MATRIX_UQ_PCE_MULTIPLY_TESTS_SCALAR_OP( SCALAR, KokkosMultiply )
1028 #define CRSMATRIX_UQ_PCE_TESTS_STORAGE( STORAGE ) \
1029 typedef Sacado::UQ::PCE<STORAGE> UQ_PCE_ ## STORAGE; \
1030 CRSMATRIX_UQ_PCE_TESTS_MATRIXSCALAR( UQ_PCE_ ## STORAGE ) \
1031 CRS_MATRIX_UQ_PCE_MULTIPLY_TESTS_SCALAR( UQ_PCE_ ## STORAGE ) \
1032 CRSMATRIX_UQ_PCE_MEAN_MULTIPLY_TESTS( UQ_PCE_ ## STORAGE )
1034 #define CRSMATRIX_UQ_PCE_TESTS_ORDINAL_SCALAR_DEVICE( ORDINAL, SCALAR, DEVICE ) \
1035 typedef Stokhos::DynamicStorage<ORDINAL,SCALAR,DEVICE> DS; \
1036 CRSMATRIX_UQ_PCE_TESTS_STORAGE( DS )
1038 #define CRSMATRIX_UQ_PCE_TESTS_DEVICE( DEVICE ) \
1039 CRSMATRIX_UQ_PCE_TESTS_ORDINAL_SCALAR_DEVICE( int, double, DEVICE )
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
MatrixType::execution_space execution_space
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
Stokhos::StandardStorage< int, double > storage_type
MatrixType::size_type size_type
const MatrixType m_matrix
MatrixType::value_type value_type
bool compareVecs(const VectorType1 &a1, const std::string &a1_name, const VectorType2 &a2, const std::string &a2_name, const ValueType &rel_tol, const ValueType &abs_tol, Teuchos::FancyOStream &out)
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
bool test_embedded_pce(const typename PCEType::ordinal_type nGrid, const typename PCEType::ordinal_type stoch_dim, const typename PCEType::ordinal_type poly_ord, KokkosSparse::DeviceConfig dev_config, Multiply multiply_op, Teuchos::FancyOStream &out)
ordinal generate_fem_graph(ordinal N, std::vector< std::vector< ordinal > > &graph)
static bool check(const MatrixType matrix, Teuchos::FancyOStream &out)
Kokkos::DefaultExecutionSpace execution_space
MatrixType::execution_space execution_space
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
MatrixType buildDiagonalMatrix(typename MatrixType::ordinal_type nrow, typename MatrixType::ordinal_type mp_vector_size)
MatrixType::ordinal_type ordinal_type
static void apply(const MatrixType matrix)
scalar generate_vector_coefficient(const ordinal nFEM, const ordinal nStoch, const ordinal iColFEM, const ordinal iStoch)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P...> >::value, unsigned >::type dimension_scalar(const View< T, P...> &view)
bool compareRank2(const vector_type &y, const vector_type &y_exp, const scalar_type rel_tol, const scalar_type abs_tol, Teuchos::FancyOStream &out)
IntType map_fem_graph_coord(const IntType &N, const IntType &i, const IntType &j, const IntType &k)
MatrixType::value_type value_type
MatrixType::ordinal_type ordinal_type
ReplaceDiagonalValuesKernel(const MatrixType matrix)
MatrixType::size_type size_type
void multiply(const CrsMatrix< MatrixValue, Device, Layout > &A, const InputMultiVectorType &x, OutputMultiVectorType &y, const std::vector< OrdinalType > &col_indices, SingleColumnMultivectorMultiply)
TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL(Kokkos_SG_SpMv, CrsProductTensorCijk, Scalar, Device)
static bool check(const MatrixType matrix, Teuchos::FancyOStream &out)
AddDiagonalValuesAtomicKernel(const MatrixType matrix)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Kokkos_MV_Multiply_Op KokkosMultiply
MatrixType::execution_space execution_space
void operator()(const Matrix &A, const InputVector &x, OutputVector &y) const
static void apply(const MatrixType matrix)
MatrixType::size_type size_type
static bool check(const MatrixType matrix, Teuchos::FancyOStream &out)
Stokhos_MV_Multiply_Op(const Tag &tg=Tag())
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 c fastAccessCoeff(j)-expr2.val(j)
Multivariate orthogonal polynomial basis generated from a total-order complete-polynomial tensor prod...
kokkos_cijk_type build_cijk(ordinal_type stoch_dim, ordinal_type poly_ord)
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)
Legendre polynomial basis.
scalar generate_matrix_coefficient(const ordinal nFEM, const ordinal nStoch, const ordinal iRowFEM, const ordinal iColFEM, const ordinal iStoch)
const MatrixType m_matrix
KOKKOS_INLINE_FUNCTION void operator()(const size_type i) const
Abstract base class for 1-D orthogonal polynomials.
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Kokkos_CrsMatrix_MP, ReplaceValues, MatrixScalar)
AddDiagonalValuesKernel(const MatrixType matrix)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< InputType, InputP... > >::value &&Kokkos::is_view_uq_pce< Kokkos::View< OutputType, OutputP... > >::value >::type spmv(KokkosKernels::Experimental::Controls, const char mode[], const AlphaType &a, const MatrixType &A, const Kokkos::View< InputType, InputP... > &x, const BetaType &b, const Kokkos::View< OutputType, OutputP... > &y, const RANK_ONE)
MatrixType::ordinal_type ordinal_type
const MatrixType m_matrix
bool compareRank1(const vector_type &y, const vector_type &y_exp, const scalar_type rel_tol, const scalar_type abs_tol, Teuchos::FancyOStream &out)
void operator()(const Matrix &A, const InputVector &x, OutputVector &y) const
bool compare_rank_2_views(const array_type &y, const array_type &y_exp, const scalar_type rel_tol, const scalar_type abs_tol, Teuchos::FancyOStream &out)
static void apply(const MatrixType matrix)
MatrixType::value_type value_type
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)