Title: How to properly use join_many? · arrayfire/arrayfire-rust · Discussion #344 · GitHub
Open Graph Title: How to properly use join_many? · arrayfire/arrayfire-rust · Discussion #344
X Title: How to properly use join_many? · arrayfire/arrayfire-rust · Discussion #344
Description: How to properly use join_many?
Open Graph Description: join_many requires the use of Vec::<&Array
X Description: join_many requires the use of Vec::<&Array<T>> to do the array joining. To do so, I need to create another vector Vec::<Array<T>> to store the arrays first before joinin...
Opengraph URL: https://github.com/arrayfire/arrayfire-rust/discussions/344
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"How to properly use join_many?","text":"join_many requires the use of Vec::<&Array<T>> to do the array joining. To do so, I need to create another vector Vec::<Array<T>> to store the arrays first before joining.
\nCan the array be joined from Vec::<Array<T>> directly without converting it to Vec::<&Array<T>>?
\nuse arrayfire::*;\nfn main() {\n\n let mut vs = Vec::<Array<i32>>::new();\n let mut v2s = Vec::<&Array<i32>>::new();\n for i in 0..10{\n let a = range::<i32>(dim4!(4), 0) * i;\n vs.push(a);\n }\n for i in 0..10{\n v2s.push(&vs[i]);\n }\n let v3 = join_many(1, v2s);\n print(&v3);\n}\n
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"@3togo Perhaps join_many macro is what you are looking for ? It takes care of creating the vector out of Array references and passing it down to join function for you.
\nThe reason most APIs of arrayfire-rust crate have Array& as arguments to enable reuse of the same memory for multiple operations. Otherwise, Array would be consumed by the first join_many and the original array can't be reused without a clone operation which is not free of cost always.
","upvoteCount":2,"url":"https://github.com/arrayfire/arrayfire-rust/discussions/344#discussioncomment-3618553"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:78da26cb-848a-f64c-eecc-0a6bb9a2244d |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | AA4C:54B94:93B0FF:CEB8D6:696E62B8 |
| html-safe-nonce | 605e337a50db968730efccfd83ea3e227c93af7553ce1eca02eb9ad93a93a5d1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTRDOjU0Qjk0OjkzQjBGRjpDRUI4RDY6Njk2RTYyQjgiLCJ2aXNpdG9yX2lkIjoiNzEzOTYwNTY5MDc0ODY1ODM2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 20cc6c2a9b3d078c568d5c6e1fc91d9e88f6e1f571d8d3dedb9da6cc4599675f |
| hovercard-subject-tag | discussion:4365168 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/arrayfire/arrayfire-rust/344/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/688488d6eb4bcaf8aed8f850843e0531e307a3ae4d7de6b44f8df18e61c32505/arrayfire/arrayfire-rust/discussions/344 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/688488d6eb4bcaf8aed8f850843e0531e307a3ae4d7de6b44f8df18e61c32505/arrayfire/arrayfire-rust/discussions/344 |
| og:image:alt | join_many requires the use of Vec::<&Array |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 99a4a74f92e7618f6e15b4dbb9f4470c8d31701a90d89c21ff31970528b7f0c3 |
| turbo-cache-control | no-preview |
| go-import | github.com/arrayfire/arrayfire-rust git https://github.com/arrayfire/arrayfire-rust.git |
| octolytics-dimension-user_id | 5395442 |
| octolytics-dimension-user_login | arrayfire |
| octolytics-dimension-repository_id | 35817370 |
| octolytics-dimension-repository_nwo | arrayfire/arrayfire-rust |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 35817370 |
| octolytics-dimension-repository_network_root_nwo | arrayfire/arrayfire-rust |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ef0d97829e997c64864f25a29b00067f5dc3a4c4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width