C# linear algebra library - c#

Is there stable linear algebra (more specifically, vectors, matrices, multidimensional arrays and basic operations on them) library for C#?
Search yielded a few open source libraries which are either not updated for couple of years or are in an early beta stage - and Centerspace NMath. Which alternatives are worth checking?

Math.NET. We're using it in production.

See: http://en.wikipedia.org/wiki/List_of_numerical_libraries
http://www.alglib.net/ - Open source. Multi-language library.
http://www.mathdotnet.com/ - Open source. As mentioned by others. dnAnalytics is replaced by http://numerics.mathdotnet.com/ in this.
http://www.lutzroeder.com/dotnet/ - Lutz Roeder has a open source port Mapack.Net of LAPACK.
http://www.extremeoptimization.com/ - Commercial.

I am using ILNumerics.NET
www.ilnumerics.net
Very good support and stable. I don't have any comparison though.

We have evaluated nMath and were quite pleased with its programmability and speed. Their support staff even worked over a weekend to figure out a bug we found. We liked that they used Intel's Kernel Math library instead of rolling their own numerics. [Edited to add: have been using in production for years]

Few weeks ago I found a new c# library FinMath contains implementations of many various methods and techniques including basic linear algebra, such as:
Vector and Matrix implementations (easy to use high-level interfaces covering most of all BLAS functionality)
Algorithms of matrix factorizations (LU, QR, SVD, Cholesky).
And many other useful things like statistics, factor and cluster analysis, linear and quadratic programming solver and etc.
Unfortunately, it's not free, but it's extremely fast, because it uses MKL for most complex computations and at the same time it distributed as single library supports both 32bit and 64bit modes and requires no special maintenance to use, like taking care about native libraries.

Have you looked into dnAnalytics?

Although it is not updated, not open source, and not for commercial usage, one might want to check out D* from Microsoft Research. It's a very cool symbolic math library, especially for doing derivatives, but really it's a little matlab in the hands of a .NET programmer.
http://research.microsoft.com/en-us/downloads/4714703d-782c-4e37-830d-0e3b7662f743

Related

Is there a compact C# port for OpenCV?

By compact I mean one that doesn't require you to pull the entire 600+MB monster of a library with you if you only need some capture/cropping/resizing/thresholding/image arithmetic done. I know I could attempt writing that subset myself, but I don't want to reinvent the wheel. And while there are loads of OpenCV wrappers floating on NuGet, nearly all of those are bloated and/or bugged to some extent.
Ideally the subset of operations require should be determined at compile time. However, as far as I'm aware, C# compiler is unable to optimize away unused methods or classes, even under assumption of Reflection not being used. So no luck on that front, I guess.
For simple tasks like you described i would recommand using Accord.net Imaging library from NuGet http://accord-framework.net/docs/html/N_Accord_Imaging.htm,
very good performance and easy to use, also check out all of Imaging.* namespace http://accord-framework.net/docs/html/R_Project_Accord_NET.htm
Good luck!
Have you given Emgu.CV or OpenCVSharp a try? I've used them couple of years ago and they only took like 100/150 MB (the whole installation).
The final end result(your released app e.g) usually takes much less space since not everything is used. Usually one or two DLLs are used based on one's usage of course. In my case it was like 20+ MB or so. So there is nothing monstrous here to be afraid of!
I didn't like OpenCVSharp much, Emgu.CV looked much better and mature. I guess I was using Emgu.CV.3.2.0.2721. The latest version though is Emgu.CV.3.4.1.2976

GUI and backend choices for a C-code simulator

