Class ActivityMap

Class Documentation

class ActivityMap

Contains the routines for importing activity maps and getting a cell value from the map.

Activity maps can be reproduction probability maps or death maps.

Public Functions

ActivityMap()
bool isNull()

Gets if the map is a null reproduction map, with no matrix storage in memory necessary.

Return
true if the map is “null” or “none”

void import(string file_name, unsigned long size_x, unsigned long size_y, shared_ptr<RNGController> random_in)

Imports the map file from the given path Requires the dimensions to be identical as the fine map file dimensions.

Parameters
  • file_name: the path to the reproduction map to import
  • size_x: the x dimensions of the map file
  • size_y: the y dimensions of the map file

void setActivityFunction()

Correctly sets the reproduction function to either rejectionSampleNull or rejectionSample depending on if a reproduction map is used or not.

void setOffsets(const unsigned long &x_offset, const unsigned long &y_offset, const unsigned long &xdim, const unsigned long &ydim)

Sets the offsets for the reproduction map from the sample grid.

Parameters
  • x_offset: the x offset from the sample grid
  • y_offset: the y offset from the sample grid
  • xdim: the x dimension of the sample grid
  • ydim: the y dimension of the sample grid

bool rejectionSampleNull(const unsigned long &x, const unsigned long &y, const long &xwrap, const long &ywrap)

Returns true for all cell values Function to be pointed to in cases where there is no reproduction map.

Return
true always
Parameters
  • random_number: random number object to pass forward
  • x: x coordinate of the lineage on the sample grid
  • y: y coordinate of the lineage on the sample grid
  • xwrap: x wrapping of the lineage
  • ywrap: y wrapping of the lineage

bool rejectionSample(const unsigned long &x, const unsigned long &y, const long &xwrap, const long &ywrap)

Returns true for all cell values Function to be pointed to in cases where there is no reproduction map.

Return
true always
Parameters
  • random_number: random number object to pass forward
  • x: x coordinate of the lineage on the sample grid
  • y: y coordinate of the lineage on the sample grid
  • xwrap: x wrapping of the lineage
  • ywrap: y wrapping of the lineage

double getVal(const unsigned long &x, const unsigned long &y, const long &xwrap, const long &ywrap)

Gets the value of the reproduction map at that location.

Return
value of the reproduction map at the required location
Parameters
  • x: x coordinate of the lineage on the sample grid
  • y: y coordinate of the lineage on the sample grid
  • xwrap: x wrapping of the lineage
  • ywrap: y wrapping of the lineage

bool actionOccurs(const unsigned long &x, const unsigned long &y, const long &xwrap, const long &ywrap)

Tests if the random action occurs.

Return
value of the reproduction map at the required location
Parameters
  • x: x coordinate of the lineage on the sample grid
  • y: y coordinate of the lineage on the sample grid
  • xwrap: x wrapping of the lineage
  • ywrap: y wrapping of the lineage

void standardiseValues()

Standardises probability values from 0-1.

double get(const unsigned long &rows, const unsigned long &cols)

Get the value at the specified index.

Return
the value at the specified row and column
Parameters
  • rows: the row index to obtain
  • cols: the column index to obtain

double getMean() const

Gets the arithmetic mean of the Map object.

Return
the mean value

ActivityMap &operator=(const ActivityMap &rm)

Equality operator.

Return
the self ActivityMap object
Parameters

Protected Types

typedef bool (ActivityMap::*rep_ptr)(const unsigned long &x, const unsigned long &y, const long &xwrap, const long &ywrap)

Protected Attributes

Map<double> activity_map
string map_file
double max_val
bool null_map
unsigned long offset_x
unsigned long offset_y
unsigned long x_dim
unsigned long y_dim
shared_ptr<RNGController> random
rep_ptr activity_map_checker_fptr

Friends

ostream &operator<<(ostream &os, ActivityMap &r)

Operator for outputting to an ostream.

Return
the os object
Parameters
  • os: the ostream to output to
  • r: the ActivityMap to read from

istream &operator>>(istream &is, ActivityMap &r)

Operator for inputting from an istream.

Return
the is object
Parameters
  • is: the istream to input from
  • r: the ActivityMap to input to