{"id":7938,"date":"2022-09-11T01:45:01","date_gmt":"2022-09-10T20:15:01","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/"},"modified":"2022-09-11T01:45:01","modified_gmt":"2022-09-10T20:15:01","slug":"solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/","title":{"rendered":"[Solved] How to pass the values stored in vector container to a new variable?"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-69797200\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"69797200\" data-parentid=\"69796259\" data-score=\"1\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<pre><code>double position_array = first_cells();\n<\/code><\/pre>\n<p>This tries to invoke <code>first_cells<\/code> (a vector) as a callable (but it doesn&#8217;t implement <code>operator()<\/code>: <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.cppreference.com\/w\/cpp\/container\/vector\">https:\/\/en.cppreference.com\/w\/cpp\/container\/vector<\/a>).<\/p>\n<p>Assuming that the loop variable is there for a reason, why not use it:<\/p>\n<pre><code>double position_array = first_cells[i];\n<\/code><\/pre>\n<p>Note also<\/p>\n<ul>\n<li>\n<p>this does a possibly unwanted conversion of <code>float<\/code> to <code>double<\/code><\/p>\n<\/li>\n<li>\n<p>if you want bounds-checking, use<\/p>\n<pre><code>  double position_array = first_cells.at(i);\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>The name <code>position_array<\/code> does suggest some more confusion. Did you actually want the three-value tupled cell instead of just the first value?<\/p>\n<hr>\n<p>Getting first rows instead of first cells:<\/p>\n<pre><code>auto       ds         = open_dataset(argv[1]);\narray_2d_t first_rows = row_from_all_frames(ds, 0);\n<\/code><\/pre>\n<p>Which you can use:<\/p>\n<pre><code>size_t     nsamples   = first_rows.size();\n\nstd::cout &lt;&lt; \"no. of samples: \" &lt;&lt; nsamples &lt;&lt; \"\\n\";\n\n\/\/ main loop\nfor (size_t i = 1; i &lt; nsamples; ++i) {\n    auto position_array = first_rows[i];\n    \/\/ double position_array = static_cast&lt;double&gt;(std::rand()) \/ RAND_MAX;\n    std::cout &lt;&lt; \"position arrays: \"       \/\/\n              &lt;&lt; position_array[0] &lt;&lt; \", \" \/\/\n              &lt;&lt; position_array[1] &lt;&lt; \", \" \/\/\n              &lt;&lt; position_array[2] &lt;&lt; std::endl;\n    \/\/ append data to the correlator, which possibly computes some time\n    \/\/ correlations\n    \/\/corr.sample(position_array);\n}\n<\/code><\/pre>\n<p>Note that <code>position_array<\/code> is a sub array view from <code>multi_array<\/code>, so the interface is consistent with multi_array types.<\/p>\n<p>Prints, on my system:<\/p>\n<pre><code>no. of samples: 75\nposition arrays: 80.03, 35.42, 4.35\nposition arrays: 80.19, 35.62, 4.27\nposition arrays: 79.78, 35.68, 4.13\nposition arrays: 79.51, 35.93, 4.1\nposition arrays: 79.44, 35.46, 4.27\nposition arrays: 79.5, 35.43, 4.38\nposition arrays: 79.03, 35.72, 4.54\nposition arrays: 79.12, 35.89, 4.28\nposition arrays: 79.04, 36.35, 3.99\nposition arrays: 79.06, 36.16, 4.52\nposition arrays: 79.22, 35.96, 4.39\nposition arrays: 79.07, 35.84, 4.28\nposition arrays: 79.43, 35.09, 4.4\nposition arrays: 79.38, 35.13, 3.81\nposition arrays: 78.87, 35.73, 4.54\nposition arrays: 79.3, 35.82, 4.33\nposition arrays: 79.38, 35.45, 3.98\nposition arrays: 79.5, 35.48, 3.88\nposition arrays: 79.16, 34.93, 4.35\nposition arrays: 78.86, 35.2, 4.44\nposition arrays: 79.15, 35.53, 4.08\nposition arrays: 79.41, 35.67, 3.87\nposition arrays: 79.83, 35.61, 4.19\nposition arrays: 79.63, 35.26, 3.86\nposition arrays: 79.94, 35.42, 4.11\nposition arrays: 80.32, 35.06, 4.01\nposition arrays: 79.99, 35.44, 3.97\nposition arrays: 79.82, 35.31, 4.07\nposition arrays: 80, 34.97, 4.07\nposition arrays: 80.22, 35.07, 3.91\nposition arrays: 80.38, 35.56, 3.92\nposition arrays: 80.6, 35.14, 4.11\nposition arrays: 80.57, 34.93, 4.15\nposition arrays: 80.05, 35.33, 4.46\nposition arrays: 80.12, 35.21, 4.2\nposition arrays: 80.12, 35.39, 3.97\nposition arrays: 80.19, 35.69, 4.18\nposition arrays: 80.4, 35, 3.96\nposition arrays: 80.55, 35.39, 4.26\nposition arrays: 80.52, 34.85, 4.07\nposition arrays: 80.57, 34.66, 4.04\nposition arrays: 80.69, 34.64, 4.05\nposition arrays: 80.94, 34.53, 3.88\nposition arrays: 81.12, 33.99, 4.22\nposition arrays: 81.25, 34.02, 4.08\nposition arrays: 81.68, 33.82, 4.17\nposition arrays: 81.75, 33.89, 4.35\nposition arrays: 82.2, 34.24, 4.28\nposition arrays: 81.83, 34.51, 4.17\nposition arrays: 82.17, 34.09, 4.35\nposition arrays: 82.33, 34.32, 4.3\nposition arrays: 82.65, 34.35, 4.09\nposition arrays: 82.44, 34.6, 4\nposition arrays: 82.51, 34.04, 4.41\nposition arrays: 82.4, 34.45, 4.34\nposition arrays: 81.89, 34.48, 4.18\nposition arrays: 81.59, 34.62, 4.14\nposition arrays: 81.82, 34.22, 4.34\nposition arrays: 81.43, 33.95, 4.05\nposition arrays: 81.35, 33.88, 3.9\nposition arrays: 81.44, 33.85, 4.24\nposition arrays: 81.48, 33.39, 4.25\nposition arrays: 81.51, 33.69, 4.16\nposition arrays: 81.66, 33.49, 4.34\nposition arrays: 82.1, 33.45, 4.17\nposition arrays: 82.61, 33.8, 4.07\nposition arrays: 82.51, 33.96, 4.5\nposition arrays: 82.36, 34.13, 4.46\nposition arrays: 82.46, 34.28, 4.19\nposition arrays: 82.59, 34, 4.17\nposition arrays: 82.26, 33.92, 4.44\nposition arrays: 82.2, 34.06, 4.18\nposition arrays: 82.24, 34.12, 4.29\nposition arrays: 82.16, 33.39, 3.94\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">9<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How to pass the values stored in vector container to a new variable? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] double position_array = first_cells(); This tries to invoke first_cells (a vector) as a callable (but it doesn&#8217;t implement operator(): https:\/\/en.cppreference.com\/w\/cpp\/container\/vector). Assuming that the loop variable is there for a reason, why not use it: double position_array = first_cells[i]; Note also this does a possibly unwanted conversion of float to double if you want bounds-checking, &#8230; <a title=\"[Solved] How to pass the values stored in vector container to a new variable?\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/\" aria-label=\"More on [Solved] How to pass the values stored in vector container to a new variable?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[2230,324],"class_list":["post-7938","post","type-post","status-publish","format-standard","hentry","category-solved","tag-boost","tag-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] How to pass the values stored in vector container to a new variable? - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] How to pass the values stored in vector container to a new variable? - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] double position_array = first_cells(); This tries to invoke first_cells (a vector) as a callable (but it doesn&#8217;t implement operator(): https:\/\/en.cppreference.com\/w\/cpp\/container\/vector). Assuming that the loop variable is there for a reason, why not use it: double position_array = first_cells[i]; Note also this does a possibly unwanted conversion of float to double if you want bounds-checking, ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-10T20:15:01+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] How to pass the values stored in vector container to a new variable?\",\"datePublished\":\"2022-09-10T20:15:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/\"},\"wordCount\":134,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"boost\",\"c++\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/\",\"name\":\"[Solved] How to pass the values stored in vector container to a new variable? - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-09-10T20:15:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] How to pass the values stored in vector container to a new variable?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] How to pass the values stored in vector container to a new variable? - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] How to pass the values stored in vector container to a new variable? - JassWeb","og_description":"[ad_1] double position_array = first_cells(); This tries to invoke first_cells (a vector) as a callable (but it doesn&#8217;t implement operator(): https:\/\/en.cppreference.com\/w\/cpp\/container\/vector). Assuming that the loop variable is there for a reason, why not use it: double position_array = first_cells[i]; Note also this does a possibly unwanted conversion of float to double if you want bounds-checking, ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/","og_site_name":"JassWeb","article_published_time":"2022-09-10T20:15:01+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] How to pass the values stored in vector container to a new variable?","datePublished":"2022-09-10T20:15:01+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/"},"wordCount":134,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["boost","c++"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/","url":"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/","name":"[Solved] How to pass the values stored in vector container to a new variable? - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-09-10T20:15:01+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-pass-the-values-stored-in-vector-container-to-a-new-variable\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] How to pass the values stored in vector container to a new variable?"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/7938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=7938"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/7938\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=7938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=7938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=7938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}