Nestedsums library
Ssum Class Reference

Ssums form an algebra. More...

#include <Ssum.h>

Inheritance diagram for Ssum:
Ssum_to_Infinity harmonic_sum harmonic_sum_to_Infinity harmonic_sum_to_Infinity

Public Member Functions

 Ssum (const GiNaC::ex &nc)
 
 Ssum (const GiNaC::ex &nc, const GiNaC::ex &llc)
 
void archive (GiNaC::archive_node &node) const override
 
void read_archive (const GiNaC::archive_node &node, GiNaC::lst &sym_lst) override
 
unsigned return_type (void) const override
 
void print (const GiNaC::print_context &c, unsigned level=0) const override
 
unsigned precedence (void) const override
 
GiNaC::ex eval () const override
 
GiNaC::ex subs (const GiNaC::exmap &m, unsigned options=0) const override
 
virtual GiNaC::ex convert_to_Zsum_exvector (const GiNaC::exvector &Z0, const GiNaC::exvector &Z1) const
 
virtual GiNaC::ex shuffle_exvector (const GiNaC::exvector &Z0, const GiNaC::exvector &Z1, const GiNaC::exvector &Z2) const
 
virtual GiNaC::ex refine_exvector (unsigned q, const GiNaC::exvector &Z0, const GiNaC::exvector &Z1) const
 
virtual GiNaC::ex refine (unsigned q) const
 
virtual GiNaC::ex set_index (const GiNaC::ex &i) const
 
virtual GiNaC::ex shift_plus_one (void) const
 
virtual GiNaC::ex shift_minus_one (void) const
 
virtual GiNaC::ex adjust_upper_limit_downwards (const GiNaC::ex &i) const
 
virtual GiNaC::ex adjust_upper_limit_upwards (const GiNaC::ex &i) const
 
virtual GiNaC::ex adjust_upper_limit_plus_one (void) const
 
virtual GiNaC::ex index_eq_one (void) const
 
virtual GiNaC::ex get_head (int k) const
 
virtual GiNaC::ex get_tail (int k) const
 
virtual int flag_remove_negative_degrees (void) const
 
virtual GiNaC::ex remove_negative_degrees (void) const
 
virtual GiNaC::ex expand_members (int level=0) const
 
virtual GiNaC::ex eval_explicit () const
 
virtual GiNaC::ex get_first_letter (void) const
 
virtual GiNaC::ex remove_first_letter (void) const
 
virtual GiNaC::ex remove_first_letter (const GiNaC::ex &nc) const
 
virtual GiNaC::ex prepend_letter (const GiNaC::ex &lc) const
 
virtual GiNaC::ex prepend_letter (const GiNaC::ex &nc, const GiNaC::ex &lc) const
 
virtual GiNaC::ex append_letter (const GiNaC::ex &lc) const
 
virtual GiNaC::ex append_letter_list (const GiNaC::ex &lc) const
 
GiNaC::ex get_index (void) const
 
GiNaC::ex get_letter_list (void) const
 
unsigned get_depth (void) const
 
GiNaC::ex get_weight (void) const
 

Protected Member Functions

GiNaC::ex eval_ncmul (const GiNaC::exvector &v) const override
 
GiNaC::ex derivative (const GiNaC::symbol &s) const override
 
unsigned calchash (void) const override
 
virtual GiNaC::ex cast_to_Zsum (void) const
 
virtual GiNaC::ex multiply_letter_with_last_letter (const GiNaC::ex &lc) const
 
virtual GiNaC::ex multiply_letter_with_first_letter (const GiNaC::ex &lc) const
 
virtual GiNaC::ex concat_two_sums (const GiNaC::ex &Z1, const GiNaC::ex &Z2) const
 

Protected Attributes

GiNaC::ex n
 
GiNaC::ex letter_list
 

Friends

class Csum
 
GiNaC::ex shuffle_Ssum (const GiNaC::ex &Z1, const GiNaC::ex &Z2)
 
GiNaC::ex convert_Ssum_to_Zsum (const GiNaC::ex &Z1)
 
GiNaC::ex remove_trivial_Ssum (const GiNaC::ex &expr)
 

Detailed Description

Ssums form an algebra.

A Ssum is recursively defined by

\[
    S(n;m_1,...,m_k;x_1,...,x_k) = \sum\limits_{i=1}^n \frac{x_1^i}{i^{m_1}} S(i;m_2,...,m_k;x_2,...,x_k)
 \]

with

\[
    S(n) = 1
 \]

for $ n > 0 $ and

\[
    S(n) = 0
 \]

for $ n \le 0 $.

Ssums can be converted to Zsums (and vice versa).

All letters should have their index set to _default_index.

Member Function Documentation

◆ adjust_upper_limit_downwards()

ex adjust_upper_limit_downwards ( const GiNaC::ex & i) const
virtual

Adjusts the upper summation limit $n$ down to $i$, e.g.

\[
    S(n;m_1,...;x_1,...) = S(i;m_1,...;x_1,...) 
     + \sum\limits_{j=0}^{n-i-1} x_1^{j+1} \frac{x_1^i}{(i+j+1)^{m_1}} S(i+j+1;m_2,...;x_2,...)
\]

