{"id":18931085,"url":"https://github.com/kuiperzone/compensated-accumulators","last_synced_at":"2025-07-09T14:34:19.186Z","repository":{"id":151029906,"uuid":"229189687","full_name":"kuiperzone/Compensated-Accumulators","owner":"kuiperzone","description":"Lightweight C# implementations of common \"compensated sum\" accumulators.","archived":false,"fork":false,"pushed_at":"2019-12-20T04:37:28.000Z","size":28,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-12T00:50:11.690Z","etag":null,"topics":["accumulator","compensated-sum","floating-point-addition","kahan","kahan-summation","pairwise-sum","precision"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kuiperzone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-20T04:26:43.000Z","updated_at":"2023-06-15T10:23:40.000Z","dependencies_parsed_at":"2023-04-28T07:31:32.448Z","dependency_job_id":null,"html_url":"https://github.com/kuiperzone/Compensated-Accumulators","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kuiperzone/Compensated-Accumulators","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuiperzone%2FCompensated-Accumulators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuiperzone%2FCompensated-Accumulators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuiperzone%2FCompensated-Accumulators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuiperzone%2FCompensated-Accumulators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuiperzone","download_url":"https://codeload.github.com/kuiperzone/Compensated-Accumulators/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuiperzone%2FCompensated-Accumulators/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264476506,"owners_count":23614512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accumulator","compensated-sum","floating-point-addition","kahan","kahan-summation","pairwise-sum","precision"],"created_at":"2024-11-08T11:40:25.002Z","updated_at":"2025-07-09T14:34:19.149Z","avatar_url":"https://github.com/kuiperzone.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C# COMPENSATED ACCUMULATORS #\r\n\r\n## Abstract ##\r\nNumerical errors are incurred when summing sequences of finite precision floating\r\npoint numbers. However, there are a number of techniques which significantly\r\nreduce, or compensate for, the accumulation of errors.\r\n\r\nThis is a lightweight C# library comprising implementations of common \"compensated sum\"\r\naccumulators. Additionally, an Xunit test project not only provides unit testing,\r\nbut allows for performance and accuracy comparisions between the generators.\r\n\r\n## Compensated Accumulators ##\r\nImplmentations inherits a common interface *ICompensatedSum*, as follows:\r\n\r\n* KahanSum - Classic \"Kahan\" implementation.\r\n* NeumaierSum - Variation of the Kahan algorithm, also referred to as \"Kahan–Babuška\".\r\n* KleinSum - Klein variation of the Kahan algorithm, also referred to as \"Kahan-Babuška-Neumaier\" compensated sum. It offers improved accuracy over both KahanSum and NeumaierSum.\r\n* PairwiseSum - A \"pairwise\" implementation of ICompensatedSum. In this, values are buffered. Computation of the result is performed only periodically or when the Value is requred.\r\n\r\nThe KahanSum, NeumaierSum and KleinSum algorithms are variations of the same Kahan algorithm. The\r\nPairwiseSum uses a recursive approach, however, with input values buffered and computed periodically.\r\n\r\n## Accumulator Performance ##\r\nPerformance and error results are presented below. An implementation of a \"naive summation\"\r\nis also provided for comparison.\r\n\r\n| ALGORITHM | Add() | Error\r\n| :------------ | :-------- | :-------------\r\n| KahanSum      | 6.24 ns   | 1.86E-09\r\n| NeumaierSum   | 4.22 ns   | 0\r\n| KleinSum      | 5.59 ns   | 0\r\n| PairwiseSum   | 9.71 ns   | 0.015\r\n| NaiveSum      | 3.67 ns   | 0.111\r\n\r\nSmaller values are better. The test hardware was as follows:\r\n\r\n* Windows 10\r\n* .NET Core 3.0\r\n* i7-6700 3.40GHz\r\n\r\nIn generating the error result, 1000,000 pseudo random values were generated in the range 0\r\nto 1E7 and added to the accumulator. The same psuedo random sequence was then re-generated, but\r\nthis time values were subracted. The final summation, without error, must therefore equal 0.\r\nThe errors shown are the absolute deviation from zero.\r\n\r\nPerformance is presented as the average time taken to call the accumulator's ICompensatedSum.Add()\r\nmethod over many iterations.\r\n\r\n## License ##\r\nThis is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by the\r\nFree Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nIt is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this software. If not, see \u003chttp://www.gnu.org/licenses/\u003e.\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuiperzone%2Fcompensated-accumulators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuiperzone%2Fcompensated-accumulators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuiperzone%2Fcompensated-accumulators/lists"}