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

matvec::ModelTerm Class Reference

#include <termlist.h>

List of all members.


Detailed Description

a class to hold term definition for a model

See also:
Model

Definition at line 39 of file termlist.h.

Public Methods

 ModelTerm (void)
 ModelTerm (const ModelTerm &A)
 ~ModelTerm (void)
const ModelTerm & operator= (const ModelTerm &A)
int partial_match (const std::string &effectname, FieldStruct *FS)
int match (const std::string &termname, const std::string &sep, FieldStruct *FS)
void copyfrom (const ModelTerm &A)
void resize (const unsigned ne, const unsigned nt)
void input (const std::string &str, FieldStruct *FS, const unsigned nf)
void classi (const char c)
char classi (void) const
unsigned order (void) const
unsigned ntrait (void) const
unsigned size (void) const
unsigned nlevel (void) const
unsigned startaddr (void) const
void variance (const doubleMatrix &A)
void release (void)

Public Attributes

unsigned numfact
unsigned start
unsigned numtrait
unsigned numlevel
unsigned base_effect
unsigned corr_link
unsigned pos_vec
Vector< int > trait_map
unsigned nt_vec
char myclassi
Vector< int > trait
Vector< int > factorindx
Vector< unsigned > addr
GeneticDistprior

Friends

class TermList
class Model
class GLMM


Constructor & Destructor Documentation

matvec::ModelTerm::ModelTerm void   
 

Definition at line 32 of file termlist.cpp.

References addr, myclassi, numfact, numlevel, numtrait, prior, and start.

00033 {
00034    start      = 0;
00035    numfact    = 0;
00036    numlevel   = 0;
00037    numtrait   = 0;
00038    myclassi   = 'F',
00039    addr       = 0;
00040    prior      = 0;
00041 }

matvec::ModelTerm::ModelTerm const ModelTerm &    A
 

Definition at line 43 of file termlist.cpp.

References addr, copyfrom(), myclassi, numfact, numlevel, numtrait, prior, and start.

00044 {
00045    start      = 0;
00046    numfact    = 0;
00047    numlevel   = 0;
00048    numtrait   = 0;
00049    myclassi   ='F',
00050    addr       = 0;
00051    prior      = 0;
00052    copyfrom(A);
00053 }

matvec::ModelTerm::~ModelTerm void    [inline]
 

Definition at line 69 of file termlist.h.

References release().

00069 {release();}


Member Function Documentation

char matvec::ModelTerm::classi void    const [inline]
 

Definition at line 78 of file termlist.h.

References myclassi.

00078 {return myclassi;}

void matvec::ModelTerm::classi const char    c [inline]
 

Definition at line 77 of file termlist.h.

References myclassi.

Referenced by matvec::GLMM::getVarEstimates(), matvec::Model::info(), and matvec::GLMM::info().

00077 {myclassi = c;}

void matvec::ModelTerm::copyfrom const ModelTerm &    A
 

Definition at line 61 of file termlist.cpp.

References addr, base_effect, corr_link, factorindx, myclassi, nt_vec, numfact, numlevel, numtrait, pos_vec, prior, resize(), start, trait, and trait_map.

Referenced by matvec::TermList::copyfrom(), ModelTerm(), and operator=().

00062 {
00063    if (this == &A) return;
00064    resize(A.numfact,A.numtrait);
00065    base_effect = A.base_effect;
00066    pos_vec     = A.pos_vec;
00067    nt_vec      = A.nt_vec;
00068    corr_link   = A.corr_link;
00069    trait_map   = A.trait_map;
00070    start       = A.start;
00071    numlevel    = A.numlevel;
00072    myclassi    = A.myclassi;
00073    prior       = A.prior;
00074    addr        = A.addr;
00075    trait       = A.trait;
00076    factorindx  = A.factorindx;
00077 }

void matvec::ModelTerm::input const std::string &    str,
FieldStruct   FS,
const unsigned    nf
 

Definition at line 137 of file termlist.cpp.

References factorindx, matvec::fieldindex(), numtrait, and resize().

00138 {
00139    int k;
00140    std::string T(str),sep("* ");
00141    std::string::size_type begidx,endidx;
00142    std::vector<std::string> eff_name;
00143    /////////// T.split(ne,"* ");
00144    begidx = T.find_first_not_of(sep);
00145    while(begidx != std::string::npos) {
00146       endidx = T.find_first_of(sep,begidx);
00147       if (endidx == std::string::npos) endidx = T.length();
00148       eff_name.push_back(T.substr(begidx,endidx - begidx));
00149       begidx = T.find_first_not_of(sep,endidx);
00150    }
00151    unsigned ne = eff_name.size();
00152    resize(ne,numtrait);
00153    for (unsigned i=0; i<ne; i++) {
00154       k = fieldindex(eff_name[i],FS,nf);    // it cannot found
00155       factorindx[i] = k;
00156    }
00157 }

int matvec::ModelTerm::match const std::string &    termname,
const std::string &    sep,
FieldStruct   FS
 

Definition at line 104 of file termlist.cpp.

References factorindx, and numfact.

Referenced by matvec::TermList::index().

00105 {
00106    std::string s(termname);
00107    std::string::size_type begidx,endidx;
00108    std::vector<std::string> tmpstr;
00109    /////  s.split(n,sep);
00110    begidx = s.find_first_not_of(sep);
00111    while(begidx != std::string::npos) {
00112       endidx = s.find_first_of(sep,begidx);
00113       if (endidx == std::string::npos) endidx = s.length();
00114       tmpstr.push_back(s.substr(begidx,endidx - begidx));
00115       begidx = s.find_first_not_of(sep,endidx);
00116    }
00117    unsigned n = tmpstr.size();
00118    if (numfact != n) return 0;
00119    int i,j, k=1;
00120    for (i=0; i<numfact; i++) {
00121       for (j=0; j<numfact; j++) if (tmpstr[i] == FS[factorindx[j]].name()) break;
00122       if (j == numfact) { k=0; break;}
00123    }
00124    return k;
00125 }

