Einsums/TensorBase/Common.hpp#

Defined in header Einsums/TensorBase/Common.hpp.

See Overview for a list of names and headers that are part of the public Einsums API.

Defines

DEFINE_STRUCT(Name, UnderlyingType)#

Convenience macro for creating a type derived from a std::array.

Added in version 1.0.0.

namespace einsums

Todo:

Variables

static struct AllT All#

Implementation of AllT .

Added in version 1.0.0.

struct AllT#
#include <Common.hpp>

Type that indicates that all elements along a dimension should be included in a view.

Added in version 1.0.0.

template<std::size_t Rank>
struct Chunk : public std::array<std::int64_t, Rank>#
#include <Common.hpp>

Holds a list of chunks in an array.

Added in version 1.0.0.

Public Functions

template<typename ...Args>
inline explicit constexpr Chunk(Args... args)#

Aggregate constructor.

Added in version 1.0.0.

template<std::size_t Rank>
struct Count : public std::array<std::int64_t, Rank>#
#include <Common.hpp>

Holds a list of counts in an array.

Added in version 1.0.0.

Public Functions

template<typename ...Args>
inline explicit constexpr Count(Args... args)#

Aggregate constructor.

Added in version 1.0.0.

template<std::size_t Rank>
struct Dim : public std::array<std::int64_t, Rank>#
#include <Common.hpp>

Holds a list of dimensions in an array.

Added in version 1.0.0.

Public Functions

template<typename ...Args>
inline explicit constexpr Dim(Args... args)#

Aggregate constructor.

Added in version 1.0.0.

template<std::input_iterator Iterator>
inline constexpr Dim(Iterator start, Iterator end)#

Construct a dimension array and fill it with values.

Added in version 2.0.0.

Parameters:
  • start[in] An iterator to the start of the data.

  • end[in] An iterator to the end of the data.

template<std::size_t Rank>
struct Offset : public std::array<std::int64_t, Rank>#
#include <Common.hpp>

Holds a list of offsets in an array.

Added in version 1.0.0.

Public Functions

template<typename ...Args>
inline explicit constexpr Offset(Args... args)#

Aggregate constructor.

Added in version 1.0.0.

template<std::input_iterator Iterator>
inline constexpr Offset(Iterator start, Iterator end)#

Construct an offset array from an iterator. If more elements are provided than the rank, then the extra elements are ignored. If fewer elements are provided than the rank, then the array will be backfilled with zeros.

Added in version 2.0.0.

Parameters:
  • start[in] The starting iterator.

  • end[in] The ending iterator.

struct Range : public std::array<std::int64_t, 2>#
#include <Common.hpp>

Holds two values: a starting value and an ending value.

Added in version 1.0.0.

Subclassed by einsums::RemovableRange

Public Functions

constexpr Range() = default#
template<std::integral First, std::integral Second>
inline explicit constexpr Range(First first, Second second)#

Initialize a range.

Added in version 1.0.0.

inline bool is_removable() const noexcept#

Check if the range can be treated as a single value if its entries are the same. If it is removable and the entries are the same, then the rank of the tensor view created with this range will have a lower rank than the parent tensor. If it is not removable, or the entries are different, then the rank of the view will be the same as the rank of the parent.

Added in version 2.0.0.

Protected Attributes

bool _is_removable = {false}#

Holds whether the range is removable.

Added in version 2.0.0.

struct RemovableRange : public einsums::Range#
#include <Common.hpp>

Holds two values: a starting value and an ending value. It will be treated as a single value if the start and end are the same. The usefulness may not be immediately apparent. This class is mostly used in the Python compatibility layer, but as an example, look at this code segment.

RuntimeTensor<double> A{"A", 3, 3, 3}; // A is a rank-3 tensor.

auto A_view_1 = A(Range{0, 1}, Range{0, 1}, Range{0, 0});
auto A_view_2 = A(Range{0, 1}, Range{0, 1}, 0);
auto A_view_3 = A(Range{0, 1}, Range{0, 1}, RemovableRange{0, 0});

std::vector<Range> indices{Range{0, 1}, Range{0, 1}, RemovableRange{0, 0}};

auto A_view_4 = A(indices);

EINSUMS_ASSERT(A_view_1.rank() == 3);
EINSUMS_ASSERT(A_view_2.rank() == 2);
EINSUMS_ASSERT(A_view_3.rank() == 2);
EINSUMS_ASSERT(A_view_4.rank() == 2);

In the first three examples, the RemovableRange is not really needed. It can be replaced with a single value index. However, in the fourth example, we can’t use a single value because the vector can only hold ranges. Since RemovableRange extends Range, we can use it in this vector where it will be treated as if it were a single index. If the elements in the range are not the same, such as RemovableRange{0, 1}, then it behaves exactly the same as a regular Range. The removable part is a hint to the functions that look for them that they can be removed if needed.

\verbatim embed:rst 
 .. versionadded:: 2.0.0 
 \endverbatim

Public Functions

template<std::integral First, std::integral Second>
inline explicit constexpr RemovableRange(First first, Second second)#

Initialize a range.

Added in version 2.0.0.

template<std::size_t Rank>
struct Stride : public std::array<std::int64_t, Rank>#
#include <Common.hpp>

Holds a list of strides in an array.

Added in version 1.0.0.

Public Functions

template<typename ...Args>
inline explicit constexpr Stride(Args... args)#

Aggregate constructor.

Added in version 1.0.0.

template<std::input_iterator Iterator>
inline constexpr Stride(Iterator start, Iterator end)#

Construct a stride array from an iterator. If more elements are provided than the rank, then the extra elements are ignored. If fewer elements are provided than the rank, then the array will be backfilled with zeros.

Added in version 2.0.0.

Parameters:
  • start[in] The starting iterator.

  • end[in] The ending iterator.