pltaylor
05-08-2009, 01:49 PM
I am writing an app in C# and wanted to use a laguere method for finding the roots so I created a C++ dll using the code in the recipes book and compiled it. When I try to use the functions in the laguere dll they do not appear in my C# app. I believe it is because the nr3.h is not .net or CLR compliant. Does this make sense and has anybody figured a workaround for it?
thanks
ichbin
05-08-2009, 03:25 PM
The C++ in NR is not managed C++, so when you compile it you will not get a managed DLL.
Some possible courses of action:
1. Convert NR to managed C++. This is a big task.
2. Study the Laguerre root-finder algorithm and write your own version in C#. This algorithm is straightforward, small, and self-contained, so this shouldn't be too hard. But you will have to repeat the procedure the next time you want to use a different NR algorithm.
3. Use P/Invoke to call into the native DLL. Some useful documentation is here (http://msdn.microsoft.com/en-us/library/aa446536.aspx). You will get a slight perf hit, and P/Invoke is relatively obscure and advanced technique, but it will work.