MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_CutDrop.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // MueLu: A package for multigrid based preconditioning
4 //
5 // Copyright 2012 NTESS and the MueLu contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef MUELU_CUTDROP_HPP
11 #define MUELU_CUTDROP_HPP
12 
13 #include "Kokkos_Core.hpp"
14 #if KOKKOS_VERSION >= 40799
15 #include "KokkosKernels_ArithTraits.hpp"
16 #else
17 #include "Kokkos_ArithTraits.hpp"
18 #endif
19 #include "MueLu_DroppingCommon.hpp"
20 #include "MueLu_Utilities.hpp"
21 #include "Xpetra_Matrix.hpp"
22 #include "Xpetra_MultiVector.hpp"
24 
25 namespace MueLu::CutDrop {
26 
32 
37 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
39  public:
41 
42  using local_matrix_type = typename matrix_type::local_matrix_type;
43  using scalar_type = typename local_matrix_type::value_type;
44  using local_ordinal_type = typename local_matrix_type::ordinal_type;
45  using memory_space = typename local_matrix_type::memory_space;
46  using results_view = Kokkos::View<DecisionType*, memory_space>;
47 
50 
51  private:
52 #if KOKKOS_VERSION >= 40799
53  using ATS = KokkosKernels::ArithTraits<scalar_type>;
54 #else
55  using ATS = Kokkos::ArithTraits<scalar_type>;
56 #endif
57  using magnitudeType = typename ATS::magnitudeType;
58 
59  public:
61  : A(A_.getLocalMatrixDevice())
62  , results(results_) {}
63 
64  template <class local_matrix_type2>
65  struct Comparator {
66  private:
67  using scalar_type = typename local_matrix_type2::value_type;
68  using local_ordinal_type = typename local_matrix_type2::ordinal_type;
69  using memory_space = typename local_matrix_type2::memory_space;
70  using results_view = Kokkos::View<DecisionType*, memory_space>;
71 
72 #if KOKKOS_VERSION >= 40799
73  using ATS = KokkosKernels::ArithTraits<scalar_type>;
74 #else
75  using ATS = Kokkos::ArithTraits<scalar_type>;
76 #endif
77  using magnitudeType = typename ATS::magnitudeType;
78 
79  const local_matrix_type2 A;
82 
83  public:
84  KOKKOS_INLINE_FUNCTION
85  Comparator(const local_matrix_type2& A_, local_ordinal_type rlid_, const results_view& results_)
86  : A(A_)
87  , offset(A_.graph.row_map(rlid_))
88  , results(results_) {}
89 
90  KOKKOS_INLINE_FUNCTION
91  magnitudeType get_value(size_t x) const {
92  return ATS::magnitude(A.values(offset + x) * A.values(offset + x));
93  }
94 
95  KOKKOS_INLINE_FUNCTION
96  bool operator()(size_t x, size_t y) const {
97  if (results(offset + x) != UNDECIDED) {
98  if (results(offset + y) != UNDECIDED) {
99  // does not matter
100  return (x < y);
101  } else {
102  // sort undecided to the right
103  return true;
104  }
105  } else {
106  if (results(offset + y) != UNDECIDED) {
107  // sort undecided to the right
108  return false;
109  } else {
110  return get_value(x) > get_value(y);
111  }
112  }
113  }
114  };
115 
117 
118  KOKKOS_INLINE_FUNCTION
120  return comparator_type(A, rlid, results);
121  }
122 };
123 
128 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, Misc::StrengthMeasure measure>
130  public:
132  using local_matrix_type = typename matrix_type::local_matrix_type;
133  using scalar_type = typename local_matrix_type::value_type;
134  using local_ordinal_type = typename local_matrix_type::ordinal_type;
135  using memory_space = typename local_matrix_type::memory_space;
137  using diag_view_type = typename Kokkos::DualView<const scalar_type*, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged>::t_dev;
138  using results_view = Kokkos::View<DecisionType*, memory_space>;
139 
142 
143  private:
144 #if KOKKOS_VERSION >= 40799
145  using ATS = KokkosKernels::ArithTraits<scalar_type>;
146 #else
147  using ATS = Kokkos::ArithTraits<scalar_type>;
148 #endif
149  using magnitudeType = typename ATS::magnitudeType;
150 
153 
154  public:
156  : A(A_.getLocalMatrixDevice())
157  , results(results_) {
158  if constexpr ((measure == Misc::SmoothedAggregationMeasure) || (measure == Misc::SignedSmoothedAggregationMeasure)) {
160  auto lclDiag2d = diagVec->getLocalViewDevice(Xpetra::Access::ReadOnly);
161  diag = Kokkos::subview(lclDiag2d, Kokkos::ALL(), 0);
162  } else if constexpr (measure == Misc::SignedRugeStuebenMeasure) {
164  auto lcl2d = diagVec->getLocalViewDevice(Xpetra::Access::ReadOnly);
165  diag = Kokkos::subview(lcl2d, Kokkos::ALL(), 0);
166  }
167  }
168 
169  template <class local_matrix_type2, class diag_view_type2>
170  struct Comparator {
171  private:
172  using scalar_type = typename local_matrix_type2::value_type;
173  using local_ordinal_type = typename local_matrix_type2::ordinal_type;
174  using memory_space = typename local_matrix_type2::memory_space;
175  using results_view = Kokkos::View<DecisionType*, memory_space>;
176 
177 #if KOKKOS_VERSION >= 40799
178  using ATS = KokkosKernels::ArithTraits<scalar_type>;
179 #else
180  using ATS = Kokkos::ArithTraits<scalar_type>;
181 #endif
182  using magnitudeType = typename ATS::magnitudeType;
183 #if KOKKOS_VERSION >= 40799
184  using mATS = KokkosKernels::ArithTraits<magnitudeType>;
185 #else
186  using mATS = Kokkos::ArithTraits<magnitudeType>;
187 #endif
188 
189  const local_matrix_type2 A;
190  const diag_view_type2 diag;
194 
195  public:
196  KOKKOS_INLINE_FUNCTION
197  Comparator(const local_matrix_type2& A_, const diag_view_type2& diag_, const local_ordinal_type rlid_, const results_view& results_)
198  : A(A_)
199  , diag(diag_)
200  , rlid(rlid_)
201  , offset(A_.graph.row_map(rlid_))
202  , results(results_) {}
203 
204  KOKKOS_INLINE_FUNCTION
205  magnitudeType get_value(size_t x) const {
206  if constexpr (measure == Misc::SmoothedAggregationMeasure) {
207  auto x_aij = ATS::magnitude(A.values(offset + x) * A.values(offset + x));
208  auto x_aiiajj = ATS::magnitude(diag(rlid) * diag(A.graph.entries(offset + x)));
209  return (x_aij / x_aiiajj);
210  } else if constexpr (measure == Misc::SignedRugeStuebenMeasure) {
211  auto val = A.values(offset + x);
212  auto neg_aij = -ATS::real(val);
213  auto max_neg_aik = ATS::real(diag(rlid));
214  auto v = neg_aij / max_neg_aik;
215  if (ATS::real(v) <= mATS::zero()) {
216  return -ATS::magnitude(v * v);
217  } else {
218  return ATS::magnitude(v * v);
219  }
220  } else if constexpr (measure == Misc::SignedSmoothedAggregationMeasure) {
221  auto val = A.values(offset + x);
222  auto x_aiiajj = ATS::magnitude(diag(rlid) * diag(A.graph.entries(offset + x)));
223  const bool is_nonpositive = ATS::real(val) <= mATS::zero();
224  magnitudeType aij2 = ATS::magnitude(val) * ATS::magnitude(val);
225  if (!is_nonpositive)
226  aij2 = -aij2;
227  return (aij2 / x_aiiajj);
228  }
229  }
230 
231  KOKKOS_INLINE_FUNCTION
232  bool operator()(size_t x, size_t y) const {
233  if (results(offset + x) != UNDECIDED) {
234  if (results(offset + y) != UNDECIDED) {
235  // does not matter
236  return (x < y);
237  } else {
238  // sort undecided to the right
239  return true;
240  }
241  } else {
242  if (results(offset + y) != UNDECIDED) {
243  // sort undecided to the right
244  return false;
245  } else {
246  return get_value(x) > get_value(y);
247  }
248  }
249  }
250  };
251 
253 
254  KOKKOS_INLINE_FUNCTION
256  return comparator_type(A, diag, rlid, results);
257  }
258 };
259 
260 // helper function to allow partial template deduction
261 template <Misc::StrengthMeasure measure, class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
264  if constexpr (measure == Misc::UnscaledMeasure) {
266  return functor;
267  } else {
269  return functor;
270  }
271 }
272 
273 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, class DistanceFunctorType>
275  public:
277  using local_matrix_type = typename matrix_type::local_matrix_type;
278  using scalar_type = typename local_matrix_type::value_type;
279  using local_ordinal_type = typename local_matrix_type::ordinal_type;
280  using memory_space = typename local_matrix_type::memory_space;
282  using diag_view_type = typename Kokkos::DualView<const scalar_type*, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged>::t_dev;
283  using results_view = Kokkos::View<DecisionType*, memory_space>;
284 
287 
288  private:
289 #if KOKKOS_VERSION >= 40799
290  using ATS = KokkosKernels::ArithTraits<scalar_type>;
291 #else
292  using ATS = Kokkos::ArithTraits<scalar_type>;
293 #endif
294  using magnitudeType = typename ATS::magnitudeType;
295 
298  DistanceFunctorType dist2;
299 
300  public:
301  UnscaledDistanceLaplacianComparison(matrix_type& A_, DistanceFunctorType& dist2_, results_view& results_)
302  : A(A_.getLocalMatrixDevice())
303  , results(results_)
304  , dist2(dist2_) {
305  // Construct ghosted distance Laplacian diagonal
307  auto lclDiag2d = diagVec->getLocalViewDevice(Xpetra::Access::ReadOnly);
308  diag = Kokkos::subview(lclDiag2d, Kokkos::ALL(), 0);
309  }
310 
311  template <class local_matrix_type2, class DistanceFunctorType2, class diag_view_type2>
312  struct Comparator {
313  private:
314  using scalar_type = typename local_matrix_type2::value_type;
315  using local_ordinal_type = typename local_matrix_type2::ordinal_type;
316  using memory_space = typename local_matrix_type2::memory_space;
317  using results_view = Kokkos::View<DecisionType*, memory_space>;
318 
319 #if KOKKOS_VERSION >= 40799
320  using ATS = KokkosKernels::ArithTraits<scalar_type>;
321 #else
322  using ATS = Kokkos::ArithTraits<scalar_type>;
323 #endif
324  using magnitudeType = typename ATS::magnitudeType;
325 
326  const local_matrix_type2 A;
327  const diag_view_type2 diag;
328  const DistanceFunctorType2* dist2;
332 
333  const scalar_type one = ATS::one();
334 
335  public:
336  KOKKOS_INLINE_FUNCTION
337  Comparator(const local_matrix_type2& A_, const diag_view_type2& diag_, const DistanceFunctorType2* dist2_, local_ordinal_type rlid_, const results_view& results_)
338  : A(A_)
339  , diag(diag_)
340  , dist2(dist2_)
341  , rlid(rlid_)
342  , offset(A_.graph.row_map(rlid_))
343  , results(results_) {}
344 
345  KOKKOS_INLINE_FUNCTION
346  magnitudeType get_value(size_t x) const {
347  auto clid = A.graph.entries(offset + x);
348  scalar_type val;
349  if (rlid != clid) {
350  val = -one / dist2->distance2(rlid, clid);
351  } else {
352  val = diag(rlid);
353  }
354  auto aij2 = ATS::magnitude(val) * ATS::magnitude(val); // |a_ij|^2
355  return aij2;
356  }
357 
358  KOKKOS_INLINE_FUNCTION
359  bool operator()(size_t x, size_t y) const {
360  if (results(offset + x) != UNDECIDED) {
361  if (results(offset + y) != UNDECIDED) {
362  // does not matter
363  return (x < y);
364  } else {
365  // sort undecided to the right
366  return true;
367  }
368  } else {
369  if (results(offset + y) != UNDECIDED) {
370  // sort undecided to the right
371  return false;
372  } else {
373  return get_value(x) > get_value(y);
374  }
375  }
376  }
377  };
378 
380 
381  KOKKOS_INLINE_FUNCTION
383  return comparator_type(A, diag, &dist2, rlid, results);
384  }
385 };
386 
391 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, class DistanceFunctorType, Misc::StrengthMeasure measure>
393  public:
395  using local_matrix_type = typename matrix_type::local_matrix_type;
396  using scalar_type = typename local_matrix_type::value_type;
397  using local_ordinal_type = typename local_matrix_type::ordinal_type;
398  using memory_space = typename local_matrix_type::memory_space;
400  using diag_view_type = typename Kokkos::DualView<const scalar_type*, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged>::t_dev;
401  using results_view = Kokkos::View<DecisionType*, memory_space>;
402 
405 
406  private:
407 #if KOKKOS_VERSION >= 40799
408  using ATS = KokkosKernels::ArithTraits<scalar_type>;
409 #else
410  using ATS = Kokkos::ArithTraits<scalar_type>;
411 #endif
412  using magnitudeType = typename ATS::magnitudeType;
413 
416  DistanceFunctorType dist2;
417 
418  public:
419  ScaledDistanceLaplacianComparison(matrix_type& A_, DistanceFunctorType& dist2_, results_view& results_)
420  : A(A_.getLocalMatrixDevice())
421  , results(results_)
422  , dist2(dist2_) {
423  // Construct ghosted distance Laplacian diagonal
424  if constexpr ((measure == Misc::SmoothedAggregationMeasure) || (measure == Misc::SignedSmoothedAggregationMeasure)) {
426  auto lclDiag2d = diagVec->getLocalViewDevice(Xpetra::Access::ReadOnly);
427  diag = Kokkos::subview(lclDiag2d, Kokkos::ALL(), 0);
428  } else if constexpr (measure == Misc::SignedRugeStuebenMeasure) {
430  auto lclDiag2d = diagVec->getLocalViewDevice(Xpetra::Access::ReadOnly);
431  diag = Kokkos::subview(lclDiag2d, Kokkos::ALL(), 0);
432  }
433  }
434 
435  template <class local_matrix_type2, class DistanceFunctorType2, class diag_view_type2>
436  struct Comparator {
437  private:
438  using scalar_type = typename local_matrix_type2::value_type;
439  using local_ordinal_type = typename local_matrix_type2::ordinal_type;
440  using memory_space = typename local_matrix_type2::memory_space;
441  using results_view = Kokkos::View<DecisionType*, memory_space>;
442 
443 #if KOKKOS_VERSION >= 40799
444  using ATS = KokkosKernels::ArithTraits<scalar_type>;
445 #else
446  using ATS = Kokkos::ArithTraits<scalar_type>;
447 #endif
448  using magnitudeType = typename ATS::magnitudeType;
449 #if KOKKOS_VERSION >= 40799
450  using mATS = KokkosKernels::ArithTraits<magnitudeType>;
451 #else
452  using mATS = Kokkos::ArithTraits<magnitudeType>;
453 #endif
454 
455  const local_matrix_type2 A;
456  const diag_view_type2 diag;
457  const DistanceFunctorType2* dist2;
461 
462  const scalar_type one = ATS::one();
463  const scalar_type zero = ATS::zero();
464  const magnitudeType mzero = mATS::zero();
465 
466  public:
467  KOKKOS_INLINE_FUNCTION
468  Comparator(const local_matrix_type2& A_, const diag_view_type2& diag_, const DistanceFunctorType2* dist2_, local_ordinal_type rlid_, const results_view& results_)
469  : A(A_)
470  , diag(diag_)
471  , dist2(dist2_)
472  , rlid(rlid_)
473  , offset(A_.graph.row_map(rlid_))
474  , results(results_) {}
475 
476  KOKKOS_INLINE_FUNCTION
477  magnitudeType get_value(size_t x) const {
478  auto clid = A.graph.entries(offset + x);
479  scalar_type val;
480  if (rlid != clid) {
481  val = -one / dist2->distance2(rlid, clid);
482  } else {
483  val = diag(rlid);
484  }
485 
486  if constexpr (measure == Misc::SmoothedAggregationMeasure) {
487  auto aiiajj = ATS::magnitude(diag(rlid)) * ATS::magnitude(diag(clid)); // |a_ii|*|a_jj|
488  auto aij2 = ATS::magnitude(val) * ATS::magnitude(val); // |a_ij|^2
489  return (aij2 / aiiajj);
490  } else if constexpr (measure == Misc::SignedRugeStuebenMeasure) {
491  auto neg_aij = -ATS::real(val);
492  auto max_neg_aik = ATS::real(diag(rlid));
493  auto v = ATS::magnitude(neg_aij / max_neg_aik);
494  if (ATS::real(neg_aij) >= mzero)
495  return v * v;
496  else
497  return -v * v;
498  } else if constexpr (measure == Misc::SignedSmoothedAggregationMeasure) {
499  auto aiiajj = ATS::magnitude(diag(rlid)) * ATS::magnitude(diag(clid)); // |a_ii|*|a_jj|
500  const bool is_nonpositive = ATS::real(val) <= mATS::zero();
501  magnitudeType aij2 = ATS::magnitude(val) * ATS::magnitude(val); // |a_ij|^2
502  // + |a_ij|^2, if a_ij < 0, - |a_ij|^2 if a_ij >=0
503  if (!is_nonpositive)
504  aij2 = -aij2;
505  return aij2 / aiiajj;
506  }
507  }
508 
509  KOKKOS_INLINE_FUNCTION
510  bool operator()(size_t x, size_t y) const {
511  if (results(offset + x) != UNDECIDED) {
512  if (results(offset + y) != UNDECIDED) {
513  // does not matter
514  return (x < y);
515  } else {
516  // sort undecided to the right
517  return true;
518  }
519  } else {
520  if (results(offset + y) != UNDECIDED) {
521  // sort undecided to the right
522  return false;
523  } else {
524  return get_value(x) > get_value(y);
525  }
526  }
527  }
528  };
529 
531 
532  KOKKOS_INLINE_FUNCTION
534  return comparator_type(A, diag, &dist2, rlid, results);
535  }
536 };
537 
538 // helper function to allow partial template deduction
539 template <Misc::StrengthMeasure measure, class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, class DistanceFunctorType>
541  DistanceFunctorType& dist2_,
543  if constexpr (measure == Misc::UnscaledMeasure) {
545  return functor;
546  } else {
548  return functor;
549  }
550 }
551 
556 template <class comparison_type>
558  private:
559  using local_matrix_type = typename comparison_type::local_matrix_type;
560  using scalar_type = typename local_matrix_type::value_type;
561  using local_ordinal_type = typename local_matrix_type::ordinal_type;
562  using memory_space = typename local_matrix_type::memory_space;
563  using results_view = Kokkos::View<DecisionType*, memory_space>;
564 
565 #if KOKKOS_VERSION >= 40799
566  using ATS = KokkosKernels::ArithTraits<scalar_type>;
567 #else
568  using ATS = Kokkos::ArithTraits<scalar_type>;
569 #endif
570  using magnitudeType = typename ATS::magnitudeType;
571  using boundary_nodes_view = Kokkos::View<const bool*, memory_space>;
572 
574  comparison_type comparison;
577  Kokkos::View<local_ordinal_type*, memory_space> index;
578 
579  public:
580  CutDropFunctor(comparison_type& comparison_, magnitudeType threshold)
581  : A(comparison_.A)
582  , comparison(comparison_)
583  , eps(threshold)
584  , results(comparison_.results) {
585  index = Kokkos::View<local_ordinal_type*, memory_space>("indices", A.nnz());
586  }
587 
588  KOKKOS_FORCEINLINE_FUNCTION
589  void operator()(const local_ordinal_type& rlid) const {
590  auto row = A.rowConst(rlid);
591  size_t nnz = row.length;
592 
593  auto drop_view = Kokkos::subview(results, Kokkos::make_pair(A.graph.row_map(rlid), A.graph.row_map(rlid + 1)));
594  auto row_permutation = Kokkos::subview(index, Kokkos::make_pair(A.graph.row_map(rlid), A.graph.row_map(rlid + 1)));
595 
596  auto comparator = comparison.getComparator(rlid);
597 
598 #ifdef MUELU_COALESCE_DROP_DEBUG
599  {
600  Kokkos::printf("SoC: ");
601  for (local_ordinal_type k = 0; k < row.length; ++k) {
602  Kokkos::printf("%5f ", comparator.get_value(k));
603  }
604  Kokkos::printf("\n");
605  }
606 #endif
607 
608  for (size_t i = 0; i < nnz; ++i) {
609  row_permutation(i) = i;
610  }
611  Misc::serialHeapSort(row_permutation, comparator);
612 
613  size_t keepStart = 0;
614  size_t dropStart = nnz;
615  // find index where dropping starts
616  for (size_t i = 1; i < nnz; ++i) {
617  auto const& x = row_permutation(i - 1);
618  auto const& y = row_permutation(i);
619  if ((drop_view(x) != UNDECIDED) && (drop_view(y) == UNDECIDED))
620  keepStart = i;
621  if ((drop_view(x) != UNDECIDED) || (drop_view(y) != UNDECIDED))
622  continue;
623  magnitudeType x_aij = comparator.get_value(x);
624  magnitudeType y_aij = comparator.get_value(y);
625  if (eps * eps * x_aij > y_aij) {
626  if (i < dropStart) {
627  dropStart = i;
628  }
629  }
630  }
631 
632  // drop everything to the right of where values stop passing threshold
633  for (size_t i = keepStart; i < nnz; ++i) {
634  drop_view(row_permutation(i)) = Kokkos::max(dropStart <= i ? DROP : KEEP, drop_view(row_permutation(i)));
635  }
636  }
637 };
638 
639 } // namespace MueLu::CutDrop
640 
641 #endif
Kokkos::View< const bool *, memory_space > boundary_nodes_view
KOKKOS_INLINE_FUNCTION bool operator()(size_t x, size_t y) const
typename local_matrix_type::memory_space memory_space
auto make_comparison_functor(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A_, typename ScaledComparison< Scalar, LocalOrdinal, GlobalOrdinal, Node, measure >::results_view &results_)
static Teuchos::RCP< Vector > GetMatrixMaxMinusOffDiagonal(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Return vector containing: max_{i=k}(-a_ik), for each for i in the matrix.
typename local_matrix_type::ordinal_type local_ordinal_type
UnscaledComparison(matrix_type &A_, results_view &results_)
Comparator< local_matrix_type, diag_view_type > comparator_type
ScaledDistanceLaplacianComparison(matrix_type &A_, DistanceFunctorType &dist2_, results_view &results_)
KOKKOS_INLINE_FUNCTION magnitudeType get_value(size_t x) const
typename local_matrix_type2::ordinal_type local_ordinal_type
KOKKOS_INLINE_FUNCTION comparator_type getComparator(local_ordinal_type rlid) const
KOKKOS_INLINE_FUNCTION comparator_type getComparator(local_ordinal_type rlid) const
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type2::memory_space memory_space
Kokkos::View< DecisionType *, memory_space > results_view
typename matrix_type::local_matrix_type local_matrix_type
Teuchos::RCP< diag_vec_type > diagVec
KOKKOS_INLINE_FUNCTION Comparator(const local_matrix_type2 &A_, const diag_view_type2 &diag_, const DistanceFunctorType2 *dist2_, local_ordinal_type rlid_, const results_view &results_)
Kokkos::View< local_ordinal_type *, memory_space > index
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::ordinal_type local_ordinal_type
Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getMaxMinusOffDiagonal(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, DistanceFunctorType &distFunctor)
typename Kokkos::DualView< const scalar_type *, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged >::t_dev diag_view_type
Kokkos::View< DecisionType *, memory_space > results_view
Orders entries of row by .
typename local_matrix_type::memory_space memory_space
ScaledComparison(matrix_type &A_, results_view &results_)
KOKKOS_INLINE_FUNCTION comparator_type getComparator(local_ordinal_type rlid) const
Orders entries of row by where is the distance Laplacian.
Comparator< local_matrix_type > comparator_type
typename local_matrix_type::ordinal_type local_ordinal_type
typename ATS::magnitudeType magnitudeType
typename matrix_type::local_matrix_type local_matrix_type
typename comparison_type::local_matrix_type local_matrix_type
Kokkos::View< DecisionType *, memory_space > results_view
Comparator< local_matrix_type, DistanceFunctorType, diag_view_type > comparator_type
typename local_matrix_type::value_type scalar_type
typename local_matrix_type::value_type scalar_type
typename local_matrix_type::ordinal_type local_ordinal_type
KOKKOS_INLINE_FUNCTION void serialHeapSort(view_type &v, comparator_type comparator)
typename local_matrix_type2::ordinal_type local_ordinal_type
KOKKOS_INLINE_FUNCTION bool operator()(size_t x, size_t y) const
Kokkos::ArithTraits< scalar_type > ATS
Kokkos::ArithTraits< magnitudeType > mATS
typename local_matrix_type2::ordinal_type local_ordinal_type
UnscaledDistanceLaplacianComparison(matrix_type &A_, DistanceFunctorType &dist2_, results_view &results_)
typename Kokkos::DualView< const scalar_type *, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged >::t_dev diag_view_type
Kokkos::View< DecisionType *, memory_space > results_view
Kokkos::ArithTraits< scalar_type > ATS
typename Kokkos::DualView< const scalar_type *, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged >::t_dev diag_view_type
Kokkos::View< DecisionType *, memory_space > results_view
Kokkos::ArithTraits< scalar_type > ATS
typename ATS::magnitudeType magnitudeType
Order each row by a criterion, compare the ratio of values and drop all entries once the ratio is bel...
KOKKOS_INLINE_FUNCTION magnitudeType get_value(size_t x) const
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::value_type scalar_type
static RCP< Vector > GetMatrixOverlappedDiagonal(const Matrix &A)
Extract Overlapped Matrix Diagonal.
auto make_dlap_comparison_functor(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A_, DistanceFunctorType &dist2_, typename ScaledDistanceLaplacianComparison< Scalar, LocalOrdinal, GlobalOrdinal, Node, DistanceFunctorType, measure >::results_view &results_)
typename matrix_type::local_matrix_type local_matrix_type
KOKKOS_FORCEINLINE_FUNCTION void operator()(const local_ordinal_type &rlid) const
typename local_matrix_type::value_type scalar_type
typename local_matrix_type2::value_type scalar_type
KOKKOS_INLINE_FUNCTION comparator_type getComparator(local_ordinal_type rlid) const
KOKKOS_INLINE_FUNCTION bool operator()(size_t x, size_t y) const
typename local_matrix_type2::ordinal_type local_ordinal_type
typename local_matrix_type2::memory_space memory_space
Kokkos::ArithTraits< scalar_type > ATS
Kokkos::ArithTraits< scalar_type > ATS
KOKKOS_INLINE_FUNCTION bool operator()(size_t x, size_t y) const
typename local_matrix_type2::memory_space memory_space
KOKKOS_INLINE_FUNCTION magnitudeType get_value(size_t x) const
Kokkos::ArithTraits< scalar_type > ATS
Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getDiagonal(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, DistanceFunctorType &distFunctor)
KOKKOS_INLINE_FUNCTION Comparator(const local_matrix_type2 &A_, const diag_view_type2 &diag_, const local_ordinal_type rlid_, const results_view &results_)
KOKKOS_INLINE_FUNCTION Comparator(const local_matrix_type2 &A_, local_ordinal_type rlid_, const results_view &results_)
typename ATS::magnitudeType magnitudeType
Comparator< local_matrix_type, DistanceFunctorType, diag_view_type > comparator_type
KOKKOS_INLINE_FUNCTION magnitudeType get_value(size_t x) const
CutDropFunctor(comparison_type &comparison_, magnitudeType threshold)
typename matrix_type::local_matrix_type local_matrix_type
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::memory_space memory_space
Orders entries of row by .
typename local_matrix_type::memory_space memory_space
Kokkos::View< DecisionType *, memory_space > results_view
KOKKOS_INLINE_FUNCTION Comparator(const local_matrix_type2 &A_, const diag_view_type2 &diag_, const DistanceFunctorType2 *dist2_, local_ordinal_type rlid_, const results_view &results_)
typename local_matrix_type::value_type scalar_type
typename local_matrix_type2::value_type scalar_type
typename local_matrix_type2::memory_space memory_space