Jump to content

N Dimensional array to 1d Array


Recommended Posts

I am looking for a way to do convert N dimensional array to 1d array of variants. Can this be done using native labview functions (some hidden gems etc), without using OpenG?

Another issue is with maps and sets, i want to get data out as array of variants, having set or map as variant.

image.png.22d49a9bb9d052b8a373f1b11bbd9a8b.png

Link to post
Share on other sites

For arrays i came up with this, dimensions are handled up to 10 :D

image.png.8062e85c490be10960bdcae34dadc9af.png

For maps and sets it seems there is no way to cast them to variant arrays...

 

Edit. I am lost now, according to my logic 2 on the bottom should be possible:

image.png.8beb83f8a8de4c684247701ee7ffbae4.png

Edited by pawhan11
Link to post
Share on other sites

I don't have access LV2020 right now for sets but I maybe have a solution for the arrays which should be much faster and accommodate any number of dimensions,

image.png.1559011e5e72b38938da2a868b1d074f.png

Edited by ShaunR
Link to post
Share on other sites
20 hours ago, pawhan11 said:

I am looking for a way to do convert N dimensional array to 1d array of variants.

 

18 hours ago, pawhan11 said:

For arrays i came up with this, dimensions are handled up to 10

 

14 hours ago, pawhan11 said:

Nice, but I require the input to be variant, not an array.

¯\_(ツ)_/¯

 

Edited by ShaunR
  • Like 1
Link to post
Share on other sites

@ShaunR I might have formulated question incorrectly 😁 I want 3 separate functions that have:

- variant input and return 1d array of variants when input variant is array  (any dimension any data type in array)

- variant input and return array of variants when input variant is  set (any data type in set)

-variant input and return variant pairs of key values when input is Map (any data type of key and value in map)

For Maps and Sets I can get type info using Type Parsing Library but not the actual, the only way i see is digging into type descriptors...

Link to post
Share on other sites
On 1/26/2021 at 2:39 PM, pawhan11 said:

- variant input and return 1d array of variants when input variant is array  (any dimension any data type in array)

There is a VI in OpenG LabVIEW Data Library that does this for you.

image.png.90b85e545ea3b2dc3ed5a5e66a7fb779.png

On 1/26/2021 at 2:39 PM, pawhan11 said:

- variant input and return array of variants when input variant is  set (any data type in set)

-variant input and return variant pairs of key values when input is Map (any data type of key and value in map)

For Maps and Sets I can get type info using Type Parsing Library but not the actual, the only way i see is digging into type descriptors...

I took this as a challenge and added two VIs to my library on GitHub - https://github.com/LogMANOriginal/LabVIEW-Composition

Decompose Map extracts variant keys and values of variant maps

1766333078_DecomposeMapExample.png.f9a08bccce69373bc5bfe137149c091f.png

Decompose Set extracts variant elements of variant sets

2086721673_DecomposeSetExample.png.da48ecfd9dff306afdd8254567b4ea54.png

I have successfully tested these VIs with various different types, but there could still be bugs. Let me know if you find anything. I strongly discourage using these in production!

Edited by LogMAN
Fix image scaling
  • Thanks 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.