Home | History | Annotate | Download | only in clib
      1 /*---------------------------------------------------------------------------*
      2  *  log_add.c  *
      3  *                                                                           *
      4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
      5  *                                                                           *
      6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
      7  *  you may not use this file except in compliance with the License.         *
      8  *                                                                           *
      9  *  You may obtain a copy of the License at                                  *
     10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
     11  *                                                                           *
     12  *  Unless required by applicable law or agreed to in writing, software      *
     13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
     14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
     15  *  See the License for the specific language governing permissions and      *
     16  *  limitations under the License.                                           *
     17  *                                                                           *
     18  *---------------------------------------------------------------------------*/
     19 
     20 
     21 #ifndef _RTT
     22 #include <stdio.h>
     23 #endif
     24 #include <stdlib.h>
     25 #include <math.h>
     26 #include <assert.h>
     27 
     28 #include "prelib.h"
     29 #include "portable.h"
     30 
     31 #define DEBUG  0
     32 
     33 #define TAB_ENTRIES     1024
     34 
     35 static const char logadd[] = "$Id: log_add.c,v 1.3.6.10 2008/01/29 06:36:39 dahan Exp $";
     36 
     37 // #define PRINT_SOME_CODE(fMt,aRg1) printf(fMt,aRg1)
     38 #define PRINT_SOME_CODE(fMt,aRg1)
     39 
     40 /* values for default case 0 */
     41 #define DO_USE_LOGTAB__TABLE ( logtab->scale == 61  \
     42         && ( (int)(logtab->logscale*10000) == (int)(6.4f*10000)) \
     43 		&& ADD_LOG_LIMIT == 8)
     44 static const prdata logtab__table[3125] = { 271, 270, 270, 269, 269, 268, 268, 267, 267, 266, 266, 265, 265, 264, 264, 263, 263, 262, 262, 261, 261, 260, 260, 259, 259, 258, 258, 257, 257, 256, 256, 255, 255, 254, 254, 253, 253, 253, 252, 252, 251, 251, 250, 250, 249, 249, 248, 248, 247, 247, 246, 246, 245, 245, 245, 244, 244, 243, 243, 242, 242, 241, 241, 240, 240, 239, 239, 239, 238, 238, 237, 237, 236, 236, 235, 235, 234, 234, 234, 233, 233, 232, 232, 231, 231, 230, 230, 230, 229, 229, 228, 228, 227, 227, 226, 226, 226, 225, 225, 224, 224, 223, 223, 222, 222, 222, 221, 221, 220, 220, 219, 219, 219, 218, 218, 217, 217, 216, 216, 216, 215, 215, 214, 214, 214, 213, 213, 212, 212, 211, 211, 211, 210, 210, 209, 209, 208, 208, 208, 207, 207, 206, 206, 206, 205, 205, 204, 204, 204, 203, 203, 202, 202, 202, 201, 201, 200, 200, 200, 199, 199, 198, 198, 198, 197, 197, 196, 196, 196, 195, 195, 194, 194, 194, 193, 193, 192, 192, 192, 191, 191, 191, 190, 190, 189, 189, 189, 188, 188, 187, 187, 187, 186, 186, 186, 185, 185, 184, 184, 184, 183, 183, 183, 182, 182, 181, 181, 181, 180, 180, 180, 179, 179, 178, 178, 178, 177, 177, 177, 176, 176, 176, 175, 175, 174, 174, 174, 173, 173, 173, 172, 172, 172, 171, 171, 171, 170, 170, 169, 169, 169, 168, 168, 168, 167, 167, 167, 166, 166, 166, 165, 165, 165, 164, 164, 164, 163, 163, 163, 162, 162, 162, 161, 161, 161, 160, 160, 159, 159, 159, 158, 158, 158, 157, 157, 157, 157, 156, 156, 156, 155, 155, 155, 154, 154, 154, 153, 153, 153, 152, 152, 152, 151, 151, 151, 150, 150, 150, 149, 149, 149, 148, 148, 148, 147, 147, 147, 147, 146, 146, 146, 145, 145, 145, 144, 144, 144, 143, 143, 143, 143, 142, 142, 142, 141, 141, 141, 140, 140, 140, 139, 139, 139, 139, 138, 138, 138, 137, 137, 137, 137, 136, 136, 136, 135, 135, 135, 134, 134, 134, 134, 133, 133, 133, 132, 132, 132, 132, 131, 131, 131, 130, 130, 130, 130, 129, 129, 129, 128, 128, 128, 128, 127, 127, 127, 126, 126, 126, 126, 125, 125, 125, 125, 124, 124, 124, 123, 123, 123, 123, 122, 122, 122, 122, 121, 121, 121, 121, 120, 120, 120, 119, 119, 119, 119, 118, 118, 118, 118, 117, 117, 117, 117, 116, 116, 116, 116, 115, 115, 115, 115, 114, 114, 114, 114, 113, 113, 113, 113, 112, 112, 112, 112, 111, 111, 111, 111, 110, 110, 110, 110, 109, 109, 109, 109, 108, 108, 108, 108, 107, 107, 107, 107, 106, 106, 106, 106, 105, 105, 105, 105, 105, 104, 104, 104, 104, 103, 103, 103, 103, 102, 102, 102, 102, 102, 101, 101, 101, 101, 100, 100, 100, 100, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 93, 93, 93, 93, 92, 92, 92, 92, 92, 91, 91, 91, 91, 91, 90, 90, 90, 90, 90, 89, 89, 89, 89, 89, 88, 88, 88, 88, 88, 87, 87, 87, 87, 87, 86, 86, 86, 86, 86, 85, 85, 85, 85, 85, 84, 84, 84, 84, 84, 83, 83, 83, 83, 83, 82, 82, 82, 82, 82, 82, 81, 81, 81, 81, 81, 80, 80, 80, 80, 80, 79, 79, 79, 79, 79, 79, 78, 78, 78, 78, 78, 77, 77, 77, 77, 77, 77, 76, 76, 76, 76, 76, 76, 75, 75, 75, 75, 75, 74, 74, 74, 74, 74, 74, 73, 73, 73, 73, 73, 73, 72, 72, 72, 72, 72, 72, 71, 71, 71, 71, 71, 71, 70, 70, 70, 70, 70, 70, 69, 69, 69, 69, 69, 69, 68, 68, 68, 68, 68, 68, 67, 67, 67, 67, 67, 67, 67, 66, 66, 66, 66, 66, 66, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61, 61, 61, 61, 60, 60, 60, 60, 60, 60, 60, 59, 59, 59, 59, 59, 59, 59, 58, 58, 58, 58, 58, 58, 58, 57, 57, 57, 57, 57, 57, 57, 57, 56, 56, 56, 56, 56, 56, 56, 55, 55, 55, 55, 55, 55, 55, 55, 54, 54, 54, 54, 54, 54, 54, 53, 53, 53, 53, 53, 53, 53, 53, 52, 52, 52, 52, 52, 52, 52, 52, 51, 51, 51, 51, 51, 51, 51, 51, 50, 50, 50, 50, 50, 50, 50, 50, 50, 49, 49, 49, 49, 49, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, 48, 48, 47, 47, 47, 47, 47, 47, 47, 47, 47, 46, 46, 46, 46, 46, 46, 46, 46, 46, 45, 45, 45, 45, 45, 45, 45, 45, 45, 44, 44, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 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ale)
     47 {
     48   int ii;
     49 
     50   ASSERT(logtab);
     51   ASSERT(logtab->scale != 0);
     52 
     53   logtab->logscale = mul_scale;
     54   logtab->add_log_limit = (prdata)(ADD_LOG_LIMIT * mul_scale * logtab->scale);
     55   if( DO_USE_LOGTAB__TABLE) {
     56 	  logtab->table = logtab__table;
     57   } else {
     58 	prdata* table = (prdata *) CALLOC(logtab->add_log_limit + 2, sizeof(prdata), "clib.logadd");
     59 	logtab->table = table;
     60 	PRINT_SOME_CODE( "/* values for default case %d */\n", 0);
     61 	PRINT_SOME_CODE( "#define DO_USE_LOGTAB__TABLE (logtab->scale == %d  \\\n", logtab->scale);
     62     PRINT_SOME_CODE( "    && ( (int)(logtab->logscale*10000) == (int)(%ff*10000) \\\n", logtab->logscale);
     63 	PRINT_SOME_CODE( "    && ADD_LOG_LIMIT == %d) \n", ADD_LOG_LIMIT);
     64 	PRINT_SOME_CODE( "static prdata logtab__table[%d] = {", logtab->add_log_limit + 2);
     65 	for (ii = 0; ii <= logtab->add_log_limit; ii++) {
     66 		table[ii] = (prdata)(logtab->scale * mul_scale * log(1
     67 									+ exp(-(float)ii / ((float)logtab->scale * mul_scale)))
     68 									+ 0.5) ;
     69 		PRINT_SOME_CODE(" %d,", table[ii]);
     70 	}
     71 	PRINT_SOME_CODE( ", 0 }; /*%i*/\n", 0); /*not sure why the +2 above, just append 0 for now*/
     72   }
     73 #ifdef SREC_ENGINE_VERBOSE_LOGGING
     74   PLogMessage("L: log table scale is %f\n", (float)logtab->scale);
     75   PLogMessage("L: log table has %d entries\n", (int)logtab->add_log_limit);
     76 #endif
     77 #if DEBUG
     78   for (ii = 0; ii <= logtab->add_log_limit; ii++)
     79     log_report("T: %d %f\n", ii, (float)logtab->table[ii]);
     80 #endif
     81 #if REPORT_USAGE
     82   report_malloc_usage();
     83 #endif
     84   return;
     85 }
     86 
     87 void destroy_lookup_logadd(logadd_table_info *logtab)
     88 {
     89   ASSERT(logtab);
     90   ASSERT(logtab->table);
     91   if( !DO_USE_LOGTAB__TABLE ) {
     92 	FREE((char *)logtab->table);
     93   }
     94   return;
     95 }
     96