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 comment
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 comment

@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 comment
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 comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.