{"action":"created","comment":{"url":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/comments/80552834","id":80552834,"diff_hunk":"@@ -0,0 +1,258 @@\n+//! The CSC sparse matrix module.\n+\n+mod csc_matrix_arithm;\n+\n+use libnum::{One, Zero};\n+\n+use sparse_matrix::compressed_matrix::compressed_matrix_utils::*;\n+use sparse_matrix::compressed_matrix::CompressedMatrix;\n+use sparse_matrix::compressed_matrix::csr_matrix::CsrMatrix;\n+use sparse_matrix::coordinate::Coordinate;\n+use sparse_matrix::SparseMatrix;\n+\n+/// The `CscMatrix` struct.\n+///\n+/// Can be instantiated with any type.\n+#[derive(Debug, PartialEq, Eq, Hash)]\n+pub struct CscMatrix<T> {\n+    rows: usize,\n+    cols: usize,\n+    indices: Vec<usize>,\n+    nnz: usize,\n+    ptrs: Vec<usize>,\n+    values: Vec<T>,\n+}\n+\n+impl<T: Copy + One + Zero> CompressedMatrix<T> for CscMatrix<T> {\n+    /// # Examples\n+    ///\n+    /// ```\n+    /// use rulinalg::sparse_matrix::SparseMatrix;\n+    /// use rulinalg::sparse_matrix::compressed_matrix::CompressedMatrix;\n+    /// use rulinalg::sparse_matrix::compressed_matrix::csc_matrix::CscMatrix;\n+    ///\n+    /// let csc_mat = CscMatrix::new(4, 4, vec![0, 1, 2], vec![0, 1, 2, 3], vec![1, 2, 3]);\n+    ///\n+    /// assert_eq!(csc_mat.rows(), 4);\n+    /// assert_eq!(csc_mat.cols(), 4);\n+    /// ```\n+    ///\n+    /// # Panics\n+    ///\n+    /// Indices length does not match values length\n+    fn new(rows: usize,\n+           cols: usize,\n+           indices: Vec<usize>,\n+           ptrs: Vec<usize>,\n+           values: Vec<T>)\n+           -> CscMatrix<T> {\n+        assert!(indices.len() == values.len(),\n+                \"Column indices must be equal row values\");\n+\n+        let nnz = indices.len();\n+\n+        CscMatrix {\n+            rows: rows,\n+            cols: cols,\n+            indices: indices,\n+            nnz: nnz,\n+            ptrs: ptrs,\n+            values: values,\n+        }\n+    }\n+\n+    fn indices(&self) -> &[usize] {\n+        &self.indices.as_slice()\n+    }\n+    fn ptrs(&self) -> &[usize] {\n+        &self.ptrs.as_slice()\n+    }\n+    fn values(&self) -> &[T] {\n+        &self.values.as_slice()\n+    }\n+    fn set_indices(&mut self, indices: &Vec<usize>) {\n+        if indices.len() == self.nnz {\n+            self.indices = indices.clone();\n+        }\n+    }\n+    fn set_ptrs(&mut self, ptrs: &Vec<usize>) {\n+        if ptrs.len() == (self.cols + 1) {\n+            self.ptrs = ptrs.clone();\n+        }\n+    }\n+    fn set_values(&mut self, values: &Vec<T>) {\n+        if values.len() == self.nnz {\n+            self.values = values.clone();\n+        }\n+    }\n+}\n+\n+impl<T: Copy + One + Zero> SparseMatrix<T> for CscMatrix<T> {\n+\tfn from_coordinates<C>(coords: &[C]) -> CscMatrix<T> where C: Coordinate<T> {\n+    \tunimplemented!();\n+    }\n+    /// # Examples\n+    ///\n+    /// ```\n+    /// use rulinalg::sparse_matrix::SparseMatrix;\n+    /// use rulinalg::sparse_matrix::compressed_matrix::CompressedMatrix;\n+    /// use rulinalg::sparse_matrix::compressed_matrix::csc_matrix::CscMatrix;\n+    ///\n+    /// let csc_mat = CscMatrix::from_diag(&[1.0,2.0,3.0,4.0]);\n+    /// ```\n+    fn from_diag(diag: &[T]) -> CscMatrix<T> {\n+        let size = diag.len();\n+\n+        CscMatrix {\n+            rows: size,\n+            cols: size,\n+            indices: (0..size).collect::<Vec<usize>>(),\n+            nnz: size,\n+            ptrs: (0..(size + 1)).collect::<Vec<usize>>(),\n+            values: diag.to_vec(),\n+        }\n+    }\n+    /// # Examples\n+    ///\n+    /// ```\n+    /// use rulinalg::sparse_matrix::SparseMatrix;\n+    /// use rulinalg::sparse_matrix::compressed_matrix::CompressedMatrix;\n+    /// use rulinalg::sparse_matrix::compressed_matrix::csc_matrix::CscMatrix;\n+    ///\n+    /// let I = CscMatrix::<f64>::identity(4);\n+    /// ```\n+    fn identity(size: usize) -> CscMatrix<T> {\n+        CscMatrix {\n+            rows: size,\n+            cols: size,\n+            indices: (0..size).collect::<Vec<usize>>(),\n+            nnz: size,\n+            ptrs: (0..(size + 1)).collect::<Vec<usize>>(),\n+            values: vec![T::one(); size],\n+        }\n+    }\n+\n+    fn rows(&self) -> usize {\n+        self.rows\n+    }\n+    fn cols(&self) -> usize {\n+        self.cols\n+    }\n+    fn nnz(&self) -> usize {\n+        self.nnz","path":"src/sparse_matrix/compressed_matrix/csc_matrix/mod.rs","position":142,"original_position":142,"commit_id":"1955552418c75456787811eb2ad07bd1d0660a9a","original_commit_id":"1955552418c75456787811eb2ad07bd1d0660a9a","user":{"login":"Andlon","id":578309,"avatar_url":"https://avatars.githubusercontent.com/u/578309?v=3","gravatar_id":"","url":"https://api.github.com/users/Andlon","html_url":"https://github.com/Andlon","followers_url":"https://api.github.com/users/Andlon/followers","following_url":"https://api.github.com/users/Andlon/following{/other_user}","gists_url":"https://api.github.com/users/Andlon/gists{/gist_id}","starred_url":"https://api.github.com/users/Andlon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andlon/subscriptions","organizations_url":"https://api.github.com/users/Andlon/orgs","repos_url":"https://api.github.com/users/Andlon/repos","events_url":"https://api.github.com/users/Andlon/events{/privacy}","received_events_url":"https://api.github.com/users/Andlon/received_events","type":"User","site_admin":false},"body":"I'm a little tired now, so maybe I'm missing something obvious, but isn't `nnz` simply equal to `values.len()`? (in which case we could trim off a redundant member in our matrix)","created_at":"2016-09-26T19:27:21Z","updated_at":"2016-09-26T19:27:21Z","html_url":"https://github.com/AtheMathmo/rulinalg/pull/51#discussion_r80552834","pull_request_url":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/51","_links":{"self":{"href":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/comments/80552834"},"html":{"href":"https://github.com/AtheMathmo/rulinalg/pull/51#discussion_r80552834"},"pull_request":{"href":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/51"}}},"pull_request":{"url":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/51","id":86651839,"html_url":"https://github.com/AtheMathmo/rulinalg/pull/51","diff_url":"https://github.com/AtheMathmo/rulinalg/pull/51.diff","patch_url":"https://github.com/AtheMathmo/rulinalg/pull/51.patch","issue_url":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/51","number":51,"state":"open","locked":false,"title":"Sparse matrix (COO, CSC, CSR) implementations","user":{"login":"c410-f3r","id":17877264,"avatar_url":"https://avatars.githubusercontent.com/u/17877264?v=3","gravatar_id":"","url":"https://api.github.com/users/c410-f3r","html_url":"https://github.com/c410-f3r","followers_url":"https://api.github.com/users/c410-f3r/followers","following_url":"https://api.github.com/users/c410-f3r/following{/other_user}","gists_url":"https://api.github.com/users/c410-f3r/gists{/gist_id}","starred_url":"https://api.github.com/users/c410-f3r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c410-f3r/subscriptions","organizations_url":"https://api.github.com/users/c410-f3r/orgs","repos_url":"https://api.github.com/users/c410-f3r/repos","events_url":"https://api.github.com/users/c410-f3r/events{/privacy}","received_events_url":"https://api.github.com/users/c410-f3r/received_events","type":"User","site_admin":false},"body":"This initial pull request is intended to discussion the viability of sparse matrix implementations and code review","created_at":"2016-09-25T14:41:32Z","updated_at":"2016-09-26T19:38:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cc86b3282c9d9fac06202040724a7a9fc9708783","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/51/commits","review_comments_url":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/51/comments","review_comment_url":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/51/comments","statuses_url":"https://api.github.com/repos/AtheMathmo/rulinalg/statuses/1955552418c75456787811eb2ad07bd1d0660a9a","head":{"label":"c410-f3r:master","ref":"master","sha":"1955552418c75456787811eb2ad07bd1d0660a9a","user":{"login":"c410-f3r","id":17877264,"avatar_url":"https://avatars.githubusercontent.com/u/17877264?v=3","gravatar_id":"","url":"https://api.github.com/users/c410-f3r","html_url":"https://github.com/c410-f3r","followers_url":"https://api.github.com/users/c410-f3r/followers","following_url":"https://api.github.com/users/c410-f3r/following{/other_user}","gists_url":"https://api.github.com/users/c410-f3r/gists{/gist_id}","starred_url":"https://api.github.com/users/c410-f3r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c410-f3r/subscriptions","organizations_url":"https://api.github.com/users/c410-f3r/orgs","repos_url":"https://api.github.com/users/c410-f3r/repos","events_url":"https://api.github.com/users/c410-f3r/events{/privacy}","received_events_url":"https://api.github.com/users/c410-f3r/received_events","type":"User","site_admin":false},"repo":{"id":69169072,"name":"rulinalg","full_name":"c410-f3r/rulinalg","owner":{"login":"c410-f3r","id":17877264,"avatar_url":"https://avatars.githubusercontent.com/u/17877264?v=3","gravatar_id":"","url":"https://api.github.com/users/c410-f3r","html_url":"https://github.com/c410-f3r","followers_url":"https://api.github.com/users/c410-f3r/followers","following_url":"https://api.github.com/users/c410-f3r/following{/other_user}","gists_url":"https://api.github.com/users/c410-f3r/gists{/gist_id}","starred_url":"https://api.github.com/users/c410-f3r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c410-f3r/subscriptions","organizations_url":"https://api.github.com/users/c410-f3r/orgs","repos_url":"https://api.github.com/users/c410-f3r/repos","events_url":"https://api.github.com/users/c410-f3r/events{/privacy}","received_events_url":"https://api.github.com/users/c410-f3r/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/c410-f3r/rulinalg","description":"A linear algebra library in Rust designed for machine learning","fork":true,"url":"https://api.github.com/repos/c410-f3r/rulinalg","forks_url":"https://api.github.com/repos/c410-f3r/rulinalg/forks","keys_url":"https://api.github.com/repos/c410-f3r/rulinalg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/c410-f3r/rulinalg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/c410-f3r/rulinalg/teams","hooks_url":"https://api.github.com/repos/c410-f3r/rulinalg/hooks","issue_events_url":"https://api.github.com/repos/c410-f3r/rulinalg/issues/events{/number}","events_url":"https://api.github.com/repos/c410-f3r/rulinalg/events","assignees_url":"https://api.github.com/repos/c410-f3r/rulinalg/assignees{/user}","branches_url":"https://api.github.com/repos/c410-f3r/rulinalg/branches{/branch}","tags_url":"https://api.github.com/repos/c410-f3r/rulinalg/tags","blobs_url":"https://api.github.com/repos/c410-f3r/rulinalg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/c410-f3r/rulinalg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/c410-f3r/rulinalg/git/refs{/sha}","trees_url":"https://api.github.com/repos/c410-f3r/rulinalg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/c410-f3r/rulinalg/statuses/{sha}","languages_url":"https://api.github.com/repos/c410-f3r/rulinalg/languages","stargazers_url":"https://api.github.com/repos/c410-f3r/rulinalg/stargazers","contributors_url":"https://api.github.com/repos/c410-f3r/rulinalg/contributors","subscribers_url":"https://api.github.com/repos/c410-f3r/rulinalg/subscribers","subscription_url":"https://api.github.com/repos/c410-f3r/rulinalg/subscription","commits_url":"https://api.github.com/repos/c410-f3r/rulinalg/commits{/sha}","git_commits_url":"https://api.github.com/repos/c410-f3r/rulinalg/git/commits{/sha}","comments_url":"https://api.github.com/repos/c410-f3r/rulinalg/comments{/number}","issue_comment_url":"https://api.github.com/repos/c410-f3r/rulinalg/issues/comments{/number}","contents_url":"https://api.github.com/repos/c410-f3r/rulinalg/contents/{+path}","compare_url":"https://api.github.com/repos/c410-f3r/rulinalg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/c410-f3r/rulinalg/merges","archive_url":"https://api.github.com/repos/c410-f3r/rulinalg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/c410-f3r/rulinalg/downloads","issues_url":"https://api.github.com/repos/c410-f3r/rulinalg/issues{/number}","pulls_url":"https://api.github.com/repos/c410-f3r/rulinalg/pulls{/number}","milestones_url":"https://api.github.com/repos/c410-f3r/rulinalg/milestones{/number}","notifications_url":"https://api.github.com/repos/c410-f3r/rulinalg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/c410-f3r/rulinalg/labels{/name}","releases_url":"https://api.github.com/repos/c410-f3r/rulinalg/releases{/id}","deployments_url":"https://api.github.com/repos/c410-f3r/rulinalg/deployments","created_at":"2016-09-25T14:25:24Z","updated_at":"2016-09-25T14:25:25Z","pushed_at":"2016-09-26T00:17:25Z","git_url":"git://github.com/c410-f3r/rulinalg.git","ssh_url":"git@github.com:c410-f3r/rulinalg.git","clone_url":"https://github.com/c410-f3r/rulinalg.git","svn_url":"https://github.com/c410-f3r/rulinalg","homepage":"https://crates.io/crates/rulinalg","size":1289,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"AtheMathmo:master","ref":"master","sha":"4ef46b64116b8c0c23046f25929019cb9c3a6a2f","user":{"login":"AtheMathmo","id":10150986,"avatar_url":"https://avatars.githubusercontent.com/u/10150986?v=3","gravatar_id":"","url":"https://api.github.com/users/AtheMathmo","html_url":"https://github.com/AtheMathmo","followers_url":"https://api.github.com/users/AtheMathmo/followers","following_url":"https://api.github.com/users/AtheMathmo/following{/other_user}","gists_url":"https://api.github.com/users/AtheMathmo/gists{/gist_id}","starred_url":"https://api.github.com/users/AtheMathmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AtheMathmo/subscriptions","organizations_url":"https://api.github.com/users/AtheMathmo/orgs","repos_url":"https://api.github.com/users/AtheMathmo/repos","events_url":"https://api.github.com/users/AtheMathmo/events{/privacy}","received_events_url":"https://api.github.com/users/AtheMathmo/received_events","type":"User","site_admin":false},"repo":{"id":62955795,"name":"rulinalg","full_name":"AtheMathmo/rulinalg","owner":{"login":"AtheMathmo","id":10150986,"avatar_url":"https://avatars.githubusercontent.com/u/10150986?v=3","gravatar_id":"","url":"https://api.github.com/users/AtheMathmo","html_url":"https://github.com/AtheMathmo","followers_url":"https://api.github.com/users/AtheMathmo/followers","following_url":"https://api.github.com/users/AtheMathmo/following{/other_user}","gists_url":"https://api.github.com/users/AtheMathmo/gists{/gist_id}","starred_url":"https://api.github.com/users/AtheMathmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AtheMathmo/subscriptions","organizations_url":"https://api.github.com/users/AtheMathmo/orgs","repos_url":"https://api.github.com/users/AtheMathmo/repos","events_url":"https://api.github.com/users/AtheMathmo/events{/privacy}","received_events_url":"https://api.github.com/users/AtheMathmo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AtheMathmo/rulinalg","description":"A linear algebra library in Rust designed for machine learning","fork":false,"url":"https://api.github.com/repos/AtheMathmo/rulinalg","forks_url":"https://api.github.com/repos/AtheMathmo/rulinalg/forks","keys_url":"https://api.github.com/repos/AtheMathmo/rulinalg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AtheMathmo/rulinalg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AtheMathmo/rulinalg/teams","hooks_url":"https://api.github.com/repos/AtheMathmo/rulinalg/hooks","issue_events_url":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/events{/number}","events_url":"https://api.github.com/repos/AtheMathmo/rulinalg/events","assignees_url":"https://api.github.com/repos/AtheMathmo/rulinalg/assignees{/user}","branches_url":"https://api.github.com/repos/AtheMathmo/rulinalg/branches{/branch}","tags_url":"https://api.github.com/repos/AtheMathmo/rulinalg/tags","blobs_url":"https://api.github.com/repos/AtheMathmo/rulinalg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AtheMathmo/rulinalg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AtheMathmo/rulinalg/git/refs{/sha}","trees_url":"https://api.github.com/repos/AtheMathmo/rulinalg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AtheMathmo/rulinalg/statuses/{sha}","languages_url":"https://api.github.com/repos/AtheMathmo/rulinalg/languages","stargazers_url":"https://api.github.com/repos/AtheMathmo/rulinalg/stargazers","contributors_url":"https://api.github.com/repos/AtheMathmo/rulinalg/contributors","subscribers_url":"https://api.github.com/repos/AtheMathmo/rulinalg/subscribers","subscription_url":"https://api.github.com/repos/AtheMathmo/rulinalg/subscription","commits_url":"https://api.github.com/repos/AtheMathmo/rulinalg/commits{/sha}","git_commits_url":"https://api.github.com/repos/AtheMathmo/rulinalg/git/commits{/sha}","comments_url":"https://api.github.com/repos/AtheMathmo/rulinalg/comments{/number}","issue_comment_url":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/comments{/number}","contents_url":"https://api.github.com/repos/AtheMathmo/rulinalg/contents/{+path}","compare_url":"https://api.github.com/repos/AtheMathmo/rulinalg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AtheMathmo/rulinalg/merges","archive_url":"https://api.github.com/repos/AtheMathmo/rulinalg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AtheMathmo/rulinalg/downloads","issues_url":"https://api.github.com/repos/AtheMathmo/rulinalg/issues{/number}","pulls_url":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls{/number}","milestones_url":"https://api.github.com/repos/AtheMathmo/rulinalg/milestones{/number}","notifications_url":"https://api.github.com/repos/AtheMathmo/rulinalg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AtheMathmo/rulinalg/labels{/name}","releases_url":"https://api.github.com/repos/AtheMathmo/rulinalg/releases{/id}","deployments_url":"https://api.github.com/repos/AtheMathmo/rulinalg/deployments","created_at":"2016-07-09T15:27:53Z","updated_at":"2016-09-25T17:08:15Z","pushed_at":"2016-09-26T17:39:33Z","git_url":"git://github.com/AtheMathmo/rulinalg.git","ssh_url":"git@github.com:AtheMathmo/rulinalg.git","clone_url":"https://github.com/AtheMathmo/rulinalg.git","svn_url":"https://github.com/AtheMathmo/rulinalg","homepage":"https://crates.io/crates/rulinalg","size":1423,"stargazers_count":65,"watchers_count":65,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":20,"forks":14,"open_issues":20,"watchers":65,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/51"},"html":{"href":"https://github.com/AtheMathmo/rulinalg/pull/51"},"issue":{"href":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/51"},"comments":{"href":"https://api.github.com/repos/AtheMathmo/rulinalg/issues/51/comments"},"review_comments":{"href":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/51/comments"},"review_comment":{"href":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AtheMathmo/rulinalg/pulls/51/commits"},"statuses":{"href":"https://api.github.com/repos/AtheMathmo/rulinalg/statuses/1955552418c75456787811eb2ad07bd1d0660a9a"}}}}
{"actor":{"display_login":"Andlon"}}