forum.alglib.net

ALGLIB forum
It is currently Thu Mar 28, 2024 9:49 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Setting up ALGLIB in C# solution
PostPosted: Wed Feb 20, 2019 3:54 am 
Offline

Joined: Wed Feb 20, 2019 3:15 am
Posts: 2
Dear forum members,

I'm a new C# developer who did applied maths at uni, and I would love to use ALGLIB in my C# project - but I can't get it to build. This is what I've done:

  1. Downloaded C# free version from http://www.alglib.net/translator/re/alglib-3.14.0.csharp.gpl.zip
  2. Copied \csharp\net-core\src files from zip into a C# project
  3. Call code as contained in http://www.alglib.net/translator/man/manual.csharp.html#example_minbleic_d_2
  4. It wasn't working for some reason with a Class Library, so change to a Shared Library
  5. I get two duplicate assembly errors from alglib_info.cs - one for AssemblyCompanyAttribute and one for AssemblyProductAttribute
  6. Thus I remove alglib_info.cs and it builds okay and runs the example code.

I have many questions about this:

  • Why was it so hard?
  • Is the C# installation process documented anywhere?
  • Is this the normal process people follow to use ALGLIB?
  • Do people just use the Nuget dll somehow?


Top
 Profile  
 
 Post subject: Re: Setting up ALGLIB in C# solution
PostPosted: Thu Feb 21, 2019 1:05 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
Hi!

1) Can you elaborate on the specific errors reported at alglib_info.cs? It is very short .cs file, I simply do not know what can be wrong with it.

2) Generally, ALGLIB is expected to be simple to use. Either you compile .cs files (and they have to compile without additional changes) or you use precompiled assembly alglibnet2.dll.

So, I'd be glad to hear what got wrong in your case in order to fix all possible issues.


Top
 Profile  
 
 Post subject: Re: Setting up ALGLIB in C# solution
PostPosted: Wed Mar 06, 2019 11:06 pm 
Offline

Joined: Wed Feb 20, 2019 3:15 am
Posts: 2
To replicate this I created a Windows Console Project, C# .NET Framework 4.7.1 in Visual Studio Community 2017 Version 15.9.7.

I created a small example project based on the above steps (example_minbleic_d_2) into a fresh .NET Framework Console project. I ran into two issues:

  • The methods at the end of the post aren't defined!
  • After commenting out the lines below, I get the same AssemblyInfo.cs errors.

I now see what the problem is. If I make a new C# project and include all the AlgLib files (incl. alglib_info.cs) in a C# project, Visual Studio defines its own assembly info in Properties⇒AssemblyInfo.cs. That clashes with alglib_info.cs. I think this would be avoided if AlgLib distributed the C# with a VS project, or mentioned this in the documentation.

I've attached the project (without some autogenerated stuff that should regenerate if you open the solution in Visual Studio) in a 7zip (had to to get it below 1MB) in case you want to refer to it.

Code:
alglib.minbleicoptguardsmoothness(state);
alglib.minbleicoptguardgradient(state, 0.001);

...
Code:
alglib.optguardreport ogrep;
alglib.minbleicoptguardresults(state, out ogrep);
System.Console.WriteLine("{0}", ogrep.badgradsuspected); // EXPECTED: false
System.Console.WriteLine("{0}", ogrep.nonc0suspected); // EXPECTED: false
System.Console.WriteLine("{0}", ogrep.nonc1suspected); // EXPECTED: false


Attachments:
File comment: 7zip of project as given in examples, with #region defined around missing methods.
AlgLibGo.7z [792.56 KiB]
Downloaded 262 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group