I have a Fortran program which I have to convert into Java originally. I have converted the code completely but can't get appropriate resutls. The code contains lot of arithmetic calculations using double precision data type of Fortran.
I believe the data types of C++ and Java are based on same whereas of Fortran double precision is based on IEEE756. I want to know how to convert these double precision calculations into C++ normally. For example:
double precision d1 = 0.3648564D0;
d1**2 // ** indicates exponent
DSIN(d1) // sin of double precision
DCOS(d1) // cos of double precision
The above are my main concerns which I find very difficult to convert. I use sin & cos for DSIN & DCOS. But Fortran 77 deals somthing differntly with double precision. How to convert/translate that into our normal C++ application is what I am looking for.
If you can provide the same for Java that would be a plus for me, otherwise I will use the code accordingly of C++ in my Java application. I hope help from you.
You should either mark the Real and Imag fields as readonly, or make them public properties with private setters. You can append " : this()" to the constructor's signature to make C# allow property assignments in the constructor.
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"
"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)
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.