comp.lang.ada
 help / color / mirror / Atom feed
From: czgrr <czgrr@my-deja.com>
Subject: Re: Large Look-up Table question ?
Date: 1999/06/01
Date: 1999-06-01T00:00:00+00:00	[thread overview]
Message-ID: <7j0gob$3aj$1@nnrp1.deja.com> (raw)
In-Reply-To: 375299F4.CDEA8A81@hotmail.com

In article <375299F4.CDEA8A81@hotmail.com>,
  Nick Wilson <snow_moose@hotmail.com> wrote:
> I'm implementing a large matrix of values which is basically just a
big
> lookup table. What would be the best way to implement this in only
ada83
> code ? My initial idea is to use a static table for all the values but
> this seems clunky, can anyone offer some advice ?
>
> Thanks,
>
Hi Nick.

Some ways of implementing a large table include:

1. A large (set of) constant(s). Fast to run, a pain to code, watch
those brackets!, good if you have a fixed size of matrix. Big
executable size if the data is stored that way. Might be clunky but
nothing wrong with it.

2. A linked list. Slower to run, easy to code, and few changes if the
matrix size needs to be different. Slower initialisation, but this may
not matter. A set of functions to access the data.

3a. A file. Use a linked list as in 2), but the data can be stored and
edited on disk in the most convenient format (especially useful if it
is automatically generated from something else). Initialisation
consists of loading the data from file, and again a set of functions
access the data.

3b. A file, again. Accessing the data reads the file each time, with no
list or any other structure being used to hold the data (except perhaps
some caching to speed things up). Or use Direct IO to get the speed.
This is only really necessary if the matrix is so huge that you get
memory problems.


There are other possibilities, depending on what the matrix actually
holds.

4. If it is a sparse matrix, a function is a possibility which
calculates the value each time, or some sort of sub-lookup using one of
the methods above. Hash functions spring to mind.

5. If there are patterns in the data, functions may again help. Indeed,
it might be possible to completely dispense with the matrix and code it
using formulae, but this is only really possible in very specialised
cases and you probably wouldn't be thinking of using a lookup matrix
anyway.


I'm sure you'll read about other methods, this list is not means to be
exhaustive. I tend to use 3a) for larger datasets.

HTH
czgrr

--
No email, please - reply to the newsgroup. Email may be made public.
My opinions are not necessarily those of my employer.
My suggestions might not be correct. Use at your own risk.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




  parent reply	other threads:[~1999-06-01  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-31  0:00 Large Look-up Table question ? Nick Wilson
1999-06-01  0:00 ` Steve Quinlan
1999-06-01  0:00 ` czgrr [this message]
1999-06-02  0:00 ` Nick Roberts
1999-06-03  0:00   ` Ehud Lamm
1999-06-03  0:00 ` dennison
1999-06-07  0:00 ` Nick Wilson
1999-06-07  0:00   ` dennison
1999-06-09  0:00 ` Mike Brenner
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox