Skip to content

Commit 6126f22

Browse files
committed
refactor: preserve_lobound uses all_of to detect zero extents
Switches to ranges::all_of from ranges::equal to make things more obvious. Also, need to make a `p` object here, cannot use auto&& [lb, ub] directly as argument.
1 parent d1b9661 commit 6126f22

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/TiledArray/expressions/blk_tsr_expr.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include <TiledArray/expressions/unary_expr.h>
3333
#include "blk_tsr_engine.h"
3434

35+
#include <range/v3/algorithm.hpp>
36+
#include <range/v3/view.hpp>
37+
3538
#include <optional>
3639

3740
namespace TiledArray {
@@ -314,8 +317,13 @@ class BlkTsrExprBase : public Expr<Derived> {
314317
/// Sets result trange lobound such that the tile lobounds are not changed
315318
Derived& preserve_lobound() {
316319
// only set lobound if *all* dimensions have non-zero extents
317-
// so compare lower and upper bounds
318-
if (ranges::equal(lower_bound_, upper_bound_, std::less<>{})) {
320+
const bool empty = ranges::any_of(
321+
ranges::views::zip(lower_bound_, upper_bound_), [](auto&& p) {
322+
auto [lb, ub] = p;
323+
return lb >= ub;
324+
});
325+
326+
if (!empty) {
319327
return set_trange_lobound(
320328
array_.trange().make_tile_range(lower_bound()).lobound());
321329
}

0 commit comments

Comments
 (0)