|
|
Comments and Discussions
|
|
 |

|
I've been looking for something like this for a while now, and this seems to fit my needs wonderfully.
|
|
|
|

|
Any one can Help How to use DotNetMatrix to find LU Decomposition. And to return L, U,P . Please Help..
|
|
|
|

|
Hello, I have tried to use your sample code, but VS 2010 gives me this error:
"Array initializers can only be used in a variable or field initializer. Try using a new expression instead."
VS 2010 simply does not like the way the array is initialized:
double[][] array = {{1.,2.,3},{4.,5.,6.},{7.,8.,10.}};
I have tried to change it to:
double[,] array = {{1,2,3},{4,5,6},{7,8,10}};
which is correct way for VS 2010, but then GeneralMatrix(array) does not like this form.
How shall one initialize an array so that it will work with this probably awesome tool?
Many thanks for any hints.
hugo
|
|
|
|
|

|
I created two functions to get the Max and Min Values in a given matrix. If this is something you want to add to the project let me know and I will provide the code. Its just a couple of loops and a compare statement... Not sure how to contribute on Code Project, yet...
|
|
|
|

|
Hi Paul,
Great job. I just want to know if you have some updated version of theses codes?
Is there a C++ version available?
Thanks a lot.
|
|
|
|

|
Hi,
I used this dll really effectively in a research project. I like to make my work accessible to other researchers free. But with the dependency of Dll, I dont know whether I can do it or not?
Is there an copy right issue if I distribute your DLL with my dll?
Thank you
Tharindu
|
|
|
|

|
Hi
I use your Libary. it's very very nice code
but i have still a problem
i want to delet da row or a col ?
i didn#t have found a soulution for this problem
cya
muhaa
|
|
|
|

|
Hi Paul, first, thank you for sharing your work.
Here's a sample linear system I want to solve:
49x - 7y + z = 6
25x - 5y + z = 4
9x - 3y + z = 2
How can I solve this with GeneralMatrix? I would greatly appreciate it if you could give me some sample code.
Thanks,
Andy
|
|
|
|

|
Hi,
I have a 3x3 matrix, V:
V =
100 10 1
625 25 1
900 30 1
In MatLab I do the QR and get:
>> [Q,R] = qr(V,0)
Q =
-0.0909 0.8789 0.4683
-0.5680 0.3405 -0.7493
-0.8180 -0.3341 0.4683
R =
1.0e+003 *
-1.1003 -0.0396 -0.0015
0 0.0073 0.0009
0 0 0.0002
However when using the DotNetMatrix I get:
Matrix Q =
-0.0908856214131766 0.878886544558686 -0.468292905790847
-0.568035133832354 0.340488733969466 0.749268649265355
-0.817970592718589 -0.334104570207539 -0.468292905790847
While the values are good, the right hand column is all a negative of the MatLab results.
Any suggestions?
Regards
Lachlan.
|
|
|
|

|
Why make a class virtual? That causes a performance issue. You should never make a class virtual.
|
|
|
|

|
Thanks for this library, it is very useful!
I have a question: I arrive at some point with a Matrix that is singular, and I want to perform an Inverse on it.
GeneralMatrix matrixInvertQ = matrixMultiplyN.Inverse();
...
public virtual Matrix Inverse()
{
return Solve(Identity(m, m));
}
The Inverse method calls Solve, which instantiates a LUDecomposition object and calls its Solve method. There it tests for singularity, and I get the "Matrix is singular" exception.
I have very limited knowledge in mathematics, so bear with me. At the point where the matrix is considered singular, shouldn't a pseudoinverse by performed?
In the comments for the Inverse method, it says "inverse(A) if A is square, pseudoinverse otherwise".
Is there a part missing from implementation?
Thanks!
|
|
|
|

