您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ vol函数代码示例

51自学网 2021-06-03 09:46:52
  C++
这篇教程C++ vol函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中vol函数的典型用法代码示例。如果您正苦于以下问题:C++ vol函数的具体用法?C++ vol怎么用?C++ vol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了vol函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: regExp

bool rspfDtedInfo::open(const rspfFilename& file){   bool result = false;   // Test for extension, like dt0, dt1...   rspfString ext = file.ext();   rspfRegExp regExp("^[d|D][t|T][0-9]");      if ( regExp.find( ext.c_str() ) )   {      rspfDtedVol vol(file, 0);      rspfDtedHdr hdr(file, vol.stopOffset());      rspfDtedUhl uhl(file, hdr.stopOffset());      rspfDtedDsi dsi(file, uhl.stopOffset());      rspfDtedAcc acc(file, dsi.stopOffset());            //---      // Check for errors.  Must have uhl, dsi and acc records.  vol and hdr      // are for magnetic tape only; hence, may or may not be there.      //---      if ( (uhl.getErrorStatus() == rspfErrorCodes::RSPF_OK) &&           (dsi.getErrorStatus() == rspfErrorCodes::RSPF_OK) &&           (acc.getErrorStatus() == rspfErrorCodes::RSPF_OK) )      {         theFile = file;         result = true;      }      else      {         theFile.clear();      }   }   return result;}
开发者ID:vapd-radi,项目名称:rspf_v2.0,代码行数:35,


示例2: vol

std::ostream& rspfDtedInfo::print(std::ostream& out) const{   if ( theFile.size() )   {      std::string prefix = "dted.";            rspfDtedVol vol(theFile, 0);      rspfDtedHdr hdr(theFile, vol.stopOffset());      rspfDtedUhl uhl(theFile, hdr.stopOffset());      rspfDtedDsi dsi(theFile, uhl.stopOffset());      rspfDtedAcc acc(theFile, dsi.stopOffset());      if( vol.getErrorStatus() == rspfErrorCodes::RSPF_OK )      {         vol.print(out, prefix);      }      if( hdr.getErrorStatus() == rspfErrorCodes::RSPF_OK )      {         hdr.print(out, prefix);      }      if( uhl.getErrorStatus() == rspfErrorCodes::RSPF_OK )      {         uhl.print(out, prefix);      }      if( dsi.getErrorStatus() == rspfErrorCodes::RSPF_OK )      {         dsi.print(out, prefix);      }      if( acc.getErrorStatus() == rspfErrorCodes::RSPF_OK )      {         acc.print(out, prefix);      }   }   return out;}
开发者ID:vapd-radi,项目名称:rspf_v2.0,代码行数:34,


示例3: europeanOptionArraysEngine

// [[Rcpp::export]]Rcpp::List europeanOptionArraysEngine(std::string type, Rcpp::NumericMatrix par) {    QuantLib::Option::Type optionType = getOptionType(type);    int n = par.nrow();    Rcpp::NumericVector value(n), delta(n), gamma(n), vega(n), theta(n), rho(n), divrho(n);    QuantLib::Date today = QuantLib::Date::todaysDate();    QuantLib::Settings::instance().evaluationDate() = today;    QuantLib::DayCounter dc = QuantLib::Actual360();    for (int i=0; i<n; i++) {        double underlying    = par(i, 0);    // first column        double strike        = par(i, 1);    // second column        QuantLib::Spread dividendYield = par(i, 2);    // third column        QuantLib::Rate riskFreeRate    = par(i, 3);    // fourth column        QuantLib::Time maturity        = par(i, 4);    // fifth column#ifdef QL_HIGH_RESOLUTION_DATE            // in minutes        boost::posix_time::time_duration length = boost::posix_time::minutes(boost::uint64_t(maturity * 360 * 24 * 60)); #else        int length           = int(maturity*360 + 0.5); // FIXME: this could be better#endif        double volatility    = par(i, 5);    // sixth column            boost::shared_ptr<QuantLib::SimpleQuote> spot(new QuantLib::SimpleQuote( underlying ));        boost::shared_ptr<QuantLib::SimpleQuote> vol(new QuantLib::SimpleQuote( volatility ));        boost::shared_ptr<QuantLib::BlackVolTermStructure> volTS = flatVol(today, vol, dc);        boost::shared_ptr<QuantLib::SimpleQuote> qRate(new QuantLib::SimpleQuote( dividendYield ));        boost::shared_ptr<QuantLib::YieldTermStructure> qTS = flatRate(today, qRate, dc);        boost::shared_ptr<QuantLib::SimpleQuote> rRate(new QuantLib::SimpleQuote( riskFreeRate ));        boost::shared_ptr<QuantLib::YieldTermStructure> rTS = flatRate(today, rRate, dc);        #ifdef QL_HIGH_RESOLUTION_DATE    QuantLib::Date exDate(today.dateTime() + length);#else    QuantLib::Date exDate = today + length;#endif            boost::shared_ptr<QuantLib::Exercise> exercise(new QuantLib::EuropeanExercise(exDate));                boost::shared_ptr<QuantLib::StrikedTypePayoff> payoff(new QuantLib::PlainVanillaPayoff(optionType, strike));        boost::shared_ptr<QuantLib::VanillaOption> option = makeOption(payoff, exercise, spot, qTS, rTS, volTS);                value[i]  = option->NPV();        delta[i]  = option->delta();        gamma[i]  = option->gamma();        vega[i]   = option->vega();        theta[i]  = option->theta();        rho[i]    = option->rho();        divrho[i] = option->dividendRho();    }    return Rcpp::List::create(Rcpp::Named("value")  = value,                              Rcpp::Named("delta")  = delta,                              Rcpp::Named("gamma")  = gamma,                              Rcpp::Named("vega")   = vega,                              Rcpp::Named("theta")  = theta,                              Rcpp::Named("rho")    = rho,                              Rcpp::Named("divRho") = divrho);}
开发者ID:thrasibule,项目名称:rquantlib,代码行数:61,


示例4: luaL_checkinteger

int LuaFilesystem::volumePayload(lua_State *L){    /*     * Given a volume block code, return the volume's payload data as a string.     */    FlashDevice::setStealthIO(1);    unsigned code = luaL_checkinteger(L, 1);    FlashVolume vol(FlashMapBlock::fromCode(code));    if (!vol.isValid()) {        FlashDevice::setStealthIO(-1);        lua_pushfstring(L, "invalid volume");        lua_error(L);        return 0;    }    FlashBlockRef ref;    FlashMapSpan span = vol.getPayload(ref);    uint8_t *buffer = new uint8_t[span.sizeInBytes()];    if (!span.copyBytes(0, buffer, span.sizeInBytes())) {        delete buffer;        FlashDevice::setStealthIO(-1);        lua_pushfstring(L, "I/O error");        lua_error(L);        return 0;    }    lua_pushlstring(L, (const char *)buffer, span.sizeInBytes());    FlashDevice::setStealthIO(-1);    delete buffer;    return 1;}
开发者ID:andrewsmyk,项目名称:thundercracker,代码行数:34,


示例5: phi

	boost::shared_ptr<Lattice> Generalized_HullWhite::tree(const TimeGrid& grid) const {		TermStructureFittingParameter phi(termStructure());		boost::shared_ptr<ShortRateDynamics> numericDynamics(new Dynamics(phi, speed(), vol()));		boost::shared_ptr<TrinomialTree> trinomial(new TrinomialTree(numericDynamics->process(), grid));		boost::shared_ptr<ShortRateTree> numericTree(new ShortRateTree(trinomial, numericDynamics, grid));		typedef TermStructureFittingParameter::NumericalImpl NumericalImpl;		boost::shared_ptr<NumericalImpl> impl =	boost::dynamic_pointer_cast<NumericalImpl>(phi.implementation());		impl->reset();		for (Size i=0; i<(grid.size() - 1); i++) {			Real discountBond = termStructure()->discount(grid[i+1]);			const Array& statePrices = numericTree->statePrices(i);			Size size = numericTree->size(i);			Time dt = numericTree->timeGrid().dt(i);			Real dx = trinomial->dx(i);			Real x = trinomial->underlying(i,0);			Real value = 0.0;			for (Size j=0; j<size; j++) {				value += statePrices[j]*std::exp(-x*dt);				x += dx;			}			value = std::log(value/discountBond)/dt;			impl->set(grid[i], value);		}		return numericTree;	}
开发者ID:fder78,项目名称:MyQuantLib,代码行数:27,


示例6: TEST

TEST( TriangleSplitter, bugTriangle ){   Triangle vol(Vector( 11, -29,  2),                 Vector( 11, -29, -2),                 Vector(  0, -29, -2));   Array<Triangle*> frontSplit;   Array<Triangle*> backSplit;   Plane plane;   plane.set( Float_0, Float_0, Float_1, Float_0 );   vol.split(plane, frontSplit, backSplit);   CPPUNIT_ASSERT_EQUAL((unsigned int)1, frontSplit.size());   CPPUNIT_ASSERT_EQUAL((unsigned int)2, backSplit.size());   COMPARE_VEC(Vector(  11, -29,  2),  frontSplit[0]->vertex(0));   COMPARE_VEC(Vector(  11, -29,  0),  frontSplit[0]->vertex(1));   COMPARE_VEC(Vector(5.5f, -29,  0),  frontSplit[0]->vertex(2));   COMPARE_VEC(Vector(  11, -29,  0),  backSplit[0]->vertex(0));   COMPARE_VEC(Vector(  11, -29, -2),  backSplit[0]->vertex(1));   COMPARE_VEC(Vector(   0, -29, -2),  backSplit[0]->vertex(2));   COMPARE_VEC(Vector(  11, -29,  0),  backSplit[1]->vertex(0));   COMPARE_VEC(Vector(   0, -29, -2),  backSplit[1]->vertex(1));   COMPARE_VEC(Vector(5.5f, -29,  0),  backSplit[1]->vertex(2));   delete backSplit[0];   delete backSplit[1];   delete frontSplit[0];}
开发者ID:chenwenbin928,项目名称:tamy,代码行数:32,


示例7: swaption

	Real swaption(Date evaluationDate,		VanillaSwap::Type type,		Settlement::Type settlementType,		Real strike,		Real nominal,		Date exerciseDate,		Schedule fixedSchedule,		DayCounter fixedDayCount,		Schedule floatSchedule,		DayCounter floatDayCount,		Natural fixingDays,		BusinessDayConvention convention,		boost::shared_ptr<IborIndex> index,		boost::shared_ptr<YieldTermStructure> termStructure,		Volatility volatility) {			Date todaysDate = evaluationDate;			Settings::instance().evaluationDate() = todaysDate;			boost::shared_ptr<VanillaSwap> swap(new 				VanillaSwap(type, nominal, fixedSchedule, strike, fixedDayCount, floatSchedule, index, 0.0, floatDayCount, convention));			Handle<Quote> vol(boost::shared_ptr<Quote>(new SimpleQuote(volatility)));			boost::shared_ptr<PricingEngine> engine(new BlackSwaptionEngine(Handle<YieldTermStructure>(termStructure), vol));			boost::shared_ptr<Swaption> testProduct(new				Swaption(swap, boost::shared_ptr<Exercise>(new EuropeanExercise(exerciseDate)),	settlementType));			testProduct->setPricingEngine(engine);			return testProduct->NPV();	}
开发者ID:fder78,项目名称:MyQuantLib,代码行数:32,


示例8: codec_control

static rt_err_t codec_control(rt_device_t dev, rt_uint8_t cmd, void *args){    switch (cmd)    {    case CODEC_CMD_RESET:        codec_init(dev);        break;    case CODEC_CMD_VOLUME:        vol(*((uint16_t*) args));        break;    case CODEC_CMD_SAMPLERATE:        sample_rate(*((int*) args));        break;    case CODEC_CMD_EQ:        eq((codec_eq_args_t) args);        break;    case CODEC_CMD_3D:        eq3d(*((uint8_t*) args));        break;    default:        return RT_ERROR;    }    return RT_EOK;}
开发者ID:Manish-cimcon,项目名称:micro,代码行数:29,


示例9: phi

	boost::shared_ptr<Lattice> GeneralizedHullWhite::tree(                                                  const TimeGrid& grid) const{		TermStructureFittingParameter phi(termStructure());		boost::shared_ptr<ShortRateDynamics> numericDynamics(			new Dynamics(phi, speed(), vol()));		boost::shared_ptr<TrinomialTree> trinomial(			new TrinomialTree(numericDynamics->process(), grid));		boost::shared_ptr<ShortRateTree> numericTree(			new ShortRateTree(trinomial, numericDynamics, grid));		typedef TermStructureFittingParameter::NumericalImpl NumericalImpl;		boost::shared_ptr<NumericalImpl> impl =			boost::dynamic_pointer_cast<NumericalImpl>(phi.implementation());		impl->reset();		Real value = 1.0;		Real vMin = -50.0;		Real vMax = 50.0;		for (Size i=0; i<(grid.size() - 1); i++) {			Real discountBond = termStructure()->discount(grid[i+1]);			Real xMin = trinomial->underlying(i, 0);			Real dx = trinomial->dx(i);			Helper finder(i, xMin, dx, discountBond, numericTree);			Brent s1d;			s1d.setMaxEvaluations(1000);			value = s1d.solve(finder, 1e-7, value, vMin, vMax);			impl->set(grid[i], value);		}		return numericTree;	}
开发者ID:shlagbaum,项目名称:quantlib,代码行数:32,


示例10: get_volume

// [[Rcpp::export]]SEXP get_volume(std::string filename){  MincVolume vol(filename);  SEXP res = PROTECT(Rf_allocVector(REALSXP, vol.size()));  double* real_res = REAL(res);  vol.read_volume_to_buffer(real_res, MI_TYPE_DOUBLE);  UNPROTECT(1);  return(res);}
开发者ID:Mouse-Imaging-Centre,项目名称:RMINC,代码行数:9,


示例11: binaryOptionImpliedVolatilityEngine

// dumped core when we tried last// no longer under 0.3.10 and g++ 4.0.1 (Aug 2005)// [[Rcpp::export]]double binaryOptionImpliedVolatilityEngine(std::string type,                                           double value,                                           double underlying,                                           double strike,                                           double dividendYield,                                            double riskFreeRate,                                           double maturity,                                           double volatility,                                           double cashPayoff) {#ifdef QL_HIGH_RESOLUTION_DATE        // in minutes    boost::posix_time::time_duration length = boost::posix_time::minutes(maturity * 360 * 24 * 60); #else    int length = int(maturity*360 + 0.5); // FIXME: this could be better#endif    QuantLib::Option::Type optionType = getOptionType(type);    // updated again for QuantLib 0.9.0,     // cf QuantLib-0.9.0/test-suite/digitaloption.cpp    QuantLib::Date today = QuantLib::Date::todaysDate();    QuantLib::Settings::instance().evaluationDate() = today;    QuantLib::DayCounter dc = QuantLib::Actual360();    boost::shared_ptr<QuantLib::SimpleQuote> spot(new QuantLib::SimpleQuote(underlying));    boost::shared_ptr<QuantLib::SimpleQuote> qRate(new QuantLib::SimpleQuote(dividendYield));    boost::shared_ptr<QuantLib::YieldTermStructure> qTS = flatRate(today, qRate, dc);    boost::shared_ptr<QuantLib::SimpleQuote> rRate(new QuantLib::SimpleQuote(riskFreeRate));    boost::shared_ptr<QuantLib::YieldTermStructure> rTS = flatRate(today, rRate, dc);    boost::shared_ptr<QuantLib::SimpleQuote> vol(new QuantLib::SimpleQuote(volatility));    boost::shared_ptr<QuantLib::BlackVolTermStructure> volTS = flatVol(today, vol, dc);        boost::shared_ptr<QuantLib::StrikedTypePayoff>         payoff(new QuantLib::CashOrNothingPayoff(optionType, strike, cashPayoff));#ifdef QL_HIGH_RESOLUTION_DATE    QuantLib::Date exDate(today.dateTime() + length);#else    QuantLib::Date exDate = today + length;#endif            boost::shared_ptr<QuantLib::Exercise> exercise(new QuantLib::EuropeanExercise(exDate));    boost::shared_ptr<QuantLib::BlackScholesMertonProcess>         stochProcess(new QuantLib::BlackScholesMertonProcess(QuantLib::Handle<QuantLib::Quote>(spot),                                                             QuantLib::Handle<QuantLib::YieldTermStructure>(qTS),                                                             QuantLib::Handle<QuantLib::YieldTermStructure>(rTS),                                                             QuantLib::Handle<QuantLib::BlackVolTermStructure>(volTS)));    //boost::shared_ptr<PricingEngine> engine(new AnalyticEuropeanEngine(stochProcess));    boost::shared_ptr<QuantLib::PricingEngine> engine(new QuantLib::AnalyticBarrierEngine(stochProcess));    QuantLib::VanillaOption opt(payoff, exercise);    opt.setPricingEngine(engine);    return opt.impliedVolatility(value, stochProcess);}
开发者ID:blueflameenergyfinance,项目名称:rquantlib,代码行数:59,


示例12: calculate

 Real SwaptionHelper::blackPrice(Volatility sigma) const {     calculate();     Handle<Quote> vol(boost::shared_ptr<Quote>(new SimpleQuote(sigma)));     boost::shared_ptr<PricingEngine> black(new                                 BlackSwaptionEngine(termStructure_, vol));     swaption_->setPricingEngine(black);     Real value = swaption_->NPV();     swaption_->setPricingEngine(engine_);     return value; }
开发者ID:AAthresh,项目名称:quantlib,代码行数:10,


示例13: test_gliss_sin

void test_gliss_sin() {	Sine vox;	LineSegment line(3, 100, 800);	vox.set_frequency(line);	StaticVariable vol(0.1);	MulOp mul(vox, vol);	logMsg("playing gliss sin...");	run_test(mul);	logMsg("gliss sin done.");}
开发者ID:eriser,项目名称:CSL,代码行数:10,


示例14: cc

void VolRenRaycastCuda::raycast(const QMatrix4x4&, const QMatrix4x4& matView, const QMatrix4x4&){    cc(cudaGraphicsMapResources(1, &entryRes, 0));    cc(cudaGraphicsMapResources(1, &exitRes, 0));    cc(cudaGraphicsMapResources(1, &outRes, 0));    cc(cudaGraphicsMapResources(1, &volRes, 0));    cc(cudaGraphicsMapResources(1, &tfFullRes, 0));    cc(cudaGraphicsMapResources(1, &tfBackRes, 0));    cudaArray *entryArr, *exitArr, *volArr, *tfFullArr, *tfBackArr;    float *outPtr;    size_t nBytes;    cc(cudaGraphicsSubResourceGetMappedArray(&entryArr, entryRes, 0, 0));    cc(cudaGraphicsSubResourceGetMappedArray(&exitArr, exitRes, 0, 0));    cc(cudaGraphicsResourceGetMappedPointer((void**)&outPtr, &nBytes, outRes));    cc(cudaGraphicsSubResourceGetMappedArray(&volArr, volRes, 0, 0));    cc(cudaGraphicsSubResourceGetMappedArray(&tfFullArr, tfFullRes, 0, 0));    cc(cudaGraphicsSubResourceGetMappedArray(&tfBackArr, tfBackRes, 0, 0));    static std::map<Filter, cudaTextureFilterMode> vr2cu            = { { Filter_Linear, cudaFilterModeLinear }              , { Filter_Nearest, cudaFilterModePoint } };    assert(vr2cu.count(tfFilter) > 0);    updateCUDALights(matView);    cudacast(vol()->w(), vol()->h(), vol()->d(), volArr,             tfInteg->getTexFull()->width(), tfInteg->getTexFull()->height(), stepsize, vr2cu[tfFilter], tfFullArr, tfBackArr,             scalarMin, scalarMax,             frustum.getTextureWidth(), frustum.getTextureHeight(), entryArr, exitArr, outPtr);    cc(cudaGraphicsUnmapResources(1, &tfBackRes, 0));    cc(cudaGraphicsUnmapResources(1, &tfFullRes, 0));    cc(cudaGraphicsUnmapResources(1, &volRes, 0));    cc(cudaGraphicsUnmapResources(1, &entryRes, 0));    cc(cudaGraphicsUnmapResources(1, &exitRes, 0));    cc(cudaGraphicsUnmapResources(1, &outRes, 0));}
开发者ID:marwan-abdellah,项目名称:VolRen,代码行数:38,


示例15: abs

Scheme<double> Cell::phi(vector<shared_ptr<Boundary> > const &bc, int_2 bias) {  Scheme<double> sch;   if (next < 0 && prev < 0) {    sch.push_pair(id, 1.0);   } else {    // use next and prev to compute phi;    if (next >= 0 && prev >= 0) {      if (bias == 0) {	double dn = abs((grid->listCell[next]->getCoord() - getCoord())*vol()); 	double dp = abs((grid->listCell[prev]->getCoord() - getCoord())*vol()); 	sch.push_pair(prev, dn/(dn+dp)); 	sch.push_pair(next, dp/(dn+dp));       } else if (bias == -1) { 	sch.push_pair(prev, 1.0);       } else if (bias == 1) { 	sch.push_pair(next, 1.0);       }    } else {      auto bndr = (prev >= 0) ? -next-1 : -prev-1;       auto row = (prev >= 0) ? prev : next;       if (bc[bndr]->type == 0) { 	sch.push_constant(bc[bndr]->b_val);	sch.push_pair(row, bc[bndr]->a_val);       } else if (bc[bndr]->type == 1) {	auto c0 = grid->listCell[row]; 	auto norm = vol(); norm = norm/norm.abs(); 	double dx = norm*(getCoord() - c0->getCoord()); 	sch.push_constant(dx*bc[bndr]->b_val);	sch.push_pair(row, (1.0 + dx*bc[bndr]->a_val));       } else { 	cout << "Cell (Quad) :: interp :: boundary condition type not recognized " << endl; 	exit(1);       }     }  }  return sch; }
开发者ID:girdap,项目名称:girdap,代码行数:38,


示例16: test_fm_sin

void test_fm_sin() {	Sine vox, mod;	vox.set_frequency(261);	mod.set_frequency(261);	DynamicVariable fm(250, mod);	StaticVariable offset(261);	AddOp adder(offset, fm);	vox.set_frequency(adder);	StaticVariable vol(0.1);	MulOp mul(vox, vol);	logMsg("playing FM sin...");	run_test(mul);	logMsg("FM sin done.");}
开发者ID:eriser,项目名称:CSL,代码行数:14,


示例17: lock

osg::ref_ptr<ossimPlanetDtedElevationDatabase::DtedInfo> ossimPlanetDtedElevationDatabase::getInfo(const std::string& name){   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theDtedInfoMutex);   DtedFilePointerList::iterator iter = theFilePointers.find(name);   if(iter != theFilePointers.end())   {      iter->second->theTimeStamp = osg::Timer::instance()->tick();      return iter->second;   }   osg::ref_ptr<DtedInfo> info     = new DtedInfo;      ossimFilename dtedFile = ossimFilename(theLocation).dirCat(ossimFilename(name));   ifstream in;   in.open(dtedFile.c_str(), std::ios::binary|std::ios::in);   if(in.fail()) return 0;   ossimDtedVol vol(in);   ossimDtedHdr hdr(in);   ossimDtedUhl uhl(in);   in.close();      if((uhl.getErrorStatus() == ossimErrorCodes::OSSIM_ERROR))   {      return 0;   }   info->theNumLonLines  = uhl.numLonLines();   info->theNumLatPoints = uhl.numLatPoints();   info->theLatSpacing   = uhl.latInterval();   info->theLonSpacing   = uhl.lonInterval();   info->theMinLat = uhl.latOrigin();   info->theMinLon = uhl.lonOrigin();   info->theMaxLat = info->theMinLat + info->theLatSpacing*(info->theNumLatPoints-1);   info->theMaxLon = info->theMinLon + info->theLonSpacing*(info->theNumLonLines-1);   info->theTimeStamp  = osg::Timer::instance()->tick();   info->theFilename   = dtedFile;   info->theHandler = new ossimDtedHandler(dtedFile, false);   //info->theHandler->setMemoryMapFlag(false);   theFilePointers.insert(std::make_pair(name, info));   shrinkFilePointers();      return info;   }
开发者ID:star-labs,项目名称:star_ossim,代码行数:49,


示例18: calculate

    Volatility StrippedOptionletAdapter::volatilityImpl(Time length,                                                        Rate strike) const {        calculate();        std::vector<Volatility> vol(nInterpolations_);        for (Size i=0; i<nInterpolations_; ++i)            vol[i] = strikeInterpolations_[i]->operator()(strike, true);        const std::vector<Time>& optionletTimes =                                    optionletStripper_->optionletFixingTimes();        boost::shared_ptr<LinearInterpolation> timeInterpolator(new            LinearInterpolation(optionletTimes.begin(), optionletTimes.end(),                                vol.begin()));        return timeInterpolator->operator()(length, true);    }
开发者ID:21hub,项目名称:QuantLib,代码行数:15,


示例19: if

double Cell::phiVal_bcface(VecX<double> &phi, vector<shared_ptr<Boundary> > const &bc, int_2 const &bias) {  auto bndr = (prev >= 0) ? -next-1 : -prev-1;   auto row = (prev >= 0) ? prev : next;   if (bc[bndr]->type == 0) {     return bc[bndr]->b_val + phi[row]*bc[bndr]->a_val;   } else if (bc[bndr]->type == 1) {    auto c0 = grid->listCell[row];     auto norm = vol(); norm = norm/norm.abs();     double dx = norm*(getCoord() - c0->getCoord());     return dx*bc[bndr]->b_val + phi[row]*(1.0 + dx*bc[bndr]->a_val);   } else {     cout << "Cell (Quad) :: interp :: boundary condition type not recognized " << endl;     exit(1);   }}
开发者ID:girdap,项目名称:girdap,代码行数:15,


示例20: errorPrint

//------------------------------------------------------------------------------void SdFatBase::initErrorPrint(Print* pr) {  if (cardErrorCode()) {    pr->println(F("Can't access SD card. Do not reformat."));    if (cardErrorCode() == SD_CARD_ERROR_CMD0) {      pr->println(F("No card, wrong chip select pin, or SPI problem?"));    }    errorPrint(pr);  } else if (vol()->fatType() == 0) {    pr->println(F("Invalid format, reformat SD."));  } else if (!vwd()->isOpen()) {    pr->println(F("Can't open root directory."));  } else {    pr->println(F("No error found."));  }}
开发者ID:IRNAS,项目名称:bGeigieIntegrated,代码行数:16,


示例21: europeanOptionImpliedVolatilityEngine

// [[Rcpp::export]]double europeanOptionImpliedVolatilityEngine(std::string type,                                             double value,                                             double underlying,                                             double strike,                                             double dividendYield,                                             double riskFreeRate,                                             double maturity,                                             double volatility) {    const QuantLib::Size maxEvaluations = 100;    const double tolerance = 1.0e-6;      int length = int(maturity*360 + 0.5); // FIXME: this could be better    QuantLib::Option::Type optionType = getOptionType(type);    QuantLib::Date today = QuantLib::Date::todaysDate();    QuantLib::Settings::instance().evaluationDate() = today;    // new framework as per QuantLib 0.3.5    // updated for 0.3.7    QuantLib::DayCounter dc = QuantLib::Actual360();    boost::shared_ptr<QuantLib::SimpleQuote> spot(new QuantLib::SimpleQuote(underlying));    boost::shared_ptr<QuantLib::SimpleQuote> vol(new QuantLib::SimpleQuote(volatility));    boost::shared_ptr<QuantLib::BlackVolTermStructure> volTS = flatVol(today, vol, dc);    boost::shared_ptr<QuantLib::SimpleQuote> qRate(new QuantLib::SimpleQuote(dividendYield));    boost::shared_ptr<QuantLib::YieldTermStructure> qTS = flatRate(today,qRate,dc);    boost::shared_ptr<QuantLib::SimpleQuote> rRate(new QuantLib::SimpleQuote(riskFreeRate));    boost::shared_ptr<QuantLib::YieldTermStructure> rTS = flatRate(today,rRate,dc);    QuantLib::Date exDate = today + length;    boost::shared_ptr<QuantLib::Exercise> exercise(new QuantLib::EuropeanExercise(exDate));    boost::shared_ptr<QuantLib::StrikedTypePayoff> payoff(new QuantLib::PlainVanillaPayoff(optionType, strike));    boost::shared_ptr<QuantLib::VanillaOption>         option = makeOption(payoff, exercise, spot, qTS, rTS,                             volTS, Analytic,                             QuantLib::Null<QuantLib::Size>(),                             QuantLib::Null<QuantLib::Size>());    boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess>         process = makeProcess(spot, qTS, rTS,volTS);    double volguess = volatility;    vol->setValue(volguess);    return option->impliedVolatility(value, process, tolerance, maxEvaluations);}
开发者ID:alyoshkin,项目名称:rquantlib,代码行数:48,


示例22: cap_floor

	std::vector<Real> cap_floor(Date evaluationDate,		CapFloor::Type type,		Real strike,		Real nominal,		Schedule schedule,		Natural fixingDays,		BusinessDayConvention convention,		boost::shared_ptr<IborIndex> index,		boost::shared_ptr<YieldTermStructure> termStructure,		Volatility volatility) {			Date todaysDate = evaluationDate;			Settings::instance().evaluationDate() = todaysDate;			std::vector<Real> nominals = std::vector<Real>(1, nominal);					/*Make Leg*/			Leg leg = IborLeg(schedule, index)				.withNotionals(nominals)				.withPaymentDayCounter(index->dayCounter())				.withPaymentAdjustment(convention)				.withFixingDays(fixingDays);			/*Make Engine*/			Handle<Quote> vol(boost::shared_ptr<Quote>(new SimpleQuote(volatility)));			boost::shared_ptr<PricingEngine> engine = 				boost::shared_ptr<PricingEngine>(new BlackCapFloorEngine(Handle<YieldTermStructure>(termStructure), vol));			/*Pricing*/			boost::shared_ptr<CapFloor> testProduct;			switch (type) {			case CapFloor::Cap:				testProduct = boost::shared_ptr<CapFloor>(new Cap(leg, std::vector<Rate>(1, strike)));				break;			case CapFloor::Floor:				testProduct = boost::shared_ptr<CapFloor>(new Floor(leg, std::vector<Rate>(1, strike)));				break;			default:				QL_FAIL("unknown cap/floor type");			}			testProduct->setPricingEngine(engine);			std::vector<Real> rst;			rst.push_back(testProduct->NPV());					return rst;	}
开发者ID:fder78,项目名称:MyQuantLib,代码行数:47,


示例23: main

int main(int argc, char *argv[]){  int T;  scanf("%d", &T);  while(T--){    double r, R, H, V;    scanf("%lf%lf%lf%lf", &r, &R, &H, &V);    double mid, left=0 ,right=H;    while(fabs(left-right)>esp){      mid=(left+right)/2;      if(vol(r,R,mid,H)>V) right=mid;      else left=mid;    }    printf ("%.6lf/n", mid);  }  return 0;}
开发者ID:samael65535,项目名称:my_hdoj_code,代码行数:17,



注:本文中的vol函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ volume函数代码示例
C++ void函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。