lines 294-348 of file: example/multi_thread/harmonic.cpp

{xrst_begin harmonic_sum}

Multi-Threaded Implementation of Summation of 1/i
#################################################

Syntax
******
*ok* = ``harmonic_sum`` ( *sum* , *num_sum* )

Purpose
*******
Multi-threaded computation of the summation that defines the harmonic series

.. math::

   s = 1 + 1/2 + 1/3 + ... + 1/n

Thread
******
It is assumed that this function is called by thread zero,
and all the other threads are blocked (waiting).

ok
**
This return value has prototype

   ``bool`` *ok*

If this return value is false, an error occurred during ``harmonic`` .

sum
***
This argument has prototype

   ``double&`` *sum*

The input value of the argument does not matter.
Upon return it is the value of the summation; i.e. :math:`s`.

num_sum
*******
This argument has prototype

   ``size_t`` *num_sum*

It specifies the number of terms in the summation; i.e. :math:`n`.

Source
******
{xrst_literal
   // BEGIN SUM C++
   // END SUM C++
}

{xrst_end harmonic_sum}
