I was fortunate enough to find a way to execute intersect () faster when the stack overflows with a pre-sorted 1d vector, so I hope for the same luck unique ();)
Almost 1 / 4'th of my runtime is wasted using unique (). I would like to speed this up, and I can assume that this is a 1d pre-sorted vector. Are there any other low level functions that I can use to speed this up?
You can simply use diff to check if consecutive elements are the same.
diff
vector = [1 2 3 4 4 5]; uniqueVector = vector([true;diff(vector(:))>0]) uniqueVector = 1 2 3 4 5
Source: https://habr.com/ru/post/901754/More articles:Is there a way to write .emacs that will always support upstream compatibility? - emacsThe best way to store hierarchical data in hbase is hbaseConvert string to class Enum - javaBenefits of anonymous JavaScript function with namespaces - javascripttomcat does not show error message when using sendError from servlet - javaTool to convert Maven pom.xml to leiningen project.clj - mavenJava, using Iterator to find an ArrayList and remove matching objects - javaWhat can happen if I use: without_protection => true when creating a new model in rails 3.1? - ruby-on-railsMultiple AsyncTaskLoader in one action - should each bootloader be initialized in onCreate? - androidCyrillic alphabet with Microsoft SQL Server Management Studio - sql-serverAll Articles