ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

取消
显示结果 
搜索替代 
您的意思是: 

Array of clusters

已解决!
转到解答

@taras01 wrote:

Hello,


BTW.

 

Is OP still hanging around?

 

We're getting OT because you're quit.

0 项奖励
11 条消息(共 21 条)
2,172 次查看

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 项奖励
12 条消息(共 21 条)
2,165 次查看

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

"If you weren't supposed to push it, it wouldn't be a button."
13 条消息(共 21 条)
2,163 次查看

@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 项奖励
14 条消息(共 21 条)
2,158 次查看

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 项奖励
15 条消息(共 21 条)
2,144 次查看

@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 项奖励
16 条消息(共 21 条)
2,134 次查看

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 项奖励
17 条消息(共 21 条)
2,122 次查看

@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 项奖励
18 条消息(共 21 条)
2,120 次查看

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 项奖励
19 条消息(共 21 条)
2,116 次查看
解答
接受人 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 项奖励
20 条消息(共 21 条)
2,102 次查看