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

New Post: Solving Ax=B in visual basic


New Post: Solving Ax=B in visual basic

$
0
0

Hi Marcus.

 

I downloaded those 2 DLL's to my main project folder, then I added that line you mentioned. Although, when I started debugging, Visual Studio poped up a window to browse a .CS file to add to the project. I guess i should just import the DLLs somehow, tried also to add them as references, but VS won't let me do that, saying that they're not "a valid assembly or COM component"... Any thoughts ?

New Post: Solving Ax=B in visual basic

$
0
0

Hi,

You don't add them as a reference. You need to copy them to the output folder (i.e.:<project>\bin\release). What I normally do is add them to the project (Add -> Existing item) and then set the "Copy to output directory" property to "Copy Always" for both files.

New Post: Solving Ax=B in visual basic

$
0
0

WOW !

It just flies! As I told you, on my mac it was taking about 2 or 3 seconds per iteration, while with mathnetnumerics it took about 1 min. Now it is performing like Fortran's LAPACK or even better. It's actually hard to tell once it's so fast ! :)

Problem solved... THANK YOU ! :) 

New Post: QR Factorization for SparseMatrix

$
0
0

I have a trouble. When i use a big sparse matrix for QR factorization it fails and rises OutOfRange Exception. Could you help me please?

SparseMatrix m = new SparseMatrix(....); rows count = column count and grater than 1000

var qr = m.QR(); --- Fails

System.ArgumentOutOfRangeException was unhandled by user code
  Message=Non-negative number required.
Parameter name: length
  Source=mscorlib
  ParamName=length
  StackTrace:
       at System.Array.BinarySearch[T](T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
       at System.Array.BinarySearch[T](T[] array, Int32 index, Int32 length, T value)
       at MathNet.Numerics.LinearAlgebra.Storage.SparseCompressedRowMatrixStorage`1.FindItem(Int32 row, Int32 column) in c:\TeamCity\buildAgent\work\d4ecde2945c804d6\src\Numerics\LinearAlgebra\Storage\SparseCompressedRowMatrixStorage.cs:line 180
       at MathNet.Numerics.LinearAlgebra.Storage.SparseCompressedRowMatrixStorage`1.At(Int32 row, Int32 column, T value) in c:\TeamCity\buildAgent\work\d4ecde2945c804d6\src\Numerics\LinearAlgebra\Storage\SparseCompressedRowMatrixStorage.cs:line 77
       at MathNet.Numerics.LinearAlgebra.Generic.Matrix`1.At(Int32 row, Int32 column, T value) in c:\TeamCity\buildAgent\work\d4ecde2945c804d6\src\Numerics\LinearAlgebra\Generic\Matrix.cs:line 204
       at MathNet.Numerics.LinearAlgebra.Double.Factorization.UserQR.ComputeQR(Double[] u, Matrix`1 a, Int32 rowStart, Int32 rowDim, Int32 columnStart, Int32 columnDim, Int32 availableCores) in c:\TeamCity\buildAgent\work\d4ecde2945c804d6\src\Numerics\LinearAlgebra\Double\Factorization\UserQR.cs:line 218
       at MathNet.Numerics.LinearAlgebra.Double.Factorization.UserQR.<>c__DisplayClass6.<ComputeQR>b__3() in c:\TeamCity\buildAgent\work\d4ecde2945c804d6\src\Numerics\LinearAlgebra\Double\Factorization\UserQR.cs:line 204
       at System.Threading.Tasks.Task.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
  InnerException:

New Post: IR filter

$
0
0

Hi,

will there be support for IR filter in Math.NET Numerics?

I know there is Math.NET Neodym, but it depends on the discontinued Math.NET Iridium. It would be great to have the filters on top of Math.NET Numerics.

New Post: IR filter

$
0
0

Yes, it would make sense to port them over (also all the windowing functions); we already have ported some sample generators to the .Signals namespace.

What specific filters would you need? Also filter coefficient designers/calculators or are they already pre-computed in your case?

Thanks,
Christoph

PS: funny how people continue to cross-post to Meta Numerics ;) (no problem, just observed it more often recently)

New Post: IR filter

$
0
0

We are interested in IIR filters for which we have pre-computed coefficients (no need for coefficient calculators ala butter()). The zero-phase filter filtfilt() would be really helpful, too.

Thanks,
Thomas


New Post: Simplex Optimization

$
0
0

I'm not a math expert and  need a Simplex optimization function, is there an example about this?

Thanks

Alessandro

Created Issue: SVD and L2Norm out of memory exception [5719]

$
0
0
Hi,

I am working on image procession project and using SVD and L2norm on DenseMatrix. The matrix consists of of 40000 rows and 20 columns. It consists of 20 images of resolution 200*200 stacked as matrix columns.
For testing, when I scale the images to be 150*150 and below the SVD works correctly.

