{"id":26503,"date":"2021-04-26T23:10:07","date_gmt":"2021-04-27T03:10:07","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/print-three-dimensional-valarray-line-by-line-programming-code-examples-java-j2ee-j2me-valarray\/"},"modified":"2021-04-26T23:10:07","modified_gmt":"2021-04-27T03:10:07","slug":"print-three-dimensional-valarray-line-by-line-programming-code-examples-java-j2ee-j2me-valarray","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=26503","title":{"rendered":"Print three-dimensional valarray line-by-line #Programming Code Examples #Java\/J2EE\/J2ME #Valarray"},"content":{"rendered":"<pre style='padding:10px;font-size:15px'>\n\/* The following code example is taken from the book\n * &quot;The C++ Standard Library - A Tutorial and Reference&quot;\n * by Nicolai M. Josuttis, Addison-Wesley, 1999\n *\n * (C) Copyright Nicolai M. Josuttis 1999.\n * Permission to copy, use, modify, sell and distribute this software\n * is granted provided this copyright notice appears in all copies.\n * This software is provided &quot;as is&quot; without express or implied\n * warranty, and with no claim as to its suitability for any purpose.\n *\/\n#include &lt;iostream&gt;\n#include &lt;valarray&gt;\nusing namespace std;\n\n\/\/ print three-dimensional valarray line-by-line\ntemplate&lt;class T&gt;\nvoid printValarray3D (const valarray&lt;T&gt;&amp; va, int dim1, int dim2)\n{\n    for (int i=0; i&lt;va.size()\/(dim1*dim2); ++i) {\n        for (int j=0; j&lt;dim2; ++j) {\n            for (int k=0; k&lt;dim1; ++k) {\n                cout &lt;&lt; va[i*dim1*dim2+j*dim1+k] &lt;&lt; ' ';\n            }\n            cout &lt;&lt; 'n';\n        }\n        cout &lt;&lt; 'n';\n    }\n    cout &lt;&lt; endl;\n}\n\nint main()\n{\n    \/* valarray with 24 elements\n     * - two groups\n     * - four rows\n     * - three columns\n     *\/\n    valarray&lt;double&gt; va(24);\n\n    \/\/ fill valarray with values\n    for (int i=0; i&lt;24; i++) {\n        va[i] = i;\n    }\n\n    \/\/ print valarray\n    printValarray3D (va, 3, 4);\n\n    \/\/ we need two two-dimensional subsets of three times 3 values\n    \/\/ in two 12-element arrays\n    size_t lengthvalues[] = {  2, 3 };\n    size_t stridevalues[] = { 12, 3 };\n    valarray&lt;size_t&gt; length(lengthvalues,2);\n    valarray&lt;size_t&gt; stride(stridevalues,2);\n\n    \/\/ assign the second column of the first three rows\n    \/\/ to the first column of the first three rows\n    va[gslice(0,length,stride)]\n        = valarray&lt;double&gt;(va[gslice(1,length,stride)]);\n\n    \/\/ add and assign the third of the first three rows\n    \/\/ to the first of the first three rows\n    va[gslice(0,length,stride)]\n        += valarray&lt;double&gt;(va[gslice(2,length,stride)]);\n\n    \/\/ print valarray\n    printValarray3D (va, 3, 4);\n}\n\n\/*\n0 1 2\n3 4 5\n6 7 8\n9 10 11\n\n12 13 14\n15 16 17\n18 19 20\n21 22 23\n\n\n3 1 2\n9 4 5\n15 7 8\n9 10 11\n\n27 13 14\n33 16 17\n39 19 20\n21 22 23\n\n\n\n *\/\n\n<\/pre>\n<p>Note: Brought from our old site: http:\/\/www.salearningschool.com\/example_codes\/ on Jan 2nd, 2017 From: http:\/\/sitestree.com\/?p=10191<br \/> Categories:Programming Code Examples, Java\/J2EE\/J2ME, Valarray<br \/>Tags:Java\/J2EE\/J2MEValarray<br \/> Post Data:2017-01-02 16:04:23<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* The following code example is taken from the book * &quot;The C++ Standard Library &#8211; A Tutorial and Reference&quot; * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=26503\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-26503","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":10556,"url":"http:\/\/bangla.sitestree.com\/?p=10556","url_meta":{"origin":26503,"position":0},"title":"Print three-dimensional valarray line-by-line","author":"","date":"August 29, 2015","format":false,"excerpt":"\/* The following code example is taken from the book \u00a0* \"The C++ Standard Library - A Tutorial and Reference\" \u00a0* by Nicolai M. Josuttis, Addison-Wesley, 1999 \u00a0* \u00a0* (C) Copyright Nicolai M. Josuttis 1999. \u00a0* Permission to copy, use, modify, sell and distribute this software \u00a0* is granted provided\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10089,"url":"http:\/\/bangla.sitestree.com\/?p=10089","url_meta":{"origin":26503,"position":1},"title":"valarray with double value inside","author":"","date":"July 29, 2015","format":false,"excerpt":"\/* The following code example is taken from the book \u00a0* \"The C++ Standard Library - A Tutorial and Reference\" \u00a0* by Nicolai M. Josuttis, Addison-Wesley, 1999 \u00a0* \u00a0* (C) Copyright Nicolai M. Josuttis 1999. \u00a0* Permission to copy, use, modify, sell and distribute this software \u00a0* is granted provided\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"http:\/\/bangla.sitestree.com\/?cat=1420"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":62213,"url":"http:\/\/bangla.sitestree.com\/?p=62213","url_meta":{"origin":26503,"position":2},"title":"valarray with double value inside #Programming Code Examples #C++ #Valarray","author":"Author-Check- Article-or-Video","date":"May 15, 2021","format":false,"excerpt":"\/* The following code example is taken from the book * \"The C++ Standard Library - A Tutorial and Reference\" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10073,"url":"http:\/\/bangla.sitestree.com\/?p=10073","url_meta":{"origin":26503,"position":3},"title":"valarray slice","author":"","date":"July 27, 2015","format":false,"excerpt":"\/* The following code example is taken from the book * \"The C++ Standard Library - A Tutorial and Reference\" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided\u2026","rel":"","context":"In &quot;C++ \u0964 \u09b8\u09bf \u09aa\u09cd\u09b2\u09be\u09b8 \u09aa\u09cd\u09b2\u09be\u09b8&quot;","block_context":{"text":"C++ \u0964 \u09b8\u09bf \u09aa\u09cd\u09b2\u09be\u09b8 \u09aa\u09cd\u09b2\u09be\u09b8","link":"http:\/\/bangla.sitestree.com\/?cat=1439"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27259,"url":"http:\/\/bangla.sitestree.com\/?p=27259","url_meta":{"origin":26503,"position":4},"title":"valarray slice #Programming Code Examples #C++ #Valarray","author":"Author-Check- Article-or-Video","date":"May 15, 2021","format":false,"excerpt":"\/* The following code example is taken from the book * \"The C++ Standard Library - A Tutorial and Reference\" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10550,"url":"http:\/\/bangla.sitestree.com\/?p=10550","url_meta":{"origin":26503,"position":5},"title":"Valarray Example","author":"","date":"August 29, 2015","format":false,"excerpt":"\/* The following code example is taken from the book \u00a0* \"The C++ Standard Library - A Tutorial and Reference\" \u00a0* by Nicolai M. Josuttis, Addison-Wesley, 1999 \u00a0* \u00a0* (C) Copyright Nicolai M. Josuttis 1999. \u00a0* Permission to copy, use, modify, sell and distribute this software \u00a0* is granted provided\u2026","rel":"","context":"In &quot;Ajax&quot;","block_context":{"text":"Ajax","link":"http:\/\/bangla.sitestree.com\/?cat=1418"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26503"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26503\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26503"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}