Class Sum

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

Class Documentation

class Sum : public sequant::Expr

sum of zero or more summands

Sum is associative and is flattened automatically.

Public Types

using summands_type = container::svector<ExprPtr, 2>

Public Functions

Sum() = default
virtual ~Sum() = default
Sum(const Sum&) = default
Sum(Sum&&) = default
Sum &operator=(const Sum&) = default
Sum &operator=(Sum&&) = default
Sum(ExprPtrList summands)

construct a Sum out of zero or more summands

Parameters:

summands – an initializer list of summands

template<typename Iterator>
inline Sum(Iterator begin, Iterator end)

construct a Sum out of a range of summands

Parameters:
  • begin – the begin iterator

  • end – the end iterator

template<typename Range>
inline explicit Sum(Range &&rng)

construct a Sum out of a range of summands

Parameters:

rng – a range

explicit Sum(summands_type &&summands, move_only_tag)

construct a Sum by moving in the summands, no flattening is performed, but zeros will be omitted and constants added up

Parameters:

summands – the summands to move in

Sum &append(ExprPtr summand)

append a summand to the sum

Parameters:

summand – the summand

Sum &prepend(ExprPtr summand)

prepend a summand to the sum

Parameters:

summand – the summand

const summands_type &summands() const

Summands accessor.

const ExprPtr &summand(size_t i) const

Summand accessor

Parameters:

i – summand index

Returns:

ith summand

ExprPtr take_n(size_t count) const

Takes the first count elements of the sum.

ExprPtr take_n(size_t offset, size_t count) const

Takes the first count elements of the sum starting with element offset

template<typename Filter>
inline ExprPtr filter(Filter &&f) const
Template Parameters:

Filter – a boolean predicate type, such Filter(const ExprPtr&) evaluates to true

Parameters:

f – an object of Filter type Selects elements {e} for which f(e) is true

bool empty() const
Returns:

true if the number of factors is zero

std::size_t size() const
Returns:

the number of summands in a Sum

virtual std::wstring to_latex() const override
Returns:

the string representation of this in the LaTeX format

virtual Expr::type_id_type type_id() const override

Computes and returns the derived type identifier

Returns:

the hash value for this Expr

virtual ExprPtr clone() const override
Returns:

a clone of this object, i.e. an object that is equal to this

virtual void adjoint() override

adjoint of a Sum is a sum of adjoints of its factors

Sum &operator+=(const Expr &that)
Sum &operator-=(const Expr &that)
virtual ExprIterator begin_subexpr() override
virtual ExprIterator end_subexpr() override
virtual ConstExprIterator begin_subexpr() const override
virtual ConstExprIterator end_subexpr() const override
struct move_only_tag

tags ctor to move the summands directly