LineSearch* ObjectManager::getLineSearch(){ if (lineSearch_ == NULL) { if (getIfAdditive() == false) { throw Error("Line search is not implemented for the non-additive case"); } // line search, possible values: BISEC, ARMIJO, QUAD_APP std::cout << "Creating line search" << std::endl; std::string tmp = params_->getParamWoSpaces("LINE_SEARCH"); if (tmp == "BISEC") { FPType pr = getFloatValue("LS_PRECISION"); if (pr <= 0.0) throw Error("Line search precision must be positive"); lineSearch_ = new Bisection(pr, getDerivative()); } else if (tmp == "ARMIJO") { FPType dec = getFloatValue("ARMIJO_DEC"); if (dec <= 0.0) throw Error("Decrement for Armijo search must be positive"); lineSearch_ = new Armijo(dec, getDerivative()); } else if (tmp == "QUAD_APP") { lineSearch_ = new QuadApp(getDerivative(), getNet()); } else { throw Error("Unexpected value of parameter <LINE_SEARCH>"); } std::cout << "Line search created" << std::endl; } return lineSearch_; };
void Response_Functional<panzer::Traits::Jacobian>:: scatterResponse() { Teuchos::RCP<Thyra::MultiVectorBase<double> > dgdx_unique = getDerivative(); Teuchos::rcp_dynamic_cast<ThyraObjContainer<double> >(uniqueContainer_)->set_f_th(dgdx_unique->col(0)); linObjFactory_->ghostToGlobalContainer(*ghostedContainer_,*uniqueContainer_,LinearObjContainer::F); }
StepSizeAdd* ObjectManager::getStepSizeAdd(){ assert(getIfAdditive() == true); if (stepSizeAdd_ == NULL) { std::cout << "Creating StepSizeAdd" << std::endl; stepSizeAdd_ = new StepSizeAdd(getLineSearch(), getDerivative()); // so far only additive step size stepSize_ = stepSizeAdd_; std::cout << "StepSizeAdd created" << std::endl; } return stepSizeAdd_; };
void Func::process(const Eref &e, ProcPtr p) { if (!_valid){ return; } if (_mode & 1){ valueOut()->send(e, getValue()); } if (_mode & 2){ derivativeOut()->send(e, getDerivative()); } }
StepSize* ObjectManager::getStepSize(){ if (stepSize_ == NULL) { std::cout << "Creating StepSize" << std::endl; if (getIfAdditive() == true) { std::string tmp = params_->getParamWoSpaces("LINE_SEARCH"); stepSizeAdd_ = new StepSizeAdd(getLineSearch(), getDerivative()); // so far only additive step size stepSize_ = stepSizeAdd_; } else { throw Error("Step size is not implemented for the non-additive case"); } std::cout << "StepSize created" << std::endl; } return stepSize_; };
void Function::process(const Eref &e, ProcPtr p) { if (!_valid){ return; } vector < double > databuf; requestOut()->send(e, &databuf); for (unsigned int ii = 0; (ii < databuf.size()) && (ii < _pullbuf.size()); ++ii){ *_pullbuf[ii] = databuf[ii]; } _value = getValue(); _rate = (_value - _lastValue) / p->dt; switch (_mode){ case 1: { valueOut()->send(e, _value); break; } case 2: { derivativeOut()->send(e, getDerivative()); break; } case 3: { rateOut()->send(e, _rate); break; } default: { valueOut()->send(e, _value); derivativeOut()->send(e, getDerivative()); rateOut()->send(e, _rate); break; } } _lastValue = _value; }
iSpline3D* otPolyLineSpline3::getNormal() { unsigned int count = getPointList().getCount(); otPolyLineSpline3* normalSpline = new otPolyLineSpline3(count); otPolyLineSpline3* derivativeSpline = (otPolyLineSpline3 *)getDerivative(); otPolyLineSpline3* secondDerivativeSpline = (otPolyLineSpline3 *)getSecondDerivative(); normalSpline->setPoint(points[0].x,*(new otVector3)); for(unsigned int i=1;i<count-1;i++) { otVector3 derivative=derivativeSpline->getPointList()[i].y; otVector3 secondDerivative=secondDerivativeSpline->getPointList()[i].y; normalSpline->setPoint(points[i].x,(secondDerivative -derivative*((derivative|secondDerivative))).normalize() ); } return normalSpline; }
DerivationNode* Derivator::_derive(const DerivationNode* node) { if (node->first == 0 && node->last == 0) { if (FunctionParser::isNumber(node->s)) { return new DerivationNode("0"); } return new DerivationNode("1"); } if (node->op != 0){ switch (node->op) { case '+': case '-': { if (node->last->first == 0 && FunctionParser::isNumber(node->last->s)) { return _derive(node->first); } if (node->first->first == 0 && FunctionParser::isNumber(node->last->s)) { return (node->op == '+' ? _derive(node->last) : new DerivationNode(new DerivationNode("-1"), _derive(node->last), '*')); } return new DerivationNode(_derive(node->first), _derive(node->last), node->op); break; } case '*': { if (node->first->first == 0 && FunctionParser::isNumber(node->first->s)) { return new DerivationNode(node->first, _derive(node->last), '*'); } if (node->last->first == 0 && FunctionParser::isNumber(node->last->s)) { return new DerivationNode(node->last, _derive(node->first), '*'); } DerivationNode* f = new DerivationNode(_derive(node->first), node->last, '*'); DerivationNode* ss = new DerivationNode(node->first, _derive(node->last), '*'); return new DerivationNode(f, ss, '+'); break; } case '/': { if (node->last->first == 0 && FunctionParser::isNumber(node->last->s)) { DerivationNode* one = new DerivationNode("1"); DerivationNode* next = new DerivationNode(node->last->s); DerivationNode* div = new DerivationNode(one, next, '/'); return new DerivationNode(div, _derive(node->first), '*'); } else { DerivationNode* f = new DerivationNode(_derive(node->first), node->last, '*'); DerivationNode* ss = new DerivationNode(node->first, _derive(node->last), '*'); DerivationNode* up = new DerivationNode(f, ss, '-'); DerivationNode* p = new DerivationNode("2"); DerivationNode* down = new DerivationNode(node->last, p, '^'); return new DerivationNode(up, down, '/'); } break; } case '^': { double n = FunctionParser::doubleFromStr(node->last->s); DerivationNode* p = new DerivationNode(FunctionParser::strFromDouble(n - 1)); DerivationNode* f = new DerivationNode(node->first, p, '^'); DerivationNode* ss = new DerivationNode(node->last, f, '*'); return new DerivationNode(ss, _derive(node->first), '*'); } } } else { return new DerivationNode(getDerivative(node), _derive(node->last), '*'); } }
SenderChainKey SenderChainKey::getNext() const { return SenderChainKey(iteration + 1, getDerivative(CHAIN_KEY_SEED, chainKey)); }
SenderMessageKey SenderChainKey::getSenderMessageKey() const { return SenderMessageKey(iteration, getDerivative(MESSAGE_KEY_SEED, chainKey)); }