tatami_stats
Matrix statistics for tatami
Loading...
Searching...
No Matches
Public Member Functions | List of all members
tatami_stats::sums::RunningDense< Output_, Value_, Index_ > Class Template Reference

Running sums from dense data. More...

#include <sums.hpp>

Public Member Functions

 RunningDense (Index_ num, Output_ *sum, bool skip_nan)
 
void add (const Value_ *ptr)
 

Detailed Description

template<typename Output_, typename Value_, typename Index_>
class tatami_stats::sums::RunningDense< Output_, Value_, Index_ >

Running sums from dense data.

This considers a scenario with a set of equilength "objective" vectors \([v_1, v_2, v_3, ..., v_n]\), but data are only available for "observed" vectors \([p_1, p_2, p_3, ..., p_m]\), where the \(j\)-th element of \(p_i\) is the \(i\)-th element of \(v_j\). The idea is to repeatedly call add() for ptr corresponding to observed vectors from 0 to \(m - 1\), and then finally call finish() to obtain the sum for each objective vector.

This class uses naive accumulation to obtain the sum for each objective vector. Callers should use a sufficiently high-precision Output_ such as double to mitigate round-off errors.

Template Parameters
Output_Type of the output data.
Value_Type of the input value.
Index_Type of the row/column indices.

Constructor & Destructor Documentation

◆ RunningDense()

template<typename Output_ , typename Value_ , typename Index_ >
tatami_stats::sums::RunningDense< Output_, Value_, Index_ >::RunningDense ( Index_  num,
Output_ *  sum,
bool  skip_nan 
)
inline
Parameters
numNumber of objective vectors, i.e., \(n\).
[out]sumPointer to an output array of length num. This should be zeroed on input, and will store the running sums after each add().
skip_nanSee Options::skip_nan for details.

Member Function Documentation

◆ add()

template<typename Output_ , typename Value_ , typename Index_ >
void tatami_stats::sums::RunningDense< Output_, Value_, Index_ >::add ( const Value_ *  ptr)
inline

Add the next observed vector to the running sums.

Parameters
[in]ptrPointer to an array of values of length my_num, corresponding to an observed vector.

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