{"action":"created","comment":{"url":"https://api.github.com/repos/matlisp/matlisp/pulls/comments/172166516","pull_request_review_id":101136252,"id":172166516,"diff_hunk":"@@ -0,0 +1,43 @@\n+;;; Interop\n+;;; Functions to convert between Matlisp tensors and CL arrays\n+\n+(in-package #:matlisp)\n+\n+(defgeneric as-tensor (object)\n+  (:documentation \"Returns OBJECT as a Matlisp tensor type. May share storage or copy.\"))\n+\n+(defmethod as-tensor ((object tensor))\n+  \"If already a tensor then just return\"\n+  object)\n+\n+(defmethod as-tensor ((object simple-vector))\n+  \"Simple vectors can be used as store for a tensor. \n+   The resulting tensor will share storage with the vector.\"\n+  (make-instance (tensor (array-element-type object)) \n+                 :dimensions  (coerce (array-dimensions object) '(simple-array index-type (*)))\n+                 :store object))\n+\n+(defmethod as-tensor ((object array))\n+  \"Convert array OBJECT to tensor by copying contents\"\n+  (copy object\n+        (tensor (array-element-type object))))\n+\n+;;;\n+\n+(defgeneric as-array (object)\n+  (:documentation \"Returns OBJECT as a CL array type. May share storage or copy. \"))\n+\n+(defmethod as-array ((object array))\n+  \"If already an array, just return\"\n+  object)\n+\n+(defmethod as-array ((object tensor))","path":"src/base/interop.lisp","position":34,"original_position":34,"commit_id":"14bb54a95dc33d9d833e122ec022aa96544c991c","original_commit_id":"14bb54a95dc33d9d833e122ec022aa96544c991c","user":{"login":"bendudson","id":219233,"avatar_url":"https://avatars1.githubusercontent.com/u/219233?v=4","gravatar_id":"","url":"https://api.github.com/users/bendudson","html_url":"https://github.com/bendudson","followers_url":"https://api.github.com/users/bendudson/followers","following_url":"https://api.github.com/users/bendudson/following{/other_user}","gists_url":"https://api.github.com/users/bendudson/gists{/gist_id}","starred_url":"https://api.github.com/users/bendudson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendudson/subscriptions","organizations_url":"https://api.github.com/users/bendudson/orgs","repos_url":"https://api.github.com/users/bendudson/repos","events_url":"https://api.github.com/users/bendudson/events{/privacy}","received_events_url":"https://api.github.com/users/bendudson/received_events","type":"User","site_admin":false},"body":"Ah, hadn't come across the sparse matrix/tensor parts yet. Thanks! \r\nDo you think this general approach has any merit, or should users just be advised to use `copy`?","created_at":"2018-03-05T12:08:03Z","updated_at":"2018-03-05T12:08:03Z","html_url":"https://github.com/matlisp/matlisp/pull/21#discussion_r172166516","pull_request_url":"https://api.github.com/repos/matlisp/matlisp/pulls/21","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/matlisp/matlisp/pulls/comments/172166516"},"html":{"href":"https://github.com/matlisp/matlisp/pull/21#discussion_r172166516"},"pull_request":{"href":"https://api.github.com/repos/matlisp/matlisp/pulls/21"}},"in_reply_to_id":172166163},"pull_request":{"url":"https://api.github.com/repos/matlisp/matlisp/pulls/21","id":172746689,"html_url":"https://github.com/matlisp/matlisp/pull/21","diff_url":"https://github.com/matlisp/matlisp/pull/21.diff","patch_url":"https://github.com/matlisp/matlisp/pull/21.patch","issue_url":"https://api.github.com/repos/matlisp/matlisp/issues/21","number":21,"state":"open","locked":false,"title":"as-tensor and as-array functions","user":{"login":"bendudson","id":219233,"avatar_url":"https://avatars1.githubusercontent.com/u/219233?v=4","gravatar_id":"","url":"https://api.github.com/users/bendudson","html_url":"https://github.com/bendudson","followers_url":"https://api.github.com/users/bendudson/followers","following_url":"https://api.github.com/users/bendudson/following{/other_user}","gists_url":"https://api.github.com/users/bendudson/gists{/gist_id}","starred_url":"https://api.github.com/users/bendudson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendudson/subscriptions","organizations_url":"https://api.github.com/users/bendudson/orgs","repos_url":"https://api.github.com/users/bendudson/repos","events_url":"https://api.github.com/users/bendudson/events{/privacy}","received_events_url":"https://api.github.com/users/bendudson/received_events","type":"User","site_admin":false},"body":"Adds wrappers around copy and (make-instance tensor...) to convert between Matlisp tensors and CL arrays. Not sure if this is the best way to do this, but it may be more intuitive for a new user (like me).\r\n\r\n* 1D arrays and tensors share storage\r\n* Multidimensional arrays and tensors are copied\r\n* When converting multidimensional tensor to array, the result is of element-type T, not specialised.\r\n\r\nIncludes tests, which pass but are not yet run as part of the test suite.\r\n","created_at":"2018-03-04T22:47:12Z","updated_at":"2018-03-05T12:08:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fff9655c93f91b9914c2da650e729e7a83ee364c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/matlisp/matlisp/pulls/21/commits","review_comments_url":"https://api.github.com/repos/matlisp/matlisp/pulls/21/comments","review_comment_url":"https://api.github.com/repos/matlisp/matlisp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matlisp/matlisp/issues/21/comments","statuses_url":"https://api.github.com/repos/matlisp/matlisp/statuses/14bb54a95dc33d9d833e122ec022aa96544c991c","head":{"label":"bendudson:to-tensor","ref":"to-tensor","sha":"14bb54a95dc33d9d833e122ec022aa96544c991c","user":{"login":"bendudson","id":219233,"avatar_url":"https://avatars1.githubusercontent.com/u/219233?v=4","gravatar_id":"","url":"https://api.github.com/users/bendudson","html_url":"https://github.com/bendudson","followers_url":"https://api.github.com/users/bendudson/followers","following_url":"https://api.github.com/users/bendudson/following{/other_user}","gists_url":"https://api.github.com/users/bendudson/gists{/gist_id}","starred_url":"https://api.github.com/users/bendudson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendudson/subscriptions","organizations_url":"https://api.github.com/users/bendudson/orgs","repos_url":"https://api.github.com/users/bendudson/repos","events_url":"https://api.github.com/users/bendudson/events{/privacy}","received_events_url":"https://api.github.com/users/bendudson/received_events","type":"User","site_admin":false},"repo":{"id":123196076,"name":"matlisp","full_name":"bendudson/matlisp","owner":{"login":"bendudson","id":219233,"avatar_url":"https://avatars1.githubusercontent.com/u/219233?v=4","gravatar_id":"","url":"https://api.github.com/users/bendudson","html_url":"https://github.com/bendudson","followers_url":"https://api.github.com/users/bendudson/followers","following_url":"https://api.github.com/users/bendudson/following{/other_user}","gists_url":"https://api.github.com/users/bendudson/gists{/gist_id}","starred_url":"https://api.github.com/users/bendudson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendudson/subscriptions","organizations_url":"https://api.github.com/users/bendudson/orgs","repos_url":"https://api.github.com/users/bendudson/repos","events_url":"https://api.github.com/users/bendudson/events{/privacy}","received_events_url":"https://api.github.com/users/bendudson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bendudson/matlisp","description":"Matlisp is a scientific computation library for Common Lisp.","fork":true,"url":"https://api.github.com/repos/bendudson/matlisp","forks_url":"https://api.github.com/repos/bendudson/matlisp/forks","keys_url":"https://api.github.com/repos/bendudson/matlisp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bendudson/matlisp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bendudson/matlisp/teams","hooks_url":"https://api.github.com/repos/bendudson/matlisp/hooks","issue_events_url":"https://api.github.com/repos/bendudson/matlisp/issues/events{/number}","events_url":"https://api.github.com/repos/bendudson/matlisp/events","assignees_url":"https://api.github.com/repos/bendudson/matlisp/assignees{/user}","branches_url":"https://api.github.com/repos/bendudson/matlisp/branches{/branch}","tags_url":"https://api.github.com/repos/bendudson/matlisp/tags","blobs_url":"https://api.github.com/repos/bendudson/matlisp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bendudson/matlisp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bendudson/matlisp/git/refs{/sha}","trees_url":"https://api.github.com/repos/bendudson/matlisp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bendudson/matlisp/statuses/{sha}","languages_url":"https://api.github.com/repos/bendudson/matlisp/languages","stargazers_url":"https://api.github.com/repos/bendudson/matlisp/stargazers","contributors_url":"https://api.github.com/repos/bendudson/matlisp/contributors","subscribers_url":"https://api.github.com/repos/bendudson/matlisp/subscribers","subscription_url":"https://api.github.com/repos/bendudson/matlisp/subscription","commits_url":"https://api.github.com/repos/bendudson/matlisp/commits{/sha}","git_commits_url":"https://api.github.com/repos/bendudson/matlisp/git/commits{/sha}","comments_url":"https://api.github.com/repos/bendudson/matlisp/comments{/number}","issue_comment_url":"https://api.github.com/repos/bendudson/matlisp/issues/comments{/number}","contents_url":"https://api.github.com/repos/bendudson/matlisp/contents/{+path}","compare_url":"https://api.github.com/repos/bendudson/matlisp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bendudson/matlisp/merges","archive_url":"https://api.github.com/repos/bendudson/matlisp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bendudson/matlisp/downloads","issues_url":"https://api.github.com/repos/bendudson/matlisp/issues{/number}","pulls_url":"https://api.github.com/repos/bendudson/matlisp/pulls{/number}","milestones_url":"https://api.github.com/repos/bendudson/matlisp/milestones{/number}","notifications_url":"https://api.github.com/repos/bendudson/matlisp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bendudson/matlisp/labels{/name}","releases_url":"https://api.github.com/repos/bendudson/matlisp/releases{/id}","deployments_url":"https://api.github.com/repos/bendudson/matlisp/deployments","created_at":"2018-02-27T22:23:24Z","updated_at":"2018-02-27T22:23:26Z","pushed_at":"2018-03-04T22:40:18Z","git_url":"git://github.com/bendudson/matlisp.git","ssh_url":"git@github.com:bendudson/matlisp.git","clone_url":"https://github.com/bendudson/matlisp.git","svn_url":"https://github.com/bendudson/matlisp","homepage":"","size":7230,"stargazers_count":0,"watchers_count":0,"language":"Common Lisp","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"matlisp:master","ref":"master","sha":"8fc897f986956522fa881f869f8aba42927b2c96","user":{"login":"matlisp","id":7660519,"avatar_url":"https://avatars2.githubusercontent.com/u/7660519?v=4","gravatar_id":"","url":"https://api.github.com/users/matlisp","html_url":"https://github.com/matlisp","followers_url":"https://api.github.com/users/matlisp/followers","following_url":"https://api.github.com/users/matlisp/following{/other_user}","gists_url":"https://api.github.com/users/matlisp/gists{/gist_id}","starred_url":"https://api.github.com/users/matlisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matlisp/subscriptions","organizations_url":"https://api.github.com/users/matlisp/orgs","repos_url":"https://api.github.com/users/matlisp/repos","events_url":"https://api.github.com/users/matlisp/events{/privacy}","received_events_url":"https://api.github.com/users/matlisp/received_events","type":"Organization","site_admin":false},"repo":{"id":4841444,"name":"matlisp","full_name":"matlisp/matlisp","owner":{"login":"matlisp","id":7660519,"avatar_url":"https://avatars2.githubusercontent.com/u/7660519?v=4","gravatar_id":"","url":"https://api.github.com/users/matlisp","html_url":"https://github.com/matlisp","followers_url":"https://api.github.com/users/matlisp/followers","following_url":"https://api.github.com/users/matlisp/following{/other_user}","gists_url":"https://api.github.com/users/matlisp/gists{/gist_id}","starred_url":"https://api.github.com/users/matlisp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matlisp/subscriptions","organizations_url":"https://api.github.com/users/matlisp/orgs","repos_url":"https://api.github.com/users/matlisp/repos","events_url":"https://api.github.com/users/matlisp/events{/privacy}","received_events_url":"https://api.github.com/users/matlisp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/matlisp/matlisp","description":"Matlisp is a scientific computation library for Common Lisp.","fork":false,"url":"https://api.github.com/repos/matlisp/matlisp","forks_url":"https://api.github.com/repos/matlisp/matlisp/forks","keys_url":"https://api.github.com/repos/matlisp/matlisp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matlisp/matlisp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matlisp/matlisp/teams","hooks_url":"https://api.github.com/repos/matlisp/matlisp/hooks","issue_events_url":"https://api.github.com/repos/matlisp/matlisp/issues/events{/number}","events_url":"https://api.github.com/repos/matlisp/matlisp/events","assignees_url":"https://api.github.com/repos/matlisp/matlisp/assignees{/user}","branches_url":"https://api.github.com/repos/matlisp/matlisp/branches{/branch}","tags_url":"https://api.github.com/repos/matlisp/matlisp/tags","blobs_url":"https://api.github.com/repos/matlisp/matlisp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matlisp/matlisp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matlisp/matlisp/git/refs{/sha}","trees_url":"https://api.github.com/repos/matlisp/matlisp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matlisp/matlisp/statuses/{sha}","languages_url":"https://api.github.com/repos/matlisp/matlisp/languages","stargazers_url":"https://api.github.com/repos/matlisp/matlisp/stargazers","contributors_url":"https://api.github.com/repos/matlisp/matlisp/contributors","subscribers_url":"https://api.github.com/repos/matlisp/matlisp/subscribers","subscription_url":"https://api.github.com/repos/matlisp/matlisp/subscription","commits_url":"https://api.github.com/repos/matlisp/matlisp/commits{/sha}","git_commits_url":"https://api.github.com/repos/matlisp/matlisp/git/commits{/sha}","comments_url":"https://api.github.com/repos/matlisp/matlisp/comments{/number}","issue_comment_url":"https://api.github.com/repos/matlisp/matlisp/issues/comments{/number}","contents_url":"https://api.github.com/repos/matlisp/matlisp/contents/{+path}","compare_url":"https://api.github.com/repos/matlisp/matlisp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matlisp/matlisp/merges","archive_url":"https://api.github.com/repos/matlisp/matlisp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matlisp/matlisp/downloads","issues_url":"https://api.github.com/repos/matlisp/matlisp/issues{/number}","pulls_url":"https://api.github.com/repos/matlisp/matlisp/pulls{/number}","milestones_url":"https://api.github.com/repos/matlisp/matlisp/milestones{/number}","notifications_url":"https://api.github.com/repos/matlisp/matlisp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matlisp/matlisp/labels{/name}","releases_url":"https://api.github.com/repos/matlisp/matlisp/releases{/id}","deployments_url":"https://api.github.com/repos/matlisp/matlisp/deployments","created_at":"2012-06-30T09:46:04Z","updated_at":"2018-03-05T08:29:44Z","pushed_at":"2018-03-04T22:47:13Z","git_url":"git://github.com/matlisp/matlisp.git","ssh_url":"git@github.com:matlisp/matlisp.git","clone_url":"https://github.com/matlisp/matlisp.git","svn_url":"https://github.com/matlisp/matlisp","homepage":"","size":7226,"stargazers_count":128,"watchers_count":128,"language":"Common Lisp","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":13,"open_issues":7,"watchers":128,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matlisp/matlisp/pulls/21"},"html":{"href":"https://github.com/matlisp/matlisp/pull/21"},"issue":{"href":"https://api.github.com/repos/matlisp/matlisp/issues/21"},"comments":{"href":"https://api.github.com/repos/matlisp/matlisp/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/matlisp/matlisp/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/matlisp/matlisp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matlisp/matlisp/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/matlisp/matlisp/statuses/14bb54a95dc33d9d833e122ec022aa96544c991c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"bendudson"}}