// --------------------------------------------------------------------------- // CSmileyIconRecord::DeleteIconsIn // --------------------------------------------------------------------------- // void CSmileyIconRecord::DeleteIconsIn( TInt aStart, TInt aLength ) { TInt startIndex( FirstIndexIn( aStart, aLength ) ); TInt endIndex( LastIndexIn( aStart, aLength, startIndex ) ); TInt count( endIndex - startIndex ); for ( TInt i( 0 ); startIndex != KErrNotFound && i <= count; i++ ) { CSmileyIcon* icon( iIconArray[startIndex] ); iIconArray.Remove( startIndex ); delete icon; } }
void CExperimentObjectMap::fixBuild55() { CCopasiParameterGroup::index_iterator it = beginIndex(); CCopasiParameterGroup::index_iterator end = endIndex(); for (; it != end; ++it) { CDataColumn * pColumn = dynamic_cast< CDataColumn * >(*it); if (pColumn != NULL) { pColumn->fixBuild55(); } } }
double QxrdAcquisitionExtraInputsChannel::sumChannel() { QVector<double> res = readChannel(); double sum=0; int i0 = startIndex(); int i1 = endIndex(); for(int i=i0; i<i1; i++) { sum += res[i]; } return sum; }
size_t CExperimentObjectMap::getLastNotIgnoredColumn() const { elements::iterator itColumn = beginIndex(); elements::iterator endColumn = endIndex(); C_INT32 LastNotIgnored = -1; for (; itColumn != endColumn; ++itColumn) if (static_cast< CDataColumn * >(*itColumn)->getRole() != CExperiment::ignore) { C_INT32 index = strtol(static_cast< CDataColumn * >(*itColumn)->getObjectName().c_str(), NULL, 10); if (index > LastNotIgnored) LastNotIgnored = index; } return LastNotIgnored; }
double QxrdAcquisitionExtraInputsChannel::averageChannel() { QVector<double> res = readChannel(); double n=0; double sum=0; int i0 = startIndex(); int i1 = endIndex(); for(int i=i0; i<i1; i++) { sum += res[i]; n += 1; } return (n>0 ? sum/n : 0); }
bool CExperimentSet::elevateChildren() { index_iterator it = beginIndex(); index_iterator end = endIndex(); for (; it != end; ++it) { if (dynamic_cast< CCopasiParameterGroup * >(*it) == NULL) continue; if (!elevate<CExperiment, CCopasiParameterGroup>(*it)) return false; } mpExperiments = static_cast< std::vector< CExperiment * > * >(mpValue); sort(); return true; }
bool QxrdAcquisitionExtraInputsChannel::evalTrig(int polarity, bool edgeTrig) { double level = get_TriggerLevel(); double hyst = get_TriggerHysteresis(); bool tres; QVector<double> res = readChannel(); int nlow=0, nhigh=0; double tlevel = level*polarity; double lowlevel = tlevel-fabs(hyst); double highlevel = tlevel+fabs(hyst); int i0 = startIndex(); int i1 = endIndex(); for(int i=i0; i<i1; i++) { double v=res[i]*polarity; if (v < lowlevel) nlow += 1; if (edgeTrig) { if (nlow && (v > highlevel)) nhigh += 1; } else { if (v > highlevel) nhigh += 1; } } set_NLow(nlow); set_NHigh(nhigh); if (edgeTrig) { tres = ((nlow > 0) && (nhigh > 0)); } else { tres = (nhigh > 0); } return tres; }
double QxrdAcquisitionExtraInputsChannel::minimumChannel() { QVector<double> res = readChannel(); double min=0; int i0 = startIndex(); int i1 = endIndex(); for(int i=i0; i<i1; i++) { double v=res[i]; if (i == i0) { min = v; } else { if (v < min) { min = v; } } } return min; }
void Cvlars::run2() { //search the first and last fold with the same size std::vector<int> startIndex(1,0),endIndex(1,k_-1); int k = 0; for(int i = 1; i < k_; i++) { if(sizePartition_[i]!= sizePartition_[startIndex[k]]) { startIndex.push_back(i); endIndex[k] = i-1; endIndex.push_back(k_-1); k++; } } //run for each size of fold //create test and control container #pragma omp parallel { #pragma omp for schedule(dynamic,1) for(int i = 0; i < k_ ; i++) { STK::CArrayXX XControl( n_ - sizePartition_[i], p_); STK::CVectorX yControl( n_ - sizePartition_[i] ); STK::CArrayXX XTest(sizePartition_[i], p_); STK::CVectorX yTest(sizePartition_[i] ); STK::CVectorX yPred(sizePartition_[i] ); //fill the container int index = 1; int index2 = 1; for(int j = 1; j <= n_; j++) { if(partition_[j-1] != i) { yControl[index] = (*p_y_)[j]; XControl.row(index)=p_X_->row(j); index++; } else { yTest[index2] = (*p_y_)[j]; XTest.row(index2)=p_X_->row(j); index2++; } } //run lars on control data set HD::Lars lars(XControl,yControl,maxSteps_,intercept_,eps_); lars.run(); for(int s = 1 ; s <= (int) index_.size(); s++) { //we compute the prediction of the y associated to XTest lars.predict(XTest,index_[s-1], lambdaMode_, yPred); //compute the residuals residuals_(s,i+1) = (yPred-yTest).square().sum()/sizePartition_[i]; } } }//end parallel // compute mean prediction error for each index STK::CVectorX one(k_,1); cv_ = (residuals_ * one) / k_; // compute mean standard deviation of cv_ for each index for(int i = 1; i <= (int) index_.size(); i++) residuals_.row(i) -= cv_[i]; residuals_ = residuals_.square(); cvError_ = (residuals_ * one)/(k_-1)/k_; cvError_ = cvError_.sqrt(); }