Skip to content

Commit

Permalink
introduced Tile::total_size() to mirror Tensor::total_size
Browse files Browse the repository at this point in the history
  • Loading branch information
evaleev committed Aug 27, 2024
1 parent c10f8d5 commit 09bb258
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/TiledArray/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,23 @@ class Tile {

// Dimension information accessors -----------------------------------------

/// Size accessors
/// Size accessor

/// \return The number of elements in the tensor
decltype(auto) size() const { return tensor().size(); }

/// Total size accessor

/// \return The number of elements in the tensor, tallied across batches (if
/// any)
decltype(auto) total_size() const {
if constexpr (detail::has_member_function_total_size_anyreturn_v<
tensor_type>) {
return tensor().total_size();
} else
return size();
}

/// Range accessor

/// \return An object describes the upper and lower bounds of the tensor data
Expand Down
2 changes: 2 additions & 0 deletions src/TiledArray/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ GENERATE_HAS_MEMBER_TYPE(mapped_type)

GENERATE_HAS_MEMBER_FUNCTION_ANYRETURN(size)
GENERATE_HAS_MEMBER_FUNCTION(size)
GENERATE_HAS_MEMBER_FUNCTION_ANYRETURN(total_size)
GENERATE_HAS_MEMBER_FUNCTION(total_size)
GENERATE_HAS_MEMBER_FUNCTION_ANYRETURN(data)
GENERATE_HAS_MEMBER_FUNCTION(data)
GENERATE_HAS_MEMBER_FUNCTION_ANYRETURN(empty)
Expand Down

0 comments on commit 09bb258

Please sign in to comment.