I have to make a simulator. Functionalities are mentioned below:
Inputs: Unchangeable C codes
Function: Compile and run those codes and produce outputs. Each C code may variables. Input function (time based) is given for all those variables. So, if the input c code file has a simple adder int add(a,b)/* a and b change with time with a specified fn. So, at t=0 a=1,b=2 at t=4 b may change to 6 and so on*/ I have to run the code at diff times and generate outputs. Check those o/ps too. For all those purposes, I would need a GUI too.
Need suggestions for both backend and Gui tool.
P.S: My research tells me C backend with GTK for GUI is a workable solution but GTK is too lengthy and tedious. I am confused about Qt/C++ as it may not work all that well with a c backend. C++ backend would be difficult for me to import and run those input codes (extern doesnt work all the time). I also looked at C# for GUI and the linkings to dll files but that is also mentioned in many blogs as not so feasible. Any suggestions? Thanks already.
P.P.S Please suggest open source and non-licensed tools only.
C++ can and does interface trivially with any C library or "code" out there, so that's not your concern.
I'd suggest using Qt. It comes with a nice, free IDE: Qt Creator. It offers high-level functionality that often surpasses GTK. Alas, GTK library ecosystem is very "hackable" -- the underlying object model allows all sorts of creative uses and abuses, but has IMHO a very shallow learning curve -- it'll take you much longer to "fully" understand GTK than Qt.
That's simply because GTK's underlying low-level libraries offer a lot of functionality that's taken over by the C++ language or simply hidden from view in Qt. I've found GTK's underpinnings to be more flexible, but it seems all a solution in search of a problem. Qt's/C++'s much simpler and less flexible object model works just as well and is easier to learn because there's much less of it.
Think also from the viewpoint of investing your time. Learning to be proficient in C++ is portable to other projects that merely use the same language. Learning to be proficient in glib only helps you with C projects that specifically use glib, and there's much less of them I'd think than C++ projects.
Sometimes too much of a good thing is a bad thing, and that seems -- to me -- to be the case with GTK. It's a library collection that's bottom heavy with low-level functionality, but seems to be light on higher-level abstractions. Never mind that the individual libraries are all designed with slightly different guiding principles and are essentially a loosely bound collection. That's good in theory for decoupling of the components, but makes learning much harder as there's really little in the way of common design elements in the various libraries that make up GTK.
Qt, in contrast, is pretty much a single, uniform large library split into modules that you can elect not to use.
PS. Most people use "steep learning curve" incorrectly to mean that something is hard to learn. A learning curve shows "knowledge" vs. time. If it's steep, that means you are learning fast. A shallow one means you're learning slowly.

How to use the vst sdk on the .net framework

I like making music using mostly my computer and especially love using synthesisers. There is a wide range of synthesiser plugins available online which are quite awesome. I have downloaded the VST (Virtual Studio Technology) SDK which is the platform that most plugins I know of use.
I would like to know if you can use the SDK on the .Net framework to write plugins; the only documentation and tutorials I could find is for C++ and I'm not that trusted with C++. I could learn to use C++, I taught myself C# in a week, but to use an unknown language and to learn other new concepts don't seem like a good combination.
Could anyone just give me pointers in the right direction on how to get started and even if it is possible to program it using .Net?
Regards Charl
Many beginners find VST.NET the perfect choice to start off with. It comes with some samples and with VS2008/VS2010 project templates that yield working plugins. So its a great way to start.
VST.NET provides a framework that structures and groups the VST API into manageable pieces. Out of the box it provides support for common functionality such as plugin parameters and programs.
So drop by at the VST.NET codeplex site and we'll help you get started.
BTW: To my knowledge the noise project has been abandoned and although VST.NET might not appear to be very active, I still continue to react on the questions posted on its codeplex site.
I second obiwanjacobi's sentiment. VST.Net is about the only .Net VST bridge out there that I know of and the community is great. It's an excellent framework.
https://vstnet.codeplex.com/
As for the statement: "doubt .NET platform would be adequate concerning the raw performance that a VST plugin requires". This is entirely untrue. My tests have shown that on a decent computer, .Net can very easily handle basic synthesis without even raising the CPU level above a few percent. Of course, it's not going to match C++'s performance for very complex synthesis, but in cases like this, there's no reason why you can't fall back on C++ to do the more complex stuff. In fact that is where Vst.Net excels. It would allow you to build very complex synthesis as a VST, and then leverage that in .Net.
At the same time, I think you'd be hard pressed to say definitively that .Net couldn't do very complex synthesis as well. I haven't really tried, but there's no real obstacles when you pay attention to the performance of your code, which would go for any programming platform.
On top of all that, there is now .Net Native to add to the picture. .Net Native has the potential to be AS fast as C++.
I remember hearing of noisevst and VST.NET, two C# wrappers for the VST API but I don't know how stable they are. And I really doubt .NET platform would be adequate concerning the raw performance that a VST plugin requires.
So I would recommend learning a little bit of C++. Yes, C++ is so big and complex that nobody on earth knows every feature of it. But for plugin development purposes all you need to do is to implement a couple of methods. You can start from the provided samples in the VST API. Audio DSP code wouldn't look much different if you'd use C#, C++ or any other mainstream language anyway.
If you also want to implement a GUI for your plugin, that's where the things start getting hairy. VSTGUI is simple but lacks many features. I can recommend WDL's iPlug framework but that would require a little more than basic C++.

