QMCPACK
test_cuSolverInverter.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2022 QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 #include "Configuration.h"
19 #include "checkMatrix.hpp"
20 #include "createTestMatrix.h"
21 
22 namespace qmcplusplus
23 {
24 
25 using LogValue = std::complex<double>;
26 
27 TEMPLATE_TEST_CASE("cuSolverInverter", "[wavefunction][fermion]", double, float)
28 {
29  // TestType is defined by Catch. It is the type in each instantiation of the templated test case.
30 #ifdef QMC_COMPLEX
31  using FullPrecValue = std::complex<double>;
32  using Value = std::complex<TestType>;
33 #else
34  using FullPrecValue = double;
35  using Value = TestType;
36 #endif
38  const int N = 3;
39 
40  Matrix<Value> m(N, N);
41  Matrix<Value> m_invT(N, N);
43  LogValue log_value;
44 
45  SECTION("identity")
46  {
48 
49  solver.invert_transpose(m, m_invT, m_invGPU, log_value);
50  CHECK(log_value == LogComplexApprox(0.0));
51 
52  Matrix<Value> eye;
53  eye.resize(3, 3);
54  fillIdentityMatrix(eye);
55 
57  CHECKED_ELSE(check_matrix_result.result) { FAIL(check_matrix_result.result_message); }
58  }
59 
60  SECTION("3x3 matrix")
61  {
62  Matrix<Value> a(N, N);
63  Matrix<Value> a_T(N, N);
65 
66  simd::transpose(a.data(), a.rows(), a.cols(), a_T.data(), a_T.rows(), a_T.cols());
67  solver.invert_transpose(a_T, m_invT, m_invGPU, log_value);
69 
70  Matrix<Value> b(3, 3);
71 
73 
74  auto check_matrix_result = checkMatrix(m_invT, b);
75  CHECKED_ELSE(check_matrix_result.result) { FAIL(check_matrix_result.result_message); }
76  }
77 }
78 
79 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
CHECKED_ELSE(check_matrix_result.result)
void transpose(const T *restrict A, size_t m, size_t lda, TO *restrict B, size_t n, size_t ldb)
transpose of A(m,n) to B(n,m)
Definition: algorithm.hpp:97
std::enable_if_t< std::is_same< TMAT, T_FP >::value > invert_transpose(const Matrix< TMAT > &logdetT, Matrix< TMAT > &Ainv, Matrix< TMAT, CUDAAllocator< TMAT >> &Ainv_gpu, std::complex< TREAL > &log_value)
compute the inverse of the transpose of matrix A and its determinant value in log when T_FP and TMAT ...
auto check_matrix_result
void resize(size_type n, size_type m)
Resize the container.
Definition: OhmmsMatrix.h:99
Catch::Detail::LogComplexApprox LogComplexApprox
size_type cols() const
Definition: OhmmsMatrix.h:78
static void fillInverse(Matrix< T > &b)
size_type rows() const
Definition: OhmmsMatrix.h:77
CheckMatrixResult checkMatrix(M1 &a_mat, M2 &b_mat, const bool check_all=false, std::optional< const double > eps=std::nullopt)
This function checks equality a_mat and b_mat elements M1, M2 need to have their element type declare...
Definition: checkMatrix.hpp:63
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
void fillIdentityMatrix(Matrix< T > &m)
TEMPLATE_TEST_CASE("RandomRotationMatrix", "[numerics]", float, double)
std::complex< double > LogValue
implements matrix inversion via cuSolverDN
static void fillInput(Matrix< T > &a)