{"action":"created","comment":{"url":"https://api.github.com/repos/dealii/dealii/pulls/comments/30055368","id":30055368,"diff_hunk":"@@ -96,6 +96,79 @@\n  * InverseMatrixRichardson, SchurMatrix, ShiftedMatrix,\n  * ShiftedMatrixGeneralized, TransposeMatrix\n  *\n+ *\n+ * <h3>Packaged Operation</h3>\n+ *\n+ * An  application of a LinearOperator object to a vector via\n+ * <code>operator*</code> yields a PackagedOperation object that stores\n+ * this computation.\n+ *\n+ * The PackagedOperation class allows lazy evaluation of expressions\n+ * involving vectors and linear operators. This is done by storing the\n+ * computational expression and only performing the computation when either\n+ * the object is implicitly converted to a vector object, or\n+ * <code>apply</code> (or <code>apply_add</code>) is invoked by hand. This\n+ * avoids unnecessary temporary storage of intermediate results.\n+ *\n+ * As an example consider the addition of multiple vectors:\n+ * @code\n+ *   dealii::Vector<double> a, b, c, d;\n+ *   // ..\n+ *   dealii::Vector<double> result = a + b - c + d;\n+ * @endcode\n+ * Converting the PackagedOperation <code>a + b - c + d</code> to a vector\n+ * results in code equivalent to the following code\n+ * @code\n+ *   dealii::Vector<double> a, b, c, d;\n+ *   // ..\n+ *   dealii::Vector<double> result = a;\n+ *   result += b;\n+ *   result -= c;\n+ *   result += d;\n+ * @endcode\n+ * that avoids any intermediate storage. As a second example (involving a\n+ * LinearOperator object) consider the computation of a residual $b-Ax$:\n+ *\n+ * @code\n+ *   dealii::SparseMatrix<double> A;\n+ *   dealii::Vector<double> b, x;\n+ *   // ..\n+ *   const auto op_a = linear_operator(A);\n+ *\n+ *   dealii::Vector<double> residual =  b - op_a * x;","path":"doc/doxygen/headers/laoperators.h","position":43,"original_position":43,"commit_id":"072bf99e0cf85ed80a1ed35ba0f91c1e1409f05a","original_commit_id":"072bf99e0cf85ed80a1ed35ba0f91c1e1409f05a","user":{"login":"bangerth","id":7504421,"avatar_url":"https://avatars.githubusercontent.com/u/7504421?v=3","gravatar_id":"","url":"https://api.github.com/users/bangerth","html_url":"https://github.com/bangerth","followers_url":"https://api.github.com/users/bangerth/followers","following_url":"https://api.github.com/users/bangerth/following{/other_user}","gists_url":"https://api.github.com/users/bangerth/gists{/gist_id}","starred_url":"https://api.github.com/users/bangerth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bangerth/subscriptions","organizations_url":"https://api.github.com/users/bangerth/orgs","repos_url":"https://api.github.com/users/bangerth/repos","events_url":"https://api.github.com/users/bangerth/events{/privacy}","received_events_url":"https://api.github.com/users/bangerth/received_events","type":"User","site_admin":false},"body":"ah, or let them just read the next paragraph. or think of a way to state that the code uses \"lazy evaluation\" (the start of the next paragraph just states what lazy evaluation implies, but not that it is actually used here).","created_at":"2015-05-11T16:28:36Z","updated_at":"2015-05-11T16:28:36Z","html_url":"https://github.com/dealii/dealii/pull/882#discussion_r30055368","pull_request_url":"https://api.github.com/repos/dealii/dealii/pulls/882","_links":{"self":{"href":"https://api.github.com/repos/dealii/dealii/pulls/comments/30055368"},"html":{"href":"https://github.com/dealii/dealii/pull/882#discussion_r30055368"},"pull_request":{"href":"https://api.github.com/repos/dealii/dealii/pulls/882"}}},"pull_request":{"url":"https://api.github.com/repos/dealii/dealii/pulls/882","id":34130707,"html_url":"https://github.com/dealii/dealii/pull/882","diff_url":"https://github.com/dealii/dealii/pull/882.diff","patch_url":"https://github.com/dealii/dealii/pull/882.patch","issue_url":"https://api.github.com/repos/dealii/dealii/issues/882","number":882,"state":"open","locked":false,"title":"Add a mechanism to store a partially applied computation","user":{"login":"tamiko","id":3432917,"avatar_url":"https://avatars.githubusercontent.com/u/3432917?v=3","gravatar_id":"","url":"https://api.github.com/users/tamiko","html_url":"https://github.com/tamiko","followers_url":"https://api.github.com/users/tamiko/followers","following_url":"https://api.github.com/users/tamiko/following{/other_user}","gists_url":"https://api.github.com/users/tamiko/gists{/gist_id}","starred_url":"https://api.github.com/users/tamiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamiko/subscriptions","organizations_url":"https://api.github.com/users/tamiko/orgs","repos_url":"https://api.github.com/users/tamiko/repos","events_url":"https://api.github.com/users/tamiko/events{/privacy}","received_events_url":"https://api.github.com/users/tamiko/received_events","type":"User","site_admin":false},"body":"The alternative is to fully commit to new features and do something like this\r\n```Computation``` prototype. The idea is that the class just stores the\r\nknowledge how to apply a computation to a vector (that then contains the\r\nresult):\r\n```\r\nstd::function<void(Range &v)> result;\r\nstd::function<void(Range &v)> result_add;\r\nstd::function<void(Range &v, bool fast)> reinit_vector;\r\n```\r\nWith this, it is possible to define, e.g., the product of a LinearOperator with\r\na vector, etc.:\r\n```\r\ntemplate <typename Range, typename Domain>\r\nComputation<Range>\r\noperator*(const LinearOperator<Range, Domain> &op,\r\n          const Domain &v)\r\n{\r\n  // ...\r\n}\r\n```\r\nThis now allows to write the following:\r\n```\r\nVector<double> x;\r\nVector<double> b;\r\nSparseMatrix<double> A;\r\n\r\nauto op_A = linear_operator(A);\r\n\r\n// compute the residual:\r\nauto comp = b - op_A * x;\r\n```\r\nThe catch is that up to this point, no computation is perfomred at all. This is\r\ndone by either invoking a conversion operator, or by calling ```result```,\r\n```result_add``` directly:\r\n\r\n```\r\nVector <double> result = comp;\r\n// result += comp; - to be implemented\r\n```\r\n\r\nThe benefit is (similary to ```LinearOperator```) nice syntactic sugar:\r\n```\r\ncomp = op_A * b - op_A * x;\r\ncomp = op_A * op_A * b - op_A * x;\r\ncomp = b * op_A * op_A;\r\ncomp = b * op_A * op_B - op_C * d + op_A * x + x * op_A;\r\n```","created_at":"2015-04-26T21:47:59Z","updated_at":"2015-05-11T16:28:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7dc35822cf9103946b3cfaf420f8a512b20c9945","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dealii/dealii/pulls/882/commits","review_comments_url":"https://api.github.com/repos/dealii/dealii/pulls/882/comments","review_comment_url":"https://api.github.com/repos/dealii/dealii/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dealii/dealii/issues/882/comments","statuses_url":"https://api.github.com/repos/dealii/dealii/statuses/072bf99e0cf85ed80a1ed35ba0f91c1e1409f05a","head":{"label":"tamiko:add_computation","ref":"add_computation","sha":"072bf99e0cf85ed80a1ed35ba0f91c1e1409f05a","user":{"login":"tamiko","id":3432917,"avatar_url":"https://avatars.githubusercontent.com/u/3432917?v=3","gravatar_id":"","url":"https://api.github.com/users/tamiko","html_url":"https://github.com/tamiko","followers_url":"https://api.github.com/users/tamiko/followers","following_url":"https://api.github.com/users/tamiko/following{/other_user}","gists_url":"https://api.github.com/users/tamiko/gists{/gist_id}","starred_url":"https://api.github.com/users/tamiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamiko/subscriptions","organizations_url":"https://api.github.com/users/tamiko/orgs","repos_url":"https://api.github.com/users/tamiko/repos","events_url":"https://api.github.com/users/tamiko/events{/privacy}","received_events_url":"https://api.github.com/users/tamiko/received_events","type":"User","site_admin":false},"repo":{"id":22046756,"name":"dealii","full_name":"tamiko/dealii","owner":{"login":"tamiko","id":3432917,"avatar_url":"https://avatars.githubusercontent.com/u/3432917?v=3","gravatar_id":"","url":"https://api.github.com/users/tamiko","html_url":"https://github.com/tamiko","followers_url":"https://api.github.com/users/tamiko/followers","following_url":"https://api.github.com/users/tamiko/following{/other_user}","gists_url":"https://api.github.com/users/tamiko/gists{/gist_id}","starred_url":"https://api.github.com/users/tamiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamiko/subscriptions","organizations_url":"https://api.github.com/users/tamiko/orgs","repos_url":"https://api.github.com/users/tamiko/repos","events_url":"https://api.github.com/users/tamiko/events{/privacy}","received_events_url":"https://api.github.com/users/tamiko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tamiko/dealii","description":"","fork":true,"url":"https://api.github.com/repos/tamiko/dealii","forks_url":"https://api.github.com/repos/tamiko/dealii/forks","keys_url":"https://api.github.com/repos/tamiko/dealii/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tamiko/dealii/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tamiko/dealii/teams","hooks_url":"https://api.github.com/repos/tamiko/dealii/hooks","issue_events_url":"https://api.github.com/repos/tamiko/dealii/issues/events{/number}","events_url":"https://api.github.com/repos/tamiko/dealii/events","assignees_url":"https://api.github.com/repos/tamiko/dealii/assignees{/user}","branches_url":"https://api.github.com/repos/tamiko/dealii/branches{/branch}","tags_url":"https://api.github.com/repos/tamiko/dealii/tags","blobs_url":"https://api.github.com/repos/tamiko/dealii/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tamiko/dealii/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tamiko/dealii/git/refs{/sha}","trees_url":"https://api.github.com/repos/tamiko/dealii/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tamiko/dealii/statuses/{sha}","languages_url":"https://api.github.com/repos/tamiko/dealii/languages","stargazers_url":"https://api.github.com/repos/tamiko/dealii/stargazers","contributors_url":"https://api.github.com/repos/tamiko/dealii/contributors","subscribers_url":"https://api.github.com/repos/tamiko/dealii/subscribers","subscription_url":"https://api.github.com/repos/tamiko/dealii/subscription","commits_url":"https://api.github.com/repos/tamiko/dealii/commits{/sha}","git_commits_url":"https://api.github.com/repos/tamiko/dealii/git/commits{/sha}","comments_url":"https://api.github.com/repos/tamiko/dealii/comments{/number}","issue_comment_url":"https://api.github.com/repos/tamiko/dealii/issues/comments{/number}","contents_url":"https://api.github.com/repos/tamiko/dealii/contents/{+path}","compare_url":"https://api.github.com/repos/tamiko/dealii/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tamiko/dealii/merges","archive_url":"https://api.github.com/repos/tamiko/dealii/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tamiko/dealii/downloads","issues_url":"https://api.github.com/repos/tamiko/dealii/issues{/number}","pulls_url":"https://api.github.com/repos/tamiko/dealii/pulls{/number}","milestones_url":"https://api.github.com/repos/tamiko/dealii/milestones{/number}","notifications_url":"https://api.github.com/repos/tamiko/dealii/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tamiko/dealii/labels{/name}","releases_url":"https://api.github.com/repos/tamiko/dealii/releases{/id}","created_at":"2014-07-21T00:21:17Z","updated_at":"2015-05-07T08:20:43Z","pushed_at":"2015-05-11T09:26:01Z","git_url":"git://github.com/tamiko/dealii.git","ssh_url":"git@github.com:tamiko/dealii.git","clone_url":"https://github.com/tamiko/dealii.git","svn_url":"https://github.com/tamiko/dealii","homepage":null,"size":114868,"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":"master"}},"base":{"label":"dealii:master","ref":"master","sha":"d7f0795bab6d673335555ea9273da899b753bd47","user":{"login":"dealii","id":7506070,"avatar_url":"https://avatars.githubusercontent.com/u/7506070?v=3","gravatar_id":"","url":"https://api.github.com/users/dealii","html_url":"https://github.com/dealii","followers_url":"https://api.github.com/users/dealii/followers","following_url":"https://api.github.com/users/dealii/following{/other_user}","gists_url":"https://api.github.com/users/dealii/gists{/gist_id}","starred_url":"https://api.github.com/users/dealii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dealii/subscriptions","organizations_url":"https://api.github.com/users/dealii/orgs","repos_url":"https://api.github.com/users/dealii/repos","events_url":"https://api.github.com/users/dealii/events{/privacy}","received_events_url":"https://api.github.com/users/dealii/received_events","type":"Organization","site_admin":false},"repo":{"id":21943980,"name":"dealii","full_name":"dealii/dealii","owner":{"login":"dealii","id":7506070,"avatar_url":"https://avatars.githubusercontent.com/u/7506070?v=3","gravatar_id":"","url":"https://api.github.com/users/dealii","html_url":"https://github.com/dealii","followers_url":"https://api.github.com/users/dealii/followers","following_url":"https://api.github.com/users/dealii/following{/other_user}","gists_url":"https://api.github.com/users/dealii/gists{/gist_id}","starred_url":"https://api.github.com/users/dealii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dealii/subscriptions","organizations_url":"https://api.github.com/users/dealii/orgs","repos_url":"https://api.github.com/users/dealii/repos","events_url":"https://api.github.com/users/dealii/events{/privacy}","received_events_url":"https://api.github.com/users/dealii/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dealii/dealii","description":"The development repository for the deal.II finite element library.","fork":false,"url":"https://api.github.com/repos/dealii/dealii","forks_url":"https://api.github.com/repos/dealii/dealii/forks","keys_url":"https://api.github.com/repos/dealii/dealii/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dealii/dealii/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dealii/dealii/teams","hooks_url":"https://api.github.com/repos/dealii/dealii/hooks","issue_events_url":"https://api.github.com/repos/dealii/dealii/issues/events{/number}","events_url":"https://api.github.com/repos/dealii/dealii/events","assignees_url":"https://api.github.com/repos/dealii/dealii/assignees{/user}","branches_url":"https://api.github.com/repos/dealii/dealii/branches{/branch}","tags_url":"https://api.github.com/repos/dealii/dealii/tags","blobs_url":"https://api.github.com/repos/dealii/dealii/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dealii/dealii/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dealii/dealii/git/refs{/sha}","trees_url":"https://api.github.com/repos/dealii/dealii/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dealii/dealii/statuses/{sha}","languages_url":"https://api.github.com/repos/dealii/dealii/languages","stargazers_url":"https://api.github.com/repos/dealii/dealii/stargazers","contributors_url":"https://api.github.com/repos/dealii/dealii/contributors","subscribers_url":"https://api.github.com/repos/dealii/dealii/subscribers","subscription_url":"https://api.github.com/repos/dealii/dealii/subscription","commits_url":"https://api.github.com/repos/dealii/dealii/commits{/sha}","git_commits_url":"https://api.github.com/repos/dealii/dealii/git/commits{/sha}","comments_url":"https://api.github.com/repos/dealii/dealii/comments{/number}","issue_comment_url":"https://api.github.com/repos/dealii/dealii/issues/comments{/number}","contents_url":"https://api.github.com/repos/dealii/dealii/contents/{+path}","compare_url":"https://api.github.com/repos/dealii/dealii/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dealii/dealii/merges","archive_url":"https://api.github.com/repos/dealii/dealii/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dealii/dealii/downloads","issues_url":"https://api.github.com/repos/dealii/dealii/issues{/number}","pulls_url":"https://api.github.com/repos/dealii/dealii/pulls{/number}","milestones_url":"https://api.github.com/repos/dealii/dealii/milestones{/number}","notifications_url":"https://api.github.com/repos/dealii/dealii/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dealii/dealii/labels{/name}","releases_url":"https://api.github.com/repos/dealii/dealii/releases{/id}","created_at":"2014-07-17T14:00:26Z","updated_at":"2015-05-08T13:24:21Z","pushed_at":"2015-05-11T15:56:56Z","git_url":"git://github.com/dealii/dealii.git","ssh_url":"git@github.com:dealii/dealii.git","clone_url":"https://github.com/dealii/dealii.git","svn_url":"https://github.com/dealii/dealii","homepage":"http://www.dealii.org/","size":147760,"stargazers_count":55,"watchers_count":55,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":83,"forks":75,"open_issues":83,"watchers":55,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dealii/dealii/pulls/882"},"html":{"href":"https://github.com/dealii/dealii/pull/882"},"issue":{"href":"https://api.github.com/repos/dealii/dealii/issues/882"},"comments":{"href":"https://api.github.com/repos/dealii/dealii/issues/882/comments"},"review_comments":{"href":"https://api.github.com/repos/dealii/dealii/pulls/882/comments"},"review_comment":{"href":"https://api.github.com/repos/dealii/dealii/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dealii/dealii/pulls/882/commits"},"statuses":{"href":"https://api.github.com/repos/dealii/dealii/statuses/072bf99e0cf85ed80a1ed35ba0f91c1e1409f05a"}}}}