From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: ** X-Spam-Status: No, score=2.3 required=5.0 tests=BAYES_00,HK_RANDOM_FROM, INVALID_MSGID,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c9db882405e08110 X-Google-Attributes: gid103376,public From: czgrr Subject: Re: Large Look-up Table question ? Date: 1999/06/01 Message-ID: <7j0gob$3aj$1@nnrp1.deja.com>#1/1 X-Deja-AN: 484411858 References: <375299F4.CDEA8A81@hotmail.com> X-Http-Proxy: 1.0 x38.deja.com:80 (Squid/1.1.22) for client 193.192.234.4 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Tue Jun 01 11:38:50 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT) Date: 1999-06-01T00:00:00+00:00 List-Id: In article <375299F4.CDEA8A81@hotmail.com>, Nick Wilson 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.