Epstein Zeta Library 0.6.2
Calculates the Epstein Zeta function
Loading...
Searching...
No Matches
hpdyad.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025-2026 Jonathan Busse <jonathan@jbusse.de>
2//
3// SPDX-License-Identifier: AGPL-3.0-only
4
10#ifndef EPSTEIN_HPDYAD
11#define EPSTEIN_HPDYAD
12
16#define HPDYAD_MAX_LIMBS 32
17
28typedef struct {
29 signed char sign; // +1 or -1
30 unsigned char n; // number of used limbs (0 => zero)
31 int exp2; // global power of two (negative for dyadic rationals)
32 unsigned int limb[HPDYAD_MAX_LIMBS];
33} hpdyad_t;
38unsigned ctz64(unsigned long long x);
39
44int msb32(unsigned int x);
45
51void hpdyad_set_ull(hpdyad_t *a, unsigned long long x, signed char sign);
52
59
65void hpdyad_mul(hpdyad_t *out, const hpdyad_t *a, const hpdyad_t *b);
66
76void hpdyad_shr_bits_sticky(hpdyad_t *dst, const hpdyad_t *src, unsigned int bits);
77
84void hpdyad_shl_bits(hpdyad_t *dst, const hpdyad_t *src, int bits);
85
91void hpdyad_add(hpdyad_t *out, const hpdyad_t *a, const hpdyad_t *b);
92
97double hpdyad_to_double(const hpdyad_t *a);
98
99#endif
unsigned ctz64(unsigned long long x)
Count trailing zero bits in a 64-bit unsigned integer.
Definition hpdyad.c:17
void hpdyad_set_ull(hpdyad_t *a, unsigned long long x, signed char sign)
Initialize hpdyad from unsigned long long with sign.
Definition hpdyad.c:65
int msb32(unsigned int x)
Find index of most significant bit in a 32-bit unsigned integer.
Definition hpdyad.c:33
void hpdyad_mul(hpdyad_t *out, const hpdyad_t *a, const hpdyad_t *b)
Multiply two high precision dyadic numbers (hpdyad's): out = a * b.
Definition hpdyad.c:162
void hpdyad_add(hpdyad_t *out, const hpdyad_t *a, const hpdyad_t *b)
Add two high precision dyadic numbers (hpdyad's): out = a + b.
Definition hpdyad.c:512
#define HPDYAD_MAX_LIMBS
Maximum number of 32-bit limbs in fixed-size representation (1024 bits total).
Definition hpdyad.h:16
double hpdyad_to_double(const hpdyad_t *a)
Convert hpdyad to double with round-to-nearest-even.
Definition hpdyad.c:614
void hpdyad_normalize(hpdyad_t *a)
Normalize hpdyad: trim leading zeros and left-shift mantissa so MSB of top limb is 1.
Definition hpdyad.c:94
void hpdyad_shr_bits_sticky(hpdyad_t *dst, const hpdyad_t *src, unsigned int bits)
Right-shift mantissa with sticky bit (value-preserving)
Definition hpdyad.c:240
void hpdyad_shl_bits(hpdyad_t *dst, const hpdyad_t *src, int bits)
Left-shift mantissa by specified number of bits (value-preserving)
Definition hpdyad.c:446
Fixed-size high-precision dyadic number (hpdyad) with separate sign and binary exponent.
Definition hpdyad.h:28