Giter VIP home page Giter VIP logo

Comments (3)

jaeandersson avatar jaeandersson commented on September 23, 2024

The sparsity pattern is stored as a vector of integers where:

  • The first two elements are the dimensions (nrow, ncol)
  • The following (ncol+1) entries are the nonzero offset for each column. Note that this means that the (ncol+3)-th entry is the total number of nonzeros (nnz)
  • The last nnz entries are the row index for each nonzero. Indices are increasing for each column, with no duplicates

For a dense matrix, we have nnz=nrow * ncol, which can easily be checked, and the last part is superfluous information. So you can decrease the storage needs from (2+(ncol+1)+nrow * ncol) to (2+(ncol+1)). The problem is that every algorithm where sparsity is used needs to be specialized to handle the dense case separately. Currently, many common algorithms are, like matrix multiplication, but not all. For maintainability reasons, I would be against implementing the more compact storage (which is easy and quick to do) unless we go through all algorithms in CasADi where sparsity is being used and update them accordingly. You can of course implement it yourself in your own fork of CasADi.

It's possible to get an even more compact representation, or if you want to support something like triangular patterns or higher order tensors, by letting the third element of the sparsity vector be something else than zero. It's always zero now by definition. But again, this generation would need to be propagated everywhere in a maintainable way.

from casadi.

Mathadon avatar Mathadon commented on September 23, 2024

Okay, thanks for the feedback! I'll leave this open for now since it seems like a valid feature.

from casadi.

jaeandersson avatar jaeandersson commented on September 23, 2024

Okay, thanks for the feedback! I'll leave this open for now since it seems like a valid feature.

It would be a useful feature. It's usually hard to get funding for features that would "benefit a lot of users a little" as opposed to "benefit a few users a lot". That's the situation with a lot of potential core improvements.

from casadi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.