Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

matvec::CutSet Class Reference

#include <gnodesetderived.h>

Inheritance diagram for matvec::CutSet:

matvec::GNodeSet List of all members.

Detailed Description

This is the "cut set" class.

CutSet class has methods relevant to a "cut set"

Definition at line 34 of file gnodesetderived.h.

Public Methods

void setKeyMultiplicationCode (void)
int getKey (void)
 returns the string key to be used to put or retrieve values from the valueVector

int getOldKey (void)
double getValue (void)
 returns the relevant probability from the valueVector

double getOldValue (void)
 returns the relevant probability from the valueVector

void putValue (double x)
 puts the value x in the valueVector

void displayValues (void)
 displays the values stored in the valueVector

GNodegetLocation ()
void normalize ()
void replaceMeWith (CutSet &A)
CutSet & operator= (GNodeSet *A)
 overloaded = operator, puts the values contained by the larger set (the neighborhood set) into the new set.

CutSet & operator+= (GNodeSet *A)
 overloaded += operator, adds the values contained by the larger set (the neighborhood set) into the new set.

CutSet & operator *= (GNodeSet *A)
 overloaded *= operator, multiplies the values contained by the various cutsets.

 ~CutSet (void)
bool incr (void)
void reset (void)
void attachMeToMyGnodes (void)
void display (void)
virtual double getTargetValue (void)

Public Attributes

SafeSTLVector< unsigned > keyMultiplicationCode
std::vector< double > valueVector
unsigned connectFlag
unsigned numberOfCuts

Static Public Attributes

GeneticDistprior
unsigned currentLocus


Constructor & Destructor Documentation

matvec::CutSet::~CutSet void    [inline]
 

Definition at line 51 of file gnodesetderived.h.

00051 {;}


Member Function Documentation

void matvec::GNodeSet::attachMeToMyGnodes void    [inherited]
 

Referenced by matvec::Population::initAlleleNodeList(), matvec::Population::initGenotypeNodeList(), and matvec::Population::initJointAlleleNodeList().

void matvec::GNodeSet::display void    [inherited]
 

void matvec::CutSet::displayValues void   
 

displays the values stored in the valueVector

Definition at line 211 of file gnodederived.cpp.

References valueVector.

Referenced by normalize().

00211                               {
00212   // Authors: L. Radu Totir and Rohan L. Fernando 
00213   // (February, 2004) 
00214   // Contributors:
00215   for(unsigned i=0;i!=valueVector.size();i++){
00216     cout << valueVector[i] << endl;
00217   } 
00218 }

int matvec::CutSet::getKey void    [inline]
 

returns the string key to be used to put or retrieve values from the valueVector

Definition at line 70 of file gnodederived.cpp.

References keyMultiplicationCode.

Referenced by getValue(), operator *=(), operator+=(), and putValue().

00070                               {
00071   // Authors: L. Radu Totir and Rohan L. Fernando 
00072   // (June, 2003) 
00073   // Contributors: Robert Benson
00074   CutSet::iterator it;
00075   int key = 0;
00076   CutSet::iterator beginIt = begin();
00077   CutSet::iterator endIt = end();
00078   unsigned i=0;
00079   for (it=beginIt;it!=endIt;it++){
00080     key += ((*it)->getState())*keyMultiplicationCode[i];
00081     i++;
00082   }
00083   return key;
00084 }

GNode * matvec::CutSet::getLocation  
 

Definition at line 148 of file gnodederived.cpp.

00148                               {
00149   // Authors: L. Radu Totir and Rohan L. Fernando 
00150   // (August, 2003) 
00151   // Contributors:
00152   CutSet::iterator it;
00153   set<GNodeSet*>::iterator itFound;
00154   CutSet::iterator beginIt = begin();
00155   CutSet::iterator endIt = end();
00156   for (it=beginIt;it!=endIt;it++){
00157     itFound = (*it)->SetofGNsts.find(this);
00158     if(itFound!=(*it)->SetofGNsts.end()){
00159       return *it;
00160     }
00161   }
00162 }

int matvec::CutSet::getOldKey void    [inline]
 

Definition at line 39 of file gnodederived.cpp.

References keyMultiplicationCode.

Referenced by getOldValue().

00039                                  {
00040   // Authors: L. Radu Totir and Rohan L. Fernando 
00041   // (June, 2003) 
00042   // Contributors: Robert Benson
00043   CutSet::iterator it;
00044   int key = 0;
00045   CutSet::iterator beginIt = begin();
00046   CutSet::iterator endIt = end();
00047   unsigned i=0;
00048   for (it=beginIt;it!=endIt;it++){
00049     key += ((*it)->getOldState())*keyMultiplicationCode[i];
00050     i++;
00051   }
00052   return key;
00053 }

double matvec::CutSet::getOldValue void    [virtual]
 

returns the relevant probability from the valueVector

Reimplemented from matvec::GNodeSet.

