Quantcast
Channel: Math.NET Numerics
Viewing all 971 articles
Browse latest View live

Closed Issue: SparseMatrix doesn't add to/subtract from zero components [5666]

$
0
0
Hi,

I noticed a bug using your otherwise quite nice library with sparse matrices.
Currently, if you do the following:

var m1 = new SparseMatrix(1, 3);
var m2 = new SparseMatrix(new double[,] { { 0, 1, 1 } });

var sum1 = m1 + m2;
var sum2 = m2 + m1;

var diff = m1 - m2;

Then sum1 will give you { 0, 0, 0 } (instead of { 0, 1, 1 }) whereas sum2 will have the correct result; diff will also stay incorrectly equal to zero.

I have fixed the corresponding SparseMatrix.cs file by adding the following at the end of the for loop in the else block for both DoAdd() and DoSubtract():

// Get the begin / end index for the current row of the 'other' sparse matrix
var sparseOther = other as SparseMatrix;
var startIndexOther = sparseOther._rowIndex[i];
var endIndexOther = i < sparseOther._rowIndex.Length - 1 ? sparseOther._rowIndex[i + 1] : sparseOther.NonZerosCount;

// Look for 'forgotten' components
for (var j = startIndexOther; j < endIndexOther; j++)
{
var realColumnIndex = sparseOther._columnIndices[j];

if (At(i, realColumnIndex) == 0.0)
{
result.At(i, realColumnIndex, sparseOther._nonZeroValues[j]);
// VARIANT for DoSubtract(): result.At(i, realColumnIndex, -sparseOther._nonZeroValues[j]);
}
}

This worked for me, so I hope this will help you too. And keep up the good work!

Cheers,
Comments: (Not sure why Codeplex keeps reopening these issues all the time)

Updated Wiki: Native Providers

$
0
0

Native Linear Algebra Providers

Math.NET Numerics currently supports two native providers Intel's Math Kernel Library (MKL) and AMD's Core Math Library (ACML).

See also Math.NET Numerics With Native Linear Algebra

MKL (Windows)

  1. Install MKL on your system (we are using v10.3 Update 2).
  2. Open the NativeWrappers.sln in VS 2010 under \src\NativeWrappers\Windows .
  3. Open the Configuration Manager and select either the 32-bit or 64-bit solution platform.
  4. Right click on the MKLWrapper project and update the MKL include directory under C/C++/General and the library directory under Linker/General to point to your MKL installation.
  5. Right click on the MKLWrapper project and click rebuild.
  6. There will be two DLLs in the output directory: Math.NET.Numerics.MKL.dll and libiomp5md.dll. The output directory will be either \src\NativeWrappers\Windows\Win32\Release or \src\NativeWrappers\Windows\x64\release.
  7. Copy the two DLLs from #6 to the same directory as MathNet.Numerics.dll.
  8. Tell the Math.NET Numerics library to use the MKL provider by adding this line to your code:
MathNet.Numerics.Control.LinearAlgebraProvider =
   new MathNet.Numerics.Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider();

ACML (Windows)

  1. Install the Intel Fortran version of ACML on your system (we are using v4.4) - http://developer.amd.com/cpu/Libraries/acml/Pages/default.aspx
  2. Open the NativeWrappers.sln in VS 2010 under \src\NativeWrappers\Windows .
  3. Open the Configuration Manager and select either the 32-bit or 64-bit solution platform.
  4. Right click on the ACMLWrapper project and update the ACML include directory under C/C++/General and the library directory under Linker/General to point to your ACML installation.
  5. Right click on the ACMLWrapper project and click rebuild.
  6. There will be one DLL in the output directory: Math.NET.Numerics.ACML.dll. The output directory will be either \src\NativeWrappers\Windows\Win32\Release or \src\NativeWrappers\Windows\x64\release.
  7. Copy the DLL from #6 to the same directory as MathNet.Numerics.dll.
  8. Copy these DLLS from your ACML installation to the same directory as MathNet.Numerics: libacmlmpdll.dll, libifcoremd.dll, libiomp5md.dll, and libmmd.dll
  9. Tell the Math.NET Numerics library to use the ACML provider by adding this line to your code:
MathNet.Numerics.Control.LinearAlgebraProvider =
   new MathNet.Numerics.Algorithms.LinearAlgebra.Acml.AcmlLinearAlgebraProvider();

Note: The ACML wrapper dynamically links the ACML libraries. If you have the Intel Fortran Complier installed you can statically link them.

Updated Wiki: Documentation

$
0
0

Math.NET Numerics Documentation

Math.NET Numerics is an opensource numerical library for .Net, Silverlight, Metro and Mono. This topic lists documentation that will help you use the toolkit in your own application. In addition to the user guide, there's also a condensed API Reference available, or if you prefer examples the sample code project may give you some ideas.

User Guide

Advanced Topics

Blog Posts & Other Resources


Updated Wiki: Documentation

$
0
0

Math.NET Numerics Documentation

Math.NET Numerics is an opensource numerical library for .Net, Silverlight, Metro and Mono. This topic lists documentation that will help you use the toolkit in your own application. In addition to the user guide, there's also a condensed API Reference available, or if you prefer examples the sample code project may give you some ideas.

User Guide

Advanced Topics

Blog Posts & Other Resources


Updated Wiki: Home

$
0
0

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: EigenValue Decomposition - method failing

$
0
0

Hi all,

I have taken to using the Math.NET Numerics library for some eigenvector work as part of a social network analysis project I am doing.

The Evd() method works fine for smaller cases however for some reason, when I try to run the method on a 650 dimensional matrix, the method never (I left it for 4 hours) seems to finish. A 649 dimensional matrix finished in ~6 seconds. In both cases, the matrices are square and defined as follows:

int dimension = 650;
Matrix<double> adjMatrix = new DenseMatrix(dimension, dimension, 0);
var eig = adjMatrix.Evd(); //fails with 650 dim matrix here

I then populate a "1" where a connection exists between nodes in my network.
Here are the matrices should they be of any use to you (loads of zeroes with some ones essentially):

649 (works) - http://txtup.co/ZhbPm

650 (fails) - http://txtup.co/RhHfY

Any help would be greatly appreciated.

Created Issue: Is there a version for .Net Framework 3.5? [5722]

$
0
0
I am trying to incorporate Mathnet into a .Net Framework 3.5 scenerio, but I am getting errors from Visual Studeo telling me that the .dll is compiled for .Net Framework 3.5.

Does there already exist a version of the Mathnet .dll that will run under Framework 3.5 or do I need to learn how to compile/build the .dll file?

Thanks

Commented Issue: Is there a version for .Net Framework 3.5? [5722]

$
0
0
I am trying to incorporate Mathnet into a .Net Framework 3.5 scenerio, but I am getting errors from Visual Studeo telling me that the .dll is compiled for .Net Framework 3.5.

Does there already exist a version of the Mathnet .dll that will run under Framework 3.5 or do I need to learn how to compile/build the .dll file?

Thanks
Comments: No, Math.NET Numerics does not support .Net 3.5 and we have no plans so far to support it. Note that it's not just a matter of compiler settings, it depends on the new additions of the .Net 4 base class library. It's not impossible to back-port it as some of the missing pieces are already there for our portable build (the portable profile does not include System.Numerics), and you'd likely have to remove all parallel code paths completely. But it's still quite some work and involved, way more than just some reconfiguration. Note that its predecessor Math.NET Iridium supports .Net 3.5, maybe that's still good enough for what you need it for.

Closed Issue: Is there a version for .Net Framework 3.5? [5722]

$
0
0
I am trying to incorporate Mathnet into a .Net Framework 3.5 scenerio, but I am getting errors from Visual Studeo telling me that the .dll is compiled for .Net Framework 3.5.

Does there already exist a version of the Mathnet .dll that will run under Framework 3.5 or do I need to learn how to compile/build the .dll file?

Thanks

New Post: EigenValue Decomposition - method failing

$
0
0

Hi, is your matrix by chance strictly triangular?

New Post: EigenValue Decomposition - method failing

$
0
0

Thanks for the response, my matrix is not triangular/ symmetrical.

New Post: Math.Net NeoDym digital filters

$
0
0

Now there is an attempt to port the Neodym filters to Math.NET Numerics :-)

The actual development takes place in the filtering branch.
Every help is welcome.

New Post: EigenValue Decomposition - method failing

$
0
0

Could you post the positions of the "1" values for the 649 and 650 matrices? This would make it easier to test.

Thanks,
Marcus

New Post: EigenValue Decomposition - method failing

$
0
0

Hi Marcus,

As requested, here are the positions (as coordinates) of the "1" values in both matrices.

649 (works) - http://txtup.co/CZtcC

650 (fails) - http://txtup.co/kXzbR

As a bit of background, each dimension represents a person and if a "1" is in the location, it simply means they have communicated with that individual on that row/column.

I am adding a row into the 650 matrix at index 0 so you will notice a clear pattern as most of the coordinates are very similar (just incremented 1 in 650 to take into account the extra row).

In 650, there are just 2 extra "1" values located at (0, 129) and (129, 0) . Could the fact that this appears to be bidirectional cause problems? From a quick look through, bidirectional communications have been processed before in the working 649 version so it shouldn't matter.

Feel free to ask for anything else.

New Post: EigenValue Decomposition - method failing

$
0
0
Hi,

I tried to take a look, but the links have expired. Could email the data to me - marcus@cuda.org ?

Thanks,
Marcus

New Post: EigenValue Decomposition - method failing

New Post: EigenValue Decomposition - method failing

$
0
0
There is a bug in the EVD code where we are getting stuck in an infinite loop. Working on it.

New Post: EigenValue Decomposition - method failing

$
0
0
The code never converges to a solution. There is an iteration count, but is is never used. The FORTRAN HQR2 code (what JAMA and this code seem to be based on) errors out if the number of iterations is greater than 30*order. We should add something similar.

As to why this particular matrix doesn't converge, I don't know. I tinkered around with the convergence criteria it doesn't even seem to be close to converging.

Also, JAMA uses eps = Math.Pow(2,-52) but we use Math.Pow(2,-53) when determining if two numbers are equal. It doesn't make any difference in this case but I wanted to it out.

New Post: EigenValue Decomposition - method failing

$
0
0
Hi,

Thanks for the help. So you have no ideas as to why the matrix doesn't converge, is there something wrong with the matrix itself? I could really do with being able to display the eigenvalues for my matrix - ideas for alternative methods or anything you can do with Math.Net Numerics?

I had a go with another library from CodeProject ( http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=5835 ) and found that I could get the eigenvalues for 650 dimensions fine but then the same issue occurred with 672 and it wouldn't converge. My knowledge of matrices is being pushed as it is so I don't understand any depths of why this wouldn't happen?

New Post: EigenValue Decomposition - method failing

$
0
0
found that I could get the eigenvalues for 650 dimensions fine but then the same issue occurred with 672
Interesting, since both sets of code seem to be a port of the JAMA code but with a different "eps". I'll poke are around a little more today and try to mimic the way the original FORTRAN code works for convergence (I couldn't find the Algol code that seems to the basis of all these implementations). I'll also see give MKL a spin and seem it converges.
Viewing all 971 articles
Browse latest View live


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