cholesky.h
Go to the documentation of this file.
1 /*
2  * This file is a part of TiledArray.
3  * Copyright (C) 2020 Virginia Tech
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Eduard Valeyev
19  *
20  * cholesky.h
21  * Created: 16 October, 2020
22  *
23  */
24 #ifndef TILEDARRAY_MATH_LINALG_CHOL_H__INCLUDED
25 #define TILEDARRAY_MATH_LINALG_CHOL_H__INCLUDED
26 
27 #include <TiledArray/config.h>
28 #if TILEDARRAY_HAS_SCALAPACK
30 #endif
32 
33 namespace TiledArray::math::linalg {
34 
35 template <typename Array>
36 auto cholesky(const Array& A, TiledRange l_trange = TiledRange()) {
37 #if TILEDARRAY_HAS_SCALAPACK
38  if (A.world().size() > 1 && A.range().volume() > 10000000)
39  return scalapack::cholesky<Array>(A, l_trange);
40 #endif
41  return non_distributed::cholesky<Array>(A, l_trange);
42 }
43 
44 template <bool Both = false, typename Array>
45 auto cholesky_linv(const Array& A, TiledRange l_trange = TiledRange()) {
46 #if TILEDARRAY_HAS_SCALAPACK
47  if (A.world().size() > 1 && A.range().volume() > 10000000)
48  return scalapack::cholesky_linv<Both>(A, l_trange);
49 #endif
50  return non_distributed::cholesky_linv<Both>(A, l_trange);
51 }
52 
53 template <typename Array>
54 auto cholesky_solve(const Array& A, const Array& B,
55  TiledRange x_trange = TiledRange()) {
56 #if TILEDARRAY_HAS_SCALAPACK
57  if (A.world().size() > 1 && A.range().volume() > 10000000)
58  return scalapack::cholesky_solve<Array>(A, B, x_trange);
59 #endif
60  return non_distributed::cholesky_solve(A, B, x_trange);
61 }
62 
63 template <typename Array>
64 auto cholesky_lsolve(Op transpose, const Array& A, const Array& B,
65  TiledRange l_trange = TiledRange(),
66  TiledRange x_trange = TiledRange()) {
67 #if TILEDARRAY_HAS_SCALAPACK
68  if (A.world().size() > 1 && A.range().volume() > 10000000)
69  return scalapack::cholesky_lsolve<Array>(transpose, A, B, l_trange,
70  x_trange);
71 #endif
72  return non_distributed::cholesky_lsolve(transpose, A, B, l_trange, x_trange);
73 }
74 
75 } // namespace TiledArray::math::linalg
76 
77 namespace TiledArray {
82 } // namespace TiledArray
83 
84 #endif // TILEDARRAY_MATH_LINALG_CHOL_H__INCLUDED
auto cholesky_lsolve(Op transpose, const Array &A, const Array &B, TiledRange l_trange=TiledRange(), TiledRange x_trange=TiledRange())
Definition: cholesky.h:176
auto cholesky_linv(const Array &A, TiledRange l_trange=TiledRange())
Definition: cholesky.h:45
auto cholesky(const Array &A, TiledRange l_trange=TiledRange())
Definition: cholesky.h:36
auto cholesky_solve(const Array &A, const Array &B, TiledRange x_trange=TiledRange())
Definition: cholesky.h:54
auto cholesky_lsolve(Op transpose, const Array &A, const Array &B, TiledRange l_trange=TiledRange(), TiledRange x_trange=TiledRange())
Definition: cholesky.h:64
Range data of a tiled array.
Definition: tiled_range.h:32
void transpose(InputOp &&input_op, OutputOp &&output_op, const std::size_t m, const std::size_t n, const std::size_t result_stride, Result *result, const std::size_t arg_stride, const Args *const ... args)
Matrix transpose and initialization.
Definition: transpose.h:178
const range_type & range() const
Tile range accessor.
Definition: dist_array.h:932
Forward declarations.
Definition: dist_array.h:57
World & world() const
World accessor.
Definition: dist_array.h:1007
auto cholesky_solve(const Array &A, const Array &B, TiledRange x_trange=TiledRange())
Definition: cholesky.h:156