unsigned matvec::ModelTerm::nlevel void    const [inline]
 

Definition at line 82 of file termlist.h.

References numlevel.

00082 {return numlevel;}

unsigned matvec::ModelTerm::ntrait void    const [inline]
 

Definition at line 80 of file termlist.h.

References numtrait.

00080 {return numtrait;}

const ModelTerm & matvec::ModelTerm::operator= const ModelTerm &    A
 

Definition at line 55 of file termlist.cpp.

References copyfrom().

00056 {
00057    if (this != &A) copyfrom(A);
00058    return *this;
00059 }

unsigned matvec::ModelTerm::order void    const [inline]
 

Definition at line 79 of file termlist.h.

References numfact.

Referenced by matvec::TermList::maxorder(), and matvec::Model::prepare_data().

00079 {return numfact;}

int matvec::ModelTerm::partial_match const std::string &    effectname,
FieldStruct   FS
 

Definition at line 127 of file termlist.cpp.

References factorindx, and numfact.

00128 {
00129    int i,k=-1;
00130    for (i=0; i<numfact; i++) {
00131       if (effectname == FS[factorindx[i]].name()) break;
00132    }
00133    if (i < numfact)  k = i;
00134    return k;
00135 }

void matvec::ModelTerm::release void   
 

Definition at line 99 of file termlist.cpp.

References numfact, and numtrait.

Referenced by ~ModelTerm().

00100 {
00101    numfact = 0; numtrait = 0;
00102 }

void matvec::ModelTerm::resize const unsigned    ne,
const unsigned    nt
 

Definition at line 79 of file termlist.cpp.

References addr, factorindx, numfact, numtrait, matvec::Vector< int >::reserve(), matvec::Vector< unsigned >::resize(), matvec::Vector< int >::resize(), and trait.

Referenced by copyfrom(), input(), and matvec::TermList::resize().

00080 {
00081    if (numfact != ne) {
00082       numfact = ne;
00083       //addr.reserve(numfact);
00084       factorindx.reserve(numfact);
00085    }
00086    if (numtrait != nt) {
00087       numtrait = nt;
00088       trait.resize(numtrait);
00089       addr.resize(numtrait);
00090    }
00091 }

unsigned matvec::ModelTerm::size void    const [inline]
 

Definition at line 81 of file termlist.h.

References numfact.

00081 {return numfact;}

unsigned matvec::ModelTerm::startaddr void    const [inline]
 

Definition at line 83 of file termlist.h.

References start.

00083 {return start;}

void matvec::ModelTerm::variance const doubleMatrix   A
 

Definition at line 93 of file termlist.cpp.

References prior, and matvec::GeneticDist::var_matrix().

00094 {
00095   doubleMatrix *var = prior->var_matrix();
00096   *var = A;
00097 }


Friends And Related Function Documentation

friend class GLMM [friend]
 

Definition at line 42 of file termlist.h.

friend class Model [friend]
 

Definition at line 41 of file termlist.h.

friend class TermList [friend]
 

Definition at line 40 of file termlist.h.


Member Data Documentation

Vector<unsigned> matvec::ModelTerm::addr
 

Definition at line 64 of file termlist.h.

Referenced by copyfrom(), ModelTerm(), and resize().

unsigned matvec::ModelTerm::base_effect
 

Definition at line 46 of file termlist.h.

Referenced by copyfrom().

unsigned matvec::ModelTerm::corr_link
 

Definition at line 49 of file termlist.h.

Referenced by copyfrom().

Vector<int> matvec::ModelTerm::factorindx
 

Definition at line 63 of file termlist.h.

Referenced by copyfrom(), matvec::Model::info(), matvec::GLMM::info(), input(), match(), partial_match(), matvec::Model::prepare_data(), and resize().

char matvec::ModelTerm::myclassi
 

Definition at line 62 of file termlist.h.

Referenced by classi(), copyfrom(), and ModelTerm().

unsigned matvec::ModelTerm::nt_vec
 

Definition at line 58 of file termlist.h.

Referenced by copyfrom().

unsigned matvec::ModelTerm::numfact
 

Definition at line 44 of file termlist.h.

Referenced by copyfrom(), match(), ModelTerm(), order(), partial_match(), release(), resize(), and size().

unsigned matvec::ModelTerm::numlevel
 

Definition at line 44 of file termlist.h.

Referenced by copyfrom(), ModelTerm(), and nlevel().

unsigned matvec::ModelTerm::numtrait
 

Definition at line 44 of file termlist.h.

Referenced by copyfrom(), input(), ModelTerm(), ntrait(), release(), and resize().

unsigned matvec::ModelTerm::pos_vec
 

Definition at line 52 of file termlist.h.

Referenced by copyfrom().

GeneticDist* matvec::ModelTerm::prior
 

Definition at line 66 of file termlist.h.

Referenced by copyfrom(), matvec::Model::copyfrom(), matvec::GLMM::getVarEstimates(), matvec::Model::info(), matvec::GLMM::info(), ModelTerm(), and variance().

unsigned matvec::ModelTerm::start
 

Definition at line 44 of file termlist.h.

Referenced by copyfrom(), ModelTerm(), and startaddr().

Vector<int> matvec::ModelTerm::trait
 

Definition at line 63 of file termlist.h.

Referenced by copyfrom(), and resize().

Vector<int> matvec::ModelTerm::trait_map
 

Definition at line 55 of file termlist.h.

Referenced by copyfrom().


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