Simon Woods
Reputation
59,928
227/100 score
 Feb 16 comment Memory limit hit: optimize code for finding twin primes You should be able to use testPrime in parallel, e.g. ParallelTable[testPrime[Prime[j], 1], {j, 4, 1000}] Feb 15 answered Memory limit hit: optimize code for finding twin primes Feb 15 comment Brackets around each item in matrix I get similar results, to within a scaling factor for my slow CPU. Interesting that Join is much worse on packed arrays! Feb 15 awarded Guru Feb 14 comment Role of Accuracy in numerical evaluations, SplitBy vs GatherBy A simpler formulation of the same fundamental question: Given list = SetAccuracy[{1, 1, 1.01, 1.01, 1.02, 1.02}, 2] why does Gather[list] give a different result from Split[list] Feb 14 comment GatherBy/SplitBy and Sort a list IMO the best thing would be to remove both updates from the question, and accept an answer which best addresses the problem as originally asked. Then create a new question about why two low-accuracy numbers can give True for a==b but False for N[a]==N[b]. Feb 14 comment GatherBy/SplitBy and Sort a list The issue of how N affects Accuracy is a quite different problem to the original question regarding efficient sort & gather algorithms. It should be a separate question. People took time and trouble to answer the original question, and it's rather unfair to claim that their (perfectly good) answers don't work because of special features in your data that you didn't reveal until several hours later. It will also be more useful to future visitors looking for efficient sort & gather algorithms if the question is unencumbered by the requirement to avoid using N. Feb 13 comment GatherBy/SplitBy and Sort a list Check those results with a calculator, they are wrong! Feb 13 comment GatherBy/SplitBy and Sort a list No, the norms are {0., 1.64012, 0.632456, 0.632456, 1.64012, 1.58114, 0.640312, 0.6, 1.6, 0.640312, 1.58114} Feb 13 comment GatherBy/SplitBy and Sort a list f7 is lovely. One of those bits of code that seems obvious, once someone else has thought of it... Feb 13 comment GatherBy/SplitBy and Sort a list I'm not sure why that's what you expect. For example {-0.5, 0.4} and {0.2, -0.6} have different norms, so why are you expecting them in the same sublist? Feb 13 revised GatherBy/SplitBy and Sort a list fixed typo Feb 13 comment GatherBy/SplitBy and Sort a list For the first one you need to take into account that GatherBy returns lists of points, so you need to apply Norm to the first element not the whole list, e.g. SortBy[GatherBy[list2, Norm], N[Norm[#[[1]]]] &] Feb 13 comment GatherBy/SplitBy and Sort a list Well GatherBy[SortBy[list2, N[Norm[#]] &], Norm] gives the correct answer unlike the typo version. Feb 13 comment GatherBy/SplitBy and Sort a list The difference between using Norm and #.#& accounts for a lot of the speed differences. It would be interesting to compare the different approaches using the same norm function throughout. Feb 13 comment GatherBy/SplitBy and Sort a list Regarding the update, you have a misplaced bracket. N[Norm[#] &] should be N[Norm[#]] & Feb 13 comment How to mix symbols and text for labels in manipulate? You have multiplied the subscript and the string, instead use Row to format expressions in a row, e.g. Row[{Subscript[φ, 0], "(degrees)"}] Feb 13 comment GatherBy/SplitBy and Sort a list I suggest using #.#& in place of N@*Norm for integers - it omits the square root step but that doesn't change the ordering. Feb 13 comment GatherBy/SplitBy and Sort a list I had result = With[{n = #.# &}, list~GatherBy~n~SortBy~n@*First] - same principle but faster if list` is integers. Feb 13 comment How to count proportion of two phase in a electron microscope picture Do you have a version of the image without the text and arrows overlay?