int main(int argc, char **argv) { std::cout << "*****************************************************************" << std::endl; std::cout << "main ENTER" << std::endl; { ModelIterator1 mi(2); for (auto it = std::begin(mi); it!=std::end(mi); ++it) { std::cout << "it1" << std::endl; } } { ModelIterator2 mi(4); for (auto it = std::begin(mi); it!=std::end(mi); ++it) { std::cout << "it2" << std::endl; } } { ModelIterator3 mi(6); for (auto it = std::begin(mi); it!=std::end(mi); ++it) { std::cout << "it3 " << it.msg << std::endl; } } { ModelIterator3 mi(6); for (auto it: mi) { std::cout << "it4 " << it.msg << std::endl; } } std::cout << "main LEAVE" << std::endl; return 0; }
Space* RBS::next(void) { if (restart) { restart = false; sslr++; NoGoods& ng = e->nogoods(); // Reset number of no-goods found ng.ng(0); MetaInfo mi(stop->m_stat.restart,sslr,e->statistics().fail,last,ng); bool r = master->master(mi); stop->m_stat.nogood += ng.ng(); if (master->status(stop->m_stat) == SS_FAILED) { stop->update(e->statistics()); delete master; master = NULL; e->reset(NULL); return NULL; } else if (r) { stop->update(e->statistics()); Space* slave = master; master = master->clone(shared_data,shared_info); complete = slave->slave(mi); e->reset(slave); sslr = 0; stop->m_stat.restart++; } } while (true) { Space* n = e->next(); if (n != NULL) { // The engine found a solution restart = true; delete last; last = n->clone(); return n; } else if ( (!complete && !e->stopped()) || (e->stopped() && stop->enginestopped()) ) { // The engine must perform a true restart // The number of the restart has been incremented in the stop object sslr = 0; NoGoods& ng = e->nogoods(); ng.ng(0); MetaInfo mi(stop->m_stat.restart,sslr,e->statistics().fail,last,ng); (void) master->master(mi); stop->m_stat.nogood += ng.ng(); long unsigned int nl = ++(*co); stop->limit(e->statistics(),nl); if (master->status(stop->m_stat) == SS_FAILED) return NULL; Space* slave = master; master = master->clone(shared_data,shared_info); complete = slave->slave(mi); e->reset(slave); } else { return NULL; } } GECODE_NEVER; return NULL; }
int main() { int count; int i; int j; char floatnum[15]; char allpart[15]; char circlepart[15]; int digitalamount; int circle; int iscircle; int up; int down; int simple; scanf("%d", &count); for(i = 0; i < count; i++) { iscircle = 0; digitalamount = 0; circle = 0; scanf("%s", floatnum); for(j = 2; floatnum[j] != '\0'; j++) { if(floatnum[j] == '(' || floatnum[j] == ')') { iscircle = 1; continue; } if(iscircle != 1) { circlepart[circle] = floatnum[j]; circle++; } allpart[digitalamount] = floatnum[j]; digitalamount++; } allpart[digitalamount] = '\0'; circlepart[circle] = '\0'; if(iscircle == 1) { up = atoi(allpart) - atoi(circlepart); down = mi(digitalamount) - mi(circle); simple = gcd(down, up); printf("%d/%d\n", up / simple, down / simple); } else { up = atoi(allpart); down = mi(digitalamount); simple = gcd(down, up); printf("%d/%d\n", up / simple, down / simple); } } return 0; }
TEST_F(MatrixTest, CreateMatrix) { skelcl::Matrix<double> mi( {10,10} ); EXPECT_FALSE(mi.empty()); EXPECT_EQ(100, mi.size().elemCount()); EXPECT_EQ(0, *mi.begin()); for (size_t i = 0; i < 10; ++i) { for (size_t j = 0; j < 10; ++j) { EXPECT_EQ(0.0, mi({i,j})); } } }
// --- bool CBaseInfo::ReInit() { if ( m_curr ) { tDWORD en = DetectEnType( m_curr ); if ( m_en_type == ifAny ) m_en_type = en; else if ( m_en_type != en ) { if ( en == ifAny ) SetDWAttr( VE_PID_NODETYPE, en ); else if ( (en == ifIFace) && (m_en_type != ifPlugin) && (m_en_type != ifMethodParam) && (m_en_type != ifDataStructMember) ) { CFaceInfo ii(m_curr,false); switch( m_en_type ) { case ifType : StartHere(ii.FirstType()); break; case ifConstant : StartHere(ii.FirstConstant()); break; case ifErrCode : StartHere(ii.FirstErrCode()); break; case ifProperty : StartHere(ii.FirstProperty()); break; case ifPubMethod : StartHere(ii.FirstPubMethod()); break; case ifIntMethod : StartHere(ii.FirstIntMethod()); break; case ifDataStruct : StartHere(ii.FirstDataStruct()); break; case ifMsgClass : StartHere(ii.FirstMsgClass()); break; default : StartHere(0); m_en_type = ifAny; return false; } } else if ( (en==ifPubMethod) && (m_en_type==ifMethodParam) ) { CPubMethodInfo mi( m_curr, false ); StartHere( mi.FirstParam() ); } else if ( (en==ifIntMethod) && (m_en_type==ifMethodParam) ) { CIntMethodInfo mi( m_curr, false ); StartHere( mi.FirstParam() ); } else if ( (en==ifDataStruct) && (m_en_type==ifDataStructMember) ) { CDataStructInfo dsi( m_curr, false ); StartHere( dsi.FirstMember() ); } else { m_en_type = ifAny; StartHere( 0 ); } } tDWORD len = Name(0,0); if ( len ) { m_name = new char[len]; Name( m_name, len ); } else m_name = 0; } else m_name = 0; return true; }
void XMLFileScanner::scanInfoSection(std::string& text) { StringTokenizer st(text); std::string delim("\n\r\t "); std::string token; //TODO derzeit wird nur name des moduls eingelesen...müsste aber eigentlich reichen token = st.next(delim); //moduleinfos token = st.next(delim); //first moduleinfo while(token != "/moduleinfos") { if(token != "moduleinfo") throw std::runtime_error("Error in Format in moduleinfo section discovered.."); token = st.next(delim); //module_identifier std::string mi(token.substr(1, token.length()-2)); l.scannedModuleInfo(mi); //notify listener while(token != "/moduleinfo") { token = st.next(delim); if(token == "moduleinfo") throw std::runtime_error("Error in Format in modulinfo section discovered...closing tag missing..."); } token = st.next(delim); //moduleinfo or /moduleinfos } }
void TCartesianClassifier::domainHasChanged() { TEnumVariable *classV = mlnew TEnumVariable("new"); classVar = classV; mults = vector<int>(domain->attributes->size(), 0); TLimitsCounter counter(vector<int>(domain->attributes->size(), 0)); int mult = 1; vector<int>::reverse_iterator li(counter.limits.rbegin()); vector<int>::reverse_iterator mi(mults.rbegin()); for(TVarList::reverse_iterator vi(domain->attributes->rbegin()), ve(domain->attributes->rend()); vi!=ve; vi++) { if ((*vi)->varType!=TValue::INTVAR) raiseError("invalid attribute '%s' (discrete attributes expected)", (*vi)->get_name().c_str()); *li = (*vi)->noOfValues(); if (!*li) raiseError("invalid attribute '%s' (no values)", (*vi)->get_name().c_str()); (*(mi++)) = mult; mult *= *(li++); } counter.reset(); do { string val; TVarList::iterator vi(domain->attributes->begin()); ITERATE(TLimitsCounter, ci, counter) { if (val.length()) val+="_"; val += (*(vi++)).AS(TEnumVariable)->values->at(*ci); } classV->addValue(val); } while (counter.next()); }
ChangeItem(KWidgetList *parent, const QSync::SyncChange &change) : KWidgetListItem(parent), mChange(change) { QGridLayout *layout = new QGridLayout(this, 2, 1, KDialog::marginHint(), KDialog::spacingHint()); MemberInfo mi(change.member()); layout->addWidget(new QLabel(mi.name(), this), 0, 0); QString type; switch(change.changeType()) { case QSync::SyncChange::UnknownChange: type = i18n("Unknown"); break; case QSync::SyncChange::AddedChange: type = i18n("Added"); break; case QSync::SyncChange::DeletedChange: type = i18n("Deleted"); break; case QSync::SyncChange::ModifiedChange: type = i18n("Modified"); break; case QSync::SyncChange::UnmodifiedChange: default: type = i18n("Unmodified"); break; } layout->addWidget(new QLabel(type, this), 1, 0); }
void Network::BindToEvent(behaviac::NetworkRole netRole, const char* eventName, Agent* pAgent, CMethodBase* pMethod) { BEHAVIAC_ASSERT(netRole != NET_ROLE_DEFAULT && !this->IsSinglePlayer()); if (this->ShouldHandle(netRole)) { RemoteEventInstanceMethods_t::iterator it = m_remoteEventInstanceMethods.find(eventName); MethodInstance_t mi(pAgent, pMethod); if (it == m_remoteEventInstanceMethods.end()) { InstanceMethods_t a; a.push_back(mi); m_remoteEventInstanceMethods[eventName] = a; } else { InstanceMethods_t& a = m_remoteEventInstanceMethods[eventName]; a.push_back(mi); } this->SubscribeToRemoteEvent(eventName, pAgent, pMethod); } }
QuickLaunchAction::QuickLaunchAction(const QString & fileName, QWidget * parent) : QAction(parent), m_valid(true) { m_type = ActionFile; setText(fileName); setData(fileName); m_settingsMap["file"] = fileName; QFileInfo fi(fileName); if (fi.isDir()) { QFileIconProvider ip; setIcon(ip.icon(fi)); } else { QMimeDatabase db; XdgMimeType mi(db.mimeTypeForFile(fi)); setIcon(mi.icon()); } connect(this, SIGNAL(triggered()), this, SLOT(execAction())); }
void MainWindow::res() { QString path = QFileDialog::getOpenFileName(this,"Image to make the operation ..","",tr("Images (*.dcm *.pgm)")); if(path==""){ QMessageBox::information(this,"Information","You haven't selected any file image."); } else{ int opt = QInputDialog::getInt(this,"Options\n0. result = x - y\n1.result = |x-y|\n2.result = MAX - |x-y|","Substraction Options"); if(path.contains(".dcm")){ MedicalImages mi(path.toStdString().c_str()); path = path.replace(".dcm",".pgm"); mi.writeToPPM(path.toStdString().c_str()); } P2 res; res.load(path.toStdString().c_str()); image = applyMinus(image,res,opt); setImages(); } }
void InitMenu() { CMenuItem mi(g_plugin); mi.flags = CMIF_UNICODE | CMIF_NOTOFFLINE; mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("News Aggregator"), 500099000); Menu_ConfigureItem(mi.root, MCI_OPT_UID, "D9733E4F-1946-4390-8EB3-591E8687222E"); SET_UID(mi, 0x3ec91864, 0xefa7, 0x4994, 0xb7, 0x75, 0x6c, 0x96, 0xcb, 0x29, 0x2f, 0x93); mi.position = 10100001; if (db_get_b(NULL, MODULENAME, "AutoUpdate", 1)) mi.name.w = LPGENW("Auto Update Enabled"); else mi.name.w = LPGENW("Auto Update Disabled"); mi.hIcolibItem = GetIconHandle("main"); mi.pszService = MS_NEWSAGGREGATOR_ENABLED; hService2[0] = Menu_AddMainMenuItem(&mi); SET_UID(mi, 0x8076bb4d, 0x1e44, 0x43af, 0x97, 0x1e, 0x31, 0xd8, 0xa4, 0xe9, 0xb8, 0x37); mi.position = 20100001; mi.name.w = LPGENW("Check All Feeds"); mi.pszService = MS_NEWSAGGREGATOR_CHECKALLFEEDS; hService2[1] = Menu_AddMainMenuItem(&mi); SET_UID(mi, 0xb876484d, 0x28aa, 0x4e03, 0x9e, 0x98, 0xed, 0xbc, 0xd1, 0xcf, 0x31, 0x80); mi.position = 20100002; mi.hIcolibItem = GetIconHandle("addfeed"); mi.name.w = LPGENW("Add Feed"); mi.pszService = MS_NEWSAGGREGATOR_ADDFEED; hService2[2] = Menu_AddMainMenuItem(&mi); SET_UID(mi, 0x600bf2c2, 0xa974, 0x44d3, 0x98, 0xf9, 0xe6, 0x65, 0x7c, 0x1f, 0x63, 0x37); mi.position = 20100003; mi.hIcolibItem = GetIconHandle("importfeeds"); mi.name.w = LPGENW("Import Feeds"); mi.pszService = MS_NEWSAGGREGATOR_IMPORTFEEDS; hService2[3] = Menu_AddMainMenuItem(&mi); SET_UID(mi, 0xc09c8119, 0x64c2, 0x49bd, 0x81, 0xf, 0x54, 0x20, 0x69, 0xd7, 0x30, 0xcf); mi.position = 20100004; mi.hIcolibItem = GetIconHandle("exportfeeds"); mi.name.w = LPGENW("Export Feeds"); mi.pszService = MS_NEWSAGGREGATOR_EXPORTFEEDS; hService2[4] = Menu_AddMainMenuItem(&mi); // adding contact menu items SET_UID(mi, 0x92be499c, 0x928c, 0x4789, 0x8f, 0x36, 0x28, 0xa2, 0x9f, 0xb7, 0x1a, 0x97); mi.root = nullptr; mi.position = -0x7FFFFFFA; mi.hIcolibItem = GetIconHandle("checkfeed"); mi.name.w = LPGENW("Check feed"); mi.pszService = MS_NEWSAGGREGATOR_CHECKFEED; hService2[5] = Menu_AddContactMenuItem(&mi, MODULENAME); SET_UID(mi, 0x41a70fbc, 0x9241, 0x44c0, 0x90, 0x90, 0x87, 0xd2, 0xc5, 0x9f, 0xc9, 0xac); mi.name.w = LPGENW("Change feed"); mi.pszService = MS_NEWSAGGREGATOR_CHANGEFEED; hService2[6] = Menu_AddContactMenuItem(&mi, MODULENAME); Menu_ModifyItem(hService2[0], nullptr, GetIconHandle(db_get_b(NULL, MODULENAME, "AutoUpdate", 1) ? "enabled" : "disabled")); }
void MainWindow::xorSlot(){ QString path = QFileDialog::getOpenFileName(this,"Image to make the operation ..","",tr("Images (*.dcm *.pgm)")); if(path==""){ QMessageBox::information(this,"Information","You haven't selected any file image."); } else{ if(path.contains(".dcm")){ MedicalImages mi(path.toStdString().c_str()); path = path.replace(".dcm",".pgm"); mi.writeToPPM(path.toStdString().c_str()); } P2 res; res.load(path.toStdString().c_str()); image = applyXor(image,res); setImages(); } }
void addProtoStatusMenuItem(char *protoName) { PROTOACCOUNT *pdescr = Proto_GetAccount(protoName); if (pdescr == nullptr || pdescr->ppro == nullptr) return; HGENMENU hRoot = Menu_GetProtocolRoot(pdescr->ppro); if (hRoot == nullptr) return; char buf[200]; mir_snprintf(buf, "CSList/ShowList/%s", protoName); if (!ServiceExists(buf)) CreateServiceFunctionParam(buf, showList, (LPARAM)protoName); CMenuItem mi(g_plugin); mi.flags = CMIF_UNICODE; mi.hIcolibItem = forms[0].hIcoLibItem; mi.name.w = MODULENAME; mi.position = 2000040000; mi.pszService = buf; mi.root = hRoot; Menu_AddStatusMenuItem(&mi); RegisterHotkeys(buf, pdescr->tszAccountName, pdescr->iOrder); }
inline void ReadDict() { if (Blob_.Size() < sizeof(ui64)) { ythrow yexception() << "too small blob"; } const char* end = (const char*)Blob_.End(); const char* ptr = end - sizeof(ui64); ui64 dictlen = 0; memcpy(&dictlen, ptr, sizeof(ui64)); dictlen = LittleToHost(dictlen); if (dictlen > Blob_.Size() - sizeof(ui64)) { ythrow yexception() << "bad blob"; } const char* beg = ptr - dictlen; TMemoryInput mi(beg, dictlen); TZLibDecompress d((IZeroCopyInput*)&mi); const ui32 count = Load<ui32>(&d); for (size_t i = 0; i < count; ++i) { TArchiveRecordDescriptorRef descr(new TArchiveRecordDescriptor(&d)); Recs_.push_back(descr); Dict_[descr->Name()] = descr; } }
int main() { MemberInitializer mi(2); TraditionalConstructor tc(2); printf("mi.d1: %d\n", mi.d1); printf("tc.d1: %d\n", tc.d1); }
M inverse2x2(const M& m) { // Because then the divisions below would compile but not be correct, we must guard // against integral types. typedef typename M::value_type T; static_assert(!std::is_integral<T>::value, ""); assert(m.numRows() == 2 && m.numCols() == 2); T det = m(0,0)*m(1,1) - m(0,1)*m(1,0); M mi(2, 2, (double*)0); mi(0,0) = m(1,1); mi(1,0) = -m(1,0); mi(0,1) = -m(0,1); mi(1,1) = m(0,0); mi /= det; return mi; }
int main(void) { int n, m; while(scanf("%d%d", &n, &m), n+m) printf("%d\n", mi(n, m)); return 0; }
int main() { MyVector my; //MyVector::MyIterator mi(&my); MyIterator mi(&my); std::cout << mi.getFirst() << std::endl; return 0; }
Hierarchy get_residue(Hierarchy mhd, unsigned int index) { MatchResidueIndex mi(index); Hierarchy hd = core::find_breadth_first(mhd, mi); if (hd == IMP::core::Hierarchy()) { return Hierarchy(); } else { return hd; } }
int numSquares(int n) { vector<int> mi(n + 1, INT_MAX); mi[0] = 0; for(int i = 1; i <= n; i++) for(int j = 1; j * j <= i; j++) if(mi[i] >= mi[i - j * j] + 1) mi[i] = mi[i - j * j] + 1; return mi[n]; }
unique_ptr<RenderableObject> RenderableObject::quad(int startX, int startY, int width, int height, const glm::vec4 &color, GLenum primitive) { glm::vec3 mi(startX, startY, 0.0f); glm::vec3 ma(startX + width, startY + height, 0.0f); vector<glm::vec3> vertices; vector<glm::vec3> normals; vector<glm::vec3> texCoords; float d = 0.1; vertices.push_back(glm::vec3(mi.x, mi.y, d)); vertices.push_back(glm::vec3(mi.x, ma.y, d)); vertices.push_back(glm::vec3(ma.x, ma.y, d)); vertices.push_back(glm::vec3(ma.x, mi.y, d)); normals.push_back(glm::vec3(0.0f, 1.0f, 0.0f)); normals.push_back(glm::vec3(0.0f, 1.0f, 0.0f)); normals.push_back(glm::vec3(0.0f, 1.0f, 0.0f)); normals.push_back(glm::vec3(0.0f, 1.0f, 0.0f)); texCoords.push_back(glm::vec3(0.0f, 0.0f, 0.0f)); texCoords.push_back(glm::vec3(0.0f, 1.0f, 0.0f)); texCoords.push_back(glm::vec3(1.0f, 1.0f, 0.0f)); texCoords.push_back(glm::vec3(1.0f, 0.0f, 0.0f)); // Indices vector<GLuint> indices ={ 0, 1, 2, 0, 2, 3 }; uint nrVertices = vertices.size(); vector<RenderableObject::Vertex> attrData(nrVertices); for(uint i=0; i<nrVertices; ++i) { glm::vec3 v = vertices[i]; glm::vec3 n = normals[i]; glm::vec3 t = texCoords[i]; attrData[i].Position = v; attrData[i].Normal = n; attrData[i].Color = color; attrData[i].TexCoords = glm::vec4(t.x, t.y, 0.0f, 0.0f); } unique_ptr<RenderableObject> vbo(new RenderableObject); vbo->setData(attrData, indices, primitive); return vbo; }
ostream &operator<<(ostream& os, const Map<S,T>& m) { Mapiter<S,T> mi(m); os << '{'; while (++mi) { os << "[ " << mi.curr()->key << ' ' << mi.curr()->value << " ]"; } os << '}'; return os; }
void WebBridgeRS::broadcastMessage(QString msg) { QMapIterator<QString, QString> mi(p3service->compatablePeers); //std::cout << "boardcasting\n"; while ( mi.hasNext() ) { mi.next(); //std::cout << "to: " << mi.key().toStdString() << std::endl; //qDebug() << mi.key() << ":" << mi.value().surname() << mi.value().forename(); p3service->msgPeer(mi.key().toStdString(),msg.toStdString()); } }
TValue TCartesianClassifier::operator ()(const TExample &ex) { TExample example(domain, ex); TValue res(int(0)); vector<int>::iterator mi(mults.begin()); ITERATE(TExample, ei, example) if ((*ei).isSpecial()) return classVar->DK(); else res.intV+=(*(mi++))*(*ei).intV; return res; }
QVariantMap WebBridgeRS::getPeers() { QVariantMap qm; QMapIterator<QString, QString> mi(p3service->compatablePeers); while ( mi.hasNext() ) { mi.next(); qm.insert(mi.key(),mi.value()); } //QVariantMap qm = p3service->compatablePeers; return qm; }
void InitMainMenuItem() { CMenuItem mi(g_plugin); SET_UID(mi, 0x22b7b4db, 0xa9a1, 0x4d43, 0x88, 0x80, 0x4c, 0x23, 0x20, 0x31, 0xc6, 0xa0); mi.flags = CMIF_UNICODE; if (ServiceExists(MS_POPUP_ADDPOPUPT)) mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0); mi.pszService = MS_STATUSCHANGE_MENUCOMMAND; hEnableDisableMenu = Menu_AddMainMenuItem(&mi); opt.TempDisabled = !opt.TempDisabled; EnableDisableMenuCommand(0, 0); }
M inverse3x3(const M& m) { // Because then the divisions below would compile but not be correct, we must guard // against integral types. typedef typename M::value_type T; static_assert(!std::is_integral<T>::value, ""); assert(m.numRows() == 3 && m.numCols() == 3); // double det = m(0,0)*(m(1,1)*m(2,2)-m(1,2)*m(2,1)) // - m(0,1)*(m(1,0)*m(2,2)-m(1,2)*m(2,0)) // + m(0,2)*(m(1,0)*m(2,1)-m(1,1)*m(2,0)); T a = m(0,0); T b = m(0,1); T c = m(0,2); T d = m(1,0); T e = m(1,1); T f = m(1,2); T g = m(2,0); T h = m(2,1); T i = m(2,2); T t1 = (e-f*h/i); T t2 = (c*h/i-b); T t3 = (f*g/i-d); T t4 = (a-c*g/i); T x = t4*t1-t2*t3; M mi(3, 3, (double*)0); mi(0,0) = t1/x; mi(0,1) = t2/x; mi(0,2) = -(c*t1+f*t2)/(i*x); mi(1,0) = t3/x; mi(1,1) = t4/x; mi(1,2) = -(c*t3+f*t4)/(i*x); mi(2,0) = -(g*t1+h*t3)/(i*x); mi(2,1) = -(g*t2+h*t4)/(i*x); mi(2,2) = 1/i+1/(i*i*x)*(c*(g*t1+h*t3)+f*(g*t2+h*t4)); return mi; }
void read_genome_matrix(char matrix_file[30],int k,int m){ char strarray[500]; float c; int count=0; int z=mi(4,k); int name_num=0; int counts_num=0; FILE *fp; classify_name=(char **)malloc((m+1)*1000*sizeof(char*)); counts=(float *)malloc((m+1)*(z+2)*sizeof(float)); fp=fopen(matrix_file,"r"); if(fp==NULL){ fprintf(stderr,"matrix_file cannot be opened!\n"); }else{ while(!feof(fp)){ count=count+1; if(count==name_num*(z+1)+1 && name_num<m){ classify_name[name_num]=(char *)malloc(1000*sizeof(char)); fscanf(fp,"%s",classify_name[name_num]); #ifdef TEST printf("now:%s\n",classify_name[name_num]); if(name_num>1){ printf("last:%d,%s\n",name_num,classify_name[0]); } #endif name_num++; } else{ fscanf(fp,"%s",strarray); c=atof(strarray); counts[counts_num]=c; //printf("%d--%.4f\n",counts_num,counts[counts_num]); counts_num++; } } fclose(fp); #ifdef TEST printf("%s\n",classify_name[0]); printf("%s\n",classify_name[1]); printf("%s\n",classify_name[2]); printf("%.4f\n",counts[0]); printf("%.4f\n",counts[1]); printf("%.4f\n",counts[2]); #endif } }
/** * @brief Return molt increment matrix based on empirical data * @details Fit's a cubic spline to the empirical data. * Note that the spline function strictly requires increasing * values for each of the knots. * * @param data [description] * @return dmatrix of molt increments by sex for each size bin */ dmatrix get_empirical_molt_increment(const dvector& bin, const dmatrix& data) { cout<<"In get_empirical_molt_increment"<<endl; int n = bin.size(); ivector sex = ivector(column(data,2)); int nsex = count_factor(sex); dmatrix mi(1,nsex,1,n); ivector nh(1,nsex); nh.initialize(); // Count number of observations in each sex. for (int i = 1; i <= data.rowmax(); ++i) { int h = sex(i); nh(h) ++; } // get male and famale arrays dmatrix x(1,nsex,1,nh); dmatrix y(1,nsex,1,nh); int bb=1; int gg=1; for (int i = 1; i <= data.rowmax(); ++i) { int h = sex(i); int j = h==1 ? bb++ : gg++ ; x(h,j) = data(i,1); y(h,j) = data(i,3); } // rescale size to 0-1 over bin width for (int h = 1; h <= nsex; ++h) { dvector knts = (x(h) - min(x(h))) / (max(x(h)) - min(x(h))); dvector pnts = (bin - min(bin)) / (max(bin) - min(bin)); COUT(knts); COUT(y(h)); cubic_spline_function cSmooth(knts,y(h)); dvector test = cSmooth(pnts); COUT(cSmooth(0.5)); COUT(test); } cout<<"leaving get_empirical_molt_increment"<<endl; return mi; }