91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 5KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-05-18
  • 語(yǔ)言: C/C++
  • 標(biāo)簽: blackScholes??

資源簡(jiǎn)介

C++隱含波動(dòng)率計(jì)算函數(shù)庫(kù)

資源截圖

代碼片段和文件信息

//--------------------------------------------------------------------------------------
//?Copyright?(c)?Microsoft?Corp.?
//
//?File:?BlackScholes.cpp
//
//?Licensed?under?the?Apache?License?Version?2.0?(the?“License“);?you?may?not?use?this?
//?file?except?in?compliance?with?the?License.?You?may?obtain?a?copy?of?the?License?at?
//?http://www.apache.org/licenses/LICENSE-2.0??
//??
//?THIS?CODE?IS?PROVIDED?*AS?IS*?BASIS?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND?
//?EITHER?EXPRESS?OR?IMPLIED?INCLUDING?WITHOUT?LIMITATION?ANY?IMPLIED?WARRANTIES?OR?
//?CONDITIONS?OF?title?FITNESS?FOR?A?PARTICULAR?PURPOSE?MERCHANTABLITY?OR?NON-INFRINGEMENT.?
//??
//?See?the?Apache?Version?2.0?License?for?specific?language?governing?permissions?and?
//?limitations?under?the?License.
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------
//?Implements?Black?Scholes?sample?in?C++?AMP
//?Refer?README.txt
//--------------------------------------------------------------------------------------

#include?“blackscholes.h“

#include?
#include?
#include?
#include?

blackscholes::blackscholes(float?_volatility?float?_riskfreerate?int?_size)
{
????data_size?=?_size;
????riskfreerate?=?_riskfreerate;
????volatility?=?_volatility;

????stock_price.resize(data_size);
????option_strike.resize(data_size);
????option_years.resize(data_size);
????call_result_amp.resize(data_size);?
????put_result_amp.resize(data_size);

????srand(2012);

????for?(int?i?=?0;?i?????{
????????stock_price[i]?=?100.0f?*?(((float)rand())?/?RAND_MAX);
????????option_strike[i]?=?stock_price[i]?*?((float)rand())?/?RAND_MAX;
????????option_years[i]?=?20.0f?*?((float)rand())?/?RAND_MAX;
????????call_result_amp[i]?=?0;
????????put_result_amp[i]?=?0;
????}
}

blackscholes::~blackscholes()
{

}

void?blackscholes::execute()
{
????const?array?a_stock_price(data_size?stock_price.begin());
????const?array?a_option_strike(data_size?option_strike.begin());
????const?array?a_option_years(data_size?option_years.begin());
????array?a_call_result(data_size);
????array?a_put_result(data_size);

????float?R?=?riskfreerate;
????float?V?=?volatility;

????assert((data_size%BSCHOLES_TILE_SIZE)?==?0);

????parallel_for_each(extent<1>(data_size).tile()
????[=?&a_stock_price?&a_option_strike?&a_option_years?&a_call_result?&a_put_result]?(tiled_index?tidx)?restrict(amp)
????{
????????float?S?=?a_stock_price(tidx.global[0]);
????????float?X?=?a_option_strike(tidx.global[0]);
????????float?T?=?a_option_years(tidx.global[0]);
????????????
????????float?sqrtT?=?fast_math::sqrtf(T);
????????float?d1?=?(fast_math::logf(S?/?X)?+?(R?+?0.5f?*?V?*?V)?*?T)?/?(V?*?sqrtT);
????????float?d

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????6126??2013-02-11?10:09??BlackScholes\BlackScholes.cpp
?????文件????????2032??2013-02-11?09:59??BlackScholes\BlackScholes.h
?????文件????????7560??2013-02-11?09:57??BlackScholes\BlackScholes.vcxproj
?????文件????????1694??2012-11-09?13:39??BlackScholes\README.txt

評(píng)論

共有 條評(píng)論

相關(guān)資源