asavine / compfinance Goto Github PK
View Code? Open in Web Editor NEWCompanion code for "Modern Computational Finance: AAD and Parallel Simulations" (Antoine Savine, Wiley, 2018)
Home Page: http://www.amazon.com/gp/product/1119539455
Companion code for "Modern Computational Finance: AAD and Parallel Simulations" (Antoine Savine, Wiley, 2018)
Home Page: http://www.amazon.com/gp/product/1119539455
Whenever I open xlTest.xlsx and try and to calculate the values, Excel crashes and restarts. I am using Microsoft Excel 2016 32-bit on a Intel Corei7 7700HQ GTX 1050Ti Windows 10 Laptop. I have generated the .xll file and can see the myOwnCppFunctions functions in Excel.
The following codes will replicate the problem:
#include "AADNumber.h"
#include <chrono>
#include <iomanip>
#include <iostream>
using namespace std;
template <class T_>
T_ f(T_ x[]) {
T_ y = x[0] * 2;
return y;
}
int main() {
constexpr auto num_param = 1;
size_t n_loops = 8192;
// Using automatic adjoint differentiation
auto start = std::chrono::high_resolution_clock::now();
for (size_t i = 0; i < n_loops; ++i) {
Number::tape->mark();
Number x[num_param] = {1.0};
Number y = f(x);
y.value();
y.propagateToMark();
}
auto finish = std::chrono::high_resolution_clock::now();
std::cout << "AAD aprox. time: "
<< std::chrono::duration_cast<std::chrono::nanoseconds>(finish - start).count() / n_loops << "ns\n";
Number::tape->mark();
Number x[num_param] = {1.0};
Number y = f(x);
y.value();
y.propagateToMark();
cout << "y: " << setprecision(9) << y.value() << endl;
for (size_t i = 0; i < num_param; ++i) `{`
cout << "AAD a" << i << " = "
<< setprecision(9) << x[i].adjoint() << endl;
}
return 0;
}
The first for
loop will run out correctly and quickly. But the last set of the codes won't run out. After long time of debug, I think the problem lies at the the following lines:
Line 199 in ac718e3
end
(which is in the case we are at the last entry in the last block). Then when propagate to the mark, the following line will never be satisfied as eqau;:Line 231 in 08645c4
This line is at:
Line 306 in ac718e3
I git-cloned the CompFinance repo, built the solution with visual studio 2022 without any issue -- I just had to upgrade the windows SDK etc. (I built in debug x64 and my office 365 excel is x64 as well.)
Then I added the XLL to a blank excel file, in which I opened the test spreadsheet xlTest.xlsx.
Then, I see "#NAME?" in any cell using a function of the XLL in a formula.
These functions do not seem to be recognized by excel. (The same problem happens when building the debug xll in x86.)
I then put a breakpoint L1261 in the xlLExport.cpp file (the "entry point" of the XLL) and attached visual studio to a blank excel spreadsheet process, spreadsheet to which I added the debug x64 XLL. It indeed broke at the breakpoint I put.
The L1263 call to Excel12f worked like a charm. The L1265 call to Excel12f led to a #ifdef _WIN64 when one return(xlretFailed); Clearly, the code is x86 designed ...
The explains why all the XLL functions are not recognized by Excel, for the x64 XLL.
The #else of the #ifdef _WIN64 seems to have valid code, so I have redone the very same that preceeds, but in x86. Here, I didn't even break in the entry point ...
As I am no IT nor an XLL expert, I would be glad would someone point to a valid correction.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.