LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array of clusters

Solved!
Go to solution

@taras01 wrote:

Hello,


BTW.

 

Is OP still hanging around?

 

We're getting OT because you're quit.

0 Kudos
Message 11 of 21
(1,516 Views)

wiebe@CARYA wrote:

I got a "Sort 1D Array Of Clusters" sort of working...

 

There are caveats:

1) Getting the number of elements is tricky. To do this efficiently (not with variants), you'll have to make a .vim with cases that unbundle a cluster of each size, unbundling the last element I've now scripted this for clusters up to 200 elements. If you have more elements, you pay the price of using variant magic... But if you have 200 element clusters, you have other problems to worry about. 

 

2) All elements in the cluster are compared. Even if you want to sort on just one element... This is because we can't actually get individual elements (without variant magic). We can use compare elements, and get a cluster of Booleans, and convert it to an array, and get it's element...

 

3) Because we're converting a cluster of Booleans to an array, this will fail if the cluster is nested. Comparing a cluster with a cluster will result in a cluster of Booleans and a cluster of Booleans, and we can't convert that to an array (easily, without variant magic).

 

If I can solve 3, 2 is probably also solved, and vice versa...

 

EDIT: A 'solution' would be to make 200 VIs to compare element 0-199 and call it in a case... I'm still brainstorming about a single VI that either compares or returns a specific element practically (and without variant magic).


Got it 100% working.

 

I now have a Sort 1D Array Of Cluster.vim.

 

And it's useless... The .vims make editing sooo slow, every non-trivial change their recompile takes seconds. The execution should be fast though.

 

I guess my Compare Cluster Element (Greater).vim and Compare Cluster Element (Not Equal).vim should settle for less then 200 cases before resolving to variants.

0 Kudos
Message 12 of 21
(1,509 Views)

This works.  But it's an XNode.  Sorry.

"If you weren't supposed to push it, it wouldn't be a button."
Message 13 of 21
(1,507 Views)

@paul_cardinale wrote:

This works.  But it's an XNode.  Sorry.


It was more a test case for vims that a real need. I'd expect an XNode would make it a lot easier. It's just so damn frustrating that simple things are so hard in .vims, I just have to keep trying.

 

I hope we get more .vim tools soon. At the moment, there're way to hard to work with for arrays (moving over dimensions) and clusters. Recursion would be nice.

0 Kudos
Message 14 of 21
(1,502 Views)

wiebe@CARYA wrote:

@paul_cardinale wrote:

This works.  But it's an XNode.  Sorry.


It was more a test case for vims that a real need. I'd expect an XNode would make it a lot easier. It's just so damn frustrating that simple things are so hard in .vims, I just have to keep trying.

 

I hope we get more .vim tools soon. At the moment, there're way to hard to work with for arrays (moving over dimensions) and clusters. Recursion would be nice.


OK, here it is as a malleable (a bit klunky on the inside).

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 15 of 21
(1,488 Views)

@paul_cardinale wrote:

wiebe@CARYA wrote:

@paul_cardinale wrote:

This works.  But it's an XNode.  Sorry.


It was more a test case for vims that a real need. I'd expect an XNode would make it a lot easier. It's just so damn frustrating that simple things are so hard in .vims, I just have to keep trying.

 

I hope we get more .vim tools soon. At the moment, there're way to hard to work with for arrays (moving over dimensions) and clusters. Recursion would be nice.


OK, here it is as a malleable (a bit klunky on the inside).


I think you missed the part about not using variant magic.

 

That is going to be dreadfully slow.

0 Kudos
Message 16 of 21
(1,478 Views)

wiebe@CARYA wrote:

@paul_cardinale wrote:

wiebe@CARYA wrote:

@paul_cardinale wrote:

This works.  But it's an XNode.  Sorry.


It was more a test case for vims that a real need. I'd expect an XNode would make it a lot easier. It's just so damn frustrating that simple things are so hard in .vims, I just have to keep trying.

 

I hope we get more .vim tools soon. At the moment, there're way to hard to work with for arrays (moving over dimensions) and clusters. Recursion would be nice.


