forked from ddemidov/amgcl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_complex_erf.cpp
86 lines (62 loc) · 2.16 KB
/
test_complex_erf.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#define BOOST_TEST_MODULE TestComplex
#include <boost/test/unit_test.hpp>
#include <complex>
#include <amgcl/backend/builtin.hpp>
#include <amgcl/amg.hpp>
#include <amgcl/make_solver.hpp>
#include <amgcl/coarsening/aggregation.hpp>
#include <amgcl/coarsening/smoothed_aggregation.hpp>
#include <amgcl/coarsening/smoothed_aggr_emin.hpp>
#include <amgcl/relaxation/damped_jacobi.hpp>
#include <amgcl/relaxation/gauss_seidel.hpp>
#include <amgcl/relaxation/spai0.hpp>
#include <amgcl/relaxation/ilu0.hpp>
#include <amgcl/relaxation/ilut.hpp>
#include <amgcl/relaxation/chebyshev.hpp>
#include <amgcl/solver/cg.hpp>
#include <amgcl/solver/bicgstab.hpp>
#include <amgcl/solver/bicgstabl.hpp>
#include <amgcl/solver/gmres.hpp>
#include <amgcl/adapter/crs_tuple.hpp>
#include <amgcl/adapter/complex.hpp>
#include <amgcl/profiler.hpp>
#include "sample_problem.hpp"
namespace amgcl {
profiler<> prof;
}
BOOST_AUTO_TEST_SUITE( test_complex )
BOOST_AUTO_TEST_CASE(complex_matrix_adapter)
{
typedef std::complex<double> complex;
std::vector<int> ptr;
std::vector<int> col;
std::vector<complex> val;
std::vector<complex> rhs;
size_t n = sample_problem(32, val, col, ptr, rhs);
std::vector<complex> x(n, complex(0.0,0.0));
typedef amgcl::backend::builtin<double> Backend;
boost::property_tree::ptree prm;
prm.put("precond.coarsening.aggr.block_size", 2);
amgcl::make_solver<
amgcl::amg<
Backend,
amgcl::coarsening::smoothed_aggregation,
amgcl::relaxation::spai0
>,
amgcl::solver::bicgstab<Backend>
> solve( amgcl::adapter::complex_matrix(std::tie(n, ptr, col, val)), prm );
std::cout << solve.precond() << std::endl;
boost::iterator_range<const double*> f_range =
amgcl::adapter::complex_range(rhs);
boost::iterator_range<double*> x_range =
amgcl::adapter::complex_range(x);
size_t iters;
double resid;
std::tie(iters, resid) = solve(f_range, x_range);
BOOST_CHECK_SMALL(resid, 1e-8);
std::cout
<< "iters: " << iters << std::endl
<< "resid: " << resid << std::endl
;
}
BOOST_AUTO_TEST_SUITE_END()