with $n > i $.

For the empty sum we have

\[
    S(n) = S(i)
\]

This routine assumes $ i \ge 1 $.

Reimplemented in harmonic_sum.

◆ adjust_upper_limit_plus_one()

ex adjust_upper_limit_plus_one ( void ) const
virtual

Adjusts the upper summation limit $n$ to $n+1$, e.g.

\[
    S(n;m_1,...;x_1,...) = S(n+1;m_1,...;x_1,...) 
     \mbox{} - \frac{x_1^{n+1}}{(n+1)^{m_1}} S(n+1;m_2,...;x_2,...).
\]

Reimplemented in harmonic_sum.

◆ adjust_upper_limit_upwards()

ex adjust_upper_limit_upwards ( const GiNaC::ex & i) const
virtual

Adjusts the upper summation limit $n$ up to $i$, e.g.

\[
    S(n;m_1,...;x_1,...) = S(i;m_1,...;x_1,...) 
     \mbox{} - \sum\limits_{j=0}^{i-n-1} x_1^{-j} \frac{x_1^i}{(i-j)^{m_1}} S(i-j;m_2,...;x_2,...)
\]

with $n < i $.

For the empty sum we have

\[
    S(n) = S(i)
\]

This routine assumes $ n \ge 1 $.

This routine might give rise to poles for some values of $i$ and should be used with care.

Reimplemented in harmonic_sum.

◆ append_letter()

ex append_letter ( const GiNaC::ex & lc) const
virtual

Appends the letter lc to the letter_list.

◆ append_letter_list()

ex append_letter_list ( const GiNaC::ex & lc) const
virtual

Appends the list lc to the letter_list.

◆ cast_to_Zsum()

ex cast_to_Zsum ( void ) const
protectedvirtual

Creates a Zsum with the same upper summation index and the same letter_list.

This is a crude cast, something like reinterpret_cast.

◆ concat_two_sums()

ex concat_two_sums ( const GiNaC::ex & Z1,
const GiNaC::ex & Z2 ) const
protectedvirtual

Takes Z1 as head and Z2 as tail and forms a new sum as the concatenation of the two.

◆ convert_to_Zsum_exvector()

ex convert_to_Zsum_exvector ( const GiNaC::exvector & Z0,
const GiNaC::exvector & Z1 ) const
virtual

Method to convert a Ssum to a Zsum.

An efficient version for the conversion to Zsums, based on exvector (e.g. std::vector<GiNaC::ex> ). Z0 contains the result. Z1 is reversed order, so that we can use pop_back.

The basic formula is

\[
   S(n;m_1,...;x_1,...) = \sum\limits_{i=1}^n \frac{x_1^i}{i^{m_1}} S(i-1;m_2,...;x_2,...)
    \mbox{} + S(n;m_1+m_2,...;x_1 x_2, ...)
\]

Reimplemented in harmonic_sum.

◆ eval()

ex eval ( ) const
override

The simplifications are done in the following order:

  • If the upper summation limit is equal to infinity, we have a Ssum_to_Infinity
  • If all $x_j$'s are equal to 1, we have a harmonic sum.
  • If the upper summation index is an integer, perform the sum explicitly.

◆ eval_explicit()

ex eval_explicit ( ) const
virtual

Explicit evaluation

◆ eval_ncmul()

ex eval_ncmul ( const GiNaC::exvector & v) const
overrideprotected

A product of Ssums is simplified, if the last two have the same upper summation index.

A product is also simplified if the difference between the two upper summation indices is an integer. The factor with the "larger" upper summation index is converted to the "smaller" index with the help of the function Zsum::adjust_upper_limit_downwards. Note that the algorithm returns a product, where both factors have the "smaller" index.

◆ flag_remove_negative_degrees()

int flag_remove_negative_degrees ( void ) const
virtual

Signals if there are letters with negative or zero degrees.

Only for Ssums.

◆ get_depth()

unsigned get_depth ( void ) const
inline

Returns the depth.

◆ get_first_letter()

ex get_first_letter ( void ) const
virtual

Returns the first letter from the letter_list.

◆ get_head()

ex get_head ( int k) const
virtual

Returns from the S-sum $ S(n;m_1,...,m_l;x_1,...,x_l) $ the head $ S(n;m_1,...,m_{k-1};x_1,...,x_{k-1}) $.

◆ get_index()

GiNaC::ex get_index ( void ) const
inline

Returns the upper summation limit.

◆ get_letter_list()

GiNaC::ex get_letter_list ( void ) const
inline

Returns the letter_list.

◆ get_tail()

ex get_tail ( int k) const
virtual

Returns from the S-sum $ S(n;m_1,...,m_l;x_1,...,x_l) $ the tail $ S(n;m_k,...,m_l;x_k,...,x_l) $.

◆ get_weight()

ex get_weight ( void ) const

Returns the weight.

◆ index_eq_one()

ex index_eq_one ( void ) const
virtual

Returns

