VolumeTable: Use std::array where applicable

Makes the arrays strongly typed.
This commit is contained in:
Lioncash 2019-09-10 20:29:41 -04:00
parent 7bc23b7190
commit a8c9d555fe
1 changed files with 7 additions and 4 deletions

View File

@ -1,11 +1,12 @@
#include "amuse/VolumeTable.hpp" #include "amuse/VolumeTable.hpp"
#include <algorithm> #include <algorithm>
#include <array>
#include <cmath> #include <cmath>
namespace amuse { namespace amuse {
static const float VolumeTable[] = { constexpr std::array<float, 129> VolumeTable{
0.000000f, 0.000031f, 0.000153f, 0.000397f, 0.000702f, 0.001129f, 0.001648f, 0.002228f, 0.002930f, 0.003723f, 0.000000f, 0.000031f, 0.000153f, 0.000397f, 0.000702f, 0.001129f, 0.001648f, 0.002228f, 0.002930f, 0.003723f,
0.004608f, 0.005585f, 0.006653f, 0.007843f, 0.009125f, 0.010498f, 0.011963f, 0.013550f, 0.015198f, 0.016999f, 0.004608f, 0.005585f, 0.006653f, 0.007843f, 0.009125f, 0.010498f, 0.011963f, 0.013550f, 0.015198f, 0.016999f,
0.018860f, 0.020844f, 0.022919f, 0.025117f, 0.027406f, 0.029817f, 0.032319f, 0.034944f, 0.037660f, 0.040468f, 0.018860f, 0.020844f, 0.022919f, 0.025117f, 0.027406f, 0.029817f, 0.032319f, 0.034944f, 0.037660f, 0.040468f,
@ -18,9 +19,10 @@ static const float VolumeTable[] = {
0.452864f, 0.464217f, 0.475753f, 0.487442f, 0.499313f, 0.511399f, 0.523606f, 0.536027f, 0.548631f, 0.561419f, 0.452864f, 0.464217f, 0.475753f, 0.487442f, 0.499313f, 0.511399f, 0.523606f, 0.536027f, 0.548631f, 0.561419f,
0.574389f, 0.587542f, 0.600879f, 0.614399f, 0.628132f, 0.642018f, 0.656148f, 0.670431f, 0.684927f, 0.699637f, 0.574389f, 0.587542f, 0.600879f, 0.614399f, 0.628132f, 0.642018f, 0.656148f, 0.670431f, 0.684927f, 0.699637f,
0.714530f, 0.729637f, 0.744926f, 0.760430f, 0.776147f, 0.792077f, 0.808191f, 0.824549f, 0.841090f, 0.857845f, 0.714530f, 0.729637f, 0.744926f, 0.760430f, 0.776147f, 0.792077f, 0.808191f, 0.824549f, 0.841090f, 0.857845f,
0.874844f, 0.892056f, 0.909452f, 0.927122f, 0.945006f, 0.963073f, 0.981414f, 1.000000f, 1.000000f}; 0.874844f, 0.892056f, 0.909452f, 0.927122f, 0.945006f, 0.963073f, 0.981414f, 1.000000f, 1.000000f,
};
static const float DLSVolumeTable[] = { constexpr std::array<float, 129> DLSVolumeTable{
0.000000f, 0.000062f, 0.000248f, 0.000558f, 0.000992f, 0.001550f, 0.002232f, 0.003038f, 0.003968f, 0.005022f, 0.000000f, 0.000062f, 0.000248f, 0.000558f, 0.000992f, 0.001550f, 0.002232f, 0.003038f, 0.003968f, 0.005022f,
0.006200f, 0.007502f, 0.008928f, 0.010478f, 0.012152f, 0.013950f, 0.015872f, 0.017918f, 0.020088f, 0.022382f, 0.006200f, 0.007502f, 0.008928f, 0.010478f, 0.012152f, 0.013950f, 0.015872f, 0.017918f, 0.020088f, 0.022382f,
0.024800f, 0.027342f, 0.030008f, 0.032798f, 0.035712f, 0.038750f, 0.041912f, 0.045198f, 0.048608f, 0.052142f, 0.024800f, 0.027342f, 0.030008f, 0.032798f, 0.035712f, 0.038750f, 0.041912f, 0.045198f, 0.048608f, 0.052142f,
@ -33,7 +35,8 @@ static const float DLSVolumeTable[] = {
0.502201f, 0.513423f, 0.524769f, 0.536239f, 0.547833f, 0.559551f, 0.571393f, 0.583359f, 0.595449f, 0.607663f, 0.502201f, 0.513423f, 0.524769f, 0.536239f, 0.547833f, 0.559551f, 0.571393f, 0.583359f, 0.595449f, 0.607663f,
0.620001f, 0.632463f, 0.645049f, 0.657759f, 0.670593f, 0.683551f, 0.696633f, 0.709839f, 0.723169f, 0.736623f, 0.620001f, 0.632463f, 0.645049f, 0.657759f, 0.670593f, 0.683551f, 0.696633f, 0.709839f, 0.723169f, 0.736623f,
0.750202f, 0.763904f, 0.777730f, 0.791680f, 0.805754f, 0.819952f, 0.834274f, 0.848720f, 0.863290f, 0.877984f, 0.750202f, 0.763904f, 0.777730f, 0.791680f, 0.805754f, 0.819952f, 0.834274f, 0.848720f, 0.863290f, 0.877984f,
0.892802f, 0.907744f, 0.922810f, 0.938000f, 0.953314f, 0.968752f, 0.984314f, 1.000000f, 1.000000f}; 0.892802f, 0.907744f, 0.922810f, 0.938000f, 0.953314f, 0.968752f, 0.984314f, 1.000000f, 1.000000f,
};
float LookupVolume(float vol) { float LookupVolume(float vol) {
vol = std::clamp(vol * 127.f, 0.f, 127.f); vol = std::clamp(vol * 127.f, 0.f, 127.f);