Can this run with Windows Forms instead of console? I tried adding complex.dll as a reference (in Visual Studio 2005) but got the following error ar runtime:
LoaderLock was detected
DLL 'C:\Documents and Settings\Bill\My Documents\Visual Studio 2005\Projects\TestComplex\TestComplex\bin\Release\complex.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
I'm having serious trouble getting the standard <complex> library to work in a c++.net DLL. I can't use the one here because speed is a priority in my application. But any time I use #include <complex>, my code won't compile. I get errors like: "wasteoftime error LNK2020: unresolved token (0A000006) _CxxThrowException" and "wasteoftime error LNK2020: unresolved token (0A000016) delete".
As a test I even started a new class library project, and pasted every bit of code from the download here into mine, and still got the same problem. (the original compiles fine) Help!! And make it simple please. I'm not a Programmer by trade. I'm just a Physicist.
First of all, it's managed C++. This could be written entirely using straight C#.
Secondly, why are you using std::complex?. You're instantiated the template using a double in the C++ section, so the C# and VB side doesn't benefit from the point of a template, which is to instantiate whatever type you want. Therefore, this supports the previous point that this should have been written in C# to begin with.
BTW, C++ doesn't inherently support complex types (last time I checked). This is provided by STL.
You might want to look at this link for some simplistic examples:
As this article discusses, you might also want to overload the equality operators so we can compare complex numbers.
Finally, as you say, there's a major performance hit using complex numbers with managed C++. If I were writing a complicated math function with lots of complex number calculations, I really wouldn't want to incur these performance hits.