Comments (9)
I just looked up the documentation of the Multiply
method and I agree it's a bit sparse:
CSparse.NET/CSparse/Storage/CompressedColumnStorage.cs
Lines 473 to 478 in 2fa5b20
Do you think changing the summary would be enough:
/// <summary>
/// Sparse matrix multiplication, C = A*B, where A is current instance.
/// </summary>
from csparse.net.
I haven't tested any of the code you provided, but the first issue I see is
var aSparse = new CSparseMatrix(a.RowCount, a.ColumnCount)
That would only be ok for a square matrix. If a.RowCount != a.ColumnCount
, you should write
var aSparse = new CSparseMatrix(a.ColumnCount, a.RowCount)
Can you please test this and report back. If the problems reside, I'll have a closer look.
from csparse.net.
Hi @wo80!
Thanks for the quick help, that was it!
But I do not understand at all why this is needed.
Also, it gives the transposed matrix, so I would need to transpose my minimization problem.
No biggy, but still would like to understand the thought process behind this limitation.
from csparse.net.
You need to understand how the matrix entries are stored (see for example https://www.smcm.iqfr.csic.es/docs/intel/mkl/mkl_manual/appendices/mkl_appA_SMSF.htm).
MathNet uses CSR storage (matrix entries are stored row-wise) while CSparse uses CSC storarge (entries are stored column-wise). So if you take the CSR storage and just interpret it as CSC, it will represent the transposed matrix. This means, if your original matrix stored as CSR is m x n
, then it will represent a n x m
matrix in CSC.
Also, it gives the transposed matrix, so I would need to transpose my minimization problem. No biggy, but still would like to understand the thought process behind this limitation.
Yes, if you want to solve a least-squares problem, make sure that the CSparse m x n
matrix has m >= n
, so the MathNet matrix should be built as n x m
. You can also feed matrices with m < n
to SparseQR, but it will then compute the transposed matrix internally:
CSparse.NET/CSparse/Double/Factorization/SparseQR.cs
Lines 55 to 67 in 2fa5b20
from csparse.net.
Thanks a ton for clarifying, seems that I really misunderstood a few things.
I am actually thinking about rewriting most of my code to use CSparse directly, the performance is incredible!
Do you think changing the summary would be enough:
Absolutely, that makes it very explicit.
The issue that I have with
The sparse matrix multiplied to this instance.
is that one could interpret it as left multiplication, as right multiplication is quite uncommon.
from csparse.net.
I am actually thinking about rewriting most of my code to use CSparse directly, the performance is incredible!
I think you are right. The CSparse.NET is a port of CSparse by Tim. Davis. If i remember right, CSparse.NET had reasonably good performance compared to original CSparse although the original one is in native C or C++.
from csparse.net.
I am actually thinking about rewriting most of my code to use CSparse directly, the performance is incredible!
In case you were using the dense QR from MathNet (or even native MKL), the difference will be considerable. You can set up your matrix using the CSparse.NET CoordinateStorage
class, so in case you aren't using any other parts from MathNet, switching should be easy.
The issue that I have with [...] is that one could interpret it as left multiplication, as right multiplication is quite uncommon.
Alright, I will make sure to add a note that the matrix A
is multiplied by the other
matrix from the right.
from csparse.net.
Please leave this issue open! I will close it with the next pull request.
from csparse.net.
Thanks a ton, @wo80!
from csparse.net.
Related Issues (20)
- Dual Licensing HOT 2
- CoordinatedStorage HOT 1
- L*D*Lt decomposition HOT 7
- CLSCompliant HOT 4
- Problem with the QR factorization HOT 4
- Nonlinear equation system HOT 13
- Solving underdetermined systems with SparseQR Factorization HOT 5
- Can I create a sparse matrix by a list of triples? HOT 4
- [Question] Adding two sparse matrices HOT 8
- Rectangular QR decomposition with MathNet.Numerics HOT 4
- this[i,j] indexing for DenseMatrix HOT 1
- A bug when converting a COO matrix into CSC matrix HOT 4
- Can I slice a CSC sparse matrix? HOT 4
- Performance Issue HOT 12
- Can I construct sparse matrix from multiple diagonals? HOT 4
- Nuget .net version compatibility HOT 2
- Set value in SparseMatrix is unable? HOT 4
- Adding Span and Memory HOT 4
- Publish symbols and source for debugging HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csparse.net.