OK, here it is as a malleable (a bit klunky on the inside).


I think you missed the part about not using variant magic.

 

That is going to be dreadfully slow.


This will be faster.  But it still uses variants.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 17 of 21
(1,466 Views)

@paul_cardinale wrote:

wiebe@CARYA wrote:

@paul_cardinale wrote:

wiebe@CARYA wrote:

@paul_cardinale wrote:

This works.  But it's an XNode.  Sorry.


It was more a test case for vims that a real need. I'd expect an XNode would make it a lot easier. It's just so damn frustrating that simple things are so hard in .vims, I just have to keep trying.

 

I hope we get more .vim tools soon. At the moment, there're way to hard to work with for arrays (moving over dimensions) and clusters. Recursion would be nice.


OK, here it is as a malleable (a bit klunky on the inside).


I think you missed the part about not using variant magic.

 

That is going to be dreadfully slow.


This will be faster.  But it still uses variants.


I'll try to get some benchmarking done (Sort 1D Array, your, mine, Sort 2D Array).

 

Another difference is that Sort 2D Array allows an array of indices (not names). If a scalar is given, the order stays intact, instead for the given index. This is different from Sort 1D Array, that always uses all cluster elements for sorting. Theoretically, Sort 1D Array Of Clusters could be faster then the Sort 1D Array...

 

I can see how sorting on name could be useful, but clusters don't always have names. So accepting indices would be a requirement.

 

I don't you can use names without variant magic, but at least it's magic on 1 element, not the array. 

0 Kudos
Message 18 of 21
(1,464 Views)

wiebe@CARYA wrote:

@paul_cardinale wrote:

wiebe@CARYA wrote:

@paul_cardinale wrote:

wiebe@CARYA wrote:

@paul_cardinale wrote:

This works.  But it's an XNode.  Sorry.


It was more a test case for vims that a real need. I'd expect an XNode would make it a lot easier. It's just so damn frustrating that simple things are so hard in .vims, I just have to keep trying.

 

I hope we get more .vim tools soon. At the moment, there're way to hard to work with for arrays (moving over dimensions) and clusters. Recursion would be nice.


OK, here it is as a malleable (a bit klunky on the inside).


I think you missed the part about not using variant magic.

 

That is going to be dreadfully slow.


This will be faster.  But it still uses variants.


I'll try to get some benchmarking done (Sort 1D Array, your, mine, Sort 2D Array).


OK. Done benchmarking.

 

Your VI doesn't give the same results for floats as the Sort 1D Array for 1 element clusters:
Benchmark Sort 1D Array Of Clusters.PNG

0 Kudos
Message 19 of 21
(1,460 Views)
Solution
Accepted by topic author taras01

wiebe@CARYA wrote:

wiebe@CARYA wrote:

@paul_cardinale wrote:

wiebe@CARYA wrote:

@paul_cardinale wrote:

wiebe@CARYA wrote:

@paul_cardinale wrote:

This works.  But it's an XNode.  Sorry.


It was more a test case for vims that a real need. I'd expect an XNode would make it a lot easier. It's just so damn frustrating that simple things are so hard in .vims, I just have to keep trying.

 

I hope we get more .vim tools soon. At the moment, there're way to hard to work with for arrays (moving over dimensions) and clusters. Recursion would be nice.


OK, here it is as a malleable (a bit klunky on the inside).


I think you missed the part about not using variant magic.

 

That is going to be dreadfully slow.


This will be faster.  But it still uses variants.


I'll try to get some benchmarking done (Sort 1D Array, your, mine, Sort 2D Array).


OK. Done benchmarking.

 

Your VI doesn't give the same results for floats as the Sort 1D Array for 1 element clusters:
Benchmark Sort 1D Array Of Clusters.PNG


Probably hard to fix that.  It's getting the value from the variant as a string, then trying to use those values for an alphanumerical sort, but it won't work properly for numbers in exponential notation (which is how it sees DBLs under the hood).

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 20 of 21
(1,446 Views)