konstantin magnus Posted December 9, 2016 Share Posted December 9, 2016 (edited) How can I prevent double values in vex arrays? Also is there a way to sort them out afterwards? int collect[]; int pt_prims[] = pointprims(0, @ptnum); foreach(int pt_prim; pt_prims) { int prim_pts[] = primpoints(0, pt_prim); foreach(int prim_pt; prim_pts) { append(collect, prim_pt); } } vex_tree_connect.hipnc Edited December 9, 2016 by konstantin magnus Quote Link to comment Share on other sites More sharing options...
j00ey Posted December 10, 2016 Share Posted December 10, 2016 I'm not in front of a machine right now but could you use removevalue? Inside the second foreach do something like (pseudo code): Int temp_collect[] = collect Int has_value = removevalue(prim_pt, temp_collect) If (has_value == 0) [append(collect, prim_pt)]* *No curly braces on my phone! Quote Link to comment Share on other sites More sharing options...
petz Posted December 10, 2016 Share Posted December 10, 2016 attached is one possibility. for large arrays you might be better off using python/numpy since vex gets slow at some point ... vex_tree_connect1.hipnc Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted December 10, 2016 Author Share Posted December 10, 2016 Thank you both! 1 hour ago, petz said: for large arrays you might be better off using python/numpy since vex gets slow at some point ... I intend to use lots of small arrays. Say 500 individual trees with an average of 10 branches (each branch fusing to an array of 8 points). Does this sound more like numpy (never used it so far) or can one keep this responsive using VEX? Quote Link to comment Share on other sites More sharing options...
petz Posted December 10, 2016 Share Posted December 10, 2016 27 minutes ago, konstantin magnus said: I intend to use lots of small arrays. Say 500 individual trees with an average of 10 branches (each branch fusing to an array of 8 points). Does this sound more like numpy (never used it so far) or can one keep this responsive using VEX? lots of small arrays are not a problem at all in vex. for searching and sorting arrays with more than 1024 entires (somehow the magical number last time i checked) it might be better to use python/numpy, depending on the situation ... Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted December 10, 2016 Author Share Posted December 10, 2016 2 minutes ago, petz said: lots of small arrays are not a problem at all in vex. alright, thanks for the info. guess I can stay and learn in my little VEX world for the time being.. ; ) Quote Link to comment Share on other sites More sharing options...
acey195 Posted December 23, 2016 Share Posted December 23, 2016 (edited) On 12/10/2016 at 9:50 PM, petz said: attached is one possibility. for large arrays you might be better off using python/numpy since vex gets slow at some point ... vex_tree_connect1.hipnc I found another vex method, about 10-15% faster than geo2/attribwrangle4 in your file: int collect[], prims[], points[], i, collectSort[], collectFin[]; prims = pointprims(0, @ptnum); foreach(int prim; prims) { points = primpoints(0, prim); for( i = 0; i < len(points); i++) { if(points[i] != @ptnum) append(collect, points[i]); } } collectSort = argsort(collect); for(i = 0; i< len(collect) ; i++) { if(i == 0 || collect[ collectSort[i]] != collect[ collectSort[i-1]]) append(collectFin, collect[ collectSort[i] ]); } i[]@collect = collectFin; it does output the array in a slightly different order though, and I'm not sure if it will work the same way with a string array, but its an idea Edited December 23, 2016 by acey195 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted December 23, 2016 Author Share Posted December 23, 2016 1 hour ago, acey195 said: I found another vex method, about 10-15% faster Great, thanks! Do you see any way of preventing to store double values right from the start? or would this be even slower? Quote Link to comment Share on other sites More sharing options...
acey195 Posted December 23, 2016 Share Posted December 23, 2016 3 minutes ago, konstantin magnus said: Great, thanks! Do you see any way of preventing to store double values right from the start? or would this be even slower? well that is basically what (one of) petz's method(s) was doing, but the more often you have to search the array, the slower it will be. In my method, I do prevent putting the processed point itself in the array, but that's it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.