{"action":"created","comment":{"url":"https://api.github.com/repos/higumachan/naonn/pulls/comments/67555111","id":67555111,"diff_hunk":"@@ -0,0 +1,135 @@\n+#ifndef NAONN_VARIABLE_HPP\n+#define NAONN_VARIABLE_HPP\n+\n+\n+#include \"Expression.hpp\"\n+#include \"TypeHelper.hpp\"\n+\n+namespace nyao\n+{\n+namespace differentiation\n+{\n+namespace automatic\n+{\n+namespace variable\n+{\n+\n+using id_type = int;\n+\n+namespace impl\n+{\n+\n+template<\n+    typename Type,\n+    id_type ID,\n+    typename TypeHelper=type_helper::TypeHelper<Type>\n+>\n+class Variable\n+{\n+public:\n+  static constexpr id_type id = ID;\n+\n+  using value_type = Type;\n+  using grad_type = Type;\n+\n+  Variable(const Type& _value)\n+  {\n+    value = new Type;\n+    *value = _value;\n+    is_original = true;\n+  }\n+\n+  Variable(const Variable<Type, ID, TypeHelper>& other)\n+    : value(other.value)\n+  {\n+    is_original = false;\n+  }\n+\n+  ~Variable()\n+  {\n+    if (is_original) {\n+      delete value;\n+    }\n+  }\n+\n+  void set_value(const Type& _value)\n+  { *value = _value; }\n+\n+  value_type get_value() const\n+  { return *value; }\n+\n+  grad_type get_grad(const Variable<Type, ID, TypeHelper>&) const\n+  {\n+    return TypeHelper::one();\n+  }\n+\n+  template<typename OtherType, id_type OTHER_ID, typename OtherTypeHelper>\n+  grad_type get_grad(const Variable<OtherType, OTHER_ID, OtherTypeHelper>&) const\n+  {\n+    return (TypeHelper::zero());\n+  }\n+\n+private:\n+  value_type* value;\n+  bool is_original = false;\n+};\n+\n+namespace\n+{\n+const int CONST_VARIABLE_ID = -1;\n+}\n+\n+\n+template<\n+    typename Type,\n+    typename TypeHelper=type_helper::TypeHelper<Type>\n+>\n+struct ConstVariable\n+{\n+  using value_type = Type;\n+  using grad_type = Type;\n+\n+  static_assert(!std::is_reference<value_type>::value, \"reference\");","path":"modules/AutomaticDifferentiation/include/AutomaticDifferentiation/Variable.hpp","position":92,"original_position":92,"commit_id":"69f2f91b00995ebfc15d2a427ea1d6be4e4d6b4a","original_commit_id":"69f2f91b00995ebfc15d2a427ea1d6be4e4d6b4a","user":{"login":"orisano","id":1029249,"avatar_url":"https://avatars.githubusercontent.com/u/1029249?v=3","gravatar_id":"","url":"https://api.github.com/users/orisano","html_url":"https://github.com/orisano","followers_url":"https://api.github.com/users/orisano/followers","following_url":"https://api.github.com/users/orisano/following{/other_user}","gists_url":"https://api.github.com/users/orisano/gists{/gist_id}","starred_url":"https://api.github.com/users/orisano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orisano/subscriptions","organizations_url":"https://api.github.com/users/orisano/orgs","repos_url":"https://api.github.com/users/orisano/repos","events_url":"https://api.github.com/users/orisano/events{/privacy}","received_events_url":"https://api.github.com/users/orisano/received_events","type":"User","site_admin":false},"body":"流石にreferenceとだけ書かれてもわからない気がしますね","created_at":"2016-06-17T18:29:29Z","updated_at":"2016-06-17T18:29:29Z","html_url":"https://github.com/higumachan/naonn/pull/4#discussion_r67555111","pull_request_url":"https://api.github.com/repos/higumachan/naonn/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/higumachan/naonn/pulls/comments/67555111"},"html":{"href":"https://github.com/higumachan/naonn/pull/4#discussion_r67555111"},"pull_request":{"href":"https://api.github.com/repos/higumachan/naonn/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/higumachan/naonn/pulls/4","id":73573215,"html_url":"https://github.com/higumachan/naonn/pull/4","diff_url":"https://github.com/higumachan/naonn/pull/4.diff","patch_url":"https://github.com/higumachan/naonn/pull/4.patch","issue_url":"https://api.github.com/repos/higumachan/naonn/issues/4","number":4,"state":"open","locked":false,"title":"Feature/automatic differentiation","user":{"login":"higumachan","id":1011298,"avatar_url":"https://avatars.githubusercontent.com/u/1011298?v=3","gravatar_id":"","url":"https://api.github.com/users/higumachan","html_url":"https://github.com/higumachan","followers_url":"https://api.github.com/users/higumachan/followers","following_url":"https://api.github.com/users/higumachan/following{/other_user}","gists_url":"https://api.github.com/users/higumachan/gists{/gist_id}","starred_url":"https://api.github.com/users/higumachan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/higumachan/subscriptions","organizations_url":"https://api.github.com/users/higumachan/orgs","repos_url":"https://api.github.com/users/higumachan/repos","events_url":"https://api.github.com/users/higumachan/events{/privacy}","received_events_url":"https://api.github.com/users/higumachan/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-13T13:14:44Z","updated_at":"2016-06-17T18:29:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"815dbc2f7f69b3bbfafd1a0958d81e249c0d9863","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/higumachan/naonn/pulls/4/commits","review_comments_url":"https://api.github.com/repos/higumachan/naonn/pulls/4/comments","review_comment_url":"https://api.github.com/repos/higumachan/naonn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/higumachan/naonn/issues/4/comments","statuses_url":"https://api.github.com/repos/higumachan/naonn/statuses/69f2f91b00995ebfc15d2a427ea1d6be4e4d6b4a","head":{"label":"higumachan:feature/AutomaticDifferentiation","ref":"feature/AutomaticDifferentiation","sha":"69f2f91b00995ebfc15d2a427ea1d6be4e4d6b4a","user":{"login":"higumachan","id":1011298,"avatar_url":"https://avatars.githubusercontent.com/u/1011298?v=3","gravatar_id":"","url":"https://api.github.com/users/higumachan","html_url":"https://github.com/higumachan","followers_url":"https://api.github.com/users/higumachan/followers","following_url":"https://api.github.com/users/higumachan/following{/other_user}","gists_url":"https://api.github.com/users/higumachan/gists{/gist_id}","starred_url":"https://api.github.com/users/higumachan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/higumachan/subscriptions","organizations_url":"https://api.github.com/users/higumachan/orgs","repos_url":"https://api.github.com/users/higumachan/repos","events_url":"https://api.github.com/users/higumachan/events{/privacy}","received_events_url":"https://api.github.com/users/higumachan/received_events","type":"User","site_admin":false},"repo":{"id":60913591,"name":"naonn","full_name":"higumachan/naonn","owner":{"login":"higumachan","id":1011298,"avatar_url":"https://avatars.githubusercontent.com/u/1011298?v=3","gravatar_id":"","url":"https://api.github.com/users/higumachan","html_url":"https://github.com/higumachan","followers_url":"https://api.github.com/users/higumachan/followers","following_url":"https://api.github.com/users/higumachan/following{/other_user}","gists_url":"https://api.github.com/users/higumachan/gists{/gist_id}","starred_url":"https://api.github.com/users/higumachan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/higumachan/subscriptions","organizations_url":"https://api.github.com/users/higumachan/orgs","repos_url":"https://api.github.com/users/higumachan/repos","events_url":"https://api.github.com/users/higumachan/events{/privacy}","received_events_url":"https://api.github.com/users/higumachan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/higumachan/naonn","description":"","fork":false,"url":"https://api.github.com/repos/higumachan/naonn","forks_url":"https://api.github.com/repos/higumachan/naonn/forks","keys_url":"https://api.github.com/repos/higumachan/naonn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/higumachan/naonn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/higumachan/naonn/teams","hooks_url":"https://api.github.com/repos/higumachan/naonn/hooks","issue_events_url":"https://api.github.com/repos/higumachan/naonn/issues/events{/number}","events_url":"https://api.github.com/repos/higumachan/naonn/events","assignees_url":"https://api.github.com/repos/higumachan/naonn/assignees{/user}","branches_url":"https://api.github.com/repos/higumachan/naonn/branches{/branch}","tags_url":"https://api.github.com/repos/higumachan/naonn/tags","blobs_url":"https://api.github.com/repos/higumachan/naonn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/higumachan/naonn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/higumachan/naonn/git/refs{/sha}","trees_url":"https://api.github.com/repos/higumachan/naonn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/higumachan/naonn/statuses/{sha}","languages_url":"https://api.github.com/repos/higumachan/naonn/languages","stargazers_url":"https://api.github.com/repos/higumachan/naonn/stargazers","contributors_url":"https://api.github.com/repos/higumachan/naonn/contributors","subscribers_url":"https://api.github.com/repos/higumachan/naonn/subscribers","subscription_url":"https://api.github.com/repos/higumachan/naonn/subscription","commits_url":"https://api.github.com/repos/higumachan/naonn/commits{/sha}","git_commits_url":"https://api.github.com/repos/higumachan/naonn/git/commits{/sha}","comments_url":"https://api.github.com/repos/higumachan/naonn/comments{/number}","issue_comment_url":"https://api.github.com/repos/higumachan/naonn/issues/comments{/number}","contents_url":"https://api.github.com/repos/higumachan/naonn/contents/{+path}","compare_url":"https://api.github.com/repos/higumachan/naonn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/higumachan/naonn/merges","archive_url":"https://api.github.com/repos/higumachan/naonn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/higumachan/naonn/downloads","issues_url":"https://api.github.com/repos/higumachan/naonn/issues{/number}","pulls_url":"https://api.github.com/repos/higumachan/naonn/pulls{/number}","milestones_url":"https://api.github.com/repos/higumachan/naonn/milestones{/number}","notifications_url":"https://api.github.com/repos/higumachan/naonn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/higumachan/naonn/labels{/name}","releases_url":"https://api.github.com/repos/higumachan/naonn/releases{/id}","deployments_url":"https://api.github.com/repos/higumachan/naonn/deployments","created_at":"2016-06-11T15:26:46Z","updated_at":"2016-06-11T15:37:52Z","pushed_at":"2016-06-17T18:13:41Z","git_url":"git://github.com/higumachan/naonn.git","ssh_url":"git@github.com:higumachan/naonn.git","clone_url":"https://github.com/higumachan/naonn.git","svn_url":"https://github.com/higumachan/naonn","homepage":null,"size":76,"stargazers_count":0,"watchers_count":0,"language":"CMake","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"higumachan:develop","ref":"develop","sha":"22ac7c79b53050838d55116c66dcca2eb3fa4ee4","user":{"login":"higumachan","id":1011298,"avatar_url":"https://avatars.githubusercontent.com/u/1011298?v=3","gravatar_id":"","url":"https://api.github.com/users/higumachan","html_url":"https://github.com/higumachan","followers_url":"https://api.github.com/users/higumachan/followers","following_url":"https://api.github.com/users/higumachan/following{/other_user}","gists_url":"https://api.github.com/users/higumachan/gists{/gist_id}","starred_url":"https://api.github.com/users/higumachan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/higumachan/subscriptions","organizations_url":"https://api.github.com/users/higumachan/orgs","repos_url":"https://api.github.com/users/higumachan/repos","events_url":"https://api.github.com/users/higumachan/events{/privacy}","received_events_url":"https://api.github.com/users/higumachan/received_events","type":"User","site_admin":false},"repo":{"id":60913591,"name":"naonn","full_name":"higumachan/naonn","owner":{"login":"higumachan","id":1011298,"avatar_url":"https://avatars.githubusercontent.com/u/1011298?v=3","gravatar_id":"","url":"https://api.github.com/users/higumachan","html_url":"https://github.com/higumachan","followers_url":"https://api.github.com/users/higumachan/followers","following_url":"https://api.github.com/users/higumachan/following{/other_user}","gists_url":"https://api.github.com/users/higumachan/gists{/gist_id}","starred_url":"https://api.github.com/users/higumachan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/higumachan/subscriptions","organizations_url":"https://api.github.com/users/higumachan/orgs","repos_url":"https://api.github.com/users/higumachan/repos","events_url":"https://api.github.com/users/higumachan/events{/privacy}","received_events_url":"https://api.github.com/users/higumachan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/higumachan/naonn","description":"","fork":false,"url":"https://api.github.com/repos/higumachan/naonn","forks_url":"https://api.github.com/repos/higumachan/naonn/forks","keys_url":"https://api.github.com/repos/higumachan/naonn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/higumachan/naonn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/higumachan/naonn/teams","hooks_url":"https://api.github.com/repos/higumachan/naonn/hooks","issue_events_url":"https://api.github.com/repos/higumachan/naonn/issues/events{/number}","events_url":"https://api.github.com/repos/higumachan/naonn/events","assignees_url":"https://api.github.com/repos/higumachan/naonn/assignees{/user}","branches_url":"https://api.github.com/repos/higumachan/naonn/branches{/branch}","tags_url":"https://api.github.com/repos/higumachan/naonn/tags","blobs_url":"https://api.github.com/repos/higumachan/naonn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/higumachan/naonn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/higumachan/naonn/git/refs{/sha}","trees_url":"https://api.github.com/repos/higumachan/naonn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/higumachan/naonn/statuses/{sha}","languages_url":"https://api.github.com/repos/higumachan/naonn/languages","stargazers_url":"https://api.github.com/repos/higumachan/naonn/stargazers","contributors_url":"https://api.github.com/repos/higumachan/naonn/contributors","subscribers_url":"https://api.github.com/repos/higumachan/naonn/subscribers","subscription_url":"https://api.github.com/repos/higumachan/naonn/subscription","commits_url":"https://api.github.com/repos/higumachan/naonn/commits{/sha}","git_commits_url":"https://api.github.com/repos/higumachan/naonn/git/commits{/sha}","comments_url":"https://api.github.com/repos/higumachan/naonn/comments{/number}","issue_comment_url":"https://api.github.com/repos/higumachan/naonn/issues/comments{/number}","contents_url":"https://api.github.com/repos/higumachan/naonn/contents/{+path}","compare_url":"https://api.github.com/repos/higumachan/naonn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/higumachan/naonn/merges","archive_url":"https://api.github.com/repos/higumachan/naonn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/higumachan/naonn/downloads","issues_url":"https://api.github.com/repos/higumachan/naonn/issues{/number}","pulls_url":"https://api.github.com/repos/higumachan/naonn/pulls{/number}","milestones_url":"https://api.github.com/repos/higumachan/naonn/milestones{/number}","notifications_url":"https://api.github.com/repos/higumachan/naonn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/higumachan/naonn/labels{/name}","releases_url":"https://api.github.com/repos/higumachan/naonn/releases{/id}","deployments_url":"https://api.github.com/repos/higumachan/naonn/deployments","created_at":"2016-06-11T15:26:46Z","updated_at":"2016-06-11T15:37:52Z","pushed_at":"2016-06-17T18:13:41Z","git_url":"git://github.com/higumachan/naonn.git","ssh_url":"git@github.com:higumachan/naonn.git","clone_url":"https://github.com/higumachan/naonn.git","svn_url":"https://github.com/higumachan/naonn","homepage":null,"size":76,"stargazers_count":0,"watchers_count":0,"language":"CMake","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/higumachan/naonn/pulls/4"},"html":{"href":"https://github.com/higumachan/naonn/pull/4"},"issue":{"href":"https://api.github.com/repos/higumachan/naonn/issues/4"},"comments":{"href":"https://api.github.com/repos/higumachan/naonn/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/higumachan/naonn/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/higumachan/naonn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/higumachan/naonn/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/higumachan/naonn/statuses/69f2f91b00995ebfc15d2a427ea1d6be4e4d6b4a"}}}}
{"actor":{"display_login":"orisano"}}