Comments (4)
There is no such method. The reason is that setting a single value in a sparse matrix is very inefficient (involves a binary search and possibly memory reallocation).
The SparseMatrix
class gives you public access to the ColumnPointers
, RowIndices
and Values
arrays, so feel free to set the values directly, but usually there are better ways than accessing the values of a sparse matrix like that. Could you explain your use case?
from csparse.net.
My problem is the following:
I have to solve a sequence of sparse square linear systems. In each iteration, some coefficients will change. I have the row, column and new value for each coefficient that needs to change.
I used Mathnet's dense matrices, but with CSparse it greatly reduced the resolution time, but I think I can improve the problem modification time. I tried:
- Build the sparse matrix with Mathnet. In each iteration set the news values using Mathnet At operator, convert to CSparse and solve with CSparse.
- Construct the dense matrix with double[,]. In each iteration set the news values using Array At operator, convert to CSparse using OfArray and solve with CSparse.
The above approaches are pretty similar with (1) slightly better in my tests.
Is there a better way to do this?
from csparse.net.
In each iteration, some coefficients will change.
In what way do the values change exactly?
- If you have a starting matrix
A_0
, is it an update likeA_{i+1} = A_i + C_i
? Then just buildC_i
and compute the sum. - If the non-zero pattern of the matrix doesn't change (meaning no new non-zeros are introduced during the iteration process), no memory allocations are needed and modifying the values directly might be efficient.
MathNet does provide the feature you are looking for in SparseCompressedRowMatrixStorage.cs, so you could either do the updates with MathNet and use the wiki example to compute the sparse factorization, or take the code and use it to create a similar method for CSparse.NET. I'll provide help, if necessary.
from csparse.net.
Thanks for the explanations about sparse structures. Despite having a mask of coefficients, they are not necessarily non-zero. So I can't modify just the values without having to reallocate memory. I think the combination of Array[,]+CSparse will be enough for me. Thank you for your help.
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
- Adding Span and Memory HOT 4
- `CompressedColumnStorage<T>.Transpose` yields wrong result leading to sequential issues in `Solver`s HOT 9
- 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.