473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

lookup tables

what are lookup tables ? How can they be used to optimise the code ?

Nov 14 '05 #1
10 3778


ju**********@yahoo.co.in wrote:
what are lookup tables ? How can they be used to optimise the code ?

Its mainly used for bit fiddling.
See the FAQ's - 20.12 and 20.13
@ http://www.eskimo.com/~scs/C-faq/top.html

- Ravi

Nov 14 '05 #2
ju**********@yahoo.co.in wrote:
what are lookup tables ? How can they be used to optimise the code ?

Please do your own homework.

You have posted all the questions of your homework here:
1: padding between variables in a structure
2: Multiple return statements Vs goto's
3: wrinting an optimised code
4: register variables
5: doubt related to string pointers.
6: which is better "switch" or "if-else"
Nov 14 '05 #3

jacob navia wrote:
ju**********@yahoo.co.in wrote:
what are lookup tables ? How can they be used to optimise the code ?

Please do your own homework.

You have posted all the questions of your homework here:
1: padding between variables in a structure
2: Multiple return statements Vs goto's
3: wrinting an optimised code
4: register variables
5: doubt related to string pointers.
6: which is better "switch" or "if-else"


I did search the answers on net but got confused more and more.
So, I thought to post them here.

Nov 14 '05 #4
Ravi Uday wrote:


ju**********@yahoo.co.in wrote:
what are lookup tables ? How can they be used to optimise the code ?

Its mainly used for bit fiddling.
See the FAQ's - 20.12 and 20.13
@ http://www.eskimo.com/~scs/C-faq/top.html

- Ravi

Wrong.
Many trigonomy (sp?) functions, such as sine and
tangent are implemented using lookup tables. To
my knowledge, this is not bit twiddling; but a
fast method for obtaining a result.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
Nov 14 '05 #5
ju**********@yahoo.co.in wrote:
what are lookup tables ? Lookup tables are tables consisting of data either
with a key in the record or an implied key (such
as an array).
How can they be used to optimise the code ?

Many times, lookup tables are used to implement
a function which would take more time to calculate
using a formula. A classic example is the sine
function.

Another usage of lookup tables is to convert values.

A lookup table can also be used for authentication.
As far as optimization goes, lookup tables trade
memory space for execution speed. Sometimes they
trade execution speed for ease of maintenance or
change.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
Nov 14 '05 #6


Thomas Matthews wrote:
Ravi Uday wrote:


ju**********@yahoo.co.in wrote:
what are lookup tables ? How can they be used to optimise the code ?
Its mainly used for bit fiddling.
See the FAQ's - 20.12 and 20.13
@ http://www.eskimo.com/~scs/C-faq/top.html

- Ravi

Wrong.
Many trigonomy (sp?) functions, such as sine and
tangent are implemented using lookup tables. To
my knowledge, this is not bit twiddling; but a
fast method for obtaining a result.

Did you read the FAQs i had pointed ??

Most common usage of
look-up table that i have seen
is when using a series of function-pointers
which gets invoked based on some input.
There were some sample code posted here some time back :)

- Ravi


Nov 14 '05 #7
On Wed, 18 May 2005 10:50:10 +0530, Ravi Uday <ra******@gmail.com>
wrote:


ju**********@yahoo.co.in wrote:
what are lookup tables ? How can they be used to optimise the code ?

Its mainly used for bit fiddling.


Hardly. Lookup tables have many uses. For optimization you might think
of a lookup table as a list of precalculated values, for applications
where it is faster to look up a value than calculate it.

--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 14 '05 #8
On 17 May 2005 22:11:40 -0700, ju**********@yahoo.co.in wrote:

what are lookup tables ? How can they be used to optimise the code ?


On some machines, they can't. On Cray's, for example, it's faster to
calculate bit values than look them up in a table. You're micro-optimizing
again.
--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Nov 14 '05 #9
Thomas Matthews wrote:
Ravi Uday wrote:


ju**********@yahoo.co.in wrote:
what are lookup tables ? How can they be used to optimise the code ?

