{"action":"created","issue":{"url":"https://api.github.com/repos/josdejong/mathjs/issues/335","labels_url":"https://api.github.com/repos/josdejong/mathjs/issues/335/labels{/name}","comments_url":"https://api.github.com/repos/josdejong/mathjs/issues/335/comments","events_url":"https://api.github.com/repos/josdejong/mathjs/issues/335/events","html_url":"https://github.com/josdejong/mathjs/issues/335","id":70430311,"number":335,"title":"Sparse Matrix implementation","user":{"login":"rjbaucells","id":1074987,"avatar_url":"https://avatars.githubusercontent.com/u/1074987?v=3","gravatar_id":"","url":"https://api.github.com/users/rjbaucells","html_url":"https://github.com/rjbaucells","followers_url":"https://api.github.com/users/rjbaucells/followers","following_url":"https://api.github.com/users/rjbaucells/following{/other_user}","gists_url":"https://api.github.com/users/rjbaucells/gists{/gist_id}","starred_url":"https://api.github.com/users/rjbaucells/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjbaucells/subscriptions","organizations_url":"https://api.github.com/users/rjbaucells/orgs","repos_url":"https://api.github.com/users/rjbaucells/repos","events_url":"https://api.github.com/users/rjbaucells/events{/privacy}","received_events_url":"https://api.github.com/users/rjbaucells/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/josdejong/mathjs/labels/design%20decision","name":"design decision","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-23T14:44:13Z","updated_at":"2015-04-24T12:11:56Z","closed_at":null,"body":"I opened this issue to start a conversation about the implementation I worked on related to Sparse Matrices. I implemented two Sparse Matrix storage formats, the Compressed Column Storage `CCS` and the Compressed Row Storage `CRS`. The two storage formats are very similar, in fact they are the same one looked from a row index (`CRS`) and the other from a column index (`CCS`).\r\n\r\nAt the beginning I though we needed both storage formats since one has advantages over the other for some cases; as an example, if an algorithm needs to process a row at a time the `CRS` is the way to go if it needs to process a column at a time the `CCS` is better.\r\n\r\nHaving both formats is putting an overhead on the algorithm implementations since we have to implement all possible combinations. For example a simple Matrix * Matrix multiplication will need 9 different implementations since we have three formats available (`dense`, `ccs` and `crs`). See current v2 implementation of `multiply()`.\r\n\r\nThe majority of algorithms I have seen are designed for `CCS`, it is the format used by Matlab, Scilab and others. So what I am proposing here is to drop `CRS` (in V2) and implement everything related to sparse matrices using `CCS`.\r\n\r\nWe will leave the pluggable architecture in place so more storage formats can be added if needed for a specific algorithm. This way we can check at the beginning if the storage format is compatible with the algorithm and throw an exception if this is not the case.\r\n\r\nWhat do you think?"},"comment":{"url":"https://api.github.com/repos/josdejong/mathjs/issues/comments/95912739","html_url":"https://github.com/josdejong/mathjs/issues/335#issuecomment-95912739","issue_url":"https://api.github.com/repos/josdejong/mathjs/issues/335","id":95912739,"user":{"login":"josdejong","id":568626,"avatar_url":"https://avatars.githubusercontent.com/u/568626?v=3","gravatar_id":"","url":"https://api.github.com/users/josdejong","html_url":"https://github.com/josdejong","followers_url":"https://api.github.com/users/josdejong/followers","following_url":"https://api.github.com/users/josdejong/following{/other_user}","gists_url":"https://api.github.com/users/josdejong/gists{/gist_id}","starred_url":"https://api.github.com/users/josdejong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josdejong/subscriptions","organizations_url":"https://api.github.com/users/josdejong/orgs","repos_url":"https://api.github.com/users/josdejong/repos","events_url":"https://api.github.com/users/josdejong/events{/privacy}","received_events_url":"https://api.github.com/users/josdejong/received_events","type":"User","site_admin":false},"created_at":"2015-04-24T12:11:56Z","updated_at":"2015-04-24T12:11:56Z","body":"Thanks for opening this discussion. It makes sense to me to just keep one of the two sparse matrix implementations, that will make things a lot easier, and I think you are right that we would not loose that much functionality.\r\n\r\nI'm ok with removing CRS and just keeping CCS. How do you think about renaming `CcsMatrix` to `SparseMatrix`, and change creation from `math.matrix([...], 'ccs')` to `math.matrix([...], 'sparse')`? We could also introduce a new convenience function `math.sparse([...])` like Matlab has. That may make things more intuitive to use."}}