void PlayerOptions::Init() { m_bSetScrollSpeed = false; m_fMaxScrollBPM = 0; m_SpeedfMaxScrollBPM = 1.0f; m_fTimeSpacing = 0; m_SpeedfTimeSpacing = 1.0f; m_fScrollSpeed = 1.0f; m_SpeedfScrollSpeed = 1.0f; m_fScrollBPM = CMOD_DEFAULT; m_SpeedfScrollBPM = 1.0f; ZERO( m_fAccels ); ONE( m_SpeedfAccels ); ZERO( m_fEffects ); ONE( m_SpeedfEffects ); ZERO( m_fAppearances ); ONE( m_SpeedfAppearances ); ZERO( m_fScrolls ); ONE( m_SpeedfScrolls ); m_fDark = 0; m_SpeedfDark = 1.0f; m_fBlind = 0; m_SpeedfBlind = 1.0f; m_fCover = 0; m_SpeedfCover = 1.0f; m_fRandAttack = 0; m_SpeedfRandAttack = 1.0f; m_fNoAttack = 0; m_SpeedfNoAttack = 1.0f; m_fPlayerAutoPlay = 0; m_SpeedfPlayerAutoPlay = 1.0f; m_fPerspectiveTilt = 0; m_SpeedfPerspectiveTilt = 1.0f; m_fSkew = 0; m_SpeedfSkew = 1.0f; m_fPassmark = 0; m_SpeedfPassmark = 1.0f; m_fRandomSpeed = 0; m_SpeedfRandomSpeed = 1.0f; ZERO( m_bTurns ); ZERO( m_bTransforms ); m_bMuteOnError = false; m_FailType = FailType_Immediate; m_sNoteSkin = ""; }
uint8_t manchester_send_no_crc_calc(data_t* data) { ZERO(); del_us(25.0-0.125); ONE(); del_us(25.0-0.125-0.625); for(uint8_t i = 32; i > 0; --i) { if((*data).a & 0b10000000) { ZERO(); del_us(25-0.125); ONE(); } else { ONE(); del_us(25-0.125); ZERO(); } del_us(25-0.125-2.5-0.500); (*data).abcd = (*data).abcd << 1; // 20 cycles = 2.5 us } ONE(); return COMM_SUCCESS; }
void PlayerOptions::Init() { m_LifeType = LifeType_Bar; m_DrainType = DrainType_Normal; m_BatteryLives = 4; m_MinTNSToHideNotes= PREFSMAN->m_MinTNSToHideNotes; m_bSetScrollSpeed = false; m_fMaxScrollBPM = 0; m_SpeedfMaxScrollBPM = 1.0f; m_fTimeSpacing = 0; m_SpeedfTimeSpacing = 1.0f; m_fScrollSpeed = 1.0f; m_SpeedfScrollSpeed = 1.0f; m_fScrollBPM = CMOD_DEFAULT; m_SpeedfScrollBPM = 1.0f; ZERO( m_fAccels ); ONE( m_SpeedfAccels ); ZERO( m_fEffects ); ONE( m_SpeedfEffects ); ZERO( m_fAppearances ); ONE( m_SpeedfAppearances ); ZERO( m_fScrolls ); ONE( m_SpeedfScrolls ); m_fDark = 0; m_SpeedfDark = 1.0f; m_fBlind = 0; m_SpeedfBlind = 1.0f; m_fCover = 0; m_SpeedfCover = 1.0f; m_fRandAttack = 0; m_SpeedfRandAttack = 1.0f; m_fNoAttack = 0; m_SpeedfNoAttack = 1.0f; m_fPlayerAutoPlay = 0; m_SpeedfPlayerAutoPlay = 1.0f; m_fPerspectiveTilt = 0; m_SpeedfPerspectiveTilt = 1.0f; m_fSkew = 0; m_SpeedfSkew = 1.0f; m_fPassmark = 0; m_SpeedfPassmark = 1.0f; m_fRandomSpeed = 0; m_SpeedfRandomSpeed = 1.0f; ZERO( m_bTurns ); ZERO( m_bTransforms ); m_bMuteOnError = false; m_sNoteSkin = ""; }
uint8_t manchester_send(data_t* data) { (*data).d = CRC_INITIAL_REMAINDER; ZERO(); // Calculate CRC here in parts. This should be well timed. (*data).d ^= (*data).a; // 3 cycles CALC_CRC((*data).d); // Grand total 48+24+3 = 75 cycles = 9.375 us. (*data).d ^= (*data).b; // 3 cycles CALC_CRC((*data).d); // Grand total 48+24+3 = 75 cycles = 9.375 us. del_us(25 - 9.375 - 9.375 - 0.250); ONE(); (*data).d ^= (*data).c; // 3 cycles CALC_CRC((*data).d); // Grand total 48+24+3 = 75 cycles = 9.375 us. del_us(25 - 9.375 - 0.250); for(uint8_t i = 32; i > 0; --i) { if((*data).a & 0b10000000) { ZERO(); del_us(25-0.125); ONE(); } else { ONE(); del_us(25-0.125); ZERO(); } del_us(25-0.125-2.5-0.250); (*data).abcd = (*data).abcd << 1; } ONE(); return COMM_SUCCESS; }
//each vtree node is associated with a set of litsets (clauses or terms) //the totality of these litsets represent an fnf (cnf or dnf) //returns an sdd which is equivalent to the cnf/dnf associated with vtree SddNode* apply_vtree_manual(Vtree* vtree, BoolOp op, SddManager* manager) { SddNode* base; if(sdd_vtree_is_leaf(vtree)) base = ONE(manager,op); else { SddNode* l_node = apply_vtree_manual(sdd_vtree_left(vtree),op,manager); SddNode* r_node = apply_vtree_manual(sdd_vtree_right(vtree),op,manager); base = sdd_apply_in_vtree(l_node,r_node,op,vtree,manager); } SddSize litset_count = DATA(vtree,litset_count); if(litset_count==0) return base; //no clauses/terms stored at vtree node //apply litsets may change root of vtree due to vtree search Vtree** vtree_loc = sdd_vtree_location(vtree,manager); SddNode* node = apply_litsets_manual(base,op,vtree,manager); vtree = *vtree_loc; //root may have changed SddManagerOptions* options = sdd_manager_options(manager); if(options->vtree_search_mode==2) { sdd_ref(node,manager); //to SWITCH-TO-LIBRARY-SEARCH, comment in the next line, comment out the one after vtree_search(vtree,manager); // sdd_vtree_minimize(vtree,manager); //library's version of vtree search algorithm sdd_deref(node,manager); } return node; }
//each vtree node is associated with a set of litsets (clauses or terms) //the totality of these litsets represent an fnf (cnf or dnf) //returns an sdd which is equivalent to the cnf/dnf associated with vtree SddNode* apply_vtree_auto(Vtree* vtree, BoolOp op, SddManager* manager) { //get litsets associated with vtree node //do this first as vtree root may be changed by dynamic vtree search LitSet** litsets = DATA(vtree,litsets); SddSize litset_count = DATA(vtree,litset_count); sort_litsets_by_lca(litsets,litset_count,manager); SddNode* node; if(sdd_vtree_is_leaf(vtree)) node = ONE(manager,op); else { SddNode* l_node = apply_vtree_auto(sdd_vtree_left(vtree),op,manager); sdd_ref(l_node,manager); SddNode* r_node = apply_vtree_auto(sdd_vtree_right(vtree),op,manager); sdd_deref(l_node,manager); node = sdd_apply(l_node,r_node,op,manager); } while(litset_count--) { //compile and integrate litset sdd_ref(node,manager); SddNode* litset = apply_litset_auto(*litsets++,manager); //may gc node sdd_deref(node,manager); node = sdd_apply(litset,node,op,manager); //recompute lcas of remaining clauses and sort again sort_litsets_by_lca(litsets,litset_count,manager); } return node; }
void frameFieldBackgroundMesh2D::reset(bool erase_2D3D) { // computes cross field simpleFunction<double> ONE(1.0); computeCrossField(ONE); computeSmoothness(); // evalDiffusivityFunction eval_diff(this); // exportSmoothness("smoothness_iter_0.pos"); // for (int i=1;i<30;i++){ // computeCrossField(eval_diff); // computeSmoothness(); // // stringstream ss; // ss << "smoothness_iter_" << i << ".pos"; // exportSmoothness(ss.str()); // // stringstream sscf; // sscf << "crossfield_iter_" << i << ".pos"; // exportCrossField(sscf.str()); // } if (erase_2D3D) { _3Dto2D.clear(); _2Dto3D.clear(); } }
//converts a clause/term into an equivalent sdd //all variables of litset must appear in vtree SddNode* apply_litset_manual(LitSet* litset, Vtree* vtree, SddManager* manager) { BoolOp op = litset->op; //conjoin (term) or disjoin (clause) SddLiteral* literals = litset->literals; SddNode* node = ONE(manager,op); for(SddLiteral i=0; i<litset->literal_count; i++) { SddNode* literal = sdd_manager_literal(literals[i],manager); node = sdd_apply_in_vtree(node,literal,op,vtree,manager); } return node; }
//converts a clause/term into an equivalent sdd SddNode* apply_litset_auto(LitSet* litset, SddManager* manager) { BoolOp op = litset->op; //conjoin (term) or disjoin (clause) SddLiteral* literals = litset->literals; SddNode* node = ONE(manager,op); //will not be gc'd for(SddLiteral i=0; i<litset->literal_count; i++) { SddNode* literal = sdd_manager_literal(literals[i],manager); node = sdd_apply(node,literal,op,manager); } return node; }
Polynomial spolynomial(const SPI & spi,const FactBase & fc,TimingRecorder * timers) { if(timers) { timers->start(s_spolynomialsTiming); }; const GroebnerRule & first = fc.rule(spi.leftID()); const GroebnerRule & second = fc.rule(spi.rightID()); Monomial tip1(first.LHS()); Monomial tip2(second.LHS()); Monomial right1, left2, one; int len1 = spi.overlapLength(); MonomialIterator w1 = tip2.begin(); for(int k=1;k<=len1;++k) { ++w1;}; int max1 = tip2.numberOfFactors()-1; // The following line is for a faster run-time. right1.reserve(max1-len1+1); for(int i=len1;i<=max1;++i,++w1) { right1 *= (*w1); } MonomialIterator w2 = tip1.begin(); int max2 = tip1.numberOfFactors() - len1; // The following line is for a faster run-time. left2.reserve(max2); for(i=0;i< max2;++i,++w2) { left2 *= (*w2); } Term ONE(one); #if 0 Monomial check1(tip1); check1 *= right1; Monomial check2(left2); check2 *= tip1; if(check1!=check2) { DBG(); }; #endif Polynomial result1(first.RHS()); Polynomial result2(second.RHS()); result1 *= Term(right1); result2.premultiply(Term(left2)); result1 -= result2; if(timers) { timers->printpause("spolynomial Timing:",s_spolynomialsTiming); }; return result1; };
void backgroundMesh2D::computeSizeField() { GFace *face = dynamic_cast<GFace*>(gf); if(!face) { Msg::Error("Entity is not a face in background mesh"); return; } list<GEdge*> e; replaceMeshCompound(face, e); list<GEdge*>::const_iterator it = e.begin(); DoubleStorageType sizes; for( ; it != e.end(); ++it ) { if (!(*it)->isSeam(face)) { for(unsigned int i = 0; i < (*it)->lines.size(); i++ ) { MVertex *v1 = (*it)->lines[i]->getVertex(0); MVertex *v2 = (*it)->lines[i]->getVertex(1); if (v1 != v2) { double d = sqrt((v1->x() - v2->x()) * (v1->x() - v2->x()) + (v1->y() - v2->y()) * (v1->y() - v2->y()) + (v1->z() - v2->z()) * (v1->z() -v2->z())); for (int k=0; k<2; k++) { MVertex *v = (*it)->lines[i]->getVertex(k); DoubleStorageType::iterator itv = sizes.find(v); if (itv == sizes.end()) sizes[v] = log(d); else itv->second = 0.5 * (itv->second + log(d)); } } } } } simpleFunction<double> ONE(1.0); propagateValues(sizes,ONE); std::map<MVertex*,MVertex*>::iterator itv2 = _2Dto3D.begin(); for ( ; itv2 != _2Dto3D.end(); ++itv2) { MVertex *v_2D = itv2->first; MVertex *v_3D = itv2->second; sizeField[v_2D] = exp(sizes[v_3D]); } }
PView *GMSH_DistancePlugin::execute(PView *v) { int id_pt = (int) DistanceOptions_Number[0].def; int id_line = (int) DistanceOptions_Number[1].def; int id_face = (int) DistanceOptions_Number[2].def; double type = (double) DistanceOptions_Number[3].def; int ortho = (int) DistanceOptions_Number[6].def; PView *view = new PView(); _data = getDataList(view); #if defined(HAVE_SOLVER) #if defined(HAVE_TAUCS) linearSystemCSRTaucs<double> *lsys = new linearSystemCSRTaucs<double>; #else linearSystemCSRGmm<double> *lsys = new linearSystemCSRGmm<double>; lsys->setNoisy(1); lsys->setGmres(1); lsys->setPrec(5.e-8); #endif dofManager<double> * dofView = new dofManager<double>(lsys); #endif std::vector<GEntity*> _entities; GModel::current()->getEntities(_entities); if (!_entities.size() || !_entities[_entities.size()-1]->getMeshElement(0)) { Msg::Error("This plugin needs a mesh !"); return view; } GEntity* ge = _entities[_entities.size()-1]; int integrationPointTetra[2] = {0,0}; int numnodes = 0; for (unsigned int i = 0; i < _entities.size()-1; i++) numnodes += _entities[i]->mesh_vertices.size(); int totNodes = numnodes + _entities[_entities.size()-1]->mesh_vertices.size(); int order = ge->getMeshElement(0)->getPolynomialOrder(); int totNumNodes = totNodes + ge->getNumMeshElements()*integrationPointTetra[order-1]; std::vector<SPoint3> pts; std::vector<double> distances; std::vector<MVertex* > pt2Vertex; pts.clear(); distances.clear(); pt2Vertex.clear(); pts.reserve(totNumNodes); distances.reserve(totNumNodes); pt2Vertex.reserve(totNumNodes); std::map<MVertex*,double> _distanceE_map; std::map<MVertex*,int> _isInYarn_map; std::vector<int> index; std::vector<double> distancesE; std::vector<double> distances2; std::vector<double> distancesE2; std::vector<int> isInYarn; std::vector<int> isInYarn2; std::vector<SPoint3> closePts; std::vector<SPoint3> closePts2; for (int i=0; i<totNumNodes; i++) { distances.push_back(1.e22); } int k = 0; for (unsigned int i=0; i<_entities.size(); i++){ GEntity* ge = _entities[i]; _maxDim = std::max(_maxDim, ge->dim()); for (unsigned int j=0; j<ge->mesh_vertices.size(); j++) { MVertex *v = ge->mesh_vertices[j]; pts.push_back(SPoint3(v->x(), v->y(), v->z())); _distance_map.insert(std::make_pair(v, 0.0)); /* TO DO (by AM) SPoint3 p_empty(); _closePts_map.insert(std::make_pair(v, p_empty)); */ pt2Vertex[k] = v; k++; } } // Compute geometrical distance to mesh boundaries //------------------------------------------------------ if (type < 0.0 ) { bool existEntity = false; for (unsigned int i=0; i<_entities.size(); i++) { GEntity* g2 = _entities[i]; int gDim = g2->dim(); std::vector<int> phys = g2->getPhysicalEntities(); bool computeForEntity = false; for(unsigned int k = 0; k<phys.size(); k++) { int tagp = phys[k]; if (id_pt == 0 && id_line == 0 && id_face == 0 && gDim == _maxDim - 1) computeForEntity = true; else if ((tagp == id_pt && gDim == 0) || (tagp == id_line && gDim == 1) || (tagp == id_face && gDim == 2)) computeForEntity = true; } if (computeForEntity) { existEntity = true; for (unsigned int k = 0; k < g2->getNumMeshElements(); k++) { std::vector<double> iDistances; std::vector<SPoint3> iClosePts; std::vector<double> iDistancesE; std::vector<int> iIsInYarn; MElement *e = g2->getMeshElement(k); MVertex *v1 = e->getVertex(0); MVertex *v2 = e->getVertex(1); SPoint3 p1(v1->x(), v1->y(), v1->z()); SPoint3 p2(v2->x(), v2->y(), v2->z()); if ((e->getNumVertices() == 2 && order == 1) || (e->getNumVertices() == 3 && order == 2)) { signedDistancesPointsLine(iDistances, iClosePts, pts, p1, p2); } else if ((e->getNumVertices() == 3 && order == 1) || (e->getNumVertices() == 6 && order == 2)) { MVertex *v3 = e->getVertex(2); SPoint3 p3 (v3->x(),v3->y(),v3->z()); signedDistancesPointsTriangle(iDistances, iClosePts, pts, p1, p2, p3); } for (unsigned int kk=0; kk<pts.size(); kk++) { if (std::abs(iDistances[kk]) < distances[kk]) { distances[kk] = std::abs(iDistances[kk]); MVertex *v = pt2Vertex[kk]; _distance_map[v] = distances[kk]; /* TO DO (by AM) _closePts_map[v] = iClosePts[kk]; */ } } } } } if (!existEntity){ if (id_pt != 0) Msg::Error("The Physical Point does not exist !"); if (id_line != 0) Msg::Error("The Physical Line does not exist !"); if (id_face != 0) Msg::Error("The Physical Surface does not exist !"); return view; } printView(_entities, _distance_map); /* TO DO (by AM) printView(_entities, _closePts_map); */ } // Compute PDE for distance function //----------------------------------- else if (type > 0.0) { #if defined(HAVE_SOLVER) bool existEntity = false; SBoundingBox3d bbox; for(unsigned int i = 0; i < _entities.size(); i++){ GEntity* ge = _entities[i]; int gDim = ge->dim(); bool fixForEntity = false; std::vector<int> phys = ge->getPhysicalEntities(); for(unsigned int k = 0; k < phys.size(); k++) { int tagp = phys[k]; if (id_pt == 0 && id_line == 0 && id_face == 0 && gDim == _maxDim - 1) fixForEntity = true; else if ((tagp == id_pt && gDim == 0) || (tagp == id_line && gDim == 1) || (tagp == id_face && gDim == 2) ) fixForEntity = true; } if (fixForEntity) { existEntity = true; for (unsigned int i = 0; i < ge->getNumMeshElements(); ++i) { MElement *t = ge->getMeshElement(i); for (int k=0; k<t->getNumVertices(); k++) { MVertex *v = t->getVertex(k); dofView->fixVertex(v, 0, 1, 0.); bbox += SPoint3(v->x(), v->y(), v->z()); } } } } if (!existEntity){ if (id_pt != 0) Msg::Error("The Physical Point does not exist !"); if (id_line != 0) Msg::Error("The Physical Line does not exist !"); if (id_face != 0) Msg::Error("The Physical Surface does not exist !"); return view; } std::vector<MElement *> allElems; for(unsigned int ii = 0; ii < _entities.size(); ii++){ if(_entities[ii]->dim() == _maxDim) { GEntity *ge = _entities[ii]; for(unsigned int i = 0; i < ge->getNumMeshElements(); ++i) { MElement *t = ge->getMeshElement(i); allElems.push_back(t); for (int k = 0; k < t->getNumVertices(); k++) dofView->numberVertex(t->getVertex(k), 0, 1); } } } double L = norm(SVector3(bbox.max(), bbox.min())); double mu = type*L; simpleFunction<double> DIFF(mu*mu), ONE(1.0); distanceTerm distance(GModel::current(), 1, &DIFF, &ONE); for (std::vector<MElement* >::iterator it = allElems.begin(); it != allElems.end(); it++){ SElement se((*it)); distance.addToMatrix(*dofView, &se); } groupOfElements gr(allElems); distance.addToRightHandSide(*dofView, gr); Msg::Info("Distance Computation: Assembly done"); lsys->systemSolve(); Msg::Info("Distance Computation: System solved"); for (std::map<MVertex*,double >::iterator itv = _distance_map.begin(); itv != _distance_map.end() ; ++itv) { MVertex *v = itv->first; double value; dofView->getDofValue(v, 0, 1, value); value = std::min(0.9999, value); double dist = -mu * log(1. - value); itv->second = dist; } printView(_entities, _distance_map); #endif } _data->setName("distance"); _data->Time.push_back(0); _data->setFileName(_fileName.c_str()); _data->finalize(); // compute also orthogonal vector to distance field // A Uortho = -C DIST //------------------------------------------------ if (ortho > 0) { #if defined(HAVE_SOLVER) #ifdef HAVE_TAUCS linearSystemCSRTaucs<double> *lsys2 = new linearSystemCSRTaucs<double>; #else linearSystemCSRGmm<double> *lsys2 = new linearSystemCSRGmm<double>; lsys->setNoisy(1); lsys->setGmres(1); lsys->setPrec(5.e-8); #endif dofManager<double> myAssembler(lsys2); simpleFunction<double> ONE(1.0); double dMax = 1.0; //EMI TO CHANGE std::vector<MElement *> allElems; for(unsigned int ii = 0; ii < _entities.size(); ii++){ if (_entities[ii]->dim() == _maxDim) { GEntity *ge = _entities[ii]; for (unsigned int i=0; i<ge->getNumMeshElements(); ++i) { MElement *t = ge->getMeshElement(i); double vMean = 0.0; for (int k = 0; k < t->getNumVertices(); k++) { std::map<MVertex*, double>::iterator it = _distance_map.find(t->getVertex(k)); vMean += it->second; } vMean /= t->getNumVertices(); if (vMean < dMax) allElems.push_back(ge->getMeshElement(i)); } } } int mid = (int)floor(allElems.size() / 2.); MElement *e = allElems[mid]; MVertex *vFIX = e->getVertex(0); myAssembler.fixVertex(vFIX, 0, 1, 0.0); for (std::vector<MElement* >::iterator it = allElems.begin(); it != allElems.end(); it++){ MElement *t = *it; for(int k = 0; k < t->getNumVertices(); k++) myAssembler.numberVertex(t->getVertex(k), 0, 1); } orthogonalTerm *ortho; ortho = new orthogonalTerm(GModel::current(), 1, &ONE, &_distance_map); // if (type < 0) // ortho = new orthogonalTerm(GModel::current(), 1, &ONE, view); // else // ortho = new orthogonalTerm(GModel::current(), 1, &ONE, dofView); for (std::vector<MElement* >::iterator it = allElems.begin(); it != allElems.end(); it++){ SElement se((*it)); ortho->addToMatrix(myAssembler, &se); } groupOfElements gr(allElems); ortho->addToRightHandSide(myAssembler, gr); Msg::Info("Orthogonal Computation: Assembly done"); lsys2->systemSolve(); Msg::Info("Orthogonal Computation: System solved"); PView *view2 = new PView(); PViewDataList *data2 = getDataList(view2); data2->setName("ortogonal field"); Msg::Info("Writing orthogonal.pos"); FILE * f5 = Fopen("orthogonal.pos","w"); fprintf(f5,"View \"orthogonal\"{\n"); for (std::vector<MElement* >::iterator it = allElems.begin(); it != allElems.end(); it++){ MElement *e = *it; int numNodes = e->getNumVertices(); if (e->getType() == TYPE_POLYG) numNodes = e->getNumChildren() * e->getChild(0)->getNumVertices(); std::vector<double> x(numNodes), y(numNodes), z(numNodes); std::vector<double> *out2 = data2->incrementList(1, e->getType(), numNodes); std::vector<MVertex*> nods; std::vector<double> orth; if(!e->getNumChildren()) for(int i=0; i<numNodes; i++) nods.push_back(e->getVertex(i)); else for(int i = 0; i < e->getNumChildren(); i++) for(int j = 0; j < e->getChild(i)->getNumVertices(); j++) nods.push_back(e->getChild(i)->getVertex(j)); for(int nod = 0; nod < numNodes; nod++) out2->push_back((nods[nod])->x()); for(int nod = 0; nod < numNodes; nod++) out2->push_back((nods[nod])->y()); for(int nod = 0; nod < numNodes; nod++) out2->push_back((nods[nod])->z()); if (_maxDim == 2) switch (numNodes) { case 2: fprintf(f5,"SL("); break; case 3: fprintf(f5,"ST("); break; case 4: fprintf(f5,"SQ("); break; default: Msg::Fatal("Error in Plugin 'Distance' (numNodes=%g).",numNodes); break; } else if (_maxDim == 3) switch (numNodes) { case 4: fprintf(f5,"SS("); break; case 8: fprintf(f5,"SH("); break; case 6: fprintf(f5,"SI("); break; case 5: fprintf(f5,"SY("); break; default: Msg::Fatal("Error in Plugin 'Distance' (numNodes=%g).",numNodes); break; } for (int j=0; j<numNodes; j++) { MVertex *v = nods[j]; if (j) fprintf(f5, ",%g,%g,%g", v->x(), v->y(), v->z()); else fprintf(f5, "%g,%g,%g", v->x(), v->y(), v->z()); double value; myAssembler.getDofValue(v, 0, 1, value); orth.push_back(value); } fprintf(f5,"){"); for (unsigned int i=0; i<orth.size(); i++) { out2->push_back(orth[i]); if (i) fprintf(f5,",%g", orth[i]); else fprintf(f5,"%g", orth[i]); } fprintf(f5,"};\n"); } fprintf(f5,"};\n"); fclose(f5); lsys->clear(); lsys2->clear(); data2->Time.push_back(0); data2->setFileName("orthogonal.pos"); data2->finalize(); #endif } return view; }
bool SymbolicList::getType(GVN & gvn, TIType & type) const { double dstart, dstep, dend; bool known = false; if (symbolic) { const MultivariatePolynomial & mpStart = *start.gvnVal->poly; const MultivariatePolynomial & mpStep = *step.gvnVal->poly; const MultivariatePolynomial & mpEnd = *end.gvnVal->poly; if (mpStart.isConstant() && mpStep.isConstant() && mpEnd.isConstant()) { dstart = mpStart.constant; dstep = mpStep.constant; dend = mpEnd.constant; known = true; } } else { dstart = start.dval; dstep = step.dval; dend = end.dval; known = true; } if (known) { double out; int _type = ForList64::checkList(dstart, dend, dstep, out); switch (_type) { case 0: type = TIType(gvn, TIType::EMPTY); return true; case 1: type = TIType(gvn, TIType::DOUBLE); return true; case 2: { const uint64_t N = ForList64::size(dstart, dend, dstep); type = TIType(gvn, TIType::DOUBLE, 1, N); return true; } default: return false; } } GVN::Value * gvnStart = start.gvnVal, * gvnStep = step.gvnVal, * gvnEnd = end.gvnVal; if (!gvnStep->poly->isConstant()) { return false; } dstep = gvnStep->poly->constant; if (dstep == 0) { type = TIType(gvn, TIType::EMPTY); return true; } if (dstep != -1 && dstep != 1) { // TODO : we must be able to handle general step (even if -1 or 1 seem to be the most frequent values) // but it implies that we need a symbolic division on polynomials. return false; } GVN::Value * ONEValue = gvn.getValue(1.); SymbolicDimension ONE(gvn, ONEValue); if (gvnStart->value == gvnEnd->value) { type = TIType(gvn, TIType::DOUBLE, ONE, ONE); return true; } GVN::Value * v; if (dstep == 1) { v = gvn.getValue(OpValue::Kind::MINUS, *gvnEnd, *gvnStart); } else { v = gvn.getValue(OpValue::Kind::MINUS, *gvnStart, *gvnEnd); } v = gvn.getValue(OpValue::Kind::PLUS, *v, *ONEValue); if (v->poly->constant < 0 && v->poly->isCoeffNegative(false)) { type = TIType(gvn, TIType::EMPTY); return true; } type = TIType(gvn, TIType::DOUBLE, ONE, SymbolicDimension(gvn, v)); return true; }
void tst_QTabBar::selectionBehaviorOnRemove_data() { QTest::addColumn<QTabBar::SelectionBehavior>("selectionBehavior"); QTest::addColumn<int>("tabs"); QTest::addColumn<IntList>("select"); QTest::addColumn<IntList>("remove"); QTest::addColumn<int>("expected"); // Count select remove current QTest::newRow("left-1") << QTabBar::SelectLeftTab << 3 << (IntList() << 0) << ONE(0) << 0; QTest::newRow("left-2") << QTabBar::SelectLeftTab << 3 << (IntList() << 0) << ONE(1) << 0; // not removing current QTest::newRow("left-3") << QTabBar::SelectLeftTab << 3 << (IntList() << 0) << ONE(2) << 0; // not removing current QTest::newRow("left-4") << QTabBar::SelectLeftTab << 3 << (IntList() << 1) << ONE(0) << 0; // not removing current QTest::newRow("left-5") << QTabBar::SelectLeftTab << 3 << (IntList() << 1) << ONE(1) << 0; QTest::newRow("left-6") << QTabBar::SelectLeftTab << 3 << (IntList() << 1) << ONE(2) << 1; QTest::newRow("left-7") << QTabBar::SelectLeftTab << 3 << (IntList() << 2) << ONE(0) << 1; // not removing current QTest::newRow("left-8") << QTabBar::SelectLeftTab << 3 << (IntList() << 2) << ONE(1) << 1; // not removing current QTest::newRow("left-9") << QTabBar::SelectLeftTab << 3 << (IntList() << 2) << ONE(2) << 1; QTest::newRow("right-1") << QTabBar::SelectRightTab << 3 << (IntList() << 0) << ONE(0) << 0; QTest::newRow("right-2") << QTabBar::SelectRightTab << 3 << (IntList() << 0) << ONE(1) << 0; // not removing current QTest::newRow("right-3") << QTabBar::SelectRightTab << 3 << (IntList() << 0) << ONE(2) << 0; // not removing current QTest::newRow("right-4") << QTabBar::SelectRightTab << 3 << (IntList() << 1) << ONE(0) << 0; // not removing current QTest::newRow("right-5") << QTabBar::SelectRightTab << 3 << (IntList() << 1) << ONE(1) << 1; QTest::newRow("right-6") << QTabBar::SelectRightTab << 3 << (IntList() << 1) << ONE(2) << 1; // not removing current QTest::newRow("right-7") << QTabBar::SelectRightTab << 3 << (IntList() << 2) << ONE(0) << 1; // not removing current QTest::newRow("right-8") << QTabBar::SelectRightTab << 3 << (IntList() << 2) << ONE(1) << 1; // not removing current QTest::newRow("right-9") << QTabBar::SelectRightTab << 3 << (IntList() << 2) << ONE(2) << 1; QTest::newRow("previous-0") << QTabBar::SelectPreviousTab << 3 << (IntList()) << ONE(0) << 0; QTest::newRow("previous-1") << QTabBar::SelectPreviousTab << 3 << (IntList()) << ONE(1) << 0; // not removing current QTest::newRow("previous-2") << QTabBar::SelectPreviousTab << 3 << (IntList()) << ONE(2) << 0; // not removing current QTest::newRow("previous-3") << QTabBar::SelectPreviousTab << 3 << (IntList() << 2) << ONE(0) << 1; // not removing current QTest::newRow("previous-4") << QTabBar::SelectPreviousTab << 3 << (IntList() << 2) << ONE(1) << 1; // not removing current QTest::newRow("previous-5") << QTabBar::SelectPreviousTab << 3 << (IntList() << 2) << ONE(2) << 0; // go back one QTest::newRow("previous-6") << QTabBar::SelectPreviousTab << 4 << (IntList() << 0 << 2 << 3 << 1) << (IntList() << 1) << 2; // go back two QTest::newRow("previous-7") << QTabBar::SelectPreviousTab << 4 << (IntList() << 0 << 2 << 3 << 1) << (IntList() << 1 << 2) << 1; // go back three QTest::newRow("previous-8") << QTabBar::SelectPreviousTab << 4 << (IntList() << 0 << 2 << 3 << 1) << (IntList() << 1 << 2 << 1) << 0; // pick from the middle QTest::newRow("previous-9") << QTabBar::SelectPreviousTab << 4 << (IntList() << 0 << 2 << 3 << 1) << (IntList() << 2 << 1) << 1; // every other one QTest::newRow("previous-10") << QTabBar::SelectPreviousTab << 7 << (IntList() << 0 << 2 << 4 << 6) << (IntList() << 6 << 4) << 2; }
/**************************************************************************** ** *F FuncONE( <self>, <obj> ) . . . . . . . . . . . . . . . . . call 'ONE' */ Obj FuncONE ( Obj self, Obj obj ) { return ONE(obj); }
void AnalysisVisitor::visit(ast::ListExp & e) { logger.log(L"ListExp", e.getLocation()); if (e.getParent()->isVarDec()) { visitInVarDecCtxt(e); return; } e.getStart().accept(*this); Result & Rstart = e.getStart().getDecorator().getResult(); e.getEnd().accept(*this); Result & Rend = e.getEnd().getDecorator().getResult(); e.getStep().accept(*this); Result & Rstep = e.getStep().getDecorator().getResult(); double start = 1; double step = 1; double end = 1; if (Rstart.getConstant().getDblValue(start) && Rstep.getConstant().getDblValue(step) && Rend.getConstant().getDblValue(end)) { // Start, Step & End are constant ! double out; int type = ForList64::checkList(start, end, step, out); switch (type) { case 0: e.getDecorator().setResult(Result(TIType(dm.getGVN(), TIType::EMPTY), -1)); break; case 1: e.getDecorator().setResult(Result(TIType(dm.getGVN(), TIType::DOUBLE), -1)); break; case 2: { const uint64_t N = ForList64::size(start, end, step); TIType T(dm.getGVN(), TIType::DOUBLE, 1, N); if (N == 1) { out = start; } e.getDecorator().setResult(Result(T, dm.getTmpId(T, false))); break; } default: break; } e.setValues(start, step, end, out); setResult(e.getDecorator().res); return; } if (step == 0 || tools::isNaN(step) || !tools::isFinite(step) || tools::isNaN(start) || !tools::isFinite(start) || tools::isNaN(end) || !tools::isFinite(end)) { e.getDecorator().setResult(Result(TIType(dm.getGVN(), TIType::EMPTY), -1)); return; } if (!Rstep.getConstant().getDblValue(step) || (step != -1 && step != 1)) { Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false), -1)); setResult(res); return; } if (!Rstart.getType().isscalar() || !Rend.getType().isscalar()) { Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false), -1)); setResult(res); return; } GVN::Value * gvnStart; if (Rstart.getConstant().getDblValue(start)) { if (tools::getIntType(start) == tools::NOTANINT) { gvnStart = getGVN().getValue((double)tools::cast<int>(start + step)); } else { gvnStart = getGVN().getValue((double)tools::cast<int>(start)); } } else { gvnStart = Rstart.getConstant().getGVNValue(); if (!gvnStart) { Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false), -1)); setResult(res); return; } } GVN::Value * gvnEnd; if (Rend.getConstant().getDblValue(end)) { if (tools::getIntType(end) == tools::NOTANINT) { gvnEnd = getGVN().getValue((double)tools::cast<int>(end - step)); } else { gvnEnd = getGVN().getValue((double)tools::cast<int>(end)); } } else { gvnEnd = Rend.getConstant().getGVNValue(); if (!gvnEnd) { Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false), -1)); setResult(res); return; } } GVN::Value * ONEValue = getGVN().getValue(int64_t(1)); SymbolicDimension ONE(getGVN(), ONEValue); GVN::Value * v; if (gvnStart->value == gvnEnd->value) { Result & res = e.getDecorator().setResult(Result(TIType(getGVN(), TIType::DOUBLE, ONE, ONE))); setResult(res); return; } if (step == 1) { v = getGVN().getValue(OpValue::Kind::MINUS, *gvnEnd, *gvnStart); } else { v = getGVN().getValue(OpValue::Kind::MINUS, *gvnStart, *gvnEnd); } v = getGVN().getValue(OpValue::Kind::PLUS, *v, *ONEValue); if (v->poly->constant < 0 && v->poly->isCoeffNegative(false)) { TIType type(getGVN(), TIType::EMPTY); e.getDecorator().res = Result(type); } else { bool res = getCM().check(ConstraintManager::POSITIVE, v); if (res) { TIType type(getGVN(), TIType::DOUBLE, ONE, SymbolicDimension(getGVN(), v)); e.getDecorator().setResult(type); } else { Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false), -1)); setResult(res); return; } } setResult(e.getDecorator().res); }