{"action":"created","comment":{"url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/25122808","id":25122808,"diff_hunk":"@@ -0,0 +1,146 @@\n+/*\n+ * Copyright (c) The Shogun Machine Learning Toolbox\n+ * Written (w) 2015 Wu Lin\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions are met:\n+ *\n+ * 1. Redistributions of source code must retain the above copyright notice, this\n+ *    list of conditions and the following disclaimer.\n+ * 2. Redistributions in binary form must reproduce the above copyright notice,\n+ *    this list of conditions and the following disclaimer in the documentation\n+ *    and/or other materials provided with the distribution.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ *\n+ * The views and conclusions contained in the software and documentation are those\n+ * of the authors and should not be interpreted as representing official policies,\n+ * either expressed or implied, of the Shogun Development Team.\n+ *\n+ */\n+\n+#include <shogun/machine/gp/GaussianARDFITCKernel.h>\n+\n+using namespace shogun;\n+\n+CGaussianARDFITCKernel::CGaussianARDFITCKernel() : CGaussianARDKernel()\n+{\n+\tinit();\n+}\n+void CGaussianARDFITCKernel::init()\n+{\n+}\n+\n+CGaussianARDFITCKernel::~CGaussianARDFITCKernel()\n+{\n+}\n+\n+#ifdef HAVE_CXX11\n+#include <shogun/mathematics/linalg/linalg.h>\n+CGaussianARDFITCKernel::CGaussianARDFITCKernel(int32_t size, float64_t width)\n+\t\t: CGaussianARDKernel(size,width)\n+{\n+\tinit();\n+}\n+\n+CGaussianARDFITCKernel::CGaussianARDFITCKernel(CDotFeatures* l,\n+\t\tCDotFeatures* r, int32_t size, float64_t width)\n+\t\t: CGaussianARDKernel(l, r, size, width)\n+{\n+\tinit();\n+}\n+\n+CGaussianARDFITCKernel* CGaussianARDFITCKernel::obtain_from_generic(CKernel* kernel)\n+{\n+\tif (kernel->get_kernel_type()!=K_GAUSSIANARDFITC)\n+\t{\n+\t\tSG_SERROR(\"Provided kernel is not of type CGaussianARDFITCKernel!\\n\");\n+\t}\n+\n+\t/* since an additional reference is returned */\n+\tSG_REF(kernel);\n+\treturn (CGaussianARDFITCKernel*)kernel;\n+}\n+\n+#include <typeinfo>\n+CSGObject *CGaussianARDFITCKernel::shallow_copy() const\n+{\n+\t// TODO: remove this after all the classes get shallow_copy properly implemented\n+\t// this assert is to avoid any subclass of CGaussianARDFITCKernel accidentally called\n+\t// with the implement here\n+\tASSERT(typeid(*this) == typeid(CGaussianARDFITCKernel))\n+\tCGaussianARDFITCKernel *ker = new CGaussianARDFITCKernel(cache_size, m_width);\n+\tif (lhs)\n+\t{\n+\t\tker->CGaussianARDKernel::init(lhs, rhs);\n+\t}\n+\treturn ker;\n+}\n+\n+SGMatrix<float64_t> CGaussianARDFITCKernel::get_parameter_gradient(\n+\t\tconst TParameter* param, index_t index)\n+{\n+\tif (!strcmp(param->m_name, \"latent_features\"))\n+\t{\n+\t\tREQUIRE(lhs && rhs, \"Features not set!\\n\")\n+\t\tREQUIRE(index>=0 && index<num_lhs,\"\")\n+\t\tint32_t idx_l=index;\n+\t\tSGVector<float64_t> left_vec=((CDotFeatures *)lhs)->get_computed_dot_feature_vector(idx_l);\n+\t\tSGMatrix<float64_t> res(left_vec.vlen, num_rhs);\n+\n+\t\tfor (int32_t idx_r=0; idx_r<num_rhs; idx_r++)\n+\t\t{\n+\t\t\tSGVector<float64_t> right_vec=((CDotFeatures *)rhs)->get_computed_dot_feature_vector(idx_r);\n+\t\t\tSGMatrix<float64_t> res_transpose(res.get_column_vector(idx_r),1,left_vec.vlen,false);\n+\t\t\tlinalg::add(left_vec, right_vec, right_vec, 1.0, -1.0);\n+\t\t\tfloat64_t scalar_weight=1.0;\n+\t\t\t//column vector\n+\t\t\tSGMatrix<float64_t> right=compute_right_product(right_vec, scalar_weight);\n+\t\t\t//row vector\n+\t\t\tSGMatrix<float64_t> right_transpose(right.matrix,1,right.num_rows,false);\n+\t\t\tif (m_ARD_type==KT_SCALAR)\n+\t\t\t{\n+\t\t\t\tscalar_weight*=m_weights[0];\n+\t\t\t\tSGMatrix<float64_t> weights(1,right.num_rows);\n+\t\t\t\tweights.set_const(scalar_weight);\n+\t\t\t\tlinalg::matrix_product(right_transpose, weights, res_transpose);\n+\t\t\t}\n+\t\t\telse\n+\t\t\t{\n+\t\t\t\tif(m_ARD_type==KT_DIAG)\n+\t\t\t\t{\n+\t\t\t\t\tSGMatrix<float64_t> weights(m_weights.matrix,1,m_weights.num_rows,false);\n+\t\t\t\t\tlinalg::elementwise_product(right_transpose, weights, res_transpose);\n+\t\t\t\t}\n+\t\t\t\telse if(m_ARD_type==KT_FULL)\n+\t\t\t\t{\n+\t\t\t\t\tlinalg::matrix_product(right_transpose, m_weights, res_transpose);\n+\t\t\t\t}\n+\t\t\t\telse\n+\t\t\t\t{","path":"src/shogun/machine/gp/GaussianARDFITCKernel.cpp","position":130,"original_position":130,"commit_id":"726dbe4f3fd6ed42101020b9b59f192953d5ad29","original_commit_id":"726dbe4f3fd6ed42101020b9b59f192953d5ad29","user":{"login":"karlnapf","id":699071,"avatar_url":"https://avatars.githubusercontent.com/u/699071?v=3","gravatar_id":"","url":"https://api.github.com/users/karlnapf","html_url":"https://github.com/karlnapf","followers_url":"https://api.github.com/users/karlnapf/followers","following_url":"https://api.github.com/users/karlnapf/following{/other_user}","gists_url":"https://api.github.com/users/karlnapf/gists{/gist_id}","starred_url":"https://api.github.com/users/karlnapf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlnapf/subscriptions","organizations_url":"https://api.github.com/users/karlnapf/orgs","repos_url":"https://api.github.com/users/karlnapf/repos","events_url":"https://api.github.com/users/karlnapf/events{/privacy}","received_events_url":"https://api.github.com/users/karlnapf/received_events","type":"User","site_admin":false},"body":"No {}","created_at":"2015-02-21T15:25:51Z","updated_at":"2015-02-21T15:25:51Z","html_url":"https://github.com/shogun-toolbox/shogun/pull/2725#discussion_r25122808","pull_request_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2725","_links":{"self":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/25122808"},"html":{"href":"https://github.com/shogun-toolbox/shogun/pull/2725#discussion_r25122808"},"pull_request":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2725"}}},"pull_request":{"url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2725","id":29650111,"html_url":"https://github.com/shogun-toolbox/shogun/pull/2725","diff_url":"https://github.com/shogun-toolbox/shogun/pull/2725.diff","patch_url":"https://github.com/shogun-toolbox/shogun/pull/2725.patch","issue_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2725","number":2725,"state":"open","locked":false,"title":"add a kernel to support FITC inference","user":{"login":"yorkerlin","id":6913996,"avatar_url":"https://avatars.githubusercontent.com/u/6913996?v=3","gravatar_id":"","url":"https://api.github.com/users/yorkerlin","html_url":"https://github.com/yorkerlin","followers_url":"https://api.github.com/users/yorkerlin/followers","following_url":"https://api.github.com/users/yorkerlin/following{/other_user}","gists_url":"https://api.github.com/users/yorkerlin/gists{/gist_id}","starred_url":"https://api.github.com/users/yorkerlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yorkerlin/subscriptions","organizations_url":"https://api.github.com/users/yorkerlin/orgs","repos_url":"https://api.github.com/users/yorkerlin/repos","events_url":"https://api.github.com/users/yorkerlin/events{/privacy}","received_events_url":"https://api.github.com/users/yorkerlin/received_events","type":"User","site_admin":false},"body":"@karlnapf \r\ntake a look at this","created_at":"2015-02-19T21:22:12Z","updated_at":"2015-02-21T15:25:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"496875c79f1808f6d79ee7c00c6cc496de509bf2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2725/commits","review_comments_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2725/comments","review_comment_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/{number}","comments_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2725/comments","statuses_url":"https://api.github.com/repos/shogun-toolbox/shogun/statuses/726dbe4f3fd6ed42101020b9b59f192953d5ad29","head":{"label":"yorkerlin:develop","ref":"develop","sha":"726dbe4f3fd6ed42101020b9b59f192953d5ad29","user":{"login":"yorkerlin","id":6913996,"avatar_url":"https://avatars.githubusercontent.com/u/6913996?v=3","gravatar_id":"","url":"https://api.github.com/users/yorkerlin","html_url":"https://github.com/yorkerlin","followers_url":"https://api.github.com/users/yorkerlin/followers","following_url":"https://api.github.com/users/yorkerlin/following{/other_user}","gists_url":"https://api.github.com/users/yorkerlin/gists{/gist_id}","starred_url":"https://api.github.com/users/yorkerlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yorkerlin/subscriptions","organizations_url":"https://api.github.com/users/yorkerlin/orgs","repos_url":"https://api.github.com/users/yorkerlin/repos","events_url":"https://api.github.com/users/yorkerlin/events{/privacy}","received_events_url":"https://api.github.com/users/yorkerlin/received_events","type":"User","site_admin":false},"repo":{"id":22841885,"name":"shogun","full_name":"yorkerlin/shogun","owner":{"login":"yorkerlin","id":6913996,"avatar_url":"https://avatars.githubusercontent.com/u/6913996?v=3","gravatar_id":"","url":"https://api.github.com/users/yorkerlin","html_url":"https://github.com/yorkerlin","followers_url":"https://api.github.com/users/yorkerlin/followers","following_url":"https://api.github.com/users/yorkerlin/following{/other_user}","gists_url":"https://api.github.com/users/yorkerlin/gists{/gist_id}","starred_url":"https://api.github.com/users/yorkerlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yorkerlin/subscriptions","organizations_url":"https://api.github.com/users/yorkerlin/orgs","repos_url":"https://api.github.com/users/yorkerlin/repos","events_url":"https://api.github.com/users/yorkerlin/events{/privacy}","received_events_url":"https://api.github.com/users/yorkerlin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yorkerlin/shogun","description":"The Shogun Machine Learning Toolbox (Source Code)","fork":true,"url":"https://api.github.com/repos/yorkerlin/shogun","forks_url":"https://api.github.com/repos/yorkerlin/shogun/forks","keys_url":"https://api.github.com/repos/yorkerlin/shogun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yorkerlin/shogun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yorkerlin/shogun/teams","hooks_url":"https://api.github.com/repos/yorkerlin/shogun/hooks","issue_events_url":"https://api.github.com/repos/yorkerlin/shogun/issues/events{/number}","events_url":"https://api.github.com/repos/yorkerlin/shogun/events","assignees_url":"https://api.github.com/repos/yorkerlin/shogun/assignees{/user}","branches_url":"https://api.github.com/repos/yorkerlin/shogun/branches{/branch}","tags_url":"https://api.github.com/repos/yorkerlin/shogun/tags","blobs_url":"https://api.github.com/repos/yorkerlin/shogun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yorkerlin/shogun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yorkerlin/shogun/git/refs{/sha}","trees_url":"https://api.github.com/repos/yorkerlin/shogun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yorkerlin/shogun/statuses/{sha}","languages_url":"https://api.github.com/repos/yorkerlin/shogun/languages","stargazers_url":"https://api.github.com/repos/yorkerlin/shogun/stargazers","contributors_url":"https://api.github.com/repos/yorkerlin/shogun/contributors","subscribers_url":"https://api.github.com/repos/yorkerlin/shogun/subscribers","subscription_url":"https://api.github.com/repos/yorkerlin/shogun/subscription","commits_url":"https://api.github.com/repos/yorkerlin/shogun/commits{/sha}","git_commits_url":"https://api.github.com/repos/yorkerlin/shogun/git/commits{/sha}","comments_url":"https://api.github.com/repos/yorkerlin/shogun/comments{/number}","issue_comment_url":"https://api.github.com/repos/yorkerlin/shogun/issues/comments/{number}","contents_url":"https://api.github.com/repos/yorkerlin/shogun/contents/{+path}","compare_url":"https://api.github.com/repos/yorkerlin/shogun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yorkerlin/shogun/merges","archive_url":"https://api.github.com/repos/yorkerlin/shogun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yorkerlin/shogun/downloads","issues_url":"https://api.github.com/repos/yorkerlin/shogun/issues{/number}","pulls_url":"https://api.github.com/repos/yorkerlin/shogun/pulls{/number}","milestones_url":"https://api.github.com/repos/yorkerlin/shogun/milestones{/number}","notifications_url":"https://api.github.com/repos/yorkerlin/shogun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yorkerlin/shogun/labels{/name}","releases_url":"https://api.github.com/repos/yorkerlin/shogun/releases{/id}","created_at":"2014-08-11T14:28:01Z","updated_at":"2015-02-19T21:21:14Z","pushed_at":"2015-02-19T21:52:18Z","git_url":"git://github.com/yorkerlin/shogun.git","ssh_url":"git@github.com:yorkerlin/shogun.git","clone_url":"https://github.com/yorkerlin/shogun.git","svn_url":"https://github.com/yorkerlin/shogun","homepage":"http://www.shogun-toolbox.org","size":50414,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"develop"}},"base":{"label":"shogun-toolbox:develop","ref":"develop","sha":"612bd40a0982679dfae62ae225440bf7de0f0da6","user":{"login":"shogun-toolbox","id":690673,"avatar_url":"https://avatars.githubusercontent.com/u/690673?v=3","gravatar_id":"","url":"https://api.github.com/users/shogun-toolbox","html_url":"https://github.com/shogun-toolbox","followers_url":"https://api.github.com/users/shogun-toolbox/followers","following_url":"https://api.github.com/users/shogun-toolbox/following{/other_user}","gists_url":"https://api.github.com/users/shogun-toolbox/gists{/gist_id}","starred_url":"https://api.github.com/users/shogun-toolbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shogun-toolbox/subscriptions","organizations_url":"https://api.github.com/users/shogun-toolbox/orgs","repos_url":"https://api.github.com/users/shogun-toolbox/repos","events_url":"https://api.github.com/users/shogun-toolbox/events{/privacy}","received_events_url":"https://api.github.com/users/shogun-toolbox/received_events","type":"Organization","site_admin":false},"repo":{"id":1555094,"name":"shogun","full_name":"shogun-toolbox/shogun","owner":{"login":"shogun-toolbox","id":690673,"avatar_url":"https://avatars.githubusercontent.com/u/690673?v=3","gravatar_id":"","url":"https://api.github.com/users/shogun-toolbox","html_url":"https://github.com/shogun-toolbox","followers_url":"https://api.github.com/users/shogun-toolbox/followers","following_url":"https://api.github.com/users/shogun-toolbox/following{/other_user}","gists_url":"https://api.github.com/users/shogun-toolbox/gists{/gist_id}","starred_url":"https://api.github.com/users/shogun-toolbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shogun-toolbox/subscriptions","organizations_url":"https://api.github.com/users/shogun-toolbox/orgs","repos_url":"https://api.github.com/users/shogun-toolbox/repos","events_url":"https://api.github.com/users/shogun-toolbox/events{/privacy}","received_events_url":"https://api.github.com/users/shogun-toolbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shogun-toolbox/shogun","description":"The Shogun Machine Learning Toolbox (Source Code)","fork":false,"url":"https://api.github.com/repos/shogun-toolbox/shogun","forks_url":"https://api.github.com/repos/shogun-toolbox/shogun/forks","keys_url":"https://api.github.com/repos/shogun-toolbox/shogun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shogun-toolbox/shogun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shogun-toolbox/shogun/teams","hooks_url":"https://api.github.com/repos/shogun-toolbox/shogun/hooks","issue_events_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/events{/number}","events_url":"https://api.github.com/repos/shogun-toolbox/shogun/events","assignees_url":"https://api.github.com/repos/shogun-toolbox/shogun/assignees{/user}","branches_url":"https://api.github.com/repos/shogun-toolbox/shogun/branches{/branch}","tags_url":"https://api.github.com/repos/shogun-toolbox/shogun/tags","blobs_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/refs{/sha}","trees_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shogun-toolbox/shogun/statuses/{sha}","languages_url":"https://api.github.com/repos/shogun-toolbox/shogun/languages","stargazers_url":"https://api.github.com/repos/shogun-toolbox/shogun/stargazers","contributors_url":"https://api.github.com/repos/shogun-toolbox/shogun/contributors","subscribers_url":"https://api.github.com/repos/shogun-toolbox/shogun/subscribers","subscription_url":"https://api.github.com/repos/shogun-toolbox/shogun/subscription","commits_url":"https://api.github.com/repos/shogun-toolbox/shogun/commits{/sha}","git_commits_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/commits{/sha}","comments_url":"https://api.github.com/repos/shogun-toolbox/shogun/comments{/number}","issue_comment_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/comments/{number}","contents_url":"https://api.github.com/repos/shogun-toolbox/shogun/contents/{+path}","compare_url":"https://api.github.com/repos/shogun-toolbox/shogun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shogun-toolbox/shogun/merges","archive_url":"https://api.github.com/repos/shogun-toolbox/shogun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shogun-toolbox/shogun/downloads","issues_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues{/number}","pulls_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls{/number}","milestones_url":"https://api.github.com/repos/shogun-toolbox/shogun/milestones{/number}","notifications_url":"https://api.github.com/repos/shogun-toolbox/shogun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shogun-toolbox/shogun/labels{/name}","releases_url":"https://api.github.com/repos/shogun-toolbox/shogun/releases{/id}","created_at":"2011-04-01T10:44:32Z","updated_at":"2015-02-21T03:42:10Z","pushed_at":"2015-02-20T15:14:56Z","git_url":"git://github.com/shogun-toolbox/shogun.git","ssh_url":"git@github.com:shogun-toolbox/shogun.git","clone_url":"https://github.com/shogun-toolbox/shogun.git","svn_url":"https://github.com/shogun-toolbox/shogun","homepage":"http://www.shogun-toolbox.org","size":191651,"stargazers_count":688,"watchers_count":688,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":415,"mirror_url":null,"open_issues_count":342,"forks":415,"open_issues":342,"watchers":688,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2725"},"html":{"href":"https://github.com/shogun-toolbox/shogun/pull/2725"},"issue":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2725"},"comments":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2725/comments"},"review_comments":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2725/comments"},"review_comment":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2725/commits"},"statuses":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/statuses/726dbe4f3fd6ed42101020b9b59f192953d5ad29"}}}}