Quantcast
Viewing all 971 articles
Browse latest View live

New Post: Getting C# examples to compile in VS2012

Thanks Cristoph, that indeed takes things a bit further. I now get following build error: error CS0012: The type 'System.Numerics.Complex' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
However, if I add:
using MathNet.Numerics.LinearAlgebra.Complex;
error CS0104: 'DenseMatrix' is an ambiguous reference between 'MathNet.Numerics.LinearAlgebra.Double.DenseMatrix' and 'MathNet.Numerics.LinearAlgebra.Complex.DenseMatrix'

And besides, this does not solve the original error either. So the Complex include must be somewhere else. System.Numerics does not exist as an inlude.
The example doesn't provide any clues, so I am a bit at a loss.

Commented Unassigned: is gammaupperincomplete correct? [5732]

When using the following values...

double a = 0;
double x = 0.2247;
double ans = MathNet.Numerics.SpecialFunctions.GammaUpperIncomplete(a, x);

...I am getting an answer of infinity.

This site: http://keisan.casio.com/exec/system/1180573447

...gives me the correct answer of 1.128

When I numerically integrate I also get an answer of approx. 1.128

What am I doing wrong when using your incomplete gamma function? The problem centers around using a value for a of zero.

Thanks! Love your math library!


Comments: GammaUpperIncomplete currently only supports a > 0 and x > 0 (according to docs). For a = 0 this functions becomes the exponential integral (Ei) function. It would be great if we could add this function (and extend GammaUpperIncomplete to a=0) to support this case. Could you open an issue on this over at Github https://github.com/mathnet/mathnet-numerics? We don't use Codeplex for issues. Thanks, Christoph

Closed Unassigned: is gammaupperincomplete correct? [5732]

When using the following values...

double a = 0;
double x = 0.2247;
double ans = MathNet.Numerics.SpecialFunctions.GammaUpperIncomplete(a, x);

...I am getting an answer of infinity.

This site: http://keisan.casio.com/exec/system/1180573447

...gives me the correct answer of 1.128

When I numerically integrate I also get an answer of approx. 1.128

What am I doing wrong when using your incomplete gamma function? The problem centers around using a value for a of zero.

Thanks! Love your math library!


Comments: Please use Github instead. Thanks.

Updated Wiki: Home

Math.NET Numerics

Numerics is the numerical foundation of the Math.NET project, aiming to provide methods and algorithms for numerical computations in science, engineering and every day use. Covered topics include special functions, linear algebra, probability models, random numbers, interpolation, integral transforms and more.

Math.NET Numerics targets Microsoft .Net 4.0 and Mono, and in addition to a purely managed implementation also supports native hardware optimization.

Math.NET Numerics Website

Please report issues over at GitHub instead of here. Thanks.

New Post: Is anyone interested in Point2D & 3D, Vector2D & 3D and coordinatesystem etc?

Hi Johan,

Sorry for the delay and the confusion. I see that you have seen the new repository, let's coordinate there instead of here.

Thanks,
Christoph

New Post: Getting C# examples to compile in VS2012

I've just:
  • created an empty project in VS 2012
  • added the v3.0.2 NuGet package of Math.NET Numerics
  • copied over the body of the Main function you pasted
  • Added the "MathNet.Numerics.LinearAlgebra.Double" namespace
and it worked fine for me. I've uploaded it to http://1drv.ms/1vo80rz (also includes a small variation of the example since the custom formatting is no longer needed).

Does this version work for you? Can you spot a difference between this and your project? I'm certainly interested in what exactly is causing your problem.

Thanks,
Christoph

Created Unassigned: Report Issues at GitHub Instead [5733]

https://github.com/mathnet/mathnet-numerics/issues?state=open

Thanks!

Edited Unassigned: Please report Issues at GitHub Instead [5733]

https://github.com/mathnet/mathnet-numerics/issues?state=open

Thanks!

Edited Unassigned: Please report Issues at GitHub Instead [5733]

https://github.com/mathnet/mathnet-numerics/issues

Thanks!

New Post: Getting C# examples to compile in VS2012

What was missing is a reference to System.Numerics which is apparently required, but not referenced by default (in my case / VS config) when I create a new project. System.Numerics is part of VS and can be found in the Reference manager under Assemblies\Framework. With that included it runs fine.

Below I have copied your improved example to share the new formatting with others.
using System;
using System.Globalization;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;

namespace MathNetNumericsExamplesVS11
{
    class Program
    {
        static void Main(string[] args)
        {
            OriginalExample();
            MoreReasonableExample();

            Console.ReadKey();
        }

        static void OriginalExample()
        {
            // Format matrix output to console
            // NOTE: this is no longer, Math.NET Numerics now has decent matrix formatting,
            //       see MoreReasonableExample
            var formatProvider = (CultureInfo)CultureInfo.InvariantCulture.Clone();
            formatProvider.TextInfo.ListSeparator = " ";

            // Create square symmetric matrix
            var matrix = DenseMatrix.OfArray(new[,] { { 1.0, 2.0, 3.0 }, { 2.0, 1.0, 4.0 }, { 3.0, 4.0, 1.0 } });
            Console.WriteLine(@"Initial square symmetric matrix");
            Console.WriteLine(matrix.ToString("#0.00\t", formatProvider));
            Console.WriteLine();

            // Perform eigenvalue decomposition of symmetric matrix
            var evd = matrix.Evd();
            Console.WriteLine(@"Perform eigenvalue decomposition of symmetric matrix");

            // 1. Eigen vectors
            Console.WriteLine(@"1. Eigen vectors");
            Console.WriteLine(evd.EigenVectors.ToString("#0.00\t", formatProvider));
            Console.WriteLine();
        }

