Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have some numerical code involving complex numbers representing points on a plane. Some of these are equal but not identical, ie

{Exp[2 Pi I (-1./10)], ..., Exp[2 Pi I (9./10)]}

I want to make (the equivalent of) a dictionary mapping each to its coordinate in the list (because using Position repeatedly would take too long). But both Downvalues and matching rules (with a Dispatch table) match based on the form of the expression rather than its value (and Hash hashes based on the form of the expression as well).
Eg, if

{a == b, a===b}
==> {True, False}
then

f[a] = 1; {f[a], f[b]}
{1, f[b]}

Is there some way to associate the points with their position (with faster than O(n) lookup) based on their value? I feel like there should also be some way to do it using rounding, but I haven't gotten it to work.

share|improve this question
1  
Hello Zaq. I believe a similar question has been asked before. (I shall look for it.) One possibility is to use Round (with a second parameter) to quantize your data. –  Mr.Wizard May 16 at 20:17
1  
Not a duplicate, but related: (15907). And this is the one I think I was remembering: (1072) -- also not an exact duplicate, but quite close. –  Mr.Wizard May 16 at 20:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.