Definition at line 59 of file gnodederived.cpp.

References getOldKey(), and valueVector.

00059                                {
00060   // Authors: L. Radu Totir and Rohan L. Fernando 
00061   // (June, 2003) 
00062   // Contributors: 
00063   int key = getOldKey();
00064   return valueVector[key];
00065 }

virtual double matvec::GNodeSet::getTargetValue void    [inline, virtual, inherited]
 

Reimplemented in matvec::TransitionSet.

Definition at line 122 of file gnodestuff.h.

00122                                        {
00123       throw exception("GNodeSet::getTargetValue(void): call for virtual function");
00124     };

double matvec::CutSet::getValue void    [virtual]
 

returns the relevant probability from the valueVector

Reimplemented from matvec::GNodeSet.

Definition at line 90 of file gnodederived.cpp.

References getKey(), and valueVector.

00090                             {
00091   // Authors: L. Radu Totir and Rohan L. Fernando 
00092   // (June, 2003) 
00093   // Contributors:
00094                 int key = getKey();
00095                 if(key > valueVector.size()){
00096                         cout << "key > size in CutSet::getValue\n";
00097                         exit(1);
00098                 }
00099                 return valueVector[key];
00100 }

bool matvec::GNodeSet::incr void    [inherited]
 

Referenced by operator *=(), operator+=(), and operator=().

void matvec::CutSet::normalize  
 

Definition at line 164 of file gnodederived.cpp.

References displayValues(), and valueVector.

Referenced by operator *=(), and operator+=().

00164                       {
00165   // Authors: L. Radu Totir and Rohan L. Fernando 
00166   // (February, 2004) 
00167   // Contributors:    
00168   double sum = 0.0;
00169   double temp= 1.0;
00170   for(unsigned i=0;i!=valueVector.size();i++){
00171     // cout << "sum after summing " << i+1 << " value = " << sum << endl;
00172     sum+=valueVector[i];
00173   }
00174   if(sum!=0.0){
00175     temp = 1/sum;
00176   }
00177   // cout << "Sum in normalize() = " << sum << endl;
00178   if(sum>1e-20){ // original value -14, set to -20 by me (LRT 9/24/04)
00179     //       cout << "Unscaled probabilities: " << endl;
00180     //       displayValues();
00181     for(unsigned i=0;i!=valueVector.size();i++){
00182       valueVector[i]*=temp;
00183     } 
00184     //       cout << "Scaling factor = " << temp << endl;
00185     //       CutSet::iterator itC;
00186     //       cout << "CutSet Members: [";
00187     //       for (itC=begin();itC!=end();itC++){
00188     //  cout << (*itC)->id << " ";
00189     //       } 
00190     //       cout << "]" << endl;
00191     //       cout << "Scaled probabilities: " << endl;
00192     //       displayValues();
00193   }
00194   else if(sum==0.0){
00195     throw matvec::InvalidSample();
00196   }
00197   else{
00198     cout << "Sum used for scaling = " << sum << endl;
00199     CutSet::iterator itC;
00200     cout << "CutSet Members: [";
00201     for (itC=begin();itC!=end();itC++){
00202       cout << (*itC)->id << " ";
00203     } 
00204     cout << "]" << endl;
00205     displayValues();
00206     cerr << " Need scaling in CutSet::normalize(), sum = " << sum << endl;
00207     exit(1);
00208   }
00209 }

CutSet & matvec::CutSet::operator *= GNodeSet   A
 

overloaded *= operator, multiplies the values contained by the various cutsets.

Definition at line 277 of file gnodederived.cpp.

References getKey(), matvec::GNodeSet::getValue(), matvec::GNodeSet::incr(), normalize(), matvec::GNodeSet::reset(), and valueVector.

00277                                       {
00278   // Authors: L. Radu Totir and Rohan L. Fernando 
00279   // (June, 2003) 
00280   // Contributors:
00281   reset();
00282   do{
00283         unsigned key = getKey();  
00284     //double temp = getValue();
00285     double Atemp = A->getValue();
00286     //putValue(temp*Atemp);
00287         valueVector[key] *= Atemp;
00288   } while(incr());
00289   normalize();
00290   return *this;
00291 }

CutSet & matvec::CutSet::operator+= GNodeSet   A
 

overloaded += operator, adds the values contained by the larger set (the neighborhood set) into the new set.

Definition at line 256 of file gnodederived.cpp.

References getKey(), matvec::GNodeSet::getValue(), matvec::GNodeSet::incr(), normalize(), matvec::GNodeSet::reset(), and valueVector.

00256                                       {
00257   // Authors: L. Radu Totir and Rohan L. Fernando 
00258   // (June, 2003) 
00259   // Contributors:
00260   A->reset();
00261   do{
00262     //double temp  = getValue();
00263         unsigned key = getKey();
00264     double Atemp = A->getValue();
00265     //putValue(temp + Atemp);
00266         valueVector[key] += Atemp;
00267   } while(A->incr());
00268   //scalling next
00269   normalize();
00270   return *this;
00271 }

