本文整理汇总了C++中Array1D::GetDim方法的典型用法代码示例。如果您正苦于以下问题:C++ Array1D::GetDim方法的具体用法?C++ Array1D::GetDim怎么用?C++ Array1D::GetDim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array1D
的用法示例。
在下文中一共展示了Array1D::GetDim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: T
T Tree2<T>::CalculateLikelihood(const Array1D<T> ¶ms, const Array1D<char> &observed_vals,
const Array1D<char> &possible_vals, T(*f)(const char, const char, const T, const Array1D<T>&))
{
T retval = 0.0e0;
int nodestraversed = 0;
int nodeid = std::numeric_limits<int>::quiet_NaN();
int npossible = possible_vals.GetDim();
Array2D<T> B(nodecount,npossible,0.0e0);
/* Start at root node */
pCurrent = pHead;
while(nodestraversed < nodecount){
pCurrent->nvisits += 1;
nodeid = pCurrent->nodeid;
if(pCurrent->nvisits == pCurrent->nchildren-1 &&
pCurrent->pchild1 != NULL){
if(pCurrent->pchild1->nvisits != pCurrent->pchild1->nchildren+1){
//newickstr += "(";
GoToChildNode(1);
}
}
if(pCurrent->nvisits == pCurrent->nchildren &&
pCurrent->pchild1 != NULL){
if(pCurrent->pchild1->nvisits != pCurrent->pchild1->nchildren+1){
//newickstr += "(";
GoToChildNode(1);
}
}
if(pCurrent->nvisits == pCurrent->nchildren &&
pCurrent->pchild2 != NULL){
if(pCurrent->pchild2->nvisits != pCurrent->pchild2->nchildren+1){
//newickstr += ",";
GoToChildNode(2);
}
}
if(pCurrent->nvisits == pCurrent->nchildren+1/* &&
(pCurrent->pchild1 != NULL || pCurrent->pchild2 != NULL)*/){
/*
Check type of node. Note that this DOES NOT account for a node with a single
child!
*/
int i = pCurrent->nodeid;
if(pCurrent->nchildren == 0){
/* Calculate B(:,:) values for leaf */
for(int j=0; j<npossible; j++){
char sp = possible_vals(j);
char si = observed_vals(i-1);
T t = pCurrent->qtyparent;
T tmp = f(sp,si,t,params);
//B(i,j) = f(sp,si,t,params);
B(i,j) = tmp;
}
}
if(pCurrent->nchildren == 2 && pCurrent != pHead){
/* Calculate B(:,:) values for non-root branch */
for(int j=0; j<npossible; j++){
char sp = possible_vals(j);
T t = pCurrent->qtyparent;
int c1 = pCurrent->pchild1->nodeid;
int c2 = pCurrent->pchild2->nodeid;
for(int k=0; k<npossible; k++){
char si = possible_vals(k);
T tmp = f(sp,si,t,params)*B(c1,k)*B(c2,k);
//B(i,j) += f(sp,si,t,params)*B(c1,k)*B(c2,k);
B(i,j) += tmp;
}
}
}
if(pCurrent->nchildren == 2 && pCurrent == pHead){
/* Calculate total likelihood */
for(int j=0; j<npossible; j++){
int c1 = pCurrent->pchild1->nodeid;
int c2 = pCurrent->pchild2->nodeid;
T tmp = params(i)*B(c1,j)*B(c2,j);
//retval += params(i)*B(c1,j)*B(c2,j);
retval += tmp;
}
}
GoToParentNode();
nodestraversed += 1;
}
// if(pCurrent->nvisits == pCurrent->nchildren+1 &&
// (pCurrent->pchild1 == NULL && pCurrent->pchild2 == NULL)){
// /*
// Check type of node. Note that this DOES NOT account for a node with a single
// child!
// */
// int i = pCurrent->nodeid;
// if(pCurrent->nchildren == 0){
// /* Calculate B(:,:) values for leaf */
// for(int j=0; j<npossible; j++){
// char sp = possible_vals(j);
// char si = observed_vals(i);
// T t = pCurrent->qtyparent;
// T tmp = f(sp,si,t,params);
// //B(i,j) = f(sp,si,t,params);
//.........这里部分代码省略.........