mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 22:35:45 +00:00
Initial commit
This commit is contained in:
commit
826ee2b085
7 changed files with 98 additions and 0 deletions
1
tests/.gitignore
vendored
Normal file
1
tests/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
kahan
|
||||
13
tests/Makefile
Normal file
13
tests/Makefile
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
CXXFLAGS = -I.. -std=c++11 -W -Wall -O3 -march=native -ffast-math
|
||||
CXX = clang++ -stdlib=libc++
|
||||
#CXX = g++
|
||||
|
||||
.PHONY: clean test
|
||||
|
||||
test: kahan
|
||||
./kahan
|
||||
|
||||
clean:
|
||||
rm -f kahan
|
||||
|
||||
19
tests/kahan.cc
Normal file
19
tests/kahan.cc
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
Test for the Kahan summation algorithm
|
||||
|
||||
Copyright 2018 Ahmet Inan <inan@aicodix.de>
|
||||
*/
|
||||
|
||||
#include "kahan.hh"
|
||||
|
||||
int main()
|
||||
{
|
||||
const double pi = 3.14159265358979323846;
|
||||
DSP::Kahan<double> kahan(3.0);
|
||||
for (double i = 2.0; i < 181423.0; i += 4.0) {
|
||||
kahan(4.0 / (i * (i + 1.0) * (i + 2.0)));
|
||||
kahan(-4.0 / ((i + 2.0) * (i + 3.0) * (i + 4.0)));
|
||||
}
|
||||
return kahan() != pi;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue