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

Created Issue: Algorithms.LinearAlgebra.Acml disappeared [5720]

$
0
0
Algorithms.LinearAlgebra.Acml namesapace as well as several others - apart from MKL have disappeared in the latest version.
This means that native wrapper tests no longer build.
In general I must say that it is horrendously complicated to enable any non-managed BLAS engine.
It would be really nice if default download included at least one non-managed BLAS implementation - e.g. the reference one. As it stands, one has to spend huge amount of time obtaining pieces of software from various sources.
It also means that default (managed) implementation is several factors of magnitude slower than Matlab, R or the like when it comes to manipulating sizeable matrices.

New Post: DescriptiveStatistics basic operation question

$
0
0

 

I realize this is probably a basic question, but I could not find it elsewhere. Could someone explain to me why this assertion always fails?
var sampleData = new MathNet.Numerics.Distributions.Normal(100, 10).Samples().Take(100);
            var statisticsOnSampleData = new DescriptiveStatistics(sampleData);
            var statistics = new DescriptiveStatistics(sampleData);
            Assert.AreEqual(statisticsOnSampleData.Maximum, statistics.Maximum);

For example, in the test I just ran I got:

TestStatsLibrary:
  Expected: 140.76833900997369d
  But was:  130.09605112204633d

Which is too big of a difference for overflow.

New Post: DescriptiveStatistics basic operation question

$
0
0

Note that sampleData is an enumerable that will generate different samples on each enumeration. Lines 2 and 3 thus operate on different data.

If you use sampleData2 = sampleData.ToArray() or sampleData.ToList() instead, both statistics should be equivalent.

New Post: DescriptiveStatistics basic operation question

New Post: VB.Net to F# interfacing

$
0
0

As a VB.NET developer in the area of data analysis in scientific research, I find the Math.NET library and F# very appealing.  My VB.NET library is extensive and I'm playing around with Math.NET and F# integration for enhancing and extending various utilities.

One question, what is the best way to pass a matrix or multi-dimensional array from VB.NET to F#.NET?  Should I use the Numerics' DenseMatrix?  What would the calling function look like and parameter passing look like.  My arrays are in the scale of 8x1000000 integer and double.

Any thoughts?  Examples?

dgp

New Post: VB.Net to F# interfacing

$
0
0

 

let arr : double[,] =

    Array2D.init 8 1000000 (fun x y -> 0.0)

Anton Tayanovskyy gave me this structure from the F# site cs.hubfs.com

Reviewed: Math.NET Numerics v2.3.0 (Jan 14, 2013)

$
0
0
Rated 5 Stars (out of 5) - A fantastic open source project that fills a void for .NET with a variety of options. Documentation is a bit too light, but it seems that the project is currently quite active.

Commented Issue: Bug in LinearAlgebra.Double.Matrix in DoTransposeAndMultiply() [5673]

$
0
0
The code here is:
protected override void DoTransposeAndMultiply(Matrix<double> other, Matrix<double> result)
{
for (var j = 0; j < RowCount; j++)
{
for (var i = 0; i < RowCount; i++)
{
var s = 0.0;
for (var l = 0; l < ColumnCount; l++)
{
s += At(i, l) * other.At(j, l);
}

result.At(i, j, s);
}
}
}

With einstein/summation notation, what we should be doing is:
C_ij = A_il * B_lj^T = A_il * B_jl
i:Ranges from 1 to A.Rows
j:Ranges from 1 to B.Rows
l:Ranges from 1 to A.Columns or B.Columns since they are equal.

Therefore, in the code, j should be:
for (var j = 0; j < other.RowCount; j++) instead of for (var j = 0; j < RowCount; j++)

Another way to perceive a problem is to note that i and j both range from 0 to RowCount(exclusive). Therefore the resulting matrix C_ij would always be square which is not the case.

On another note, I don't understand WHEN this method would actually be called. The calls I find (eg in DenseMatrix:Matrix) are like this:

if (denseOther == null || denseResult == null)
{
base.DoTransposeAndMultiply(other, result);
}

So this method is called only when one of the parameters are null?
Comments: Fixed in changeset 8206966c88b1

Edited Issue: SparseMatrix.SubMatrix() throws IndexOutOfRangeException [5671]

$
0
0
Hi,

I'm still using your nice library and I've found a little bug again, this time in the SubMatrix() method for sparse matrices.
If you do something like this:
var matrix = new SparseMatrix(10, 10, 1.0);
var sub = matrix.SubMatrix(8, 2, 0, 2);

then the method will throw an IndexOutOfRangeException. This is due to a little typo in one of the boundary checks:
var endIndex = row < _rowIndex.Length - 1 ? _rowIndex[i + 1] : NonZerosCount;
should really be:
var endIndex = i < _rowIndex.Length - 1 ? _rowIndex[i + 1] : NonZerosCount;
(row being the index of the smaller to-be-output submatrix's row, whereas i is the index of the matrix's row currently being parsed).

