Quantum/osc/complex.cpp

57 lines
4.5 KiB
C++
Raw Normal View History

2023-12-16 16:17:02 +01:00
#include "complex.h"
static const double common_table [] = {
+0.00000000, +0.02454123, +0.04906767, +0.07356456, +0.09801714, +0.12241068, +0.14673047, +0.17096189,
+0.19509032, +0.21910124, +0.24298018, +0.26671276, +0.29028468, +0.31368174, +0.33688985, +0.35989504,
+0.38268343, +0.40524131, +0.42755509, +0.44961133, +0.47139674, +0.49289819, +0.51410274, +0.53499762,
+0.55557023, +0.57580819, +0.59569930, +0.61523159, +0.63439328, +0.65317284, +0.67155895, +0.68954054,
+0.70710678, +0.72424708, +0.74095113, +0.75720885, +0.77301045, +0.78834643, +0.80320753, +0.81758481,
+0.83146961, +0.84485357, +0.85772861, +0.87008699, +0.88192126, +0.89322430, +0.90398929, +0.91420976,
+0.92387953, +0.93299280, +0.94154407, +0.94952818, +0.95694034, +0.96377607, +0.97003125, +0.97570213,
+0.98078528, +0.98527764, +0.98917651, +0.99247953, +0.99518473, +0.99729046, +0.99879546, +0.99969882,
+1.00000000, +0.99969882, +0.99879546, +0.99729046, +0.99518473, +0.99247953, +0.98917651, +0.98527764,
+0.98078528, +0.97570213, +0.97003125, +0.96377607, +0.95694034, +0.94952818, +0.94154407, +0.93299280,
+0.92387953, +0.91420976, +0.90398929, +0.89322430, +0.88192126, +0.87008699, +0.85772861, +0.84485357,
+0.83146961, +0.81758481, +0.80320753, +0.78834643, +0.77301045, +0.75720885, +0.74095113, +0.72424708,
+0.70710678, +0.68954054, +0.67155895, +0.65317284, +0.63439328, +0.61523159, +0.59569930, +0.57580819,
+0.55557023, +0.53499762, +0.51410274, +0.49289819, +0.47139674, +0.44961133, +0.42755509, +0.40524131,
+0.38268343, +0.35989504, +0.33688985, +0.31368174, +0.29028468, +0.26671276, +0.24298018, +0.21910124,
+0.19509032, +0.17096189, +0.14673047, +0.12241068, +0.09801714, +0.07356456, +0.04906767, +0.02454123,
+0.00000000, -0.02454123, -0.04906767, -0.07356456, -0.09801714, -0.12241068, -0.14673047, -0.17096189,
-0.19509032, -0.21910124, -0.24298018, -0.26671276, -0.29028468, -0.31368174, -0.33688985, -0.35989504,
-0.38268343, -0.40524131, -0.42755509, -0.44961133, -0.47139674, -0.49289819, -0.51410274, -0.53499762,
-0.55557023, -0.57580819, -0.59569930, -0.61523159, -0.63439328, -0.65317284, -0.67155895, -0.68954054,
-0.70710678, -0.72424708, -0.74095113, -0.75720885, -0.77301045, -0.78834643, -0.80320753, -0.81758481,
-0.83146961, -0.84485357, -0.85772861, -0.87008699, -0.88192126, -0.89322430, -0.90398929, -0.91420976,
-0.92387953, -0.93299280, -0.94154407, -0.94952818, -0.95694034, -0.96377607, -0.97003125, -0.97570213,
-0.98078528, -0.98527764, -0.98917651, -0.99247953, -0.99518473, -0.99729046, -0.99879546, -0.99969882,
-1.00000000, -0.99969882, -0.99879546, -0.99729046, -0.99518473, -0.99247953, -0.98917651, -0.98527764,
-0.98078528, -0.97570213, -0.97003125, -0.96377607, -0.95694034, -0.94952818, -0.94154407, -0.93299280,
-0.92387953, -0.91420976, -0.90398929, -0.89322430, -0.88192126, -0.87008699, -0.85772861, -0.84485357,
-0.83146961, -0.81758481, -0.80320753, -0.78834643, -0.77301045, -0.75720885, -0.74095113, -0.72424708,
-0.70710678, -0.68954054, -0.67155895, -0.65317284, -0.63439328, -0.61523159, -0.59569930, -0.57580819,
-0.55557023, -0.53499762, -0.51410274, -0.49289819, -0.47139674, -0.44961133, -0.42755509, -0.40524131,
-0.38268343, -0.35989504, -0.33688985, -0.31368174, -0.29028468, -0.26671276, -0.24298018, -0.21910124,
-0.19509032, -0.17096189, -0.14673047, -0.12241068, -0.09801714, -0.07356456, -0.04906767, -0.02454123,
-0.00000000, +0.02454123, +0.04906767, +0.07356456, +0.09801714, +0.12241068, +0.14673047, +0.17096189,
+0.19509032, +0.21910124, +0.24298018, +0.26671276, +0.29028468, +0.31368174, +0.33688985, +0.35989504,
+0.38268343, +0.40524131, +0.42755509, +0.44961133, +0.47139674, +0.49289819, +0.51410274, +0.53499762,
+0.55557023, +0.57580819, +0.59569930, +0.61523159, +0.63439328, +0.65317284, +0.67155895, +0.68954054,
+0.70710678, +0.72424708, +0.74095113, +0.75720885, +0.77301045, +0.78834643, +0.80320753, +0.81758481,
+0.83146961, +0.84485357, +0.85772861, +0.87008699, +0.88192126, +0.89322430, +0.90398929, +0.91420976,
+0.92387953, +0.93299280, +0.94154407, +0.94952818, +0.95694034, +0.96377607, +0.97003125, +0.97570213,
+0.98078528, +0.98527764, +0.98917651, +0.99247953, +0.99518473, +0.99729046, +0.99879546, +0.99969882
};
static const double * sintab = common_table;
static const double * costab = common_table + 64;
complex::complex(const double x, const double y) : re(x), im(y) {
}
complex & complex::exp (const unsigned int n) {
const unsigned a = n & 0xFF;
re = costab [a];
im = sintab [a];
return * this;
}