jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Namespaces | Typedefs | Functions | Variables
big_int_ops.hpp File Reference
#include <cstdint>
#include <cassert>
#include <jau/cpp_lang_util.hpp>
#include <jau/cpuid.hpp>
#include <jau/ct_utils.hpp>
#include <jau/math/math_error.hpp>
Include dependency graph for big_int_ops.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  jau
 __pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
 
namespace  jau::mp
 big_int_t (this file) (c) 2024 Gothel Software e.K.
 
namespace  jau::mp::impl
 
namespace  jau::mp::ops
 

Typedefs

typedef jau::uint_bytes< impl::best_word_byte_size() *2 >::type jau::mp::mp_dword_t
 
typedef jau::uint_bytes< impl::best_word_byte_size()>::type jau::mp::mp_word_t
 

Functions

void jau::mp::ops::basecase_mul (mp_word_t z[], size_t z_size, const mp_word_t x[], size_t x_size, const mp_word_t y[], size_t y_size) noexcept
 
constexpr size_t jau::mp::impl::best_word_byte_size ()
 
mp_word_t jau::mp::ops::bigint_add2 (mp_word_t x[], size_t x_size, const mp_word_t y[], size_t y_size) noexcept
 Two operand addition with carry out. More...
 
void jau::mp::ops::bigint_add3 (mp_word_t z[], const mp_word_t x[], size_t x_size, const mp_word_t y[], size_t y_size) noexcept
 Three operand addition. More...
 
mp_word_t jau::mp::ops::bigint_add3_nc (mp_word_t z[], const mp_word_t x[], size_t x_size, const mp_word_t y[], size_t y_size) noexcept
 Three operand addition with carry out. More...
 
int jau::mp::ops::bigint_cmp (const mp_word_t x[], size_t x_size, const mp_word_t y[], size_t y_size) noexcept
 Compare unsigned x and y mp_word_t. More...
 
CT::Mask< mp_word_t > jau::mp::ops::bigint_ct_is_eq (const mp_word_t x[], size_t x_size, const mp_word_t y[], size_t y_size) noexcept
 
CT::Mask< mp_word_t > jau::mp::ops::bigint_ct_is_lt (const mp_word_t x[], size_t x_size, const mp_word_t y[], size_t y_size, bool lt_or_equal=false) noexcept
 Compare x and y Return ~0 if x[0:x_size] < y[0:y_size] or 0 otherwise If lt_or_equal is true, returns ~0 also for x == y. More...
 
mp_word_t jau::mp::ops::bigint_divop (mp_word_t n1, mp_word_t n0, mp_word_t d)
 Computes ((n1<<bits) + n0) / d. More...
 
mp_word_t jau::mp::ops::bigint_linmul2 (mp_word_t x[], size_t x_size, mp_word_t y) noexcept
 
void jau::mp::ops::bigint_linmul3 (mp_word_t z[], const mp_word_t x[], size_t x_size, mp_word_t y) noexcept
 
mp_word_t jau::mp::ops::bigint_modop (mp_word_t n1, mp_word_t n0, mp_word_t d)
 Compute ((n1<<bits) + n0) % d. More...
 
void jau::mp::ops::bigint_shl1 (mp_word_t x[], size_t x_size, size_t x_words, size_t word_shift, size_t bit_shift) noexcept
 
void jau::mp::ops::bigint_shl2 (mp_word_t y[], const mp_word_t x[], size_t x_size, size_t word_shift, size_t bit_shift) noexcept
 
void jau::mp::ops::bigint_shr1 (mp_word_t x[], size_t x_size, size_t word_shift, size_t bit_shift) noexcept
 
void jau::mp::ops::bigint_shr2 (mp_word_t y[], const mp_word_t x[], size_t x_size, size_t word_shift, size_t bit_shift) noexcept
 
mp_word_t jau::mp::ops::bigint_sub2 (mp_word_t x[], size_t x_size, const mp_word_t y[], size_t y_size) noexcept
 Two operand subtraction. More...
 
void jau::mp::ops::bigint_sub2_rev (mp_word_t x[], const mp_word_t y[], size_t y_size) noexcept
 Two operand subtraction, x = y - x; assumes y >= x. More...
 
mp_word_t jau::mp::ops::bigint_sub3 (mp_word_t z[], const mp_word_t x[], size_t x_size, const mp_word_t y[], size_t y_size) noexcept
 Three operand subtraction. More...
 
int32_t jau::mp::ops::bigint_sub_abs (mp_word_t z[], const mp_word_t x[], size_t x_size, const mp_word_t y[], size_t y_size) noexcept
 Set z to abs(x-y), ie if x >= y, then compute z = x - y Otherwise compute z = y - x No borrow is possible since the result is always >= 0. More...
 
void jau::mp::ops::mul64x64_128 (const uint64_t a, const uint64_t b, uint64_t &lo, uint64_t &hi) noexcept
 64x64->128 bit multiplication More...
 
mp_word_t jau::mp::ops::word8_add2 (mp_word_t x[8], const mp_word_t y[8], mp_word_t carry) noexcept
 
mp_word_t jau::mp::ops::word8_add3 (mp_word_t z[8], const mp_word_t x[8], const mp_word_t y[8], mp_word_t carry) noexcept
 
mp_word_t jau::mp::ops::word8_linmul2 (mp_word_t x[8], mp_word_t y, mp_word_t carry) noexcept
 
mp_word_t jau::mp::ops::word8_linmul3 (mp_word_t z[8], const mp_word_t x[8], mp_word_t y, mp_word_t carry) noexcept
 
mp_word_t jau::mp::ops::word8_madd3 (mp_word_t z[8], const mp_word_t x[8], mp_word_t y, mp_word_t carry) noexcept
 
mp_word_t jau::mp::ops::word8_sub2 (mp_word_t x[8], const mp_word_t y[8], mp_word_t carry) noexcept
 
mp_word_t jau::mp::ops::word8_sub2_rev (mp_word_t x[8], const mp_word_t y[8], mp_word_t carry) noexcept
 
mp_word_t jau::mp::ops::word8_sub3 (mp_word_t z[8], const mp_word_t x[8], const mp_word_t y[8], mp_word_t carry) noexcept
 
mp_word_t jau::mp::ops::word_add (const mp_word_t x, const mp_word_t y, mp_word_t &carry) noexcept
 
mp_word_t jau::mp::ops::word_madd2 (mp_word_t a, mp_word_t b, mp_word_t &c) noexcept
 Word Multiply/Add. More...
 
mp_word_t jau::mp::ops::word_madd3 (mp_word_t a, mp_word_t b, mp_word_t c, mp_word_t &d) noexcept
 Word Multiply/Add. More...
 
mp_word_t jau::mp::ops::word_sub (mp_word_t x, mp_word_t y, mp_word_t &carry) noexcept
 

Variables

constexpr const bool jau::mp::has_mp_dword = is_builtin_int128_available()
 
constexpr const size_t jau::mp::mp_word_bits = impl::best_word_byte_size() * CHAR_BIT
 
constexpr const mp_word_t jau::mp::mp_word_max = ~static_cast<mp_word_t>(0)