Nemo
2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
|
A class to handle matrix in params, coerces matrix into a vector of same total size. More...
#include <tmatrix.h>
Public Member Functions | |
TMatrix () | |
TMatrix (const TMatrix &mat) | |
copy constructor. More... | |
TMatrix (unsigned int rows, unsigned int cols) | |
Creates an array of doubles of size = rows*cols. More... | |
~TMatrix () | |
void | copy (const TMatrix &mat) |
Copy a matrix. More... | |
void | copy_recycle (const TMatrix &mat) |
Copy elements of 'mat', recycling elements of 'mat' if its size is smaller than current matrix. More... | |
void | set (unsigned int i, unsigned int j, double val) |
Sets element at row i and column j to value val. More... | |
void | assign (double val) |
Assigns a value to all element of the matrix. More... | |
void | reset (unsigned int rows, unsigned int cols) |
Re-allocate the existing matrix with assigned rows and cols dimensions. More... | |
void | reset (unsigned int rows, unsigned int cols, double value) |
Reset the existing matrix to the new dimensions and copies the value to all elements. More... | |
void | reset (unsigned int rows, unsigned int cols, double *array) |
Reset the existing matrix to the new dimensions and copies the array. More... | |
void | reset () |
Reset members to zero state. More... | |
double | get (unsigned int i, unsigned int j) |
Accessor to element at row i and column j. More... | |
double * | get () const |
Accessor to the whole array. More... | |
double * | getValArray () const |
unsigned int | get_dims (unsigned int *dims) |
Accessor to the matrix dimensions. More... | |
unsigned int | getNbRows () |
Gives the number of rows. More... | |
unsigned int | nrows () |
unsigned int | getNbCols () |
Gives the number of columns. More... | |
unsigned int | ncols () |
unsigned int | length () |
Returns the number of elements in the matrix. More... | |
void | getColumnView (unsigned int col, unsigned int n, double *array) |
Gives access to a column of the matrix. More... | |
void | getRowView (unsigned int row, unsigned int n, double *array) |
Gives access to a row of the matrix. More... | |
void | plus (unsigned int i, unsigned int j, double value) |
Adds a value to an element of the matrix. More... | |
void | matrix_increment (double value) |
Adds a value to all elements in a matrix. More... | |
void | minus (unsigned int i, unsigned int j, double value) |
Substracts a value from an element of the matrix. More... | |
void | multi (unsigned int i, unsigned int j, double value) |
Multiply an element of the matrix by a value. More... | |
void | divide (unsigned int i, unsigned int j, double value) |
Divide an element of the matrix by a value. More... | |
void | transpose () |
Transpose the matrix, swaps columns for rows. More... | |
double | colSum (unsigned int col) |
Sum all elements in a column. More... | |
double | rowSum (unsigned int row) |
Sum all elements in a row. More... | |
void | show_up () |
string | to_string () |
Writes the matrix into a string in Nemo's matrix input format. More... | |
Private Attributes | |
unsigned int | _rows |
unsigned int | _cols |
unsigned int | _length |
double * | _val |
A class to handle matrix in params, coerces matrix into a vector of same total size.
|
inline |
|
inline |
|
inline |
Assigns a value to all element of the matrix.
Referenced by reset(), LCE_Patch_Extinction::set_matrix_param(), LCE_Selection_base::set_param_rate_of_change(), LCE_Selection_base::set_std_rate_of_change(), TTNeutralGenesSH::setAlleleTables(), LCE_Disperse_base::setBasicLatticeMatrix(), TTNeutralGenesSH::setCoaMatrix(), TProtoQuanti::setDominanceParameters(), TTNeutralGenesSH::setFstMatrix(), LCE_Disperse_base::setIndentityDispMatrix(), TTNeutralGenesSH::setNeiGeneticDistance(), LCE_Selection_base::setSelectionMatrix(), and LCE_Disperse_base::setSteppingStone1DMatrix().
|
inline |
|
inline |
Copy a matrix.
References _cols, _length, _rows, and _val.
Referenced by copy_recycle(), LCE_Breed_Wolbachia::setParameters(), Metapop::setPatchSizes(), and TMatrix().
|
inline |
Copy elements of 'mat', recycling elements of 'mat' if its size is smaller than current matrix.
Will only copy as many elements as necessary given _rows and _cols of current matrix.
References _cols, _length, _rows, _val, copy(), error(), and set().
Referenced by TProtoQuanti::setDominanceParameters().
Divide an element of the matrix by a value.
References _cols, _length, _val, and error().
Referenced by TTNeutralGenesSH::setAlleleTables(), and TTNeutralGenesSH::setCoaMatrix().
|
inline |
Accessor to the whole array.
References _val.
Referenced by transpose().
Accessor to element at row i and column j.
References _cols, _length, _val, and fatal().
Referenced by Metapop::buildPatchArray(), LCE_Selection_base::changeLocalOptima(), LCE_Disperse_base::checkBackwardDispersalMatrix(), LCE_Disperse_base::checkForwardDispersalMatrix(), LCE_Patch_Extinction::do_remove(), LCE_Patch_Extinction::execute(), LCE_QuantiModifier::execute(), TProtoQuanti::get_dominance(), LCE_Patch_Extinction::get_harvest_size(), TProtoQuanti::get_trait_var(), TTNeutralGenesSH::getCoa(), LCE_Breed_base::getFecundity(), LCE_Selection_base::getFitnessMultivariateGaussian(), LCE_Selection_base::getFitnessMultivariateGaussian_VE(), LCE_Selection_base::getFitnessUnivariateGaussian(), LCE_Selection_base::getFitnessUnivariateGaussian_VE(), LCE_Selection_base::getFitnessUnivariateQuadratic(), TTNeutralGenesSH::getFst_ij(), TProtoBDMI::getGenoFitnessDiplo(), TProtoBDMI::getGenoFitnessHaplo(), TTNeutralGenesSH::getGlobalAlleleFreq(), LCE_Breed_base::getMeanFecundity(), TTNeutralGenesSH::getNeiGeneticDistance(), Metapop::getPatchCapacity(), TTDispersal::init_sequence(), LCE_Breed_Wolbachia::inoculate_wolbachia(), LCE_Breed_base::NonWrightFisherPopulation(), LCE_Breed_Quanti::NonWrightFisherPopulation(), LCE_Resize::removeDesignatedPatch(), FileHandler::set_OccMatrix(), LCE_Selection_base::set_param_rate_of_change(), LCE_Selection_base::set_sel_model(), LCE_Selection_base::set_std_rate_of_change(), LCE_Disperse_base::setBasicLatticeMatrix(), TTNeutralGenesSH::setCoaMatrix(), TProtoQuanti::setContinuousMutationModel(), TProtoQuanti::setDiallelicMutationModel(), TProtoQuanti::setDominanceParameters(), TProtoDeletMutations_bitstring::setEffectsFromInput(), LCE_Breed_base::setFecundity(), TTNeutralGenesSH::setFst_li(), TTNeutralGenesSH::setFstatWeirCockerham(), TTNeutralGenesSH::setFstatWeirCockerham_MS(), TTNeutralGenesSH::setFstMatrix(), TTProtoWithMap::setGeneticMapParameters(), TTNeutralGenesSH::setHt(), TTNeutralGenesSH::setHt2(), LCE_Disperse_base::setLatticeAbsorbingMatrix(), LCE_Disperse_base::setLatticeReflectingMatrix(), LCE_Disperse_base::setLatticeTorrusMatrix(), TTNeutralGenesSH::setLociDivCounter(), TTProtoWithMap::setNumLociPerChromosome(), LCE_StatServiceNotifier::setOccurence(), LCE_Breed_Disperse::setParameters(), LCE_Resize::setParameters(), TProtoQuanti::setParameters(), Metapop::setPatchCapacities(), LCE_Init_BDMI::setPatchFreq(), LCE_Selection_base::setSelectionMatrix(), setSpatialMatrix(), LCE_Init_BDMI::setSpatialPattern(), TProtoBDMI::showGenoTable(), ParamsParser::sym_matrix(), transpose(), LCE_Resize::updatePatchCapacities(), Metapop::updatePatchState(), and TTNeutralGenesFH::write_varcompWC().
Accessor to the matrix dimensions.
dims | an array of at least 2 elements to store the row [0] and column [1] numbers. May be NULL. |
References _cols, _length, and _rows.
Referenced by TProtoQuanti::setContinuousMutationModel().
Gives access to a column of the matrix.
col | index of col to view |
n | size of the storing array passed, must be equal to no. of rows |
array | array where the column values will be stored |
|
inline |
Gives the number of columns.
References _cols.
Referenced by LCE_Resize::buildNewPatchArrayNoBackup(), LCE_Resize::buildNewPatchArrayWithBackup(), LCE_Disperse_base::checkBackwardDispersalMatrix(), LCE_Disperse_base::checkForwardDispersalMatrix(), LCE_Resize::execute(), TTNeutralGenesSH::getCoa(), TTNeutralGenesSH::getFst_ij(), TTNeutralGenesSH::getNeiGeneticDistance(), LCE_Resize::removeDesignatedPatch(), LCE_Patch_Extinction::set_matrix_param(), LCE_Selection_base::set_sel_model(), TProtoDeletMutations_bitstring::setEffectsFromInput(), TTProtoWithMap::setGeneticMapParameters(), TTProtoWithMap::setNumLociPerChromosome(), LCE_Breed_Disperse::setParameters(), LCE_Resize::setParameters(), TProtoBDMI::setParameters(), LCE_Init_BDMI::setParameters(), TProtoQuanti::setParameters(), LCE_Init_BDMI::setPatchFreq(), LCE_Selection_base::setSelectionMatrix(), setSpatialMatrix(), LCE_Init_BDMI::setSpatialPattern(), LCE_Resize::updateParameters(), and LCE_Resize::updatePatchCapacities().
|
inline |
Gives the number of rows.
References _rows.
Referenced by LCE_Disperse_base::checkBackwardDispersalMatrix(), LCE_Disperse_base::checkForwardDispersalMatrix(), TTDispersal::init_sequence(), LCE_Patch_Extinction::set_matrix_param(), TProtoDeletMutations_bitstring::setEffectsFromInput(), TTProtoWithMap::setGeneticMapParameters(), TTProtoWithMap::setNumLociPerChromosome(), LCE_Init_BDMI::setParameters(), TProtoQuanti::setParameters(), LCE_Init_BDMI::setPatchFreq(), LCE_Selection_base::setSelectionMatrix(), setSpatialMatrix(), and LCE_Init_BDMI::setSpatialPattern().
Gives access to a row of the matrix.
row | index of row to view |
n | size of the storing array passed, must be equal to no. of columns |
array | array where the row values will be stored |
References _cols, _rows, _val, and error().
Referenced by LCE_QuantiInit::execute(), LCE_Init_BDMI::execute(), and LCE_NtrlInit::execute().
|
inline |
References _val.
Referenced by FileHandler::set_OccMatrix().
|
inline |
Returns the number of elements in the matrix.
References _length.
Referenced by TTNeutralGenesSH::setCoaMatrix(), TTNeutralGenesSH::setFstMatrix(), TTNeutralGenesSH::setNeiGeneticDistance(), and Metapop::setPatchCapacities().
|
inline |
Adds a value to all elements in a matrix.
Multiply an element of the matrix by a value.
References _cols, _length, _val, and error().
Referenced by LCE_Selection_base::set_std_rate_of_change().
|
inline |
References _cols.
Referenced by LCE_Breed::execute(), LCE_QuantiModifier::execute(), LCE_Breed_Quanti::execute(), FileHandler::set_OccMatrix(), LCE_Selection_base::set_param_rate_of_change(), LCE_Selection_base::set_std_rate_of_change(), TProtoQuanti::setDiallelicMutationModel(), LCE_Breed_base::setFecundity(), LCE_StatServiceNotifier::setOccurence(), and LCE_Breed_Wolbachia::setParameters().
|
inline |
References _rows.
Referenced by LCE_Selection_base::changeLocalOptima(), FileHandler::set_OccMatrix(), LCE_Selection_base::set_param_rate_of_change(), LCE_Selection_base::set_std_rate_of_change(), TProtoQuanti::setDiallelicMutationModel(), LCE_Breed_base::setFecundity(), LCE_StatServiceNotifier::setOccurence(), LCE_QuantiModifier::setParameters(), and LCE_Breed_Wolbachia::setParameters().
Adds a value to an element of the matrix.
References _cols, _length, _val, and error().
Referenced by LCE_Selection_base::changeLocalOptima(), matrix_increment(), TTNeutralGenesSH::setAlleleTables(), TTNeutralGenesSH::setCoaMatrix(), TProtoQuanti::setDominanceParameters(), and LCE_Disperse_base::setLatticeAbsorbingMatrix().
|
inline |
Re-allocate the existing matrix with assigned rows and cols dimensions.
References _cols, _length, _rows, and _val.
Referenced by LCE_Disperse_base::allocateDispMatrix(), TTNeutralGenesSH::allocateTables(), Param::parse_matrix(), LCE_Selection_base::set_local_optima(), LCE_Patch_Extinction::set_matrix_param(), FileHandler::set_OccMatrix(), LCE_Selection_base::set_param_rate_of_change(), LCE_Selection_base::set_std_rate_of_change(), TTNeutralGenesSH::setCoaMatrix(), TProtoQuanti::setDominanceParameters(), LCE_Breed_base::setFecundity(), TTNeutralGenesSH::setFstMatrix(), LCE_Disperse_base::setIndentityDispMatrix(), TTNeutralGenesSH::setNeiGeneticDistance(), LCE_QuantiModifier::setParameters(), LCE_Init_BDMI::setParameters(), Metapop::setPatchCapacities(), LCE_Selection_base::setSelectionMatrix(), setSpatialMatrix(), and LCE_Resize::updateParameters().
|
inline |
Sum all elements in a row.
References _cols, _rows, and _val.
Referenced by LCE_Disperse_base::setLatticeReflectingMatrix().
Sets element at row i and column j to value val.
References _cols, _length, _val, and error().
Referenced by copy_recycle(), Param::parse_matrix(), LCE_Selection_base::set_param_rate_of_change(), LCE_Selection_base::set_std_rate_of_change(), LCE_Disperse_base::setBasicLatticeMatrix(), LCE_Breed_base::setFecundity(), TTNeutralGenesSH::setFstMatrix(), TProtoBDMI::setGenoFitnessValue(), LCE_Disperse_base::setIndentityDispMatrix(), LCE_Disperse_base::setIsland_MigrantPool_Matrix(), LCE_Disperse_base::setIsland_PropagulePool_Matrix(), LCE_Disperse_base::setLatticeAbsorbingMatrix(), LCE_Disperse_base::setLatticeReflectingMatrix(), LCE_Disperse_base::setLatticeTorrusMatrix(), TTNeutralGenesSH::setNeiGeneticDistance(), Metapop::setPatchCapacities(), LCE_Init_BDMI::setPatchFreq(), LCE_Selection_base::setSelectionMatrix(), setSpatialMatrix(), LCE_Init_BDMI::setSpatialPattern(), LCE_Disperse_base::setSteppingStone1DMatrix(), ParamsParser::sym_matrix(), and transpose().
|
inline |
References _cols, _rows, _val, and message().
Referenced by TProtoQuanti::setContinuousMutationModel(), LCE_Disperse_base::setReducedDispMatrix(), and Metapop::show_up().
|
inline |
Writes the matrix into a string in Nemo's matrix input format.
References _cols, _rows, and _val.
Referenced by LCE_Selection_base::set_std_rate_of_change(), and ParamsParser::sym_matrix().
|
inline |
Transpose the matrix, swaps columns for rows.
References _cols, _rows, get(), reset(), and set().
Referenced by LCE_Disperse_base::setLatticeReflectingMatrix(), and LCE_Disperse_base::setSteppingStone1DMatrix().
|
private |
Referenced by colSum(), copy(), copy_recycle(), divide(), get(), get_dims(), getColumnView(), getNbCols(), getRowView(), matrix_increment(), minus(), multi(), ncols(), plus(), reset(), rowSum(), set(), show_up(), TMatrix(), to_string(), and transpose().
|
private |
|
private |
Referenced by colSum(), copy(), copy_recycle(), get_dims(), getColumnView(), getNbRows(), getRowView(), matrix_increment(), nrows(), reset(), rowSum(), show_up(), TMatrix(), to_string(), and transpose().
|
private |
Referenced by assign(), colSum(), copy(), copy_recycle(), divide(), get(), getColumnView(), getRowView(), getValArray(), minus(), multi(), plus(), reset(), rowSum(), set(), show_up(), TMatrix(), to_string(), and ~TMatrix().