3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-26 14:23:38 +01:00
dft_tools/test/speed/gf_s.cpp
Olivier Parcollet 47cb8a03f7 [arrays] Important changes in implementation.
- Simplify group_indices
  - Only for C ordered, remove complex compile time.
  - Could be generalized to non C ordered, but no need.
- Fix slice for custom orders.
- Generalize the group_indices for the custom order.
- Add c_ordered_transposed_view (useful ?)
- Improve slice, special for ellipsis (quicker).
- Simplify TraversalOrder
- Assignement. Specialize one case for speed.
- use FORCEINLINE in foreach, according to speed test for clang
- add one speed test
- Modify iterators for better speed.
- along the lines decided for the foreach
- update doc.
2014-10-18 21:20:17 +02:00

57 lines
1.2 KiB
C++

//#define TRIQS_ARRAYS_ENFORCE_BOUNDCHECK
//#define TRIQS_ARRAYS_CHECK_WEAK_REFS
#include <triqs/gfs.hpp>
using namespace triqs::gfs;
using namespace triqs::arrays;
#define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> " << (X) << std::endl << std::endl;
#include <triqs/gfs/local/functions.hpp>
const int nl_interne = 1000;
const int N = 1000;
typedef double VALUE_TYPE;
// typedef int VALUE_TYPE;
// inline VALUE_TYPE fnt(size_t i) { return i*(i+2.0)*(i-8.0);}
inline VALUE_TYPE fnt(size_t i) { return i; } //*(i+2.0)*(i-8);}
// inline VALUE_TYPE fnt(size_t i) { return i*(i+2.0)*(i-8);}
struct with_g {
void operator()() {
double beta = 1;
auto G = gf<imfreq>{{beta, Fermion, N}, {2, 2}};
G() = 0;
for (int u = 0; u < nl_interne; ++u)
// for (int i =0; i<N-1; ++i) G.on_mesh(i)(0,0) = fnt(i);
for (int i = 0; i < N - 1; ++i) G[i](0, 0) = fnt(i);
}
};
struct array_code {
void operator()() {
double beta = 1;
auto G = gf<imfreq>{{beta, Fermion, N}, {2, 2}};
G() = 0;
auto V = G.data();
for (int u = 0; u < nl_interne; ++u)
for (int i = 0; i < N - 1; ++i) V(i, 0, 0) = fnt(i);
}
};
#include "./speed_tester.hpp"
int main() {
try {
speed_tester<array_code>(100);
speed_tester<with_g>(100);
}
TRIQS_CATCH_AND_ABORT;
}