From 4efc9b152c89aafe8a8b4f47c7f0d3d9db945df8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 8 Jun 2013 21:28:27 +0200 Subject: COMMON: Save memory by allocating only required entries in Cosine-/SineTable. The tables only contain (2^bitPrecision)/2 entries. The code allocated twice as many entries previously. --- common/cosinetables.cpp | 2 +- common/sinetables.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/cosinetables.cpp b/common/cosinetables.cpp index fe8f454e14..e6bf790611 100644 --- a/common/cosinetables.cpp +++ b/common/cosinetables.cpp @@ -34,7 +34,7 @@ CosineTable::CosineTable(int bitPrecision) { int m = 1 << _bitPrecision; double freq = 2 * M_PI / m; - _table = new float[m]; + _table = new float[m / 2]; // Table contains cos(2*pi*x/n) for 0<=x<=n/4, // followed by its reverse diff --git a/common/sinetables.cpp b/common/sinetables.cpp index 2198dbfd1a..7338166d39 100644 --- a/common/sinetables.cpp +++ b/common/sinetables.cpp @@ -34,7 +34,7 @@ SineTable::SineTable(int bitPrecision) { int m = 1 << _bitPrecision; double freq = 2 * M_PI / m; - _table = new float[m]; + _table = new float[m / 2]; // Table contains sin(2*pi*i/m) for 0<=i