Questions tagged [lookup-tables]

A look-up table is an array or matrix of data that contains items that can be searched. Lookup tables may be arranged as key-value pairs, where the keys are the data items being searched (looked up) and the values are either the actual data or pointers to where the data are located.

A look - up table is an array or matrix of data that contains items that are searched. Lookup tables may be arranged as key-value pairs, where the keys are the data items being searched (looked up) and the values are either the actual data or pointers to where the data are located.

798 questions
47
votes
3 answers

Is there a convenient way to apply a lookup table to a large array in numpy?

I’ve got an image read into numpy with quite a few pixels in my resulting array. I calculated a lookup table with 256 values. Now I want to do the following: for i in image.rows: for j in image.cols: mapped_image[i,j] =…
Profpatsch
  • 4,918
  • 5
  • 27
  • 32
41
votes
6 answers

Lookup table vs switch in C embedded software

In another thread, I was told that a switch may be better than a lookup table in terms of speed and compactness. So I'd like to understand the differences between this: Lookup table static void func1(){} static void func2(){} typedef enum { …
Plouff
  • 3,290
  • 2
  • 27
  • 45
30
votes
5 answers

gcc warning: braces around scalar initializer

I have look-up-table as defined below and I'm making use of GCC. When I compile I get warnings as warning: braces around scalar initializer What does this warning mean? How should I initialize this LUT? Am I making a mistake in initializing this…
HaggarTheHorrible
  • 7,083
  • 20
  • 70
  • 81
17
votes
5 answers

TSQL table variable initialization

I have the following TSQL table variable: declare @NumDaysMonth table ( month_id smallint, num_days smallint ) I just want a quick look-up for the number of days in each month. How can I initialize this table like a C array: int…
CodeKingPlusPlus
  • 15,383
  • 51
  • 135
  • 216
16
votes
4 answers

Is there a simple way to create a javascript lookup table?

I'm looking for a simple way of looking up a value, using javascript, against a number of dimensions: eg. (I'm going to use products and product options to describe this, the data is coming from a database in a very similar format) Colour Size…
Paul
  • 9,409
  • 13
  • 64
  • 113
16
votes
8 answers

Fastest possible string key lookup for known set of keys

Consider a lookup function with the following signature, which needs to return an integer for a given string key: int GetValue(string key) { ... } Consider furthermore that the key-value mappings, numbering N, are known in advance when the source…
Pavel Minaev
  • 99,783
  • 25
  • 219
  • 289
16
votes
6 answers

Java 8 - store lambdas in List

I wonder if it's possible to store lambdas in some container, for ex. ArrayList or HashMap. I want to change that code: public enum OPCODE implements BinaryOperator { MOV((x, y) -> y), INC((x, y) -> ++x), DEC((x, y) -> --x), …
Jump3r
  • 1,028
  • 13
  • 29
15
votes
2 answers

What's the best way to do a lookup table in C?

I am working on an embedded C project. I have an LCD display and for each character there is a 5x7 dot matrix. To display a specific character you have to shift in 5 bytes that correlate with the dots to turn on. So I need to make some kind of…
PICyourBrain
  • 9,976
  • 26
  • 91
  • 136
15
votes
2 answers

Calculate a 32-bit CRC lookup table in C/C++

I want to calculate a 32-bit CRC lookup table. One way I tried is by using the following code from this website: #include #include void make_crc_table() { unsigned long POLYNOMIAL = 0x04c11db7; unsigned long WIDTH = 8…
Programmer_D
  • 601
  • 2
  • 15
  • 27
15
votes
5 answers

Simple lookup to insert values in an R data frame

This is a seemingly simple R question, but I don't see an exact answer here. I have a data frame (alldata) that looks like this: Case zip market 1 44485 NA 2 44488 NA 3 43210 NA There are over 3.5 million…
Dino Fire
  • 419
  • 2
  • 6
  • 9
14
votes
4 answers

Country, State, Province WebService?

Are there any good webservices out there that provide good lookup information for Countries and States/Provinces? If so what ones do you use?
Smallinov
  • 1,272
  • 2
  • 9
  • 16
13
votes
3 answers

Small Tables in Python?

Let's say I don't have more than one or two dozen objects with different properties, such as the following: UID, Name, Value, Color, Type, Location I want to be able to call up all objects with Location = "Boston", or Type = "Primary". Classic…
akoumjian
  • 1,594
  • 1
  • 15
  • 20
12
votes
2 answers

How to use LUT with JavaScript?

I'm new to image processing. I want to use JavaScript to apply effects to images using LUTs (LookUp Tables) or the corresponding lookup PNGs, something like this: I have googled a lot and couldn't find an article or any resource which will describe…
Karlen Kishmiryan
  • 7,322
  • 5
  • 35
  • 45
11
votes
1 answer

Cosine lookup table with c++

Here's a snippet that should generate a cosine lookup table of 2048 elements, taken from the book Building Embedded Systems by Changyi Gu: #include #include template constexpr T look_up_table_elem (int i) { return…
xtrinch
  • 2,232
  • 1
  • 24
  • 46
11
votes
3 answers

algorithm behind the generation of the reverse bits lookup table(8 bit)

I found the lookup table here. The table is generated as a reverse bits table of 8 bits. I can not figure out why it works. Please explain the theory behind it. Thanks static const unsigned char BitReverseTable256[256] = { # define R2(n) n,…
louxiu
  • 2,830
  • 3
  • 28
  • 42
1
2 3
53 54