mirror of
https://github.com/triqs/dft_tools
synced 2024-12-24 13:23:37 +01:00
Fix #108 (tentatively).
- Pb was that indices for gf where empty when constructed with default args from C++. - changed into : make indices from the shape in the default case. - also added more, simpler construction, for the indices to easy C++ construction.
This commit is contained in:
parent
88800c903c
commit
e5928de7f5
@ -433,7 +433,9 @@ namespace gfs {
|
||||
|
||||
gf(typename B::mesh_t m, target_shape_t shape = target_shape_t{}, typename B::indices_t const &ind = typename B::indices_t{}, std::string name = "")
|
||||
: B(std::move(m), factory::make_data(m, shape), factory::make_singularity(m, shape), typename B::symmetry_t{}, ind, name, // clean unncessary types
|
||||
typename B::evaluator_t{}) {}
|
||||
typename B::evaluator_t{}) {
|
||||
if (this->_indices.is_empty()) this->_indices = typename B::indices_t(shape);
|
||||
}
|
||||
|
||||
friend void swap(gf &a, gf &b) noexcept { a.swap_impl(b); }
|
||||
|
||||
|
@ -83,8 +83,24 @@ namespace gfs {
|
||||
std::vector<std::vector<std::string>> ind;
|
||||
|
||||
indices_2() = default;
|
||||
|
||||
indices_2(std::vector<std::vector<std::string>> _ind) : ind(std::move(_ind)) {}
|
||||
|
||||
// from a size
|
||||
indices_2(int L) : indices_2(arrays::mini_vector<int, 2>{L, L}) {};
|
||||
|
||||
// from a shape
|
||||
indices_2(arrays::mini_vector<int, 2> const & shape) : ind(2) {
|
||||
for (int i = 0; i < shape[0]; ++i) ind[0].push_back(std::to_string(i));
|
||||
for (int i = 0; i < shape[1]; ++i) ind[1].push_back(std::to_string(i));
|
||||
}
|
||||
|
||||
// indices from a vector<T> : L and R are the same.
|
||||
template <typename T> indices_2(std::vector<T> const & _ind) : ind(2) {
|
||||
for (auto const &i : _ind) ind[0].push_back(std::to_string(i));
|
||||
ind[1] = ind[0];
|
||||
}
|
||||
|
||||
bool is_empty() const { return ind.size() == 0; }
|
||||
|
||||
void resize(int s) { ind.resize(s);}
|
||||
@ -173,6 +189,7 @@ namespace gfs {
|
||||
friend nothing operator+(nothing, nothing) { return nothing(); }
|
||||
template <typename RHS> friend void assign_from_expression(nothing &, RHS) {}
|
||||
template<typename A> bool check_size(A) {return true;}
|
||||
bool is_empty() const { return false;}
|
||||
};
|
||||
|
||||
inline nothing transpose(nothing) { return {};}
|
||||
|
Loading…
Reference in New Issue
Block a user