void ossimQuadTreeWarp::getShift(ossimDpt& result, const ossimDpt& pt)const { getShift(result, findNode(pt), pt); }
void ccShiftAndScaleCloudDlg::onClick(QAbstractButton* button) { bool saveInfo = false; m_applyAll = false; m_cancel = false; if (button == m_ui->buttonBox->button(QDialogButtonBox::Yes)) { saveInfo = true; } else if (button == m_ui->buttonBox->button(QDialogButtonBox::YesToAll)) { saveInfo = true; m_applyAll = true; } else if (button == m_ui->buttonBox->button(QDialogButtonBox::Cancel)) { m_cancel = true; } if (saveInfo) { s_lastInfo.valid = true; s_lastInfo.shift = getShift(); s_lastInfo.scale = getScale(); } }
// Restituisce lo scostamento della fonte di luce // 1 = sopra o destra // 0 = nessuno // -1 = sotto o sinistra int SolarTracker::Axis::track() { int shift = getShift(); int newDirection = 0; if(shift > 0) { newDirection = 1; } else if(shift < 0) { newDirection = -1; } if(this->lastDirection == newDirection) { // spostamento nella stessa direzione return this->lastDirection; } else { // gestione soglia if(abs(shift) >= this->threshold) { this->lastDirection = newDirection; return this->lastDirection; } else { return 0; } } }
void ccShiftAndScaleCloudDlg::updateLocalSystem() { CCVector3d localPoint = m_localPoint; double localDiagonal = m_localDiagonal; if (!m_reversedMode || keepGlobalPos()) { localPoint = (m_originalPoint + getShift()) * getScale(); localDiagonal = m_originalDiagonal * getScale(); } //adaptive precision double maxCoord = std::max(fabs(localPoint.x),fabs(localPoint.y)); maxCoord = std::max(fabs(localPoint.z),maxCoord); int digitsBeforeDec = static_cast<int>(floor(log10(maxCoord)))+1; int prec = std::max(0,8-digitsBeforeDec); m_ui->xDestLabel->setText(QString("x = %1").arg(localPoint.x,0,'f',prec)); m_ui->xDestLabel->setStyleSheet(ccGlobalShiftManager::NeedShift(localPoint.x) ? QString("color: red;") : QString() ); m_ui->yDestLabel->setText(QString("y = %1").arg(localPoint.y,0,'f',prec)); m_ui->yDestLabel->setStyleSheet(ccGlobalShiftManager::NeedShift(localPoint.y) ? QString("color: red;") : QString() ); m_ui->zDestLabel->setText(QString("z = %1").arg(localPoint.z,0,'f',prec)); m_ui->zDestLabel->setStyleSheet(ccGlobalShiftManager::NeedShift(localPoint.z) ? QString("color: red;") : QString() ); m_ui->diagDestLabel->setText(QString("diagonal = %1").arg(localDiagonal,0,'f',prec)); m_ui->diagDestLabel->setStyleSheet(ccGlobalShiftManager::NeedRescale(localDiagonal) ? QString("color: red;") : QString() ); }
ossimDpt ossimQuadTreeWarp::getShift(const ossimDpt& pt)const { ossimDpt result; getShift(result, pt); return result; }
HtmlParser(const std::string &file_name) : _result(false) { std::string title; std::string body; Tree tr; html::ParserDom parser; parser.parse(getHtmlString(file_name)); tr = parser.getTree(); TreeIter it = tr.begin(); TreeIter end = tr.end(); _root_depth = tr.depth(it); while (it != end) { std::string shift = getShift(tr.depth(it)); if (not it->tagName().empty() && not it->isComment()) { if (it->isTag()) { if (it->tagName() == "head") { title = parseHead(tr, it); } if (it->tagName() == "body") { body = (b::format("<![CDATA[\n%s%s%s%s%s%s%s%s]]>") % shift % it->text() % "\n" % parseBody(tr, it) % shift % it->closingText() % "\n" % shift ).str(); } } } ++it; } b::format res = b::format( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<items>\n" " <snip1 type=\"contenttype\">\n" " <title type=\"field\">\n" " %s\n" " </title>\n" " <body type=\"field\">\n" " <value>\n" " %s\n" " </value>\n" " </body>\n" " </snip1>\n" "</items>\n" ) % title % body ; std::cout << res.str() << std::flush; _result = true; }
void ossimQuadTreeWarp::forward(ossimDpt& pt)const { if(theWarpEnabledFlag) { ossimDpt shift; getShift(shift, pt); pt += shift; } }
void SkFlipPixelRef::CopyBitsFromAddr(const SkBitmap& dst, const SkRegion& clip, const void* srcAddr) { const int shift = getShift(dst.config()); if (shift < 0) { return; } const SkIRect bounds = {0, 0, dst.width(), dst.height()}; SkRegion::Cliperator iter(clip, bounds); while (!iter.done()) { copyRect(dst, iter.rect(), srcAddr, shift); iter.next(); } }
int main(void) { int shift = 0; char* pSentence = NULL; char* pEncrypted = NULL; pSentence = getSentence(); shift = getShift(); pEncrypted = caesarShiftCipher(pSentence, shift); puts("\nOriginal Sentence: "); puts(pSentence); puts("\nEncrypted Sentence: "); puts(pEncrypted); return 0; }
void ossimQuadTreeWarp::forward(const ossimDpt& pt, ossimDpt& result)const { if(theWarpEnabledFlag) { ossimDpt shift; getShift(shift, pt); result = pt + shift; } else { result = pt; } }
void ccShiftAndScaleCloudDlg::updateGlobalSystem() { CCVector3d P = m_originalPoint; double diag = m_originalDiagonal; if (m_reversedMode && !keepGlobalPos()) { P = (m_localPoint - getShift()) / getScale(); diag = m_localDiagonal / getScale(); } m_ui->xOriginLabel->setText(QString("x = %1").arg(P.x,0,'f')); m_ui->xOriginLabel->setStyleSheet(AlmostEq(P.x,m_originalPoint.x) ? QString() : QString("color: purple;")); m_ui->yOriginLabel->setText(QString("y = %1").arg(P.y,0,'f')); m_ui->yOriginLabel->setStyleSheet(AlmostEq(P.y,m_originalPoint.y) ? QString() : QString("color: purple;")); m_ui->zOriginLabel->setText(QString("z = %1").arg(P.z,0,'f')); m_ui->zOriginLabel->setStyleSheet(AlmostEq(P.z,m_originalPoint.z) ? QString() : QString("color: purple;")); m_ui->diagOriginLabel->setText(QString("diagonal = %1").arg(diag,0,'f')); m_ui->diagOriginLabel->setStyleSheet(AlmostEq(diag,m_originalDiagonal) ? QString() : QString("color: purple;")); }
std::string parseBody(const Tree &tr, const TreeIter &parent) { std::uint32_t cnum = tr.number_of_children(parent); std::string res; for (std::uint32_t i = 0; i < cnum; i++) { TreeIter it = tr.child(parent, i); if (not it->isComment()) { std::string shift = getShift(tr.depth(it)); if (tr.number_of_children(it)) { res += (b::format("%s%s%s%s%s%s%s") % shift % it->text() % "\n" % parseBody(tr, it) % shift % it->closingText() % "\n").str(); } else { res += (b::format("%s%s%s") % shift % it->text() % "\n").str(); } } } return res; }
string PowerLayer::convet2CaffeFormat() { string layerStrStart = "layer\n{\n"; string layerStrEnd = "}"; string nameStrStart = "\tname: \""; string nameStrEnd = "\"\n"; string typeStrStart = "\ttype: \""; string typeStrEnd = "\"\n"; string topStrStart = "\ttop: \""; string topStrEnd = "\"\n"; string bottomStrStart = "\tbottom: \""; string bottomStrEnd = "\"\n"; string powerParamStrStart = "\tpower_param\n\t{\n"; string powerParamStrEnd = "\t}\n"; string powerStrStart = "\t\tpower: "; string powerStrEnd = "\n"; string scaleStrStart = "\t\tscale: "; string scaleStrEnd = "\n"; string shiftStrStart = "\t\tshift: "; string shiftStrEnd = "\n"; string phaseStrStart = "\tinclude:\n\t{\n"; string phaseStrEnd = "\t}\n"; string phaseStateStrStart = "\t\tphase: "; string phaseStateStrEnd = "\n"; string outStr = layerStrStart + nameStrStart + mName + nameStrEnd + typeStrStart + getLayerType() + typeStrEnd; for(size_t i = 0; i < mTops->size(); i++) { outStr = outStr + topStrStart + (*mTops)[i] + topStrEnd; } for(size_t i = 0; i < mBottoms->size(); i++) { outStr = outStr + bottomStrStart + (*mBottoms)[i] + bottomStrEnd; } outStr = outStr + powerParamStrStart; if (getPower() != 1.0) { outStr += powerStrStart + to_string(getPower()) + powerStrEnd; } if (getScale() != 1.0) { outStr += scaleStrStart + to_string(getScale()) + scaleStrEnd; } if (getShift() != 0.0) { outStr += shiftStrStart + to_string(getShift()) + shiftStrEnd; } outStr += powerParamStrEnd; if (mPhase != Phase::BOTH) { outStr += phaseStrStart + phaseStateStrStart; if (mPhase == Phase::TRAIN) { outStr += "TRAIN"; } else if (mPhase == Phase::TEST) { outStr += "TEST"; } outStr += phaseStateStrEnd + phaseStrEnd; } outStr += layerStrEnd; return outStr; }
void ossimQuadTreeWarp::getNewQuads(ossimQuadTreeWarpNode* parent, const ossimDrect& ul, const ossimDrect& ur, const ossimDrect& lr, const ossimDrect& ll, ossimQuadTreeWarpNode*& ulNode, ossimQuadTreeWarpNode*& urNode, ossimQuadTreeWarpNode*& lrNode, ossimQuadTreeWarpNode*& llNode) { ossimDpt midShift; getShift(midShift, parent, ul.lr()); ossimQuadTreeWarpVertex* midV = new ossimQuadTreeWarpVertex(ul.lr(), midShift); ulNode = new ossimQuadTreeWarpNode(ul, parent); urNode = new ossimQuadTreeWarpNode(ur, parent); lrNode = new ossimQuadTreeWarpNode(lr, parent); llNode = new ossimQuadTreeWarpNode(ll, parent); midV->addSharedNode(ulNode); midV->addSharedNode(urNode); midV->addSharedNode(lrNode); midV->addSharedNode(llNode); // get the shared vertices first. We will add ourself // to the pointer list. when we construct // the quad nodes. Note the mid point will be shared // by all quads and will be marked as adjustable // ossimQuadTreeWarpVertex* ulSharedV = getVertex(ul.ul()); ossimQuadTreeWarpVertex* urSharedV = getVertex(ur.ur()); ossimQuadTreeWarpVertex* lrSharedV = getVertex(lr.lr()); ossimQuadTreeWarpVertex* llSharedV = getVertex(ll.ll()); if(!ulSharedV|| !urSharedV|| !lrSharedV|| !llSharedV) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL: " << "ossimQuadTreeWarp::split, can't locating shared vertices. This Shouldn't happen!!!\n"; return; } // we know that the midpoint is new and is shared by all quads // so we have 2 more to check ossimQuadTreeWarpVertex* topSharedV = getVertex(ul.ur()); ossimQuadTreeWarpVertex* bottomSharedV = getVertex(lr.ll()); ossimQuadTreeWarpVertex* leftSharedV = getVertex(ul.ll()); ossimQuadTreeWarpVertex* rightSharedV = getVertex(ur.lr()); ossimDpt tempShift; if(!topSharedV) { getShift(tempShift, parent, ul.ur()); topSharedV = new ossimQuadTreeWarpVertex(ul.ur(), tempShift); theVertexList.push_back(topSharedV); } if(!bottomSharedV) { getShift(tempShift, parent, ll.lr()); bottomSharedV = new ossimQuadTreeWarpVertex(ll.lr(), tempShift); theVertexList.push_back(bottomSharedV); } if(!leftSharedV) { getShift(tempShift, parent, ul.ll()); leftSharedV = new ossimQuadTreeWarpVertex(ul.ll(), tempShift); theVertexList.push_back(leftSharedV); } if(!rightSharedV) { getShift(tempShift, parent, ur.lr()); rightSharedV = new ossimQuadTreeWarpVertex(ur.lr(), tempShift); theVertexList.push_back(rightSharedV); } theVertexList.push_back(midV); topSharedV->addSharedNode(ulNode); topSharedV->addSharedNode(urNode); bottomSharedV->addSharedNode(llNode); bottomSharedV->addSharedNode(lrNode); leftSharedV->addSharedNode(ulNode); leftSharedV->addSharedNode(llNode); rightSharedV->addSharedNode(urNode); rightSharedV->addSharedNode(lrNode); ulSharedV->addSharedNode(ulNode); urSharedV->addSharedNode(urNode); lrSharedV->addSharedNode(lrNode); llSharedV->addSharedNode(llNode); ulNode->theUlVertex = ulSharedV; ulNode->theUrVertex = topSharedV; ulNode->theLrVertex = midV; ulNode->theLlVertex = leftSharedV; urNode->theUlVertex = topSharedV; urNode->theUrVertex = urSharedV; urNode->theLrVertex = rightSharedV; urNode->theLlVertex = midV; lrNode->theUlVertex = midV; lrNode->theUrVertex = rightSharedV; lrNode->theLrVertex = lrSharedV; lrNode->theLlVertex = bottomSharedV; llNode->theUlVertex = leftSharedV; llNode->theUrVertex = midV; llNode->theLrVertex = bottomSharedV; llNode->theLlVertex = llSharedV; }
void LLL(F_mpz_mat_t B) { int kappa, kappa2, d, n, i, j, zeros, kappamax; double ** mu, ** r, ** appB, ** appSP; double * s, * mutmp, * appBtmp, * appSPtmp; double tmp = 0.0; int * expo, * alpha; mp_limb_t * Btmp; n = B->c; d = B->r; ulong shift = getShift(B); alpha = (int *) malloc(d * sizeof(int)); expo = (int *) malloc(d * sizeof(int)); mu = d_mat_init(d, d); r = d_mat_init(d, d); appB = d_mat_init(d, n); appSP = d_mat_init(d, d); s = (double *) malloc (d * sizeof(double)); appSPtmp = (double *) malloc (d * sizeof(double)); for (i = 0; i < d; i++) for (j = 0; j < d; j++) appSP[i][j] = NAN;//0.0/0.0; /* ************************** */ /* Step1: Initialization Step */ /* ************************** */ for (i = 0; i < d; i++) expo[i] = F_mpz_mat_set_line_d(appB[i], B, i, n); /* ********************************* */ /* Step2: Initializing the main loop */ /* ********************************* */ kappamax = 0; i = 0; do appSP[i][i] = d_vec_norm(appB[i], n); while ((appSP[i][i] <= 0.0) && (++i < d)); // Fixme : should this be EPS not 0.0 zeros = i - 1; /* all vectors B[i] with i <= zeros are zero vectors */ kappa = i + 1; if (zeros < d - 1) r[i][i] = appSP[i][i]; for (i = zeros + 1; i < d; i++) alpha[i] = 0; while (kappa < d) { if (kappa > kappamax) kappamax++; // Fixme : should this be kappamax = kappa instead of kappamax++ /* ********************************** */ /* Step3: Call to the Babai algorithm */ /* ********************************** */ Babai(kappa, B, mu, r, s, appB, expo, appSP, alpha[kappa], zeros, kappamax, FLINT_MIN(kappamax + 1 + shift, n)); /* ************************************ */ /* Step4: Success of Lovasz's condition */ /* ************************************ */ /* ctt * r.coeff[kappa-1][kappa-1] <= s[kappa-2] ?? */ tmp = r[kappa-1][kappa-1] * ctt; tmp = ldexp (tmp, 2*(expo[kappa-1] - expo[kappa])); if (tmp <= s[kappa-1]) { alpha[kappa] = kappa; tmp = mu[kappa][kappa-1] * r[kappa][kappa-1]; r[kappa][kappa] = s[kappa-1] - tmp; kappa++; } else { /* ******************************************* */ /* Step5: Find the right insertion index kappa */ /* kappa2 remains the initial kappa */ /* ******************************************* */ kappa2 = kappa; do { kappa--; if (kappa > zeros + 1) { tmp = r[kappa-1][kappa-1] * ctt; tmp = ldexp(tmp, 2*(expo[kappa-1] - expo[kappa2])); } } while ((kappa >= zeros + 2) && (s[kappa-1] <= tmp)); for (i = kappa; i < kappa2; i++) if (kappa <= alpha[i]) alpha[i] = kappa; for (i = kappa2; i > kappa; i--) alpha[i] = alpha[i-1]; for (i = kappa2 + 1; i <= kappamax; i++) if (kappa < alpha[i]) alpha[i] = kappa; alpha[kappa] = kappa; /* ****************************** */ /* Step6: Update the mu's and r's */ /* ****************************** */ mutmp = mu[kappa2]; for (i = kappa2; i > kappa; i--) mu[i] = mu[i-1]; mu[kappa] = mutmp; mutmp = r[kappa2]; for (i = kappa2; i > kappa; i--) r[i] = r[i-1]; r[kappa] = mutmp; r[kappa][kappa] = s[kappa]; /* ************************ */ /* Step7: Update B and appB */ /* ************************ */ Btmp = B->rows[kappa2]; for (i = kappa2; i > kappa; i--) B->rows[i] = B->rows[i-1]; B->rows[kappa] = Btmp; appBtmp = appB[kappa2]; for (i = kappa2; i > kappa; i--) appB[i] = appB[i-1]; appB[kappa] = appBtmp; j = expo[kappa2]; for (i = kappa2; i > kappa; i--) expo[i] = expo[i-1]; expo[kappa] = j; /* *************************** */ /* Step8: Update appSP: tricky */ /* *************************** */ for (i = 0; i <= kappa2; i++) appSPtmp[i] = appSP[kappa2][i]; for (i = kappa2 + 1; i <= kappamax; i++) appSPtmp[i] = appSP[i][kappa2]; for (i = kappa2; i > kappa; i--) { for (j = 0; j < kappa; j++) appSP[i][j] = appSP[i-1][j]; appSP[i][kappa] = appSPtmp[i-1]; for (j = kappa + 1; j <= i; j++) appSP[i][j] = appSP[i-1][j-1]; for (j = kappa2 + 1; j <= kappamax; j++) appSP[j][i] = appSP[j][i-1]; } for (i = 0; i < kappa; i++) appSP[kappa][i] = appSPtmp[i]; appSP[kappa][kappa] = appSPtmp[kappa2]; for (i = kappa2 + 1; i <= kappamax; i++) appSP[i][kappa] = appSPtmp[i]; if (r[kappa][kappa] <= 0.0) { zeros++; kappa++; appSP[kappa][kappa] = d_vec_norm(appB[kappa], n); r[kappa][kappa] = appSP[kappa][kappa]; } kappa++; } } free(alpha); free(expo); d_mat_clear(mu); d_mat_clear(r); d_mat_clear(appB); d_mat_clear(appSP); free(s); free(appSPtmp); }