Thread: Look Up Tables
View Single Post
  #4   Spotlight this post!  
Unread 01-03-2005, 13:09
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Look Up Tables

Quote:
Originally Posted by amateurrobotguy
...Like on table 1 find this number. Then from that number, goto table 2 with the same row and find that number.

Code:
const int table_length = 18;
rom const int x[]= {0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255};
rom const int y[]= {0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255};
Basically I want something like:

Search x(135)
a=x postition
goto y(a)
Your example is probably poorly chosen to indicate what you want. The x and y arrays are identical, so whatever you put in as your search is what you get out as the result.

Lookup tables are most easily used as replacements for a simple y=f(x) computation when f() involves lots of multiplication. I don't know what function you're trying to perform with your pair of tables, but what you asked for reduces to a simple f(x) = x.