CutSet & matvec::CutSet::operator= GNodeSet   A
 

overloaded = operator, puts the values contained by the larger set (the neighborhood set) into the new set.

Definition at line 240 of file gnodederived.cpp.

References matvec::GNodeSet::getValue(), matvec::GNodeSet::incr(), and matvec::GNodeSet::reset().

00240                                      {
00241   // Authors: L. Radu Totir and Rohan L. Fernando 
00242   // (June, 2003) 
00243   // Contributors:
00244   reset();
00245   do{
00246     double Atemp = A->getValue();
00247     (*this).putValue(Atemp);
00248   } while(incr());
00249   return *this;
00250 }

void matvec::CutSet::putValue double    x
 

puts the value x in the valueVector

Definition at line 105 of file gnodederived.cpp.

References getKey(), and valueVector.

00105                               {
00106         // Authors: L. Radu Totir and Rohan L. Fernando 
00107         // (June, 2003) 
00108         // Contributors:
00109         int key = getKey();
00110         if(key > valueVector.size()){
00111                 cout << "key > size in CutSet::putValue\n";
00112                 exit(1);
00113         }
00114         valueVector[key] = x;
00115 }

void matvec::CutSet::replaceMeWith CutSet &    A
 

Definition at line 223 of file gnodederived.cpp.

References matvec::GNodeSet::connectFlag, matvec::GNodeSet::currentLocus, keyMultiplicationCode, matvec::GNodeSet::numberOfCuts, matvec::GNodeSet::prior, and valueVector.

00223                                    {
00224   // Authors: L. Radu Totir and Rohan L. Fernando 
00225   // (June, 2003) 
00226   // Contributors:
00227   GNodeSet::iterator it;
00228   connectFlag = A.connectFlag;
00229   numberOfCuts = A.numberOfCuts;
00230   prior = A.prior;
00231   currentLocus = A.currentLocus;
00232   clear();
00233   for (it=A.begin();it!=A.end();it++){
00234     insert(*it);
00235   }
00236   keyMultiplicationCode = A.keyMultiplicationCode;
00237   valueVector = A.valueVector;
00238 }

void matvec::GNodeSet::reset void    [inherited]
 

Referenced by operator *=(), operator+=(), and operator=().

void matvec::CutSet::setKeyMultiplicationCode void   
 

Definition at line 120 of file gnodederived.cpp.

References keyMultiplicationCode, and valueVector.

00120                                          {
00121   // Authors: L. Radu Totir and Rohan L. Fernando 
00122   // (July, 2004) 
00123   // Contributors:
00124   unsigned mySize = (size()) ? size():1;
00125   keyMultiplicationCode.resize(mySize);
00126   CutSet::iterator it;
00127   CutSet::iterator beginIt = begin();
00128   CutSet::iterator endIt = end();
00129   unsigned state = 1;
00130   unsigned i = 0;
00131   for (it=beginIt;it!=endIt;it++){
00132         keyMultiplicationCode[i] = (*it)->sampled ? 0 : state;
00133     i++;
00134     state *= (*it)->sampled ? 1 : (*it)->getWeight();
00135   }
00136   valueVector.resize(state,0.0);
00137 }


Member Data Documentation

unsigned matvec::GNodeSet::connectFlag [inherited]
 

Definition at line 111 of file gnodestuff.h.

Referenced by replaceMeWith().

unsigned matvec::GNodeSet::currentLocus [static, inherited]
 

Definition at line 43 of file gnodestuff.cpp.

Referenced by matvec::GenoFounderSet::getValue(), matvec::AlleleFounderSet::getValue(), and replaceMeWith().

SafeSTLVector<unsigned> matvec::CutSet::keyMultiplicationCode
 

Definition at line 36 of file gnodesetderived.h.

Referenced by getKey(), getOldKey(), replaceMeWith(), and setKeyMultiplicationCode().

unsigned matvec::GNodeSet::numberOfCuts [inherited]
 

Definition at line 112 of file gnodestuff.h.

Referenced by replaceMeWith().

GeneticDist * matvec::GNodeSet::prior [static, inherited]
 

Definition at line 42 of file gnodestuff.cpp.

Referenced by matvec::RAlleleFounderSet::getValue(), matvec::GenoFounderSet::getValue(), matvec::AlleleFounderSet::getValue(), and replaceMeWith().

std::vector<double> matvec::CutSet::valueVector
 

Definition at line 37 of file gnodesetderived.h.

Referenced by displayValues(), getOldValue(), getValue(), normalize(), operator *=(), operator+=(), putValue(), replaceMeWith(), and setKeyMultiplicationCode().


The documentation for this class was generated from the following files:
Generated on Thu Jun 16 17:14:17 2005 for Matvec by doxygen1.2.16