Where can I find simple beta cdf implementation

I need to use beta distribution and inverse beta distribution in my project.
There is quite good but complicated implementation in GSL, but I don't want to use such a big library only to get one function.
I would like to either, implement it on my own or link some simple library. Do you know any sources that could help me? I'm looking for any books/articles about numerical approximation of beta CDF and its inverse, libraries where it could be implemented. Any other suggestions would be also appreciated.
Any programming language, but C++/C# preffered.
Here is a managed C++ library that has the beta CDF and its inverse: DCDFLIB. It's a port of the popular Fortran/C library of the same name. If you have questions about how to use the code, I'm familiar with it and can help.
You could take DCDFLIB and delete what you don't use, but it's still going to be big. Implementing the beta CDF and its inverse accurately for a wide range of parameters is complicated.
Well, I found some other libraries/implementations:
Boost library for C++
Some code in C# at google code
And simple but not exactly perfect implementation of inverse beta cdf
Fifteen seconds of googling lead to this page at fsu.edu with code for the CDF of the non-central Beta distribution in several languages.
That said, I'd re-consider your stance on the GNU GSL as that is also a pretty high-quality and well-vetted library.

Comparing C# and Java

I learned Java in college, and then I was hired by a C# shop and have used that ever since. I spent my first week realizing that the two languages were almost identical, and the next two months figuring out the little differences. For the most part, was I noticing the things that Java had that C# doesn't, and thus was mostly frustrated. (example: enum types which are full-fledged classes, not just integers with a fresh coat of paint) I have since come to appreciate the C# world, but I can't say I knew Java well enough to really contrast the two so I'm curious to get a community cross-section.
What are the relative merits and weaknesses of C# and Java? This includes everything from language structure to available IDEs and server software.
Comparing and contrasting the languages between the two can be quite difficult, as in many ways it is the associated libraries that you use in association with the language that best showcases the various advantages of one of another.
So I'll try to list out as many things I can remember or that have already been posted and note who I think has the advantage:
GUI development (thick or thin). C# combined with .NET is currently the better choice.
Automated data source binding. C# has a strong lead with LINQ, also a wealth of 3rd part libraries also gives the edge
SQL connections. Java
Auto-boxing. Both languages provide it, but C# Properties provides a better design for it in regards to setters and getters
Annotation/Attributes. C# attributes are a stronger and clear implementation
Memory management - Java VM in all the testing I have done is far superior to CLR
Garbage collection - Java is another clear winner here. Unmanaged code with the C#/.NET framework makes this a nightmare, especially when working with GUI's.
Generics - I believe the two languages are basically tied here... I've seen good points showing either side being better. My gut feeling is that Java is better, but nothing logic to base it on. Also I've used C# generics ALLOT and Java generics only a few times...
Enumerations. Java all the way, C# implementation is borked as far as I'm concerned.
XML - Toss up here. The XML and serialization capabilities you get with .NET natively beats what you get with eclipse/Java out of the box. But there are lots of libraries for both products to help with XML... I've tried a few and was never really happy with any of them. I've stuck with native C# XML combined with some custom libraries I made on my own and I'm used to it, so hard to give this a far comparison at this point...
IDE - Eclipse is better than Visual Studio for non-GUI work. So Java wins for non-GUI and Visual Studio wins for GUI...
Those are all the items I can't think off for the moment... I'm sure you can literally pick hundreds of items to compare and contrasting the two. Hopefully this lists is a cross section of the more commonly used features...
One difference is that C# can work with Windows better. The downside of this is that it doesn't work well with anything but Windows (except maybe with Mono, which I haven't tried).
Another thing to keep in mind, you may also want to compare their respective VMs.
Comparing the CLR and Java VM will give you another way to differentiate between the two.
For example, if doing heavy multithreading, the Java VM has a stronger memory model than the CLR (.NET's equivalent).
C# has a better GUI with WPF, something that Java has traditionally been poor at.
C# has LINQ which is quite good.
Otherwise the 2 are practically the same - how do you think they created such a large class library so quickly when .NET first came out? Things have changed slightly since then, but fundamentally, C# could be called MS-Java.
Don't take this as anything more than an opinion, but personally I can't stand Java's GUI. It's just close enough to Windows but not quite, so it gets into an uncanny valley area where it's just really upsetting to me.
C# (and other .Net languages, I suppose) allow me to make programs that perfectly blend into Windows, and that makes me happy.
Of course, it's moot if we're not talking about developing a desktop application...
Java:
Enums in Java kick so much ass, its not even funny.
Java supports generic variance
C#:
C# is no longer limited to Windows (Mono).
The lack of the keyword internal in Java is rather disappointing.
You said:
enum types which are full-fledged classes, not just integers with a fresh coat of paint
Have you actually looked at the output? If you compile an application with enums in in then read the CIL you'll see that an enum is actually a sealed class deriving from System.Enum.
Tools such as Red-Gate (formerly Lutz Roeder's) Reflector will disassemble it as close to the orginal C# as possible so it may not be easily visible what is actually happening under the hood.
As Elizabeth Barrett Browning said: How do I love thee? Let me count the ways.
Please excuse the qualitative (vs. quantitative) aspect of this post.
Comparing these 2 languages (and their associated run-times) is very difficult. Comparisons can be at many levels and focus on many different aspects (such as GUI development mentioned in earlier posts). Preference between them is often personal and not just technical.
C# was originally based on Java (and the CLR on the JRE) but, IMHO, has, in general, gone beyond Java in its features, expressiveness and possibly utility. Being controlled by one company (vs. a committee), C# can move forward faster than Java can. The differences ebb and flow across releases with Java often playing catch up (such as the recent addition of lambdas to Java which C# has had for a long time). Neither language is a super-set of the other in all aspects as both have features (and foibles) the other lacks.
A detailed side-by-side comparison would likely take several 100s of pages. But my net is that for most modern business related programming tasks they are similar in power and utility. The most critical difference is probably in portability. Java runs on nearly all popular platforms, which C# runs mostly only on Windows-based platforms (ignoring Mono, which has not been widely successful). Java, because of its portability, arguably has a larger developer community and thus more third party library and framework support.
If you feel the need to select between them, your best criteria is your platform of interest. If all your work will run only on Windows systems, IMHO, C#/CLR, with its richer language and its ability to directly interact with Windows' native APIs, is a clear winner. If you need cross system portability then Java/JRE is a clear winner.
PS. If you need more portable jobs skills, then IMHO Java is also a winner.

Categories