Lookup tables in c(LUT in c) :

              In Embedded Systems computing execution time is an important factor deciding the performance of the device.Look up tables are used to maximize the execution speed of the embedded code to get the desired performance.

             A simple term used to explain the lookup table , we can say it a pre-computed table which has some calculated values in it.say for example an array of intergers contains calculated values starting from initial  to its maximum size.

       An simple illustrative code example,
//#include "LUT.h"

static double sqrtMag[256];
/* API's */
void initSqrtValues(void);

int main(int argc,char *argv[])
 //unsigned long int x = 0x1234;
 printf("LookUpTables in c usage:\n");
 /* Get the square root values from the precomputed lookuptables */
    printf(" Square root of %d from lookuptable = %f \n",5,sqrtMag[5]);
 printf(" Square root of %d from lookuptable = %f \n",10,sqrtMag[10]);
 //printf(" x before endian conversion : %x \n x after endian conversion = %x \n",x,ByteSwap2(x));
 return 0;

void initSqrtValues(void)
  int i ,len = (sizeof(sqrtMag)/sizeof(sqrtMag[0]));
  for ( i = 1; i < len ; i++)
   sqrtMag[i] = (i);
   printf("sqrtMag[%d] = %f \n",i,sqrtMag[i]);


sunitha vishnu said...

It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
Android Training in Chennai
Ios Training in Chennai

Unknown said...

myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance