Hi Craig, On 05/06/2015 12:05 PM, Craig DeForest wrote: > Try this (NOTE NiceSlice syntax): > > $mask = ($a != $a->range(-1,$a->dim(0),'e')); > $mask->(0) .= 1; > $ui = which($mask);
Thanks, but the trouble with this method is it relies on the duplicated values being next to each other. It won't work if $a=pdl(1,2,2,1,2,2) for example. I'm using the result to index another vector so don't want to sort it first. Regards, Trevor. >> On May 5, 2015, at 5:13 PM, Trevor Carey-Smith >> <[email protected]> wrote: >> >> I am using uniqind() but I need it to return the index of the *first* >> unique value. As it is the function returns a seemingly random index: >> >> pdl> $a=pdl(1,2,2,2) >> pdl> p $a->uniqind >> [0 1] >> pdl> $b=pdl(1,2,2,2,2) >> pdl> p $b->uniqind >> [0 2] >> >> Can anyone provide an efficient way of doing this? >> >> I have come up with a convoluted method that does not scale well (when >> the vector is large and has many non-unique values): >> >> pdl> $tmp=$b->uniq->(*1)->minus($b,0) == 0 >> pdl> p $tmp->mult(xvals($tmp)+1,0)->setvaltobad(0)->minimum->minus(1,0) >> [0 1] >> >> My PDL version is old (v2.4.7), but it is installed on a server and they >> would rather avoid upgrades... >> >> Thanks for any help, >> Trevor. ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ pdl-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pdl-general