Working in VS 2010 professional, win7 , 64bit.

Commented Issue: SVD and L2Norm out of memory exception [5719]

$
0
0
Hi,

I am working on image procession project and using SVD and L2norm on DenseMatrix. The matrix consists of of 40000 rows and 20 columns. It consists of 20 images of resolution 200*200 stacked as matrix columns.
For testing, when I scale the images to be 150*150 and below the SVD works correctly.

Working in VS 2010 professional, win7 , 64bit.

Comments: The code sample i use: this.D = new DenseMatrix(rows, cols,0); for(int i=0; i<rows; i++) for (int j = 0; j < cols; j++) { this.D[i,j] =Matrix_D[i, j]; // Matrix_D is byte[,] } float mu_k = this.D.L2Norm(); var svd = D.Svd(true); MessageBox.Show("SVD OK"); when the Matrix_D size is 18000*3 I get "out of memory exception" when the Matrix_D size is 15000*3 everything is ok.

New Post: Math.Net Numerics Svd vs. DGESVD

$
0
0

Hi,

it may be a dump question but I've a program which is written in C and uses the dgesvd function of netlib (http://www.netlib.org/lapack/double/dgesvd.f).

Now I want to rewrite what is done in the C program in C# and tried to use Math.Net Numerics Double.DenseSvd and I don't get the same results.

Can someone tell me what is the difference between both implementations?

I used the following input matrix:

DenseMatrix A = new DenseMatrix(24, 3);
A[0, 0] = 0.00853749999998854;    A[0, 1] = 89.2522666666667;    A[0, 2] = 0;
A[1, 0] = -0.0175625000000537;    A[1, 1] = 55.1682666666667;    A[1, 2] = 0;
A[2, 0] = -0.0174625000000788;    A[2, 1] = 50.8299666666667;    A[2, 2] = 0;
A[3, 0] = 0.000137499999937063;   A[3, 1] = 32.6130666666667;    A[3, 2] = 0;
A[4, 0] = 0.025837499999966;      A[4, 1] = 2.34146666666666;    A[4, 2] = 0;
A[5, 0] = 0.0247375000000147;     A[5, 1] = 0.0117666666666638;  A[5, 2] = 0;
A[6, 0] = 0.00273749999996653;    A[6, 1] = -17.3512333333333;   A[6, 2] = 0;
A[7, 0] = -0.0143625000000611;    A[7, 1] = -27.1400333333333;   A[7, 2] = 0;
A[8, 0] = -0.0251625000000786;    A[8, 1] = -35.9106333333333;   A[8, 2] = 0;
A[9, 0] = -0.026762500000018;     A[9, 1] = -39.7074333333333;   A[9, 2] = 0;
A[10, 0] = -0.0261625000000549;   A[10, 1] = -43.1843333333333;  A[10, 2] = 0;
A[11, 0] = -0.010362500000042;    A[11, 1] = -53.1814333333333;  A[11, 2] = 0;
A[12, 0] = 0.0203374999999824;    A[12, 1] = -62.1617333333333;  A[12, 2] = 0;
A[13, 0] = 0.0272374999999556;    A[13, 1] = -63.9696333333333;  A[13, 2] = 0;
A[14, 0] = -0.0147625000000744;   A[14, 1] = -72.0996333333333;  A[14, 2] = 0;
A[15, 0] = -0.0130625000000464;   A[15, 1] = -69.6783333333333;  A[15, 2] = 0;
A[16, 0] = -0.00576250000005984;  A[16, 1] = -67.0790333333333;  A[16, 2] = 0;
A[17, 0] = 0.00063749999992524;   A[17, 1] = -0.530333333333337; A[17, 2] = 0;
A[18, 0] = -0.000762500000064392; A[18, 1] = 4.58916666666666;   A[18, 2] = 0;
A[19, 0] = 0.0177374999999529;    A[19, 1] = 27.9494666666667;   A[19, 2] = 0;
A[20, 0] = 0.0226374999999734;    A[20, 1] = 31.8685666666667;   A[20, 2] = 0;
A[21, 0] = 0.00643749999994725;   A[21, 1] = 81.9918666666667;   A[21, 2] = 0;
A[22, 0] = 0.00663750000001073;   A[22, 1] = 86.5695666666667;   A[22, 2] = 0;
A[23, 0] = 0.00853749999998854;   A[23, 1] = 88.8083666666667;   A[23, 2] = 0;

If I let Math.Net Numerics do the Svd and output the VT matrix I get the following result:

-0.000077323216972426711  -0.99999999701056008          0.0
-0.99999999701056008       0.000077323216972426711      0.0
 0.0                       0.0                          1.0

If I use the netlib implementation I get the following for VT:

-0.000077323216972426589  -0.99999999701056019          0.0
 0.99999999701056019      -0.000077323216972426589      0.0
 0.0                       0.0                          1.0

Also the U matrix is different but this is too much to post here...

New Post: Math.Net Numerics Svd vs. DGESVD

$
0
0

If I remember correctly, the managed Math.NET code is a port of the LINPACK SVD routine. I don't know the differences between the LAPACK and LINPACK implementations. The native provider uses LAPACK's DGESVD.  Is the U matrix as close as the VT matrix (which seems to be the same within 14 decimal places)?

Regards,
Marcus 

New Post: Math.Net Numerics Svd vs. DGESVD

$
0
0

The U matrix is as close as the VT matrix if you look at the absolute values, but the first column of the U matrix is negated.

Similar is the VT matrix but here it is the second row which is negated. As I know now, that Math.NET uses LINPACK SVD instead of LAPACK's DGESVD routine I'll try to find something with google. I thought Math.NET uses LAPACK's DGESVD and was wondering why the results are different..

Thanks for that Info!

New Post: DenseEvd throws ArgumentException(Resources.ArgumentMatrixSquare)

$
0
0

Hi,

every DenseEvd seems to throw an error if the matrix is not square, even though Hessenberg and real Schur conversions seem to be implemented. There is also a bool that is checked to see if the input matrix is symmetric, but it is set to true in the evd code itself. I do not know if this is intended. If it is not, i may open an issue.

Kekze


New Post: Math.Net Numerics Svd vs. LAPACK DGESVD

$
0
0

Ok after looking at Math.Net Numerics code I found the comment, that it's SVD is equivalent to the GESVD LAPACK routine.

What is the difference between LAPACK GESVD and LAPACK DGESVD? I know this is maybe a stupid question but I couldn't find something with google and I'm still wondering why I get different results (in case GESVD and DGESVD are the same).

Thanks

New Post: Math.Net Numerics Svd vs. LAPACK DGESVD

$
0
0

>that it's SVD is equivalent to the GESVD LAPACK routine.

The comment was meant for the ILinearAlgebra interface and probably shouldn't have been copied to the managed code implementation. I'll remove it in both places to prevent future confusion.

>What is the difference between LAPACK GESVD and LAPACK DGESVD?

DGESVD is the double precision version of GESVD, SGESVD is the single precision, and so on.


SVD is only unique up to to the sign (for real numbers, I think it is a little more complicated for complex numbers). From a quick search it seems that LAPACK uses QR decomp to compute the SVD while LINPACK uses Lanczos iterations. That probably explains the differences in signs.

New Post: Compute inverse function

$
0
0

For a given function f: x->f(x) I would like to compute numericallyits inverse function.

In other word for a given y, I'd like to compute x such f(x) = y.

 

Is there anything in the library to do so?

New Post: Math.Net Numerics Svd vs. LAPACK DGESVD

$
0
0

Well that could explain it. Thanks for your help and sorry for some maybe stupid questions..

I at least should have been able to answer the GESVD and DGESVD myself..

Updated Wiki: Special Functions

$
0
0

Special Functions

Factorial

Code Sample:
double x = SpecialFunctions.Factorial(14);
// x will now have the value 87178291200.0

double y = SpecialFunctions.Factorial(31);
// y will now have the value 8.2228386541779224E+33

Gamma

Commonly used gamma-related functions in literature:

GAMMA(a) = int(exp(-t)t^(a-1), t=0..infinity)
gamma(a,x) = int(exp(-t)t^(a-1),t=0..x)  
Gamma(a,x) = int(exp(-t)t^(a-1),t=x..infinity)  
P(a,x) = gamma(a,x)/GAMMA(a)  
Q(a,x) = Gamma(a,x)/GAMMA(a)

Digamma (Psi)

Euler Beta

Error Function

  • Error Function: Erf
  • Complementary Error Function: Erfc
  • Inverse Error Function: ErfInv
  • Inverse Complementary Error Function: ErfcInv
Code Sample:
double x = 0.9;
double res = SpecialFunctions.Erf(x);
// res will now have the value 0.7969082124

Logistic (Sigmoid)

  • Logistic Function: Logistic
  • Logit Function (inverse of Logistic): Logit

Harmonic Numbers

Bessel and Struve Functions

  • Modified Bessel function of the first kind, order 0 and 1: I0(x), I1(x)
  • Modified Bessel function of the second kind, order 0 and 1: K0(x), K1(x), plus exponentially scaled versions of them
  • Modified Struve function of order 0 and 1: L0(x), L1(x)
  • Modified Bessel minus modified Struve: I0(x)-L0(x), I1(x)-L1(x)

Various Numerically Stable Functions

Viewing all 971 articles
Browse latest View live


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