int SHAMapTreeNode::getBranchCount () const { assert (isInner ()); int count = 0; for (int i = 0; i < 16; ++i) if (!isEmptyBranch (i)) ++count; return count; }
bool alex::Sphere::intersect(const alex::Ray &ray, cv::Vec3d &intersection, cv::Vec3d &normalVecN, bool &outsideIn) const { double t = (this->position - ray.getStartPoint()).dot(ray.getDirectionN()); auto nearestPoint = ray.getStartPoint() + ray.getDirectionN() * t; if (!isInner(nearestPoint)) return false; double nearestDis = cv::norm(nearestPoint - this->position); auto nearestPointToIntersection = sqrt(this->radius * this->radius - nearestDis * nearestDis); auto vec = ray.getDirectionN() * nearestPointToIntersection; outsideIn = !isInner(ray.getStartPoint()); if (outsideIn && t < 0) return false; intersection = outsideIn ? nearestPoint - vec : nearestPoint + vec; normalVecN = outsideIn ? intersection - this->position : this->position - intersection; return true; }
// TODO A quoi sert "nb_nonlinear_vars" ? int LinearRelaxXTaylor::X_Linearization(const IntervalVector& box, int ctr, corner_point cpoint, IntervalVector& G, int id_point, int& nb_nonlinear_vars, LinearSolver& lp_solver) { CmpOp op= sys.ctrs[ctr].op; if(op!=EQ && isInner(box, sys, ctr)) return 0; //the constraint is satisfied int cont=0; if(ctr==goal_ctr) op = LEQ; if(op==EQ) { cont+=X_Linearization(box, ctr, cpoint, LEQ, G, id_point, nb_nonlinear_vars, lp_solver); cont+=X_Linearization(box, ctr, cpoint, GEQ, G, id_point, nb_nonlinear_vars, lp_solver); } else cont+=X_Linearization(box, ctr, cpoint, op, G, id_point, nb_nonlinear_vars, lp_solver); return cont; }
std::string SHAMapTreeNode::getString () const { std::string ret = "NodeID("; ret += lexicalCastThrow <std::string> (getDepth ()); ret += ","; ret += getNodeID ().GetHex (); ret += ")"; if (isInner ()) { for (int i = 0; i < 16; ++i) if (!isEmptyBranch (i)) { ret += "\nb"; ret += lexicalCastThrow <std::string> (i); ret += " = "; ret += mHashes[i].GetHex (); } } if (isLeaf ()) { if (mType == tnTRANSACTION_NM) ret += ",txn\n"; else if (mType == tnTRANSACTION_MD) ret += ",txn+md\n"; else if (mType == tnACCOUNT_STATE) ret += ",as\n"; else ret += ",leaf\n"; ret += " Tag="; ret += getTag ().GetHex (); ret += "\n Hash="; ret += mHash.GetHex (); ret += "/"; ret += lexicalCast <std::string> (mItem->peekSerializer ().getDataLength ()); } return ret; }
void dump() const { AccessedStorage::dump(); llvm::dbgs() << "<" << (isInner() ? "" : "inner") << (containsRead() ? "" : "containsRead") << ">\n"; }
/*NOTE: bad design*/ void readExtraCons(char *bin_fname) { int dbg = 0; FILE *fcons; char fname[256], str[256], token[256]; int pos; int idL1, idL2, k; loop_t *l1, *l2; sprintf(fname,"%s.econ",bin_fname);//extra constraint fcons = fopen(fname,"r"); if (!fcons) return; while (fgets(str,256,fcons)!=0) { pos = 0; getNextToken(token, str, &pos, " "); if (dbg) { fprintf(dbgAddr,"Cons Type %s",token);fflush(dbgAddr); } if (strcmp(token,"eql")==0) { //format: eql L1_id L2_id k //relative loop bound: lp bound L1 = lp iteration L2 + k sscanf(str+pos,"%d %d %d", &idL1, &idL2, &k); l1 = loops[idL1]; l2 = loops[idL2]; if (isInner(idL1,idL2) == 0) { printf("\nWrong RLB cons: L%d is not inner loop of L%d", l1->id, l2->id); exit(1); } l1->rId = l2->id; l1->rBound = k; l1->rType = EQL_LB; if (dbg) { fprintf(dbgAddr,"\nEqual outer interation bound:"); fprintf(dbgAddr," LB L%d <= LI L%d + %d", idL1, idL2, k); fflush(dbgAddr); } } else if (strcmp(token,"inv")==0) { //format: inv L1_id L2_id k //inverse loop bound: lp bound L1 = k - lp iteration L2 sscanf(str+pos,"%d %d %d", &idL1, &idL2, &k); l1 = loops[idL1]; l2 = loops[idL2]; if (isInner(l1->id,l2->id) == 0) { printf("\nWrong RLB cons: L%d is not inner loop of L%d", l1->id, l2->id); exit(1); } l1->rId = l2->id; l1->rBound = k; l1->rType = INV_LB; if (dbg) { fprintf(dbgAddr,"\nInverse outer interation bound:"); fprintf(dbgAddr," LB L%d <= %d - LI L%d", idL1, k, idL2); fflush(dbgAddr); } } else { fprintf(dbgAddr,"\nUnknown constraint: %s",str); fflush(dbgAddr); } } }