eXpress “1.5”

FrequencyMatrix< T > Class Template Reference

frequencymatrix.h express More...

#include <frequencymatrix.h>

List of all members.

Public Member Functions

 FrequencyMatrix ()
 Dummy FrequencyMatrix Constructor.
 FrequencyMatrix (size_t m, size_t n, T alpha, bool logged=true)
 FrequencyMatrix constructor initializes the matrix values to the given pseudo-counts.
operator() (size_t i, size_t j, bool normalized=true) const
 An accessor for the frequency at a given position in the matrix (logged if table is logged).
operator() (size_t k, bool normalized=true) const
 An accessor for the frequency at a given position in the flattened matrix (logged if table is logged).
void increment (size_t i, size_t j, T incr_amt)
 A member function to increase the mass of a given position in the matrix.
void increment (size_t k, T incr_amt)
 A member function to increase the mass of a given position in the flattened matrix (logged if table is logged).
sum (size_t i) const
 An accessor for the row sum (normalizer), (logged if table is logged).
size_t argmax (size_t i) const
 A member function that finds and returns the argmax (index of mode) of the given distribution.
void set_logged (bool logged)
 A member function that converts the table between log-space and non-log space.
void fix ()
 A member function that normalizes and "locks" the matrix values so that no changes can be made.
bool is_fixed () const
 An accessor for the value of _fixed, which specifies whether or not the matrix has been fixed (irrevocable).

Detailed Description

template<class T>
class FrequencyMatrix< T >

frequencymatrix.h express

Created by Adam Roberts on 4/23/11. Copyright 2011 Adam Roberts. All rights reserved. The FrequencyMatrix class keeps track of the frequency parameters in order to allow for constant-time probability look-ups and updates. The table is 2D to allow multiple distributions to be stored in one FrequencyMatrix. The first dimension (rows) are the different distributions. Values are stored in log space by default.

Author:
Adam Roberts
Date:
2011 Artistic License 2.0

Definition at line 27 of file frequencymatrix.h.


Constructor & Destructor Documentation

template<class T>
FrequencyMatrix< T >::FrequencyMatrix ( size_t  m,
size_t  n,
alpha,
bool  logged = true 
)

FrequencyMatrix constructor initializes the matrix values to the given pseudo-counts.

Parameters:
ma size_t specifying the number of distributions (rows).
na size_t specifying the number of values in each distribution (columns).
alphathe intial psuedo-counts (un-logged).
loggedbool that specifies if the table is to be stored logged.

Definition at line 143 of file frequencymatrix.h.


Member Function Documentation

template<class T >
size_t FrequencyMatrix< T >::argmax ( size_t  i) const

A member function that finds and returns the argmax (index of mode) of the given distribution.

Parameters:
ithe distribution (row).
Returns:
The argmax of the distribution.

Definition at line 217 of file frequencymatrix.h.

template<class T >
void FrequencyMatrix< T >::fix ( )

A member function that normalizes and "locks" the matrix values so that no changes can be made.

This allows for faster future lookups, but is irrevocable.

Definition at line 232 of file frequencymatrix.h.

template<class T>
void FrequencyMatrix< T >::increment ( size_t  k,
incr_amt 
)

A member function to increase the mass of a given position in the flattened matrix (logged if table is logged).

Does nothing if _fixed is true.

Parameters:
kthe array position.
incr_amtthe amount to increase the mass by (logged if table is logged).

Definition at line 189 of file frequencymatrix.h.

template<class T>
void FrequencyMatrix< T >::increment ( size_t  i,
size_t  j,
incr_amt 
)

A member function to increase the mass of a given position in the matrix.

Parameters:
ithe distribution (row).
jthe value (column).
incr_amtthe amount to increase the mass by (logged if table is logged).

Definition at line 171 of file frequencymatrix.h.

template<class T >
T FrequencyMatrix< T >::operator() ( size_t  k,
bool  normalized = true 
) const

An accessor for the frequency at a given position in the flattened matrix (logged if table is logged).

Parameters:
kthe array position.
normalizeda bool specifying whether or not the frequency should be normalized.
Returns:
The frequency at the given position in the flattened matrix (logged if table is logged).

Definition at line 166 of file frequencymatrix.h.

template<class T >
T FrequencyMatrix< T >::operator() ( size_t  i,
size_t  j,
bool  normalized = true 
) const

An accessor for the frequency at a given position in the matrix (logged if table is logged).

Parameters:
ithe distribution (row).
jthe value (column).
normalizeda bool specifying whether or not the frequency should be normalized.
Returns:
The frequency of the given value in the given distribution (logged if table is logged).

Definition at line 153 of file frequencymatrix.h.

template<class T >
void FrequencyMatrix< T >::set_logged ( bool  logged)

A member function that converts the table between log-space and non-log space.

Does nothing if _fixed is true.

Parameters:
loggedbool specifying if the table should be converted to logged or non-logged space.

Definition at line 194 of file frequencymatrix.h.

template<class T>
T FrequencyMatrix< T >::sum ( size_t  i) const [inline]

An accessor for the row sum (normalizer), (logged if table is logged).

Parameters:
ithe distribution (row).
Returns:
The sum (normalizer) for the given distribution (logged if table is (logged).

Definition at line 114 of file frequencymatrix.h.


The documentation for this class was generated from the following file:
 All Classes Functions Variables