inline int CSwapBlock::FindElt(const int Element, int *CurrentPos) const { if (m_NextBlock) { if (m_NextBlock->SmallestElt()<=Element) { *CurrentPos+=m_UsedCount; return m_NextBlock->FindElt(Element, CurrentPos); } else return m_UsedCount ? FindElt(Element, 0, (int) m_UsedCount - 1) + *CurrentPos: -1; } else return m_UsedCount ? FindElt(Element, 0, (int) m_UsedCount - 1) + *CurrentPos: -1; }
int CSVector::FindElt(const int Element, const int Min, const int Max) const { if ( m_pVector[Min] == Element ) return Min; if ( m_pVector[Max] == Element ) return Max; if ( Max <= Min + 1 ) return -1; int Middle = Min + (Max - Min) /2 ; if ( Element > m_pVector[Middle] ) return FindElt(Element, Middle, Max); else if ( Element == m_pVector[Middle] ) return Middle; else return FindElt(Element, Min, Middle); }
bool KaxCuePoint::IsSmallerThan(const EbmlElement * EltB) const { assert(EbmlId(*this) == EBML_ID(KaxCuePoint)); assert(EbmlId(*EltB) == EBML_ID(KaxCuePoint)); const KaxCuePoint & theEltB = *static_cast<const KaxCuePoint *>(EltB); // compare timecode const KaxCueTime * TimeCodeA = static_cast<const KaxCueTime *>(FindElt(EBML_INFO(KaxCueTime))); if (TimeCodeA == NULL) return false; const KaxCueTime * TimeCodeB = static_cast<const KaxCueTime *>(theEltB.FindElt(EBML_INFO(KaxCueTime))); if (TimeCodeB == NULL) return false; if (TimeCodeA->IsSmallerThan(TimeCodeB)) return true; if (TimeCodeB->IsSmallerThan(TimeCodeA)) return false; // compare tracks (timecodes are equal) const KaxCueTrack * TrackA = static_cast<const KaxCueTrack *>(FindElt(EBML_INFO(KaxCueTrack))); if (TrackA == NULL) return false; const KaxCueTrack * TrackB = static_cast<const KaxCueTrack *>(theEltB.FindElt(EBML_INFO(KaxCueTrack))); if (TrackB == NULL) return false; if (TrackA->IsSmallerThan(TrackB)) return true; if (TrackB->IsSmallerThan(TrackA)) return false; return false; }
std::vector<std::string> EbmlMaster::FindAllMissingElements() { assert(Context.GetSize() != 0); std::vector<std::string> missingElements; for (size_t ChildElementNo = 0; ChildElementNo < ElementList.size(); ChildElementNo++) { EbmlElement *childElement = ElementList[ChildElementNo]; if (!childElement->ValueIsSet()) { std::string missingValue; missingValue = "The Child Element \""; missingValue.append(EBML_NAME(childElement)); missingValue.append("\" of EbmlMaster \""); missingValue.append(EBML_NAME(this)); missingValue.append("\", does not have a value set."); missingElements.push_back(missingValue); } if (childElement->IsMaster()) { EbmlMaster *childMaster = (EbmlMaster *)childElement; std::vector<std::string> childMissingElements = childMaster->FindAllMissingElements(); for (size_t s = 0; s < childMissingElements.size(); s++) missingElements.push_back(childMissingElements[s]); } } unsigned int EltIdx; for (EltIdx = 0; EltIdx < EBML_CTX_SIZE(Context); EltIdx++) { if (EBML_CTX_IDX(Context,EltIdx).IsMandatory()) { if (FindElt(EBML_CTX_IDX_INFO(Context,EltIdx)) == NULL) { std::string missingElement; missingElement = "Missing element \""; missingElement.append(EBML_INFO_NAME(EBML_CTX_IDX_INFO(Context,EltIdx))); missingElement.append("\" in EbmlMaster \""); missingElement.append(EBML_INFO_NAME(*EBML_CTX_MASTER(Context))); missingElement.append("\""); missingElements.push_back(missingElement); } } } return missingElements; }
bool EbmlMaster::CheckMandatory() const { assert(Context.GetSize() != 0); unsigned int EltIdx; for (EltIdx = 0; EltIdx < EBML_CTX_SIZE(Context); EltIdx++) { if (EBML_CTX_IDX(Context,EltIdx).IsMandatory()) { if (FindElt(EBML_CTX_IDX_INFO(Context,EltIdx)) == NULL) { #if defined(LIBEBML_DEBUG) // you are missing this Mandatory element // const char * MissingName = EBML_INFO_NAME(EBML_CTX_IDX_INFO(Context,EltIdx)); #endif // LIBEBML_DEBUG return false; } } } return true; }
// // Returns the value of the solution at $x$ // double OdeProb::GetSol(double x) const { int m1; // The equation must be solved! assert(m_y); assert(IsInRange(x)); const size_t n = FindElt(x); const Element& e = Elt(n); // s - Locat coordiante for element "e" const double s = std::min(std::max(e.Xinv(x), -1.0), 1.0); // MIN, MAX - To avoid the rounding errors // Sum over all basis function with support on the element $e$ double val = 0; /* // Left vertex basis function m1 = e.m_dof.front(); if(m1 > -1) val += m_y->Get(m1) * Basis(0, s); else { // Apply the Dirichlet boundary conditions if(m_left.m_type == BndrType_Dir) val += m_left.m_val * Basis(0, s); } // Right vertex basis function m1 = e.m_dof.back(); if(m1 > -1) val += m_y->Get(m1) * Basis(1, s); else { // Apply the Dirichlet boundary conditions if(m_right.m_type == BndrType_Dir) val += m_right.m_val * Basis(1, s); } // Bubble basis functions for(size_t j = 1; j < e.m_dof.size() - 1; j++) { m1 = e.m_dof[j]; val += m_y->Get(m1) * Basis(j, s); } */ // It works only with zero Dirichlet bpundary conditions for(size_t i = 0; i < e.m_dof.size(); i++) { const int m = e.m_dof[i]; if(m < 0) continue; const size_t psiI = e.PsiId(i); val += m_y->Get(m) * Basis(psiI, s); } // Non-zero Dirichlet bpundary conditions are applied { // Left vertex basis function assert(m_left.m_type == BndrType_Dir); m1 = e.m_dof.front(); if(m1 < 0) { const size_t psiI = e.PsiId(0); val += m_left.m_val * Basis(psiI, s); } // Right vertex basis function assert(m_right.m_type == BndrType_Dir); m1 = e.m_dof.back(); if(m1 < 0) { const size_t psiI = e.PsiId(1); val += m_right.m_val * Basis(psiI, s); } } return val; }
inline int CSwapBlock::FindElt(const int Element) const { int Pos=0; return FindElt(Element,&Pos); }