MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
symmscmat.hpp
1//
2// symmscmat.hpp
3//
4// Copyright (C) 2013 Drew Lewis
5//
6// Authors: Drew Lewis
7// Maintainer: Drew Lewis and Edward Valeev
8//
9// This file is part of the MPQC Toolkit.
10//
11// The MPQC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The MPQC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the MPQC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#ifndef mpqc_interfaces_tiledarray_symmscmat_hpp
29#define mpqc_interfaces_tiledarray_symmscmat_hpp
30
31#include <tiledarray.h>
32
33namespace mpqc {
36
37#ifndef DOXYGEN
38 namespace detail{
39 using TRange1 = ::TiledArray::TiledRange1;
40 template<unsigned int N>
41 ::TiledArray::Array<double, N>
42 init_ta_array(madness::World &world, const TRange1 &trange1){
43
44 std::array<TRange1, N> blocking;
45 for(std::size_t i = 0; i < N; ++i){
46 blocking[i] = trange1;
47 }
48
49 ::TiledArray::TiledRange trange(blocking.begin(), blocking.end());
50
51 ::TiledArray::Array<double, N> array(world, trange);
52 return array;
53 }
54
55 template<typename RefMat>
56 ::TiledArray::Array<double, 2>::value_type
57 mat_to_array_task(const ::TiledArray::Range &range, const RefMat &matrix){
58
60 ::TiledArray::Array<double, 2>::value_type tile(range);
61
62 int t0start = tile.range().start()[0];
63 int t1start = tile.range().start()[1];
64 int t0size = tile.range().size()[0];
65 int t1size = tile.range().size()[1];
66 int t0end = t0start + t0size;
67 int t1end = t1start + t1size;
68
69 for(int i = t0start; i < t0end; ++i){
70
71 int tile_i = i - t0start;
72 for(int j = t1start; j < t1end; ++j){
73 int tile_j = j - t1start;
74 tile[tile_i * t1size + tile_j] = matrix->get_element(i,j);
75 }
76 }
77
78 return tile;
79 }
80
81
82
83 template<unsigned int N, typename RefMat>
84 void
85 mat_to_array(const RefMat &matrix, ::TiledArray::Array<double, N> &array){
86
87 auto it = array.pmap()->begin();
88 auto end = array.pmap()->end();
89
90 madness::World &world = array.world();
91
92 static_assert(N==2, "Feature Not Yet Implimented: Can only copy"
93 " arrays with rank 2");
94
95 for(; it != end; ++it){
96 madness::Future<typename ::TiledArray::Array<double,N>::value_type > tile =
97 world.taskq.add(
98 &mat_to_array_task<RefMat>,
99 array.trange().make_tile_range(*it),
100 matrix);
101
102 array.set(*it, tile);
103
104 }
105
106 }
107 }// namespace details
108#endif // DOXYGEN
109
114 inline ::TiledArray::Array<double, 2>
115 SymmScMat_To_TiledArray(madness::World &world,
117 const ::TiledArray::TiledRange1 trange1){
118
119 ::TiledArray::Array<double, 2> ta_array = detail::init_ta_array<2>(world, trange1);
120
121 detail::mat_to_array(matrix, ta_array);
122
123 return ta_array;
124 }
125
127 // End TiledArray Interface
128
129} // namespace mpqc
130
131
132
133
134
135
136
137
138
139#endif /* mpqc_interfaces_tiledarray_symmscmat_hpp */
A template class that maintains references counts.
Definition ref.h:361
Contains new MPQC code since version 3.
Definition integralenginepool.hpp:37
inline ::TiledArray::Array< double, 2 > SymmScMat_To_TiledArray(madness::World &world, const sc::Ref< sc::SymmSCMatrix > &matrix, const ::TiledArray::TiledRange1 trange1)
addtogroup TiledArrayInterface
Definition symmscmat.hpp:115
Matrix class derived from Eigen::Matrix with additional MPQC integration.
Definition matrix.hpp:23

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.