This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <array> | |
#include <cstddef> // std::size_t | |
template <std::size_t N, std::size_t M = 0U> | |
struct dotprod { | |
template <typename InputIt1, typename InputIt2, typename T> | |
constexpr static T sum(InputIt1 u, InputIt2 v, T init) { | |
const T uv_m{*(u + M) * T{*(v + M)}}; | |
return uv_m + dotprod<N, M + 1U>::sum(u, v, init); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 3.1415926535897932384626433832795028841971693993751058209749445923 | |
#include <stdio.h> | |
#include <stdint.h> | |
double pi_series_representation (int N) | |
{ | |
double result = 0.0; | |
int8_t sign = 1; |