File: Score.cc

package info (click to toggle)
proda 1.0-12
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 584 kB
  • sloc: cpp: 8,549; xml: 163; makefile: 109; sh: 12
file content (27 lines) | stat: -rw-r--r-- 869 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//////////////////////////////////////////////////////////////////////
// Score.cc
//////////////////////////////////////////////////////////////////////

#include "Score.h"
#include "Assert.h"

float *EXP_SCORE_TO_FLOAT_TABLE;
SCORE *LOG_EXP_PLUS_1_TABLE;

//////////////////////////////////////////////////////////////////////
// Precompute math tables
//////////////////////////////////////////////////////////////////////

void PRECOMPUTE_SCORE_TABLES(){
  LOG_EXP_PLUS_1_TABLE = new SCORE[TABLE_SIZE];
  ASSERT (LOG_EXP_PLUS_1_TABLE, "Out of memory.");
  
  EXP_SCORE_TO_FLOAT_TABLE = new float[TABLE_SIZE];
  ASSERT (EXP_SCORE_TO_FLOAT_TABLE, "Out of memory.");
  
  for (int i = 0; i < TABLE_SIZE; i++){
    LOG_EXP_PLUS_1_TABLE[i] = (SCORE)(log(exp((double)(i / SCALE)) + 1) * SCALE);
    EXP_SCORE_TO_FLOAT_TABLE[i] = (float) exp((double)(-i / SCALE));
  }

}