<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
(	O
LUT	O
)	O
is	O
an	O
array	B-Data_Structure
that	O
replaces	O
runtime	B-Library
computation	O
with	O
a	O
simpler	O
array	B-Data_Structure
indexing	O
operation	O
.	O
</s>
<s>
The	O
process	O
is	O
termed	O
as	O
"	O
direct	O
addressing	O
"	O
and	O
LUTs	O
differ	O
from	O
hash	B-Algorithm
tables	I-Algorithm
in	O
a	O
way	O
that	O
,	O
to	O
retrieve	O
a	O
value	O
with	O
key	O
,	O
a	O
hash	B-Algorithm
table	I-Algorithm
would	O
store	O
the	O
value	O
in	O
the	O
slot	O
where	O
is	O
a	O
hash	B-Error_Name
function	I-Error_Name
i.e.	O
</s>
<s>
The	O
savings	O
in	O
processing	O
time	O
can	O
be	O
significant	O
,	O
because	O
retrieving	O
a	O
value	O
from	O
memory	B-General_Concept
is	O
often	O
faster	O
than	O
carrying	O
out	O
an	O
"	O
expensive	O
"	O
computation	O
or	O
input/output	B-General_Concept
operation	O
.	O
</s>
<s>
The	O
tables	O
may	O
be	O
precalculated	O
and	O
stored	O
in	O
static	B-General_Concept
program	O
storage	O
,	O
calculated	O
(	O
or	O
"	O
pre-fetched	O
"	O
)	O
as	O
part	O
of	O
a	O
program	O
's	O
initialization	O
phase	O
(	O
memoization	O
)	O
,	O
or	O
even	O
stored	O
in	O
hardware	O
in	O
application-specific	O
platforms	O
.	O
</s>
<s>
Lookup	B-Data_Structure
tables	I-Data_Structure
are	O
also	O
used	O
extensively	O
to	O
validate	O
input	O
values	O
by	O
matching	O
against	O
a	O
list	O
of	O
valid	O
(	O
or	O
invalid	O
)	O
items	O
in	O
an	O
array	B-Data_Structure
and	O
,	O
in	O
some	O
programming	O
languages	O
,	O
may	O
include	O
pointer	O
functions	O
(	O
or	O
offsets	O
to	O
labels	O
)	O
to	O
process	O
the	O
matching	O
input	O
.	O
</s>
<s>
FPGAs	B-Architecture
also	O
make	O
extensive	O
use	O
of	O
reconfigurable	O
,	O
hardware-implemented	O
,	O
lookup	B-Data_Structure
tables	I-Data_Structure
to	O
provide	O
programmable	O
hardware	O
functionality	O
.	O
</s>
<s>
Before	O
the	O
advent	O
of	O
computers	O
,	O
lookup	B-Data_Structure
tables	I-Data_Structure
of	O
values	O
were	O
used	O
to	O
speed	O
up	O
hand	O
calculations	O
of	O
complex	O
functions	O
,	O
such	O
as	O
in	O
trigonometry	O
,	O
logarithms	O
,	O
and	O
statistical	O
density	O
functions	O
.	O
</s>
<s>
Early	O
in	O
the	O
history	O
of	O
computers	O
,	O
input/output	B-General_Concept
operations	O
were	O
particularly	O
slow	O
–	O
even	O
in	O
comparison	O
to	O
processor	O
speeds	O
of	O
the	O
time	O
.	O
</s>
<s>
It	O
made	O
sense	O
to	O
reduce	O
expensive	O
read	O
operations	O
by	O
a	O
form	O
of	O
manual	O
caching	B-General_Concept
by	O
creating	O
either	O
static	B-General_Concept
lookup	B-Data_Structure
tables	I-Data_Structure
(	O
embedded	O
in	O
the	O
program	O
)	O
or	O
dynamic	O
prefetched	O
arrays	O
to	O
contain	O
only	O
the	O
most	O
commonly	O
occurring	O
data	O
items	O
.	O
</s>
<s>
Despite	O
the	O
introduction	O
of	O
systemwide	O
caching	B-General_Concept
that	O
now	O
automates	O
this	O
process	O
,	O
application	O
level	O
lookup	B-Data_Structure
tables	I-Data_Structure
can	O
still	O
improve	O
performance	O
for	O
data	O
items	O
that	O
rarely	O
,	O
if	O
ever	O
,	O
change	O
.	O
</s>
<s>
Lookup	B-Data_Structure
tables	I-Data_Structure
were	O
one	O
of	O
the	O
earliest	O
functionalities	O
implemented	O
in	O
computer	O
spreadsheets	B-Application
,	O
with	O
the	O
initial	O
version	O
of	O
VisiCalc	B-Application
(	O
1979	O
)	O
including	O
a	O
LOOKUP	B-Data_Structure
function	O
among	O
its	O
original	O
20	O
functions	O
.	O
</s>
<s>
This	O
has	O
been	O
followed	O
by	O
subsequent	O
spreadsheets	B-Application
,	O
such	O
as	O
Microsoft	B-Application
Excel	I-Application
,	O
and	O
complemented	O
by	O
specialized	O
VLOOKUP	B-Data_Structure
and	O
HLOOKUP	O
functions	O
to	O
simplify	O
lookup	B-Data_Structure
in	O
a	O
vertical	O
or	O
horizontal	O
table	O
.	O
</s>
<s>
In	O
Microsoft	B-Application
Excel	I-Application
the	O
XLOOKUP	B-Data_Structure
function	O
has	O
been	O
rolled	O
out	O
starting	O
28	O
August	O
2019	O
.	O
</s>
<s>
Although	O
the	O
performance	O
of	O
a	O
LUT	O
is	O
a	O
guaranteed	O
for	O
a	O
lookup	B-Data_Structure
operation	O
,	O
no	O
two	O
entities	O
or	O
values	O
can	O
have	O
the	O
same	O
key	O
.	O
</s>
<s>
When	O
the	O
size	O
of	O
universe	O
—	O
where	O
the	O
keys	O
are	O
drawn	O
—	O
is	O
large	O
,	O
it	O
might	O
be	O
impractical	O
or	O
impossible	O
to	O
be	O
stored	O
in	O
memory	B-General_Concept
.	O
</s>
<s>
Hence	O
,	O
in	O
this	O
case	O
,	O
a	O
hash	B-Algorithm
table	I-Algorithm
would	O
be	O
a	O
preferable	O
alternative	O
.	O
</s>
<s>
For	O
a	O
trivial	B-Data_Structure
hash	I-Data_Structure
function	I-Data_Structure
lookup	B-Data_Structure
,	O
the	O
unsigned	O
raw	O
data	O
value	O
is	O
used	O
directly	O
as	O
an	O
index	O
to	O
a	O
one-dimensional	O
table	O
to	O
extract	O
a	O
result	O
.	O
</s>
<s>
For	O
small	O
ranges	O
,	O
this	O
can	O
be	O
amongst	O
the	O
fastest	O
lookup	B-Data_Structure
,	O
even	O
exceeding	O
binary	O
search	O
speed	O
with	O
zero	O
branches	O
and	O
executing	O
in	O
constant	O
time	O
.	O
</s>
<s>
A	O
simple	O
example	O
of	O
C	B-Language
code	O
,	O
designed	O
to	O
count	O
the	O
1	O
bits	O
in	O
a	O
int	O
,	O
might	O
look	O
like	O
this	O
:	O
</s>
<s>
It	O
can	O
be	O
"	O
unrolled	B-Operating_System
"	O
into	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
which	O
in	O
turn	O
uses	O
trivial	B-Data_Structure
hash	I-Data_Structure
function	I-Data_Structure
for	O
better	O
performance	O
.	O
</s>
<s>
The	O
bits	O
array	B-Data_Structure
,	O
bits_set	O
with	O
256	O
entries	O
is	O
constructed	O
by	O
giving	O
the	O
number	O
of	O
one	O
bits	O
set	O
in	O
each	O
possible	O
byte	O
value	O
(	O
e.g.	O
</s>
<s>
Although	O
a	O
runtime	B-Library
algorithm	O
can	O
be	O
used	O
to	O
generate	O
the	O
bits_set	O
array	B-Data_Structure
,	O
it	O
's	O
an	O
inefficient	O
usage	O
of	O
clock	O
cycles	O
when	O
the	O
size	O
is	O
taken	O
into	O
consideration	O
,	O
hence	O
a	O
precomputed	O
table	O
is	O
used	O
—	O
although	O
a	O
compile	B-Application
time	I-Application
script	O
could	O
be	O
used	O
to	O
dynamically	O
generate	O
and	O
append	O
the	O
table	O
to	O
the	O
source	O
file	O
.	O
</s>
<s>
Sum	O
of	O
ones	O
in	O
each	O
byte	O
of	O
the	O
integer	O
can	O
be	O
calculated	O
through	O
trivial	B-Data_Structure
hash	I-Data_Structure
function	I-Data_Structure
lookup	B-Data_Structure
on	O
each	O
byte	O
;	O
thus	O
,	O
effectively	O
avoiding	O
branches	O
resulting	O
in	O
considerable	O
improvement	O
in	O
performance	O
.	O
</s>
<s>
In	O
data	O
analysis	O
applications	O
,	O
such	O
as	O
image	B-Algorithm
processing	I-Algorithm
,	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
(	O
LUT	O
)	O
is	O
used	O
to	O
transform	O
the	O
input	B-General_Concept
data	I-General_Concept
into	O
a	O
more	O
desirable	O
output	O
format	O
.	O
</s>
<s>
A	O
classic	O
example	O
of	O
reducing	O
run-time	O
computations	O
using	O
lookup	B-Data_Structure
tables	I-Data_Structure
is	O
to	O
obtain	O
the	O
result	O
of	O
a	O
trigonometry	O
calculation	O
,	O
such	O
as	O
the	O
sine	O
of	O
a	O
value	O
.	O
</s>
<s>
The	O
same	O
application	O
can	O
finish	O
much	O
sooner	O
when	O
it	O
first	O
precalculates	O
the	O
sine	O
of	O
a	O
number	O
of	O
values	O
,	O
for	O
example	O
for	O
each	O
whole	O
number	O
of	O
degrees	O
(	O
The	O
table	O
can	O
be	O
defined	O
as	O
static	B-General_Concept
variables	I-General_Concept
at	O
compile	B-Application
time	I-Application
,	O
reducing	O
repeated	O
run	B-Library
time	I-Library
costs	O
)	O
.	O
</s>
<s>
When	O
the	O
program	O
requires	O
the	O
sine	O
of	O
a	O
value	O
,	O
it	O
can	O
use	O
the	O
lookup	B-Data_Structure
table	I-Data_Structure
to	O
retrieve	O
the	O
closest	O
sine	O
value	O
from	O
a	O
memory	B-General_Concept
address	O
,	O
and	O
may	O
also	O
interpolate	O
to	O
the	O
sine	O
of	O
the	O
desired	O
value	O
,	O
instead	O
of	O
calculating	O
by	O
mathematical	O
formula	O
.	O
</s>
<s>
Lookup	B-Data_Structure
tables	I-Data_Structure
are	O
thus	O
used	O
by	O
mathematics	O
coprocessors	B-General_Concept
in	O
computer	O
systems	O
.	O
</s>
<s>
An	O
error	O
in	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
was	O
responsible	O
for	O
Intel	O
's	O
infamous	O
floating-point	B-Device
divide	I-Device
bug	I-Device
.	O
</s>
<s>
Functions	O
of	O
a	O
single	O
variable	O
(	O
such	O
as	O
sine	O
and	O
cosine	O
)	O
may	O
be	O
implemented	O
by	O
a	O
simple	O
array	B-Data_Structure
.	O
</s>
<s>
Functions	O
involving	O
two	O
or	O
more	O
variables	O
require	O
multidimensional	O
array	B-Data_Structure
indexing	O
techniques	O
.	O
</s>
<s>
The	O
latter	O
case	O
may	O
thus	O
employ	O
a	O
two-dimensional	O
array	B-Data_Structure
of	O
power[x][y]	O
to	O
replace	O
a	O
function	O
to	O
calculate	O
xy	O
for	O
a	O
limited	O
range	O
of	O
x	O
and	O
y	O
values	O
.	O
</s>
<s>
Functions	O
that	O
have	O
more	O
than	O
one	O
result	O
may	O
be	O
implemented	O
with	O
lookup	B-Data_Structure
tables	I-Data_Structure
that	O
are	O
arrays	O
of	O
structures	O
.	O
</s>
<s>
As	O
mentioned	O
,	O
there	O
are	O
intermediate	O
solutions	O
that	O
use	O
tables	O
in	O
combination	O
with	O
a	O
small	O
amount	O
of	O
computation	O
,	O
often	O
using	O
interpolation	B-Algorithm
.	O
</s>
<s>
Pre-calculation	O
combined	O
with	O
interpolation	B-Algorithm
can	O
produce	O
higher	O
accuracy	O
for	O
values	O
that	O
fall	O
between	O
two	O
precomputed	O
values	O
.	O
</s>
<s>
Depending	O
on	O
the	O
values	O
being	O
precomputed	O
,	O
precomputation	O
with	O
interpolation	B-Algorithm
can	O
also	O
be	O
used	O
to	O
shrink	O
the	O
lookup	B-Data_Structure
table	I-Data_Structure
size	O
while	O
maintaining	O
accuracy	O
.	O
</s>
<s>
In	O
image	B-Algorithm
processing	I-Algorithm
,	O
lookup	B-Data_Structure
tables	I-Data_Structure
are	O
often	O
called	O
LUTs	O
(	O
or	O
3DLUT	O
)	O
,	O
and	O
give	O
an	O
output	O
value	O
for	O
each	O
of	O
a	O
range	O
of	O
index	O
values	O
.	O
</s>
<s>
One	O
common	O
LUT	O
,	O
called	O
the	O
colormap	O
or	O
palette	B-Data_Structure
,	O
is	O
used	O
to	O
determine	O
the	O
colors	O
and	O
intensity	O
values	O
with	O
which	O
a	O
particular	O
image	O
will	O
be	O
displayed	O
.	O
</s>
<s>
While	O
often	O
effective	O
,	O
employing	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
may	O
nevertheless	O
result	O
in	O
a	O
severe	O
penalty	O
if	O
the	O
computation	O
that	O
the	O
LUT	O
replaces	O
is	O
relatively	O
simple	O
.	O
</s>
<s>
Memory	B-General_Concept
retrieval	O
time	O
and	O
the	O
complexity	O
of	O
memory	B-General_Concept
requirements	O
can	O
increase	O
application	O
operation	O
time	O
and	O
system	O
complexity	O
relative	O
to	O
what	O
would	O
be	O
required	O
by	O
straight	O
formula	O
computation	O
.	O
</s>
<s>
The	O
possibility	O
of	O
polluting	B-General_Concept
the	I-General_Concept
cache	I-General_Concept
may	O
also	O
become	O
a	O
problem	O
.	O
</s>
<s>
Table	O
accesses	O
for	O
large	O
tables	O
will	O
almost	O
certainly	O
cause	O
a	O
cache	B-General_Concept
miss	O
.	O
</s>
<s>
This	O
phenomenon	O
is	O
increasingly	O
becoming	O
an	O
issue	O
as	O
processors	O
outpace	O
memory	B-General_Concept
.	O
</s>
<s>
A	O
similar	O
issue	O
appears	O
in	O
rematerialization	O
,	O
a	O
compiler	B-Application
optimization	I-Application
.	O
</s>
<s>
In	O
some	O
environments	O
,	O
such	O
as	O
the	O
Java	B-Language
programming	I-Language
language	I-Language
,	O
table	B-Data_Structure
lookups	I-Data_Structure
can	O
be	O
even	O
more	O
expensive	O
due	O
to	O
mandatory	O
bounds-checking	O
involving	O
an	O
additional	O
comparison	O
and	O
branch	O
for	O
each	O
lookup	B-Data_Structure
.	O
</s>
<s>
There	O
are	O
two	O
fundamental	O
limitations	O
on	O
when	O
it	O
is	O
possible	O
to	O
construct	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
for	O
a	O
required	O
operation	O
.	O
</s>
<s>
One	O
is	O
the	O
amount	O
of	O
memory	B-General_Concept
that	O
is	O
available	O
:	O
one	O
cannot	O
construct	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
larger	O
than	O
the	O
space	O
available	O
for	O
the	O
table	O
,	O
although	O
it	O
is	O
possible	O
to	O
construct	O
disk-based	O
lookup	B-Data_Structure
tables	I-Data_Structure
at	O
the	O
expense	O
of	O
lookup	B-Data_Structure
time	O
.	O
</s>
<s>
The	O
other	O
is	O
the	O
time	O
required	O
to	O
compute	O
the	O
table	O
values	O
in	O
the	O
first	O
instance	O
;	O
although	O
this	O
usually	O
needs	O
to	O
be	O
done	O
only	O
once	O
,	O
if	O
it	O
takes	O
a	O
prohibitively	O
long	O
time	O
,	O
it	O
may	O
make	O
the	O
use	O
of	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
an	O
inappropriate	O
solution	O
.	O
</s>
<s>
Instead	O
,	O
they	O
use	O
the	O
CORDIC	B-Algorithm
algorithm	I-Algorithm
or	O
a	O
complex	O
formula	O
such	O
as	O
the	O
following	O
Taylor	O
series	O
to	O
compute	O
the	O
value	O
of	O
sine	O
to	O
a	O
high	O
degree	O
of	O
precision	O
:	O
</s>
<s>
A	O
common	O
solution	O
is	O
to	O
initially	O
compute	O
the	O
sine	O
of	O
many	O
evenly	O
distributed	O
values	O
,	O
and	O
then	O
to	O
find	O
the	O
sine	O
of	O
x	O
we	O
choose	O
the	O
sine	O
of	O
the	O
value	O
closest	O
to	O
x	O
through	O
array	B-Data_Structure
indexing	O
operation	O
.	O
</s>
<s>
One	O
good	O
solution	O
is	O
linear	O
interpolation	B-Algorithm
,	O
which	O
draws	O
a	O
line	O
between	O
the	O
two	O
points	O
in	O
the	O
table	O
on	O
either	O
side	O
of	O
the	O
value	O
and	O
locates	O
the	O
answer	O
on	O
that	O
line	O
.	O
</s>
<s>
Here	O
is	O
an	O
example	O
using	O
linear	O
interpolation	B-Algorithm
:	O
</s>
<s>
Linear	O
interpolation	B-Algorithm
provides	O
for	O
an	O
interpolated	O
function	O
that	O
is	O
continuous	O
,	O
but	O
will	O
not	O
,	O
in	O
general	O
,	O
have	O
continuous	O
derivatives	B-Algorithm
.	O
</s>
<s>
For	O
smoother	O
interpolation	B-Algorithm
of	O
table	B-Data_Structure
lookup	I-Data_Structure
that	O
is	O
continuous	O
and	O
has	O
continuous	O
first	B-Algorithm
derivative	I-Algorithm
,	O
one	O
should	O
use	O
the	O
cubic	O
Hermite	O
spline	O
.	O
</s>
<s>
When	O
using	O
interpolation	B-Algorithm
,	O
the	O
size	O
of	O
the	O
lookup	B-Data_Structure
table	I-Data_Structure
can	O
be	O
reduced	O
by	O
using	O
nonuniform	O
sampling	O
,	O
which	O
means	O
that	O
where	O
the	O
function	O
is	O
close	O
to	O
straight	O
,	O
we	O
use	O
few	O
sample	O
points	O
,	O
while	O
where	O
it	O
changes	O
value	O
quickly	O
we	O
use	O
more	O
sample	O
points	O
to	O
keep	O
the	O
approximation	O
close	O
to	O
the	O
real	O
curve	O
.	O
</s>
<s>
For	O
more	O
information	O
,	O
see	O
interpolation	B-Algorithm
.	O
</s>
<s>
Storage	O
caches	B-General_Concept
(	O
including	O
disk	O
caches	B-General_Concept
for	O
files	O
,	O
or	O
processor	O
caches	B-General_Concept
for	O
either	O
code	O
or	O
data	O
)	O
work	O
also	O
like	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
.	O
</s>
<s>
The	O
table	O
is	O
built	O
with	O
very	O
fast	O
memory	B-General_Concept
instead	O
of	O
being	O
stored	O
on	O
slower	O
external	O
memory	B-General_Concept
,	O
and	O
maintains	O
two	O
pieces	O
of	O
data	O
for	O
a	O
sub-range	O
of	O
bits	O
composing	O
an	O
external	O
memory	B-General_Concept
(	O
or	O
disk	O
)	O
address	O
(	O
notably	O
the	O
lowest	O
bits	O
of	O
any	O
possible	O
external	O
address	O
)	O
:	O
</s>
<s>
one	O
piece	O
(	O
the	O
tag	O
)	O
contains	O
the	O
value	O
of	O
the	O
remaining	O
bits	O
of	O
the	O
address	O
;	O
if	O
these	O
bits	O
match	O
with	O
those	O
from	O
the	O
memory	B-General_Concept
address	O
to	O
read	O
or	O
write	O
,	O
then	O
the	O
other	O
piece	O
contains	O
the	O
cached	O
value	O
for	O
this	O
address	O
.	O
</s>
<s>
A	O
single	O
(	O
fast	O
)	O
lookup	B-Data_Structure
is	O
performed	O
to	O
read	O
the	O
tag	O
in	O
the	O
lookup	B-Data_Structure
table	I-Data_Structure
at	O
the	O
index	O
specified	O
by	O
the	O
lowest	O
bits	O
of	O
the	O
desired	O
external	O
storage	O
address	O
,	O
and	O
to	O
determine	O
if	O
the	O
memory	B-General_Concept
address	O
is	O
hit	O
by	O
the	O
cache	B-General_Concept
.	O
</s>
<s>
When	O
a	O
hit	O
is	O
found	O
,	O
no	O
access	O
to	O
external	O
memory	B-General_Concept
is	O
needed	O
(	O
except	O
for	O
write	O
operations	O
,	O
where	O
the	O
cached	O
value	O
may	O
need	O
to	O
be	O
updated	O
asynchronously	O
to	O
the	O
slower	O
memory	B-General_Concept
after	O
some	O
time	O
,	O
or	O
if	O
the	O
position	O
in	O
the	O
cache	B-General_Concept
must	O
be	O
replaced	O
to	O
cache	B-General_Concept
another	O
address	O
)	O
.	O
</s>
<s>
In	O
digital	O
logic	O
,	O
a	O
lookup	B-Data_Structure
table	I-Data_Structure
can	O
be	O
implemented	O
with	O
a	O
multiplexer	B-Protocol
whose	O
select	O
lines	O
are	O
driven	O
by	O
the	O
address	O
signal	O
and	O
whose	O
inputs	O
are	O
the	O
values	O
of	O
the	O
elements	O
contained	O
in	O
the	O
array	B-Data_Structure
.	O
</s>
<s>
(	O
ROM	B-Device
,	O
EPROM	B-General_Concept
,	O
EEPROM	B-General_Concept
,	O
or	O
RAM	B-Architecture
.	O
)	O
</s>
<s>
This	O
is	O
an	O
efficient	O
way	O
of	O
encoding	O
Boolean	O
logic	O
functions	O
,	O
and	O
LUTs	O
with	O
4-6	O
bits	O
of	O
input	O
are	O
in	O
fact	O
the	O
key	O
component	O
of	O
modern	O
field-programmable	B-Architecture
gate	I-Architecture
arrays	I-Architecture
(	O
FPGAs	B-Architecture
)	O
which	O
provide	O
reconfigurable	O
hardware	O
logic	O
capabilities	O
.	O
</s>
<s>
In	O
data	B-Algorithm
acquisition	I-Algorithm
and	O
control	O
systems	O
,	O
lookup	B-Data_Structure
tables	I-Data_Structure
are	O
commonly	O
used	O
to	O
undertake	O
the	O
following	O
operations	O
in	O
:	O
</s>
<s>
In	O
some	O
systems	O
,	O
polynomials	O
may	O
also	O
be	O
defined	O
in	O
place	O
of	O
lookup	B-Data_Structure
tables	I-Data_Structure
for	O
these	O
calculations	O
.	O
</s>
