#include <population.h>
Public Methods | |
| void | setupVectors (std::vector< unsigned > aVector) |
| Initialize the multiplicationCode vector used to convert an integer (e.g. individual genotype) into the vector decomposition (e.g vector of genotypes at each locus). The input vector (aVector) specifies the number of possible values (genotypes) at each position in the vector (e.g. the number of alleles at 3 loci [2 2 3]). | |
| std::vector< unsigned > | getVector (unsigned index) |
| Returns the corresponding vector decomposition for index. | |
| unsigned | getIndex (std::vector< unsigned > stateVector) |
| Returns the index for the vector decomposition given in stateVector. | |
Public Attributes | |
| unsigned | size |
| std::vector< unsigned > | maxElementVector |
| std::vector< unsigned > | multiplicationCode |
|
|
Returns the index for the vector decomposition given in stateVector.
Definition at line 2247 of file population.cpp. References multiplicationCode, and size. Referenced by matvec::Population::countHaplotypes().
02247 {
02248 // Authors: L. Radu Totir and Rohan L. Fernando
02249 // (August, 2004)
02250 // Contributors:
02251 unsigned index=0;
02252 for(unsigned i=0;i<size;i++){
02253 index+=stateVector[i]*multiplicationCode[i];
02254 }
02255 return index;
02256 }
|
|
|
Returns the corresponding vector decomposition for index.
Definition at line 2229 of file population.cpp. References maxElementVector, and size. Referenced by matvec::Population::displayHaplotypeFrequencies().
02229 {
02230 // Authors: L. Radu Totir and Rohan L. Fernando
02231 // (based on the gtindex(...) of Tianlin Wang)
02232 // (August, 2004)
02233 // Contributors:
02234 std::vector<unsigned> resultVector;
02235 resultVector.resize(size);
02236 unsigned ir=index;
02237 for (long i=size-1; i>=0; i--) {
02238 unsigned maxElement = maxElementVector[i];
02239 resultVector[i] = unsigned(fmod(double(ir),double(maxElement)));
02240 ir /= maxElement;
02241 }
02242 return resultVector;
02243 }
|
|
|
Initialize the multiplicationCode vector used to convert an integer (e.g. individual genotype) into the vector decomposition (e.g vector of genotypes at each locus). The input vector (aVector) specifies the number of possible values (genotypes) at each position in the vector (e.g. the number of alleles at 3 loci [2 2 3]).
Definition at line 2207 of file population.cpp. References maxElementVector, multiplicationCode, and size. Referenced by matvec::Population::setupRSampler().
02207 {
02208 // Authors: L. Radu Totir and Rohan L. Fernando
02209 // (August, 2004)
02210 // Contributors:
02211 maxElementVector=aVector;
02212 size = aVector.size();
02213 multiplicationCode.resize(size);
02214 multiplicationCode[size-1]=1;
02215 unsigned temp = 1;
02216 for(long i=size-2;i>=0;i--){
02217 temp *= maxElementVector[i+1];
02218 multiplicationCode[i]=temp;
02219 }
02220 }
|
|
|
Definition at line 60 of file population.h. Referenced by getVector(), and setupVectors(). |
|
|
Definition at line 61 of file population.h. Referenced by getIndex(), and setupVectors(). |
|
|
Definition at line 59 of file population.h. Referenced by getIndex(), getVector(), and setupVectors(). |
1.2.16