Hope it helps!

Cheers and good luck. ;)

Commented Issue: SparseMatrix.SubMatrix() throws IndexOutOfRangeException [5671]

$
0
0
Hi,

I'm still using your nice library and I've found a little bug again, this time in the SubMatrix() method for sparse matrices.
If you do something like this:
var matrix = new SparseMatrix(10, 10, 1.0);
var sub = matrix.SubMatrix(8, 2, 0, 2);

then the method will throw an IndexOutOfRangeException. This is due to a little typo in one of the boundary checks:
var endIndex = row < _rowIndex.Length - 1 ? _rowIndex[i + 1] : NonZerosCount;
should really be:
var endIndex = i < _rowIndex.Length - 1 ? _rowIndex[i + 1] : NonZerosCount;
(row being the index of the smaller to-be-output submatrix's row, whereas i is the index of the matrix's row currently being parsed).

Hope it helps!

Cheers and good luck. ;)
Comments: Fixed in changeset d2a96e1f16bb

Edited 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,

Commented 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: Fixed in changeset eeede6d89e65

Edited Feature: Modulo operator on matrix and vector [5662]

$
0
0
Hi - Is there a modulus operator on a matrix? More specifically, I'm creating a matrix:

var matrixA = new DenseMatrix(new[,] { { 5.0, 8.0 }, { 17.0, 3.0 } });
and I would like to perform the following operation:
var matrixB = matrixA % 26;
or something to that effect. The application is for encryption (Hill Cipher).
Thanks,
Mike

Commented Feature: Modulo operator on matrix and vector [5662]

$
0
0
Hi - Is there a modulus operator on a matrix? More specifically, I'm creating a matrix:

var matrixA = new DenseMatrix(new[,] { { 5.0, 8.0 }, { 17.0, 3.0 } });
and I would like to perform the following operation:
var matrixB = matrixA % 26;
or something to that effect. The application is for encryption (Hill Cipher).
Thanks,
Mike
Comments: Fixed in changeset df3f7fc0b460

Edited Issue: Add a IsSymmetric method to the matrix interface. [5653]

$
0
0
Add a method that checks whether a matrix is symmetric or not - optimize it for sparse matrices.

Commented Issue: Add a IsSymmetric method to the matrix interface. [5653]

$
0
0
Add a method that checks whether a matrix is symmetric or not - optimize it for sparse matrices.
Comments: Fixed in changeset 2dd9bb7555ff

New Post: new user question

$
0
0

Hi,

I am new to Math.NET Numerics and want to know the proper way to create vectors and matrices of both double and complex in the same file without prepending the namespace.  For example, is this the only way to create things?

Vector<double> a = new MathNet.Numerics.LinearAlgebra.Double.DenseVector(newdouble[] { 1, 2, 3 });
Vector<double> b = new MathNet.Numerics.LinearAlgebra.Double.DenseVector(newdouble[] { 4, 5, 6 });var c = a + b;var d = a * b;//Matrix<Complex> mat = new DenseMatrix(2, 3);

Matrix<Complex> mat = new MathNet.Numerics.LinearAlgebra.Complex.DenseMatrix(2, 3 );

Matrix<Complex> mat2 = new MathNet.Numerics.LinearAlgebra.Complex.DenseMatrix(1,3, new Complex[] { new Complex(1.0, 0.0), new Complex(2.0,0.0),new Complex(3.0, 0.0)});
Is there a way to just do the following:
Matrix<Complex> mat = new Matrix<Complex>(2,3);
Thanks

New Post: new user question

$
0
0

Hi,

There's no need to write the full namespace, just use relative ones as usual. For example:

using MathNet.Numerics.LinearAlgebra;var a = new Double.DenseVector(newdouble[] ...);var mat = new Complex.DenseMatrix(2,3);

Nevertheless, you may still want to include the .Generic, .Double and .Complex namespaces as well, if not just to get the extension methods.

Thanks,
Christoph 

New Post: 2d Gird Interpolation

$
0
0

Not out of the box yet, although the same principle could be implemented on top of the existing interpolation algorithms (even though that would not be very efficient).

Thanks,
Christoph

New Post: new user question

$
0
0

You could also use using as a sorta typedef within a file:

using Vector = MathNet.Numerics.LinearAlgebra.Double.DenseVector;
using Matrix = MathNet.Numerics.LinearAlgebra.Complex.DenseMatrix;

...

var v = new Vector(5);
var m = new Matrix(5, 5);

This should also get you access to the extension methods.

Viewing all 971 articles
Browse latest View live


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