The title pretty much says it: I learned about storage formats for sparse matrices by building a small app to play around with them. You can enter numbers into a matrix and see the corresponding representation as dense array, triplet format, compressed row storage and compressed column storage (hopefully more in the future). If you don’t know what these words mean, here is the place to find out:

App: maurobringolf.github.io/sparse-matrix-storage-formats

Repository: github.com/maurobringolf/sparse-matrix-storage-formats

It took me one day to build this mainly because of some awesome tools. I really enjoyed the development process with create-react-app1 and testing with Jest. A couple remarks:

  • I spent the majority of time writing, fixing and refactoring tests. The code is easy to test because each format is essentially a mathematical function that needs to be implemented. But I changed the underlying data representation of the output halfway through, so I had to change all existing tests up to that point. Defining all functions and data representations in the beginning could possibly have prevented this, but it was not too bad after all.

  • I spent zero time thinking about Babel or Webpack.

  • I spent zero time formatting code because I used Prettier2 for all source files including CSS and Markdown.

  • Deployment to Github pages literally took no longer than 2 minutes to setup. Now I simply type npm version patch|minor|major and the code is versioned, tested, built and deployed. I simply followed this guide.