        static void MoreReasonableExample()
        {
            // Create square symmetric matrix
            var matrix = Matrix<double>.Build.DenseOfArray(new[,] { { 1.0, 2.0, 3.0 }, { 2.0, 1.0, 4.0 }, { 3.0, 4.0, 1.0 } });
            Console.WriteLine(@"Initial square symmetric matrix");
            Console.WriteLine(matrix.ToString("G3"));
            Console.WriteLine();

            // Perform eigenvalue decomposition of symmetric matrix
            var evd = matrix.Evd();
            Console.WriteLine(@"Perform eigenvalue decomposition of symmetric matrix");

            // 1. Eigen vectors
            Console.WriteLine(@"1. Eigen vectors");
            Console.WriteLine(evd.EigenVectors.ToString("G3"));
            Console.WriteLine();
        }
    }
}
Thanks for helping me out! Jan

New Post: Getting C# examples to compile in VS2012

Thanks for the update.

Quick question - how did you add the reference to the Math.NET assemblies? When using NuGet the reference to System.Numerics is supposed to be added automatically on those platforms where it is required (not all of them, since some do not support it) but maybe that was not working properly in your case.

Thanks,
Christoph

New Post: Is MathNet.Numerics depends on System.Threading.dll?

I am using polynomial regression method from MathNet, and I got error message as follwing

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'MathNet.Numerics.LinearAlgebra.Matrix1' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MathNet.Numerics.LinearAlgebra.BuilderInstance1' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at MathNet.Numerics.LinearAlgebra.BuilderInstance`1..cctor()

=== Pre-bind state information ===
LOG: User = BROOKHAVEN\lzhao
LOG: DisplayName = System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Bicw_Dev/Bicw32/ParticleSolutions/
LOG: Initial PrivatePath = NULL

Calling assembly : MathNet.Numerics, Version=3.0.2.0, Culture=neutral, PublicKeyToken=null.

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Bicw_Dev\Bicw32\ParticleSolutions\uRheApp.exe.Config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Bicw_Dev/Bicw32/ParticleSolutions/System.Threading.DLL.
LOG: Attempting download of new URL file:///C:/Bicw_Dev/Bicw32/ParticleSolutions/System.Threading/System.Threading.DLL.
LOG: Attempting download of new URL file:///C:/Bicw_Dev/Bicw32/ParticleSolutions/System.Threading.EXE.
LOG: Attempting download of new URL file:///C:/Bicw_Dev/Bicw32/ParticleSolutions/System.Threading/System.Threading.EXE.

I have no idea what cause this problem. Could anyone help? Thanks!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

New Post: Is MathNet.Numerics depends on System.Threading.dll?

Are you targeting .Net 3.5? Only the .Net 3.5 version is supposed to depend on that assembly of the TaskParallelLibrary NuGet package.

We should make this explicit in the NuGet package with a platform-dependent dependency if possible, so the TaskParallelLibrary is added automatically if, and only if, the project is targeting .Net 3.5.

Thanks,
Christoph

New Post: Is MathNet.Numerics depends on System.Threading.dll?

Hi, Christoph

Yes. The target framework is .Net 3.5.
After I add the reference Task Parallel Library for .Net 3.5, problem solved. Thanks a lot!!!

One more question :)
Before I add MathNet.Numerics into my project. I tested it in a simple project, just to test polynomial regression function, and it works fine. I am just curious, what could cause to throw the exception that could not load the assembly System.Threading ?

Thanks!

Liang

New Post: Getting C# examples to compile in VS2012

I included the reference in the project separately, as I normally do with other .dlls. Next time I will use the NuGet method.

New Post: Is MathNet.Numerics depends on System.Threading.dll?

Was the simple test project by chance targeting .Net 4?

Polynomial regression is currently implemented with linear algebra routines, some of which are parallelized and thus cause the threading infrastructure to be loaded, if not loaded yet. On .Net 4 and higher we do parallelization using the .Net base class libraries directly, but on .Net 3.5 we have to use that package which ports some of the missing tools back to .Net 3.5.

Thanks,
Christoph

New Post: Is MathNet.Numerics depends on System.Threading.dll?

Again, you are right. The testing project targeting .Net 4.
Seems TPL is required if target framework is .Net 3.5.

Thanks for the answer!

Best Regards,
Liang

New Post: Compiler error calling MathNet Numerics DelimitedWriter.WriteFile

I'm trying to write a DenseMatrix object to a csv file using DelimitedWriter like so:
DelimitedWriter.WriteFile(originalData, "written.csv", ",");
A red line would appear saying that the type arguments for the method cannot be inferred from the usage and to specify the type arguments explicitly. So I tried doing this:
DelimitedWriter.WriteFile<Double>(originalData, "written.csv", ",");
to which I got, "The best overloaded match... has some invalid arguments".

And this:
DelimitedWriter.WriteFile<Double>(originalData<Double>, "written.csv", ",");
to which I got originalData cannot be used with type arguments. I also tried casting originalData as a Matrix (rather than DenseMatrix) but that did not work either. I'm not sure what I'm missing here. Someone on Stack Overflow said that this may be due to an issue with the new version -- when he reverted to his old version, it worked fine. Any ideas?

New Post: Transpose a vector

Hello all,

is it really not possible to transpose a vector?
i mean
A = new Vector
A_transposed = A'
shouldnt be a big problem? Or with other words this is needed
really often, isnt it?

regards,
michael

New Post: Transpose a vector

It doesn't make sense in Math.NET Numerics.
A vector here is neither a row-vector nor column-vector, unlike in Matlab.
It is just closer to a c# single dimension array.
If you need to distinguish, you can always use a 1xN or Nx1 Matrix.
You can get from a Vector to the corresponding Row or Column Matrix using:
Vector.ToRowMatrix() and Vector.ToColumnMatrx()
Viewing all 971 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>