Skip to content

Commit

Permalink
AAD-ready on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
auto-differentiation-dev committed Jul 18, 2022
1 parent 811f35a commit 2458de3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/xad.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,26 @@ jobs:
run: |
cd build
.\qlxad\test-suite\Release\quantlib-xad-test-suite --log_level=message
xad-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Setup
run: |
brew install boost
- name: Compile
env:
CXXFLAGS: -O2 -stdlib=libc++ -mmacosx-version-min=10.9
run: |
mkdir build
cd build
cmake .. -DQL_USE_AAD=XAD
make -j 2
- name: Test QuantLib
run: |
cd build
./test-suite/quantlib-test-suite --log_level=message
- name: Test QlXad
run: |
cd build
./qlxad/test-suite/quantlib-xad-test-suite --log_level=message
2 changes: 1 addition & 1 deletion ql/math/autocovariance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace QuantLib {
Array tmp(ft.size(), 0.0);
std::complex<Real> z = std::complex<Real>();
for (Size i=0; i<ft.size(); ++i) {
tmp[i] = std::norm<Real>(ft[i]);
tmp[i] = std::norm(ft[i]);
ft[i] = z;
}
fft.transform(tmp.begin(), tmp.end(), ft.begin());
Expand Down
4 changes: 2 additions & 2 deletions ql/pricingengines/vanilla/exponentialfittinghestonengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
namespace QuantLib {

namespace {
const Real values4[][129] = {
const double values4[][129] = {
{ 0.0, 234.8095791713261, 218.0318519353285, 204.6720284850595, 193.1511360370731, 182.8582046914314, 173.4749468364244, 164.8086026551506, 156.7310751326711, 149.1516659000495, 142.0031214899315, 135.2337879495259, 128.8028787692377, 122.6774602685386, 116.8304450513065, 111.2392075244396, 105.8845994688, 100.750231969514, 95.82194001552078, 91.08737561313309, 86.53569334945649, 82.15730377831932, 77.94367743446313, 73.8871872324829, 69.98098037714679, 66.21887325124759, 62.59526440015139, 59.10506191901711, 55.74362241327837, 52.50669934134626, 49.3903990256247, 46.39114297861616, 43.5056354664215, 40.73083544445857, 38.06393216564644, 35.50232389114117, 33.04359923643779, 30.68552076752596, 28.42601052750101, 26.26313722711847, 24.19510487593323, 22.22024266595088, 20.33699594873022, 18.5439181708592, 16.83966365264874, 15.22298111152472, 13.6927078455475, 12.24776450424429, 10.88715038388637, 9.60993919279611, 8.415275239483032, 7.302370002587396, 6.270499046923647, 5.318999254496381, 4.447266343313092, 3.654752650207289, 2.940965156725249, 2.305463739307505, 1.747859626059435, 1.267814040775252, 0.8650370046481092, 0.5392862212279848, 0.290365744018042, 0.11812251209679, 0.02241587414672291, 19.7904730415389, 14.64287849684275, 12.29787550435821, 10.83820345905683, 9.798443299108831, 8.999307532256775, 8.354314484533429, 7.815638985966243, 7.354263948608144, 6.951358017695886, 6.594058135618385, 6.27321659221623, 5.98211240191717, 5.715672861918123, 5.469981785549187, 5.24195701287718, 5.029132122798146, 4.829504600649047, 4.641427702702372, 4.463531827796793, 4.294666286068176, 4.133855463009227, 3.980265333061287, 3.833177538891964, 3.691969085114964, 3.556096255713026, 3.42508174873024, 3.298504289717459, 3.175990175055341, 3.057206332403495, 2.941854584510562, 2.829666875458116, 2.720401272597374, 2.613838598180361, 2.509779575606303, 2.408042398876443, 2.308460652136126, 2.210881520418866, 2.115164243858015, 2.02117877644997, 1.928804617452471, 1.837929789102533, 1.748449938844707, 1.660267547903212, 1.573291230997683, 1.487435114419195, 1.40261828167578, 1.318764277552648, 1.235800662793408, 1.153658612733963, 1.072272554169656, 0.9915798355270596, 0.9115204260895459, 0.8320366406138465, 0.7530728862177118, 0.674575428995979, 0.5964921786168993, 0.5187724907443817, 0.441366991509971, 0.364227443636659, 0.2873067415931395, 0.2105595201900571, 0.1339474500125191, 0.05752803788948557 },
{ 0.05, 234.2683512992485, 217.5652513510042, 204.2608770758455, 192.7849756796624, 182.5300291920975, 173.1795829183935, 164.5420057558895, 156.4899620596637, 148.9332999194404, 141.8051761627553, 135.054255630516, 128.6400062658957, 122.5297019371973, 116.6964275848426, 111.1177028636259, 105.7745035286647, 100.6505476345717, 95.73176333754835, 91.00588445721034, 86.46213794280316, 82.09099875973048, 77.88399510262698, 73.83355176333369, 69.93286283271761, 66.17578724116877, 62.55676228595253, 59.07073147343707, 55.7130838637403, 52.47960273993026, 49.36642189821734, 46.36998821411457, 43.48702941342039, 40.71452618812902, 38.04968796179686, 35.48993173795288, 33.03286356724488, 30.67626225039232, 28.41806495932832, 26.25635451167667, 24.18934807659869, 22.21538712511386, 20.33292846683142, 18.54053623886463, 16.83687473249949, 15.22070195972028, 13.69086387555865, 12.2462891839139, 10.88598466437716, 9.609030965992248, 8.414578821054335, 7.301845638188178, 6.270112439227548, 5.318721108968854, 4.447071930797849, 3.6546213845556, 2.940880185829794, 2.305411548018228, 1.747829649558985, 1.267798287078069, 0.865029684961297, 0.5392833869746307, 0.2903649293765078, 0.11812238095134, 0.02241587037546683, 19.69916274343335, 14.58017388582429, 12.24845416104839, 10.79710829783229, 9.763275690870078, 8.968668805528184, 8.327294608293961, 7.791601365305953, 7.332739711343556, 6.931988251617563, 6.576559758402458, 6.257360936613612, 5.967711123308542, 5.702568297969066, 5.458040145869966, 5.231063435608646, 5.019187002125522, 4.820420803212686, 4.633128420459334, 4.455948896052475, 4.287738847729877, 4.127528894736217, 3.974490372420735, 3.827909567821301, 3.687167536378474, 3.551724117193278, 3.42110514631576, 3.294892133905787, 3.17271385964117, 3.054239476077969, 2.939172808068394, 2.827247608748426, 2.718223586479143, 2.611883057621558, 2.508028110758968, 2.406478191516223, 2.307068035300078, 2.209645889430603, 2.114071977225534, 2.020217165357372, 1.927961802763817, 1.8371947049587, 1.747812262068525, 1.659717652541767, 1.572820147423197, 1.487034492492155, 1.402280357539424, 1.318481843686772, 1.235567041002679, 1.153467629790401, 1.072118519862915, 0.9914575229087829, 0.9114250537247282, 0.8319638566759891, 0.7530187542860148, 0.6745364154297774, 0.596465141400492, 0.5187546697087099, 0.4413559998512321, 0.3642212606638437, 0.2873037066466006, 0.2105583276842426, 0.1339471455650227, 0.05752801551838103 },
{ 0.1, 232.6616279835473, 216.1806101061962, 203.0409996627243, 191.6986529354063, 181.5563838387744, 172.3032201020834, 163.7509038389486, 155.7743725917344, 148.2851042961916, 141.2174782034082, 134.5211079447418, 128.1562179664579, 122.0906985643736, 116.298146028833, 110.7565105958126, 105.4471352263999, 100.3540545689635, 95.46347233134401, 90.76336415475587, 86.24317075960123, 81.89355730823829, 77.70622219186564, 73.673743285077, 69.7894530036334, 66.04733578606166, 62.44194323407706, 58.96832330580525, 55.62196080004967, 52.39872699313946, 49.29483675572285, 46.30681182898199, 43.43144920869808, 40.66579379303607, 38.00711461136637, 35.45288407815874, 33.00075981622926, 30.6485686735149, 28.39429262166695, 26.23605627654957, 24.17211582282957, 22.20084915926591, 20.32074710960723, 18.53040556739845, 16.82851846242974, 15.21387145278349, 13.68533626004034, 12.24186557666808, 10.88248848431603, 9.606306329980236, 8.412489014037567, 7.300271650171452, 6.268951562391603, 5.317885588814585, 4.446487665722357, 3.654226668717093, 2.940624490552334, 2.305254337329934, 1.747739225754234, 1.267750662450325, 0.8650074760724744, 0.5392747280127196, 0.2903624013083418, 0.1181219533036879, 0.02241585257353072, 19.42718031519661, 14.39373856919362, 12.10168617784474, 10.67516752160333, 9.658985192010958, 8.877846847619767, 8.247222882374721, 7.720380243268126, 7.268971531644766, 6.874604276997105, 6.524717945902563, 6.210381807219462, 5.925035571103697, 5.663728737701915, 5.422640138170565, 5.198762903932961, 4.989691255635626, 4.7934722209592, 4.608500040590655, 4.433439396985166, 4.267168565027318, 4.108736621179749, 3.957330758966992, 3.81225099163693, 3.672890336264371, 3.538719121118826, 3.409272433509946, 3.284139987004636, 3.162957872124423, 3.045401787571403, 2.931181445688388, 2.820035916979011, 2.711729731425256, 2.606049594111934, 2.50280160285089, 2.401808878610175, 2.302909537400565, 2.205954946162037, 2.110808216083759, 2.01734289539004, 1.925441830458653, 1.834996169603027, 1.74590448824573, 1.65807201776635, 1.571409963197856, 1.485834897307841, 1.401268220540341, 1.317635677893176, 1.234866925130263, 1.152895137830144, 1.071656657692984, 0.9910906713032496, 0.9111389172047534, 0.8317454177197424, 0.7528562324755021, 0.6744192311673117, 0.5963838838759056, 0.5187010688415302, 0.4413229019707581, 0.3642026077250811, 0.2872945188119721, 0.2105546891305471, 0.1339461934036071, 0.05752793175097446 },
Expand Down Expand Up @@ -277,7 +277,7 @@ namespace QuantLib {
const Real omega = moneyness_[n];
u = std::fabs(omega / freq);
}
const Size order = (sizeof(values4[0])/sizeof(Real) - 1)/2;
const Size order = (sizeof(values4[0])/sizeof(values4[0][0]) - 1)/2;

Real s = 0.0;
for (Size i=0; i < order; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion test-suite/fastfouriertransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void FastFourierTransformTest::testInverse() {

fft.inverse_transform(x.begin(), x.end(), ft.begin());
for (Size i=0; i<nFrq; ++i) {
tmp[i] = std::norm<Real>(ft[i]);
tmp[i] = std::norm(ft[i]);
ft[i] = z;
}
fft.inverse_transform(tmp.begin(), tmp.end(), ft.begin());
Expand Down

0 comments on commit 2458de3

Please sign in to comment.