\[
    S(1;m_1,...,m_k;x_1,...,x_k) = x_1 \cdot ... \cdot x_k
\]

◆ multiply_letter_with_first_letter()

ex multiply_letter_with_first_letter ( const GiNaC::ex & lc) const
protectedvirtual

Returns a Ssum, where the letter lc is multiplied with the first letter in the letter list of the original Ssum.

If the sum is empty, e.g. $S(n)$, the result is $\frac{x^n}{n^m} S(n)$.

◆ multiply_letter_with_last_letter()

ex multiply_letter_with_last_letter ( const GiNaC::ex & lc) const
protectedvirtual

Returns a Ssum, where the letter lc is multiplied with the last letter in the letter list of the original Ssum.

If the sum is empty, e.g. $S(n)$, the result is $\frac{x^n}{n^m} S(n)$.

◆ refine()

ex refine ( unsigned q) const
virtual

Method to convert a Ssum with upper limit $n$ to Ssums with upper limit $q \cdot n$.

◆ refine_exvector()

ex refine_exvector ( unsigned q,
const GiNaC::exvector & Z0,
const GiNaC::exvector & Z1 ) const
virtual

Helper routine to convert a Ssum with upper limit $n$ to Ssums with upper limit $q \cdot n$.

Z0 contains the result in reversed order. Z1 the letter list, which has to be converted.

The basic formula is

\[
   \sum\limits_{i=1}^n \frac{x^i}{i^m} S( q \cdot i;...)
     = q^{m-1} \sum\limits_{l=0}^{q-1}
               \sum\limits_{i=1}^{q \cdot n} \frac{1}{i^m}
               \left( r_q^l x^{1/q} \right)^i S(i;...)
\]

Here $r_q^l$ are roots of unity.

◆ remove_first_letter()

ex remove_first_letter ( void ) const
virtual

Returns a Ssum with the first letter removed from the letter_list.

Reimplemented in harmonic_sum.

◆ remove_negative_degrees()

ex remove_negative_degrees ( void ) const
virtual

Removes letters with non-positive degrees.

The basic formula is

\[
   S(n;-m_1,m_2,...;x_1,x_2,...) =
      \sum\limits_{i2=1}^n \frac{x_2^{i_2}}{i_2^{m_2}} S(i_2;m_3,...;x_3,...) 
       \sum\limits_{i_1=i_2}^n i_1^{m_1} x_1^{i_1}
\]

For $x_1 \neq 1$ we have

\[
   \sum\limits_{i_1=i_2}^n i_1^{m_1} x_1^{i_1} =
     \left( x_1^- \right)^{m_1} \left( \frac{1}{1-x_1} x_1^{i_2} - \frac{x_1}{1-x_1} x_1^n \right)
\]

For $x_1 = 1$ we have

\[
   \sum\limits_{i_1=i_2}^n i_1^{m_1} =
      \sum\limits_{i_1=1}^n i_1^{m_1} - \sum\limits_{i_1=1}^{i_2-1} i_1^{m_1}
\]

and the sums can be done analytically with the help of the Bernoulli numbers:

\[
   \sum\limits_{i=1}^{n} i^m = n^m + \sum\limits_{k=0}^m \frac{B_k}{k!} \frac{m!}{(m+1-k)!} n^{m+1-k}
\]

◆ set_index()

ex set_index ( const GiNaC::ex & i) const
virtual

Sets the upper summation index to $i$

Reimplemented in harmonic_sum.

◆ shift_minus_one()

ex shift_minus_one ( void ) const
virtual

Returns $S(n-1,m_1,...,x_1,...)$

Reimplemented in harmonic_sum.

◆ shift_plus_one()

ex shift_plus_one ( void ) const
virtual

Returns $S(n+1,m_1,...,x_1,...)$

Reimplemented in harmonic_sum.

◆ shuffle_exvector()

ex shuffle_exvector ( const GiNaC::exvector & Z0,
const GiNaC::exvector & Z1,
const GiNaC::exvector & Z2 ) const
virtual

Method to multiply two Ssums.

An efficient version for the multiplication of Ssums, based on exvector (e.g. std::vector<GiNaC::ex> ). Z0 contains the result. Z1 and Z2 are in reversed order, so that we can use pop_back.

The basic formula is

\[
   S(n;m_1,...;x_1,...) S(n;m_1',...;x_1',...) 
     = \sum\limits_{i=1}^n \frac{x_1^i}{i^{m_1}} S(i;m_2,...;x_2,...) S(i;m_1',...;x_1',...)
\]

\[
     \mbox{} + \sum\limits_{i=1}^n \frac{{x_1'}^i}{i^{m_1'}} S(i;m_1,...;x_1,...) S(i;m_2',...;x_2',...)
     \mbox{} - \sum\limits_{i=1}^n \frac{(x_1 {x_1'})^i}{i^{m_1+m_1'}} S(i;m_2,...;x_2,...) S(i;m_2',...;x_2',...)
\]

Note the minus sign in front of the last term.

Reimplemented in harmonic_sum.


The documentation for this class was generated from the following files: