1#ifndef HSOLVER_LINEAR_TEST_UTILS_H
2#define HSOLVER_LINEAR_TEST_UTILS_H
30 std::vector<T> h(n * n,
T(0));
31 for (
int j = 0; j < n; ++j)
33 h[j * n + j] =
T(1.0 + 0.4 * j);
34 for (
int i = 1; i < j; ++i)
36 const T value(0.12 / (j - i + 1), 0.07 / (i + j + 1));
38 h[i * n + j] = std::conj(value);
45std::vector<T>
multiply(
const std::vector<T>& a,
const std::vector<T>& x,
const int n,
const int nvec)
47 std::vector<T> b(n * nvec,
T(0));
48 for (
int band = 0; band < nvec; ++band)
50 for (
int j = 0; j < n; ++j)
52 for (
int i = 0; i < n; ++i)
54 b[band * n + i] += a[j * n + i] * x[band * n + j];
63std::vector<T>
local_columns(
const std::vector<T>& global,
int n,
int columns,
int start,
int dim,
int ld)
65 std::vector<T> local(ld * columns,
T(0));
66 for (
int j = 0; j < columns; ++j)
68 for (
int i = 0; i < dim; ++i)
70 local[j * ld + i] = global[j * n +
start + i];
78std::vector<Complex>
lapack_solve(
const std::vector<T>& a,
const std::vector<T>& b,
const int n,
const int nvec)
80 std::vector<Complex> lu(a.begin(), a.end());
81 std::vector<Complex> x(b.begin(), b.end());
82 std::vector<int> pivots(n);
84 container::lapackConnector::getrf(n, n, lu.data(), n, pivots.data(), info);
87 throw std::runtime_error(
"LAPACK reference factorization failed");
89 container::lapackConnector::getrs(
'N', n, nvec, lu.data(), n, pivots.data(), x.data(), n, info);
92 throw std::runtime_error(
"LAPACK reference solve failed");
This is a direct wrapper of some LAPACK routines. Column-Major version. Direct wrapping of standard L...
Definition parallel_comm.h:15
int grank
rank of parent communicator
Definition parallel_comm.h:28
int gsize
size of parent communicator
Definition parallel_comm.h:27
#define T
Definition exp.cpp:237
Definition linear_test_utils.h:13
std::vector< Complex > lapack_solve(const std::vector< T > &a, const std::vector< T > &b, const int n, const int nvec)
Definition linear_test_utils.h:78
std::complex< double > Complex
Definition linear_test_utils.h:14
std::vector< T > multiply(const std::vector< T > &a, const std::vector< T > &x, const int n, const int nvec)
Definition linear_test_utils.h:45
std::vector< T > hermitian(const int n)
Definition linear_test_utils.h:28
std::vector< T > local_columns(const std::vector< T > &global, int n, int columns, int start, int dim, int ld)
Definition linear_test_utils.h:63
hsolver::diag_comm_info world_comm()
Definition linear_test_utils.h:16
Definition diag_comm_info.h:12
iclock::time_point start
Definition test_partition.cpp:22