|
Hi:
There is a bug in the svd decomposition, inherited from Jama. The problem is with the V matrix, when n>m. The correction is:
if (wantv)
{
for (int k = n - 1; k >= 0; k--)
{
if ((k < nrt) & (e[k] != 0.0))
{
for (int j = k + 1; j < n; j++) {
double t = 0;
The bug is reported here:
http://cio.nist.gov/esd/emaildir/lists/jama/msg00430.html
|
|
|
|

|
I have problem with relation between eigenvalues and eigenvectors. My eigenvectors do not correspond with their eigenvalues. Instead they are mixed (for exaple eigenvalue a1 has vector v3, instead of v1). All eigenvalues i have are negative so can that be problem?
Thanks
Cukaric
|
|
|
|
|

|
public GeneralMatrix(double[] vals, int m)
{
this.m = m;
n = (m != 0?vals.Length / m:0);
if (m * n != vals.Length)
{
throw new System.ArgumentException("Array length must be a multiple of m.");
}
A = new double[m][];
for (int i = 0; i < m; i++)
{
A[i] = new double[n];
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
A[i][j] = vals[i + j * m];
}
}
}
I think the statement
A[i][j] = vals[i + j * m];
should be revised as
A[i][j] = vals[j + i * m];
|
|
|
|

|
Paul,
I am new to DotNet programming and I'm working on a project to determine whether a series of values over time are trending upward, down or steady. I'm working with performance data from the Windows OS.
I believe the simplest approach will be to run a least squares analysis on the data (40 points, each from a successive day). I would like to use your DotNetMatrix library but am a little out of my league. Do you have any script samples/instructions for implementing the library and especially for a least squares analyis.
Thanks for your help,
Tom
P.S. Love your message postscript, my brother.
|
|
|
|

|
This library is great! But it seems that it's lack the capability of handling dynamic size matrix. Sometime we won't know what the matrix size would be as it would grow/shrink with time, so it will be better if the library can support dynamic size.
|
|
|
|

|
Hi. In the CholeskyDecomposition constructor, a flag isspd is set. I have an example where this flag turned out to give me the wrong value.
When looking in the code, I can see a line like this:
isspd = isspd & (A[k][j] == A[j][k]);
since we are dealing with double's, this is a very dangerous way of checking for equality. Dangerous enough, at least, to make the code not work for my example.
I always recommend to use something like this:
isspd = isspd & CloseEnoughToEqual(A[k][j], A[j][k]);
where
CloseEnoughToEqual(a,b)
{
return Math.Abs(a-b) < SOMESMALLTHRESHOULD
}
SOMESMALLTHRESHOULD could then be 0.0000001 or less depending on precision. In my case, the values were 0.38490014055502542 versus 0.38490014055503252 making the code believe those two values weren't suppose to be the same
Beside this, I have found the library very useful, and well working.
Claws
|
|
|
|

|
Hmm Does this Class handle or is able to handle the Penrose-Moore Pseudo Inverse ?
I tried to modify it... however seems there are too many other functions that cannot handle the singular matrixs
also the SVD can it handle singular matrix ?
|
|
|
|

|
Hi, how could I calculate the matrix LEFT division
X = A\B
where A is af non-square matrix, with your library?
Thanks
|
|
|
|

|
In document, it said that GeneralMatrix.Inverse Method will "inverse(A) if A is square, pseudoinverse otherwise."
But I just got an error "Matrix is rank deficient"
The matrix data is
0 0 4 0 4
0 0 0 8 8
0 10 10 10 10
1 1 1 1 1
And if I try to SVD the matrix, the matrix has some problem.
The matrix from GetU() has ColumnDimension = 5, but the array A inside the atrix is 4 x 4.
Is this a bug?
|
|
|
|

|
Hi
I use your code and i have following problem.
VB.NET project and dll includes your classes with DotNetMatrix.
When I use GeneralMatrix objects in For ...Next there is OutOfMemory Exception in your source in differnt places at each time : more in constructors and sometimes in other methods. Stack memory and heap are not overflowed.
Exception was raised in line with "new double[][]" code
Can you help with solution problem? Maybe problem isn't in your sources...
|
|
|
|

|
Great Matrix code. Very useful.
Just one thing: I can't seem to find out how to print the matrix's, even though its said "Methods for reading and printing matrices are also included." Maybe I'm being stupid or maybe these methods haven't been writen.
Anyway. I added my own, very simple ToString() method. I'll post it here as it might save someone a bit of time. Just paste it into the GeneralMatrix.cs file and compile.
///
/// Converts the array into a string.
/// "First row \n Second row \n Last row \n"
///
/// String of Array Elements
public override string ToString()
{
string elementsString = "";
for(int j=0; j < m; j++)
{
for(int i=0; i < n; i++)
elementsString += A[j][i].ToString() + " ";
elementsString += "\n";
}
return elementsString;
}
Mark Sugrue
Machine Vision Research Group
Royal Holloway, Uni of London
m.sugrue@rhul.ac.uk
|
|
|
|

|
Hi,
Is this library can resolve a least square non linear problem ??
Which algorithm is implemented for the least square (Levenberg-Marquardt, Gauss, ...) ???
In advance, thanks.
See you,
Philippe
|
|
|
|

|
Great job! I just have a look at the code. I was wondering why the matrices are represented by a double[][] array instead of a double[ , ] array. Since, we will be dealing only with rectangular structures, I don't really see the advantage of using double[][]. Additionnaly, the use of double[][] implies one additionnal indirection to access to any element. That's not going to make a big change, but since the overall time of any operation on the matrix is going to be almost proportionnal to the element accessing time, it could still make a difference.
Also, there are details bothering me. Why implementing the IDisposable and destructor interfaces for GeneralMatrix ? As far, I have seen, it's not required. Remember that implementing IDisposable is really going to slow down the garbadge collection process (idem for destructor).
Idem for ISerializable, the attribute [Serializable] is itself sufficient. So why implementing the ISerializable interface ?
|
|
|
|

|
Hi Paul,
very interesting tutorial !
Any target date planned for the affine transformation ?
Jan.
|
|
|
|

|
We needed a replacement for the GDI+ Matrix class in our graphics system, VG.net. We found that for a small matrix, 3x3 affine, which is internally 2x3 floats for vector graphics, a struct provides much better performance than a class, even if you pass the matrices around as method arguments often. Furthermore, you get value semantics for your operator overloading without having to hit the heap or bother the garbage collector. Our idea was validated recently when we noticed Avalon does the same thing. Not quite as fast as C++ but close!
If you are interested, get a VG.net beta (see sig), and look at the FMatrix class. We use it internally instead of System.Drawing.Matrix. On rendering, we must use the System.Drawing class, so we do, but we avoid it as much as possible, as it uses interop and is very slow.
Regards,
Frank Hileman
check out VG.net: www.vgdotnet.com
An animated vector graphics system integrated in VS.net
|
|
|
|

|
Hello,
great work. I have the same type of library in VB on Code project, but not nearly as extended. Also it doesn't define a matrix type, but is just a sealed class that provides shared methods for working with 1 and 2 D arrays. I do have a multidimensional non-linear solver though, based on the Nelder-Mead simplex algorithm as found in 'Numerical Recipes in C'. It is literally translated from C, and is unreadable, but if you just transform the in and output data formats it should work .... This great for data- and model fitting.
Cheers
|
|
|
|
|

|
Hi paul, it is nice to see someone taking care of the dirty work (implementing a matrix library).
Jonathan de Halleux.
www.dotnetwiki.org
|
|
|
|

|
This is good because it has operator overloading and an inverse operation. It seems to have the features needed. Only '*' '+' and '-' are overloaded. Is there a good reason for this like a technical limitation, to solve ambiguity, etc?
The problems are (possibly) performance wise. In C++ you could do a lot of things (loop/function unrolling/inlining) with macros/templates inside the matrix's functions, but in C# it looks like a few objects are created. That is no big deal I suppose, but I think some people would want to see some operations in unmanaged code. In a 3D app with lots of solving going on, it might be a problem. Then again, it might not. No way to tell for real without testing I suppose.
Anyway, good work.
A request for later: include Vector and Quaternion classes.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A set of C# classes providing basic matrix operations
| Type | Article |
| Licence | Public Domain |
| First Posted | 12 Jan 2004 |
| Views | 232,742 |
| Downloads | 5,883 |
| Bookmarked | 107 times |
|
|