Into

Modules

Documentation

classPii::Mean

#include <PiiMathFunctional.h>

An adaptable unary function that calculates the sum of its arguments in successive calls and records the number of times the function has been called.

Inherits Pii::UnaryFunction< T, U >

Description

As such, the function can be used to calculate the mean value of data.

 // Calculate the mean value of a matrix:
 PiiMatrix<float> matrix(3,3);
 Pii::Mean<float> mean;
 Pii::forEach(matrix, mean);
 std::cout << mean.mean() << std::endl;

Constructors and destructor

(
  • U initialValue = 0
)

Create a new Mean function that initializes its accumulator to the given value.

Public member functions

int

Get the number of times the function has been called.

U
( )

Calculate the current mean value by dividing the accumulator by the number of invocations.

U
(
  • const T & value
)

Increment the invocation count and returns the current sum of values.

Function details

  • Mean

    (
    • U initialValue = 0
    )
    [inline]

    Create a new Mean function that initializes its accumulator to the given value.

  • int invocations

    ()
    [inline]

    Get the number of times the function has been called.

  • U mean

    ()
    [inline]

    Calculate the current mean value by dividing the accumulator by the number of invocations.

  • U operator()

    (
    • const T & value
    )
    [inline]

    Increment the invocation count and returns the current sum of values.

Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.