Its mainly used for bit fiddling.
See the FAQ's - 20.12 and 20.13
@ http://www.eskimo.com/~scs/C-faq/top.html

- Ravi

Wrong.
Many trigonomy (sp?) functions, such as sine and
tangent are implemented using lookup tables. To
my knowledge, this is not bit twiddling; but a
fast method for obtaining a result.


"Trigonometry." Easy to remember: "metry" is "measurement"
and "trigons" are "three-sided polygons," i.e. "triangles."
"Trigonometry" is "the measurement of triangles."

This is an interesting (or mildly interesting) topic in the
history of computing. In the Very Early Days when computational
power was remote, expensive, and slow, the economically effective
thing to do was to print tables of trigonometric functions, often
with "proportional parts" in the margins to assist more accurate
interpolations. Later, when automatic computers showed up, the
State of the Art switched to approximations by polynomials or
ratios of polynomials: the new machines didn't have much memory
for storing tables, but could grind out the computations at a
good enough rate to make themselves useful. Then memories got
larger, and it was back to the tables again: the computer would
store a fairly coarse table and use second- or even third-degree
methods to interpolate with good accuracy. Today the CPUs are
faster than the memory, so the practice has reverted to purely
computational methods. Tomorrow ... well, "Tomorrow and tomorrow
and tomorrow, creeps!" We do not know what tomorrow's economics
may bring to the practice of computing. What we *do* know is that
the Right Way has switched from A to B and back to A and again
to B -- and hence "conventional wisdom" is not a good predictor.

I personally wrote table-based trig functions as recently as
1979 (using one full circle == 65536 "bam," or "binary angular
measurement"). I would not do so today -- but I might do so
tomorrow; who knows where technological trade-offs may take us?
If the history of computing teaches us anything, it teaches that
we are in a fashion-driven industry -- and we don't know what
tomorrow's hemline lengths will be.

--
Eric Sosman
es*****@acm.org
Nov 14 '05 #10
Ravi Uday <ra******@gmail.com> wrote:
Thomas Matthews wrote:
Ravi Uday wrote:
ju**********@yahoo.co.in wrote:

what are lookup tables ? How can they be used to optimise the code ?

Its mainly used for bit fiddling.
See the FAQ's - 20.12 and 20.13
@ http://www.eskimo.com/~scs/C-faq/top.html
Wrong.
Many trigonomy (sp?) functions, such as sine and
tangent are implemented using lookup tables.

Did you read the FAQs i had pointed ??


I did. Those FAQs mention that bit twiddling is often implemented using
lookup tables. This does not mean that bit twiddling is the most
important thing lookup tables are used for at all. That's taking the
relationship the wrong way 'round.

Richard
Nov 14 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DKode | last post by:
Ok, My staff has determined that we will be using custom business objects for a new app we are creating. we have an object that is called Employee. The employee object has about 8 lookup...
2
by: CoreyWhite | last post by:
The future of computer architecture will use lookup tables. Currently computer processor speed outweighs the benefits of using computer memory for lookup tables, except in some cases. As computer...
9
by: Koen | last post by:
Hi all, My application uses a lot of lookup tables. I've splitted the frontend (forms, reports, etc) from the backend (data). The database has around 10 different users. The values in the...
3
by: my-wings | last post by:
I've been reading about how evil Lookup fields in tables are, but I've got to be missing something really basic. I know this subject has been covered before, because I've just spent an hour or two...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
0
by: dbuchanan | last post by:
Hello, For my datagrid I added a datagrid table style to include columns from my lookup tables. These display the values in the lookup tables rather than just the integer key value stored in the...
3
by: dbuchanan | last post by:
Hello, (Windows forms - SQL Server) I fill my datagrid with a stored procedure that includes relationships to lookup tables so that users can see the values of the combobox selections rather...
1
by: paulquinlan100 | last post by:
Hi Im having problems getting a column in one of my tables to display the lookup values correctly. The database is split, in the backend the rowsource for this particular field is set to a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.