28 #ifndef mpqc_interfaces_tiledarray_symmscmat_hpp
29 #define mpqc_interfaces_tiledarray_symmscmat_hpp
31 #include <tiledarray.h>
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){
44 std::array<TRange1, N> blocking;
45 for(std::size_t i = 0; i < N; ++i){
46 blocking[i] = trange1;
49 ::TiledArray::TiledRange trange(blocking.begin(), blocking.end());
51 ::TiledArray::Array<double, N> array(world, trange);
55 template<
typename RefMat>
56 ::TiledArray::Array<double, 2>::value_type
57 mat_to_array_task(const ::TiledArray::Range &range,
const RefMat &matrix){
60 ::TiledArray::Array<double, 2>::value_type tile(range);
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;
69 for(
int i = t0start; i < t0end; ++i){
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);
83 template<
unsigned int N,
typename RefMat>
85 mat_to_array(
const RefMat &matrix, ::TiledArray::Array<double, N> &array){
87 auto it = array.pmap()->begin();
88 auto end = array.pmap()->end();
90 madness::World &world = array.world();
92 static_assert(N==2,
"Feature Not Yet Implimented: Can only copy"
93 " arrays with rank 2");
95 for(; it != end; ++it){
96 madness::Future<typename ::TiledArray::Array<double,N>::value_type > tile =
98 &mat_to_array_task<RefMat>,
99 array.trange().make_tile_range(*it),
102 array.set(*it, tile);
114 inline ::TiledArray::Array<double, 2>
117 const ::TiledArray::TiledRange1 trange1){
119 ::TiledArray::Array<double, 2> ta_array = detail::init_ta_array<2>(world, trange1);
121 detail::mat_to_array(
matrix, ta_array);