CUSP
Loading...
Searching...
No Matches
smoothed_aggregation.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2014 NVIDIA Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
22#pragma once
23
24#include <cusp/detail/config.h>
25#include <cusp/detail/multilevel.h>
26#include <cusp/detail/execution_policy.h>
27
28#include <cusp/array1d.h>
29#include <cusp/complex.h>
30#include <cusp/precond/aggregation/detail/sa_view_traits.h>
31
32#include <thrust/detail/use_default.h>
33
34#include <vector> // TODO replace with host_vector
35
36namespace cusp
37{
38namespace precond
39{
40namespace aggregation
41{
42
43/* \cond */
44template<typename MatrixType>
45struct sa_level
46{
47 public:
48
49 typedef typename MatrixType::index_type IndexType;
50 typedef typename MatrixType::value_type ValueType;
51 typedef typename MatrixType::memory_space MemorySpace;
52 typedef typename cusp::norm_type<ValueType>::type NormType;
53
54 MatrixType A_; // matrix
55 MatrixType T; // matrix
56 cusp::array1d<IndexType,MemorySpace> aggregates; // aggregates
57 cusp::array1d<IndexType,MemorySpace> roots; // aggregates
58 cusp::array1d<ValueType,MemorySpace> B; // near-nullspace candidates
59
60 size_t num_iters;
61 NormType rho_DinvA;
62
63 sa_level(void) : num_iters(1), rho_DinvA(0) {}
64
65 template<typename SALevelType>
66 sa_level(const SALevelType& L)
67 : A_(L.A_),
68 aggregates(L.aggregates),
69 B(L.B),
70 num_iters(L.num_iters),
71 rho_DinvA(L.rho_DinvA)
72 {}
73};
74/* \endcond */
75
155template <typename IndexType,
156 typename ValueType,
157 typename MemorySpace,
158 typename SmootherType = thrust::use_default,
159 typename SolverType = thrust::use_default,
160 typename Format = thrust::use_default>
162 public cusp::multilevel<IndexType,ValueType,MemorySpace,Format,SmootherType,SolverType>::container
163{
164 private:
165
166 typedef typename detail::select_sa_matrix_type<IndexType,ValueType,MemorySpace>::type SetupMatrixType;
167 typedef typename cusp::multilevel<IndexType,ValueType,MemorySpace,Format,SmootherType,SolverType>::container ML;
168
169 public:
170
171 /* \cond */
172 std::vector< sa_level<SetupMatrixType> > sa_levels;
173 /* \endcond */
174
178 smoothed_aggregation(void) : ML() {};
179
184 template <typename MatrixType>
185 smoothed_aggregation(const MatrixType& A);
186
193 template <typename MatrixType,
194 typename ArrayType>
195 smoothed_aggregation(const MatrixType& A,
196 const ArrayType& B);
197
203 template <typename MemorySpace2,
204 typename SmootherType2,
205 typename SolverType2,
206 typename Format2>
208
215 template <typename MatrixType>
216 void initialize(const MatrixType& A);
217
226 template <typename MatrixType,
227 typename ArrayType>
228 void initialize(const MatrixType& A,
229 const ArrayType& B);
230
231 /* \cond */
232 template <typename DerivedPolicy,
233 typename MatrixType,
234 typename ArrayType>
235 void initialize(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
236 const MatrixType& A,
237 const ArrayType& B);
238 /* \endcond */
239
240protected:
241
242 /* \cond */
243 template <typename DerivedPolicy,
244 typename MatrixType>
245 void extend_hierarchy(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
246 const MatrixType& A);
247 /* \endcond */
248};
252} // end namespace aggregation
253} // end namespace precond
254} // end namespace cusp
255
256#include <cusp/precond/aggregation/detail/smoothed_aggregation.inl>
257
1D array of elements that may reside in "host" or "device" memory space
The array1d class is a 1D vector container that may contain elements stored in "host" or "device" mem...
Definition array1d.h:99
Algebraic multigrid preconditioner based on smoothed aggregation.
void initialize(const MatrixType &A, const ArrayType &B)
smoothed_aggregation(const smoothed_aggregation< IndexType, ValueType, MemorySpace2, SmootherType2, SolverType2, Format2 > &M)
smoothed_aggregation(const MatrixType &A, const ArrayType &B)
Complex numbers.