Returnsnew class instance
-
-
-
-◆ set_mpfr_precision()
-
-
-
-
-
- void set_mpfr_precision |
- ( |
- unsigned int |
- n | ) |
- |
-
-
-
-
-
Setter for the global precision of the MPFR variables.
-
- Parameters
-
-
- [in] | n | positive integer (precision in bits) |
-
-
-
-
diff --git a/docs/html/_hypercomplex_8hpp_source.html b/docs/html/_hypercomplex_8hpp_source.html
index 30f5411..2e1e8b7 100644
--- a/docs/html/_hypercomplex_8hpp_source.html
+++ b/docs/html/_hypercomplex_8hpp_source.html
@@ -103,1478 +103,1007 @@
18#ifndef HYPERCOMPLEX_HYPERCOMPLEX_HPP_
19#define HYPERCOMPLEX_HYPERCOMPLEX_HPP_
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 38template <
typename T, const
unsigned int dim>
-
-
-
- 42 static inline uint64_t** baseprodabs;
- 43 static inline bool** baseprodpos;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- 49 int64_t** M =
new int64_t*[dim];
- 50 for (
unsigned int i = 0; i < dim; i++) M[i] =
new int64_t[dim];
-
-
-
- 54 for (
unsigned int i=0; i < n; i++) {
- 55 for (
unsigned int j=0; j < n; j++) {
- 56 M[i][n+j] = M[j][i] > 0 ? M[j][i] + n : M[j][i] - n;
- 57 M[i+n][j] = M[i][j] > 0 ? M[i][j] + n : M[i][j] - n;
- 58 M[i+n][j] = M[i+n][j] * (j ? -1 : 1);
- 59 M[i+n][j+n] = -M[j][i] * (j ? -1 : 1);
-
-
-
-
- 64 baseprodabs =
new uint64_t*[dim];
- 65 baseprodpos =
new bool*[dim];
- 66 for (
unsigned int i = 0; i < dim; i++) {
- 67 baseprodabs[i] =
new uint64_t[dim];
- 68 baseprodpos[i] =
new bool[dim];
-
- 70 for (
unsigned int i=0; i < dim; i++) {
- 71 for (
unsigned int j=0; j < dim; j++) {
- 72 baseprodabs[i][j] = std::abs(M[i][j]) - 1;
- 73 baseprodpos[i][j] = (0 < M[i][j]);
-
-
- 76 for (
unsigned int i = 0; i < dim; i++) {
-
+ 47template <
typename T, const u
int64_t dim>
+
+
+
+ 51 static inline uint64_t** baseprodabs;
+ 52 static inline bool** baseprodpos;
+
+
+
+ 58 int64_t** M =
new int64_t*[dim];
+ 59 for (uint64_t i = 0; i < dim; i++) M[i] =
new int64_t[dim];
+
+
+
+ 63 for (uint64_t i=0; i < n; i++) {
+ 64 for (uint64_t j=0; j < n; j++) {
+ 65 M[i][n+j] = M[j][i] > 0 ? M[j][i] + n : M[j][i] - n;
+ 66 M[i+n][j] = M[i][j] > 0 ? M[i][j] + n : M[i][j] - n;
+ 67 M[i+n][j] = M[i+n][j] * (j ? -1 : 1);
+ 68 M[i+n][j+n] = -M[j][i] * (j ? -1 : 1);
+
+
+
+
+ 73 baseprodabs =
new uint64_t*[dim];
+ 74 baseprodpos =
new bool*[dim];
+ 75 for (uint64_t i = 0; i < dim; i++) {
+ 76 baseprodabs[i] =
new uint64_t[dim];
+ 77 baseprodpos[i] =
new bool[dim];
-
-
-
-
- 85 for (
unsigned int i = 0; i < dim; i++) {
- 86 delete[] baseprodabs[i];
- 87 delete[] baseprodpos[i];
-
-
-
-
-
-
-
-
-
-
- 103 for (
unsigned int i=0; i < dim; i++) temp[i] = T();
- 104 for (
unsigned int i=0; i < dim; i++) {
- 105 for (
unsigned int j=0; j < dim; j++) {
- 106 if (Hypercomplex::baseprodpos[i][j]) {
- 107 temp[Hypercomplex::baseprodabs[i][j]] =
- 108 temp[Hypercomplex::baseprodabs[i][j]] + H1[i] * H2[j];
-
- 110 temp[Hypercomplex::baseprodabs[i][j]] =
- 111 temp[Hypercomplex::baseprodabs[i][j]] - H1[i] * H2[j];
-
-
-
-
-
-
-
-
+ 79 for (uint64_t i=0; i < dim; i++) {
+ 80 for (uint64_t j=0; j < dim; j++) {
+ 81 baseprodabs[i][j] = std::abs(M[i][j]) - 1;
+ 82 baseprodpos[i][j] = (0 < M[i][j]);
+
+
+ 85 for (uint64_t i = 0; i < dim; i++) {
+
+
+
+
+
+
+ 94 for (uint64_t i = 0; i < dim; i++) {
+ 95 delete[] baseprodabs[i];
+ 96 delete[] baseprodpos[i];
+
+
+
+
+
+
+
+
+
+
+ 112 for (uint64_t i=0; i < dim; i++) temp[i] = T();
+ 113 for (uint64_t i=0; i < dim; i++) {
+ 114 for (uint64_t j=0; j < dim; j++) {
+ 115 if (Hypercomplex::baseprodpos[i][j]) {
+ 116 temp[Hypercomplex::baseprodabs[i][j]] =
+ 117 temp[Hypercomplex::baseprodabs[i][j]] + H1[i] * H2[j];
+
+ 119 temp[Hypercomplex::baseprodabs[i][j]] =
+ 120 temp[Hypercomplex::baseprodabs[i][j]] - H1[i] * H2[j];
+
+
+
+
+
+
-
+
-
-
-
-
- 144 unsigned int _()
const {
return dim; }
+
-
-
-
-
- 165 template <const
unsigned int newdim>
-
+
+
+
+
+ 153 uint64_t
_()
const {
return dim; }
+
+
+
+
-
-
-
-
-
-
- 191 T
const &
operator[] (
const unsigned int i)
const;
+ 174 template <const u
int64_t newdim>
+
+
+
+
+
+
+
-
+ 200 T
const &
operator[] (
const uint64_t i)
const;
-
-
-
-
-
-
-
-
-
-
-
- 238template <
typename T, const
unsigned int dim>
-
-
-
-
-
- 249template <
typename T, const
unsigned int dim>
-
-
-
-
-
- 260template <
typename T, const
unsigned int dim>
-
-
-
-
-
- 271template <
typename T, const
unsigned int dim>
-
-
-
-
-
- 282template <
typename T, const
unsigned int dim>
-
-
-
-
-
- 293template <
typename T, const
unsigned int dim>
-
-
-
-
-
- 304template <
typename T, const
unsigned int dim>
-
-
-
-
-
- 315template <
typename T, const
unsigned int dim>
-
-
- 322template <
typename T, const
unsigned int dim>
-
-
- 329template <
typename T, const
unsigned int dim>
-
-
- 336template <
typename T, const
unsigned int dim>
-
-
-
-
-
-
-
-
-
-
-
- 348template <
typename T, const
unsigned int dim>
-
-
-
- 352 throw std::invalid_argument(
"invalid dimension");
-
- 354 if ((dim & (dim - 1)) != 0) {
-
- 356 throw std::invalid_argument(
"invalid dimension");
-
- 358 for (
unsigned int i=0; i < dim; i++) arr[i] = ARR[i];
-
-
-
- 362template <
typename T, const
unsigned int dim>
-
- 364 for (
unsigned int i=0; i < dim; i++) arr[i] = H[i];
-
-
-
- 368template <
typename T, const
unsigned int dim>
-
-
-
-
-
- 374template <
typename T, const
unsigned int dim>
-
-
- 377 for (
unsigned int i=0; i < dim; i++) result += arr[i] * arr[i];
-
-
-
-
- 382template <
typename T, const
unsigned int dim>
-
-
- 385 T norm = (*this).norm();
-
- 387 throw std::invalid_argument(
"division by zero");
-
-
- 390 temparr[0] = arr[0] / (norm * norm);
- 391 for (
unsigned int i=1; i < dim; i++)
- 392 temparr[i] = -arr[i] / (norm * norm);
-
-
-
-
-
-
- 399template <
typename T, const
unsigned int dim>
- 400template <const
unsigned int newdim>
-
- 402 if (newdim <= dim)
throw std::invalid_argument(
"invalid dimension");
-
- 404 for (
unsigned int i=0; i < dim; i++) temparr[i] = arr[i];
- 405 for (
unsigned int i=dim; i < newdim; i++) temparr[i] = 0;
-
-
-
-
-
- 411template <
typename T, const
unsigned int dim>
-
-
-
- 415 for (
unsigned int i=1; i < dim; i++) temparr[i] = -arr[i];
-
-
-
-
-
- 421template <
typename T, const
unsigned int dim>
-
-
- 424 for (
unsigned int i=0; i < dim; i++) temparr[i] = -arr[i];
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 247template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 258template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 269template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 280template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 291template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 302template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 313template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 324template <
typename T, const u
int64_t dim>
+
+
+ 331template <
typename T, const u
int64_t dim>
+
+
+ 338template <
typename T, const u
int64_t dim>
+
+
+ 345template <
typename T, const u
int64_t dim>
+
+
+
+
+
+
+
+
+
+
+
+ 357template <
typename T, const u
int64_t dim>
+
+
+
+ 361 throw std::invalid_argument(
"invalid dimension");
+
+ 363 if ((dim & (dim - 1)) != 0) {
+
+ 365 throw std::invalid_argument(
"invalid dimension");
+
+ 367 for (uint64_t i=0; i < dim; i++) arr[i] = ARR[i];
+
+
+
+ 371template <
typename T, const u
int64_t dim>
+
+ 373 for (uint64_t i=0; i < dim; i++) arr[i] = H[i];
+
+
+
+ 377template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 383template <
typename T, const u
int64_t dim>
+
+
+ 386 for (uint64_t i=0; i < dim; i++) result += arr[i] * arr[i];
+
+
+
+
+ 391template <
typename T, const u
int64_t dim>
+
+
+ 394 T norm = (*this).norm();
+
+ 396 throw std::invalid_argument(
"division by zero");
+
+
+ 399 temparr[0] = arr[0] / (norm * norm);
+ 400 for (uint64_t i=1; i < dim; i++)
+ 401 temparr[i] = -arr[i] / (norm * norm);
+
+
+
+
+
+
+ 408template <
typename T, const u
int64_t dim>
+ 409template <const u
int64_t newdim>
+
+ 411 if (newdim <= dim)
throw std::invalid_argument(
"invalid dimension");
+
+ 413 for (uint64_t i=0; i < dim; i++) temparr[i] = arr[i];
+ 414 for (uint64_t i=dim; i < newdim; i++) temparr[i] = 0;
+
+
+
+
+
+ 420template <
typename T, const u
int64_t dim>
+
+
+
+ 424 for (uint64_t i=1; i < dim; i++) temparr[i] = -arr[i];
-
- 430template <
typename T, const
unsigned int dim>
-
-
-
-
- 435 if (
this == &H)
return *
this;
-
- 437 for (
unsigned int i=0; i < dim; i++) arr[i] = H[i];
-
-
-
-
-
- 443template <
typename T, const
unsigned int dim>
-
- 445 assert(0 <= i && i < dim);
-
-
-
-
- 450template <
typename T, const
unsigned int dim>
-
- 452 assert(0 <= i && i < dim);
-
-
-
-
- 457template <
typename T, const
unsigned int dim>
-
-
-
-
- 462 for (
unsigned int i=0; i < dim; i++) {
- 463 if (H1[i] != H2[i])
return false;
-
-
-
-
-
- 469template <
typename T, const
unsigned int dim>
-
-
-
-
-
+
+ 430template <
typename T, const u
int64_t dim>
+
+
+ 433 for (uint64_t i=0; i < dim; i++) temparr[i] = -arr[i];
+
+
+
+
+
+ 439template <
typename T, const u
int64_t dim>
+
+
+
+
+ 444 if (
this == &H)
return *
this;
+
+ 446 for (uint64_t i=0; i < dim; i++) arr[i] = H[i];
+
+
+
+
+
+ 452template <
typename T, const u
int64_t dim>
+
+ 454 assert(0 <= i && i < dim);
+
+
+
+
+ 459template <
typename T, const u
int64_t dim>
+
+ 461 assert(0 <= i && i < dim);
+
+
+
+
+ 466template <
typename T, const u
int64_t dim>
+
+
+
+
+ 471 for (uint64_t i=0; i < dim; i++) {
+ 472 if (H1[i] != H2[i])
return false;
+
+
-
- 478template <
typename T, const
unsigned int dim>
-
+
+ 478template <
typename T, const u
int64_t dim>
+
-
- 484 for (
unsigned int i=0; i < dim; i++) temparr[i] = H1[i] + H2[i];
-
-
-
-
-
- 490template <
typename T, const
unsigned int dim>
-
-
-
-
-
- 496 for (
unsigned int i=0; i < dim; i++) temparr[i] = H1[i] - H2[i];
-
-
-
-
-
- 502template <
typename T, const
unsigned int dim>
-
-
-
-
-
- 508 if constexpr (dim == 1) {
- 509 T temparr[] = { H1[0] * H2[0] };
-
-
-
-
-
- 515 const unsigned int halfd = dim / 2;
-
-
- 518 for (
unsigned int i=0; i < halfd; i++) temparr[i] = H1[i];
-
- 520 for (
unsigned int i=0; i < halfd; i++) temparr[i] = H1[i+halfd];
-
- 522 for (
unsigned int i=0; i < halfd; i++) temparr[i] = H2[i];
-
- 524 for (
unsigned int i=0; i < halfd; i++) temparr[i] = H2[i+halfd];
-
-
-
-
-
-
-
-
-
- 534 for (
unsigned int i=0; i < halfd; i++) temparr[i] = Ha[i];
- 535 for (
unsigned int i=0; i < halfd; i++) temparr[i+halfd] = Hb[i];
-
-
-
-
-
-
- 542template <
typename T, const
unsigned int dim>
-
-
-
-
-
- 548 throw std::invalid_argument(
"zero is not a valid argument");
-
-
- 551 for (
unsigned int i=0; i < x-1; i++) Hx *= H;
-
-
-
-
-
- 557template <
typename T, const
unsigned int dim>
-
-
-
-
-
-
-
-
-
-
- 568template <
typename T, const
unsigned int dim>
-
-
-
-
- 573 for (
unsigned int i=0; i < dim; i++) (*
this)[i] = result[i];
-
-
-
-
- 578template <
typename T, const
unsigned int dim>
-
-
-
-
- 583 for (
unsigned int i=0; i < dim; i++) (*
this)[i] = result[i];
-
-
-
-
- 588template <
typename T, const
unsigned int dim>
-
-
-
-
- 593 for (
unsigned int i=0; i < dim; i++) (*
this)[i] = result[i];
-
-
-
-
- 598template <
typename T, const
unsigned int dim>
-
-
-
-
- 603 for (
unsigned int i=0; i < dim; i++) (*
this)[i] = result[i];
-
-
-
-
- 608template <
typename T, const
unsigned int dim>
-
-
-
-
- 613 for (
unsigned int i=0; i < dim; i++) (*
this)[i] = result[i];
-
-
-
-
- 618template <
typename T, const
unsigned int dim>
-
- 620 for (
unsigned int i=0; i < dim - 1; i++) os << H[i] <<
" ";
-
-
-
-
-
- 626template <
typename T, const
unsigned int dim>
-
-
- 629 for (
unsigned int i=1; i < dim; i++) result[i] = T();
-
-
-
-
- 634template <
typename T, const
unsigned int dim>
-
-
-
-
-
-
-
- 642template <
typename T, const
unsigned int dim>
-
-
-
- 646 T norm = result.
norm();
-
- 648 result[0] =
exp(H[0]);
- 649 for (
unsigned int i=1; i < dim; i++) result[i] = zero;
-
- 651 T sinv_v = sin(norm) / norm;
- 652 for (
unsigned int i=0; i < dim; i++) result[i] *= sinv_v;
- 653 result[0] += cos(norm);
- 654 for (
unsigned int i=0; i < dim; i++) result[i] *=
exp(H[0]);
-
-
-
-
-
-
-
-
-
-
-
-
- 667static unsigned int MPFR_global_precision;
-
-
- 673 return MPFR_global_precision;
-
+
+
+
+
+ 487template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 493 for (uint64_t i=0; i < dim; i++) temparr[i] = H1[i] + H2[i];
+
+
+
+
+
+ 499template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 505 for (uint64_t i=0; i < dim; i++) temparr[i] = H1[i] - H2[i];
+
+
+
+
+
+ 511template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 517 if constexpr (dim == 1) {
+ 518 T temparr[] = { H1[0] * H2[0] };
+
+
+
+
+
+ 524 const uint64_t halfd = dim / 2;
+
+
+ 527 for (uint64_t i=0; i < halfd; i++) temparr[i] = H1[i];
+
+ 529 for (uint64_t i=0; i < halfd; i++) temparr[i] = H1[i+halfd];
+
+ 531 for (uint64_t i=0; i < halfd; i++) temparr[i] = H2[i];
+
+ 533 for (uint64_t i=0; i < halfd; i++) temparr[i] = H2[i+halfd];
+
+
+
+
+
+
+
+
+
+ 543 for (uint64_t i=0; i < halfd; i++) temparr[i] = Ha[i];
+ 544 for (uint64_t i=0; i < halfd; i++) temparr[i+halfd] = Hb[i];
+
+
+
+
+
+
+ 551template <
typename T, const u
int64_t dim>
+
+
+
+
+
+ 557 throw std::invalid_argument(
"zero is not a valid argument");
+
+
+ 560 for (uint64_t i=0; i < x-1; i++) Hx *= H;
+
+
+
+
+
+ 566template <
typename T, const u
int64_t dim>
+
+
+
+
+
+
+
+
+
+
+ 577template <
typename T, const u
int64_t dim>
+
+
+
+
+ 582 for (uint64_t i=0; i < dim; i++) (*
this)[i] = result[i];
+
+
+
+
+ 587template <
typename T, const u
int64_t dim>
+
+
+
+
+ 592 for (uint64_t i=0; i < dim; i++) (*
this)[i] = result[i];
+
+
+
+
+ 597template <
typename T, const u
int64_t dim>
+
+
+
+
+ 602 for (uint64_t i=0; i < dim; i++) (*
this)[i] = result[i];
+
+
+
+
+ 607template <
typename T, const u
int64_t dim>
+
+
+
+
+ 612 for (uint64_t i=0; i < dim; i++) (*
this)[i] = result[i];
+
+
+
+
+ 617template <
typename T, const u
int64_t dim>
+
+
+
+
+ 622 for (uint64_t i=0; i < dim; i++) (*
this)[i] = result[i];
+
+
+
+
+ 627template <
typename T, const u
int64_t dim>
+
+ 629 for (uint64_t i=0; i < dim - 1; i++) os << H[i] <<
" ";
+
+
+
+
+
+ 635template <
typename T, const u
int64_t dim>
+
+
+ 638 for (uint64_t i=1; i < dim; i++) result[i] = T();
+
+
+
+
+ 643template <
typename T, const u
int64_t dim>
+
+
+
+
+
+
+
+ 651template <
typename T, const u
int64_t dim>
+
+
+
+ 655 T norm = result.
norm();
+
+ 657 result[0] =
exp(H[0]);
+ 658 for (uint64_t i=1; i < dim; i++) result[i] = zero;
+
+ 660 T sinv_v = sin(norm) / norm;
+ 661 for (uint64_t i=0; i < dim; i++) result[i] *= sinv_v;
+ 662 result[0] += cos(norm);
+ 663 for (uint64_t i=0; i < dim; i++) result[i] *=
exp(H[0]);
+
+
+
+
+
+
+
+
+
+
+
-
- 680 MPFR_global_precision = n;
-
-
-
-
- 687 assert(!mpfr_mp_memory_cleanup());
-
-
- 692template <const
unsigned int dim>
-
-
- 695 mpfr_t* arr =
new mpfr_t[dim];
- 696 static inline uint64_t** baseprodabs;
- 697 static inline bool** baseprodpos;
-
-
-
- 703 int64_t** M =
new int64_t*[dim];
- 704 for (
unsigned int i = 0; i < dim; i++) M[i] =
new int64_t[dim];
-
-
-
- 708 for (
unsigned int i=0; i < n; i++) {
- 709 for (
unsigned int j=0; j < n; j++) {
- 710 M[i][n+j] = M[j][i] > 0 ? M[j][i] + n : M[j][i] - n;
- 711 M[i+n][j] = M[i][j] > 0 ? M[i][j] + n : M[i][j] - n;
- 712 M[i+n][j] = M[i+n][j] * (j ? -1 : 1);
- 713 M[i+n][j+n] = -M[j][i] * (j ? -1 : 1);
-
-
-
-
- 718 baseprodabs =
new uint64_t*[dim];
- 719 baseprodpos =
new bool*[dim];
- 720 for (
unsigned int i = 0; i < dim; i++) {
- 721 baseprodabs[i] =
new uint64_t[dim];
- 722 baseprodpos[i] =
new bool[dim];
-
- 724 for (
unsigned int i=0; i < dim; i++) {
- 725 for (
unsigned int j=0; j < dim; j++) {
- 726 baseprodabs[i][j] = std::abs(M[i][j]) - 1;
- 727 baseprodpos[i][j] = (0 < M[i][j]);
-
-
- 730 for (
unsigned int i = 0; i < dim; i++) {
-
-
-
-
-
-
- 739 for (
unsigned int i = 0; i < dim; i++) {
- 740 delete[] baseprodabs[i];
- 741 delete[] baseprodpos[i];
-
- 743 delete[] baseprodabs;
- 744 delete[] baseprodpos;
-
-
-
-
-
-
-
- 757 mpfr_init2(prod, MPFR_global_precision);
-
- 759 for (
unsigned int i=0; i < dim; i++)
- 760 mpfr_init2(temparr[i], MPFR_global_precision);
- 761 for (
unsigned int i=0; i < dim; i++) mpfr_set_zero(temparr[i], 0);
- 762 for (
unsigned int i=0; i < dim; i++) {
- 763 for (
unsigned int j=0; j < dim; j++) {
- 764 mpfr_mul(prod, H1[i], H2[j], MPFR_RNDN);
- 765 if (Hypercomplex::baseprodpos[i][j]) {
-
- 767 temparr[Hypercomplex::baseprodabs[i][j]],
- 768 temparr[Hypercomplex::baseprodabs[i][j]],
-
-
-
-
- 773 temparr[Hypercomplex::baseprodabs[i][j]],
- 774 temparr[Hypercomplex::baseprodabs[i][j]],
-
-
-
-
-
-
- 781 for (
unsigned int i=0; i < dim; i++) mpfr_clear(temparr[i]);
-
-
+ 678template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+ 682 static inline uint64_t** baseprodabs;
+ 683 static inline bool** baseprodpos;
+
+
+
+ 689 int64_t** M =
new int64_t*[dim];
+ 690 for (uint64_t i = 0; i < dim; i++) M[i] =
new int64_t[dim];
+
+
+
+ 694 for (uint64_t i=0; i < n; i++) {
+ 695 for (uint64_t j=0; j < n; j++) {
+ 696 M[i][n+j] = M[j][i] > 0 ? M[j][i] + n : M[j][i] - n;
+ 697 M[i+n][j] = M[i][j] > 0 ? M[i][j] + n : M[i][j] - n;
+ 698 M[i+n][j] = M[i+n][j] * (j ? -1 : 1);
+ 699 M[i+n][j+n] = -M[j][i] * (j ? -1 : 1);
+
+
+
+
+ 704 baseprodabs =
new uint64_t*[dim];
+ 705 baseprodpos =
new bool*[dim];
+ 706 for (uint64_t i = 0; i < dim; i++) {
+ 707 baseprodabs[i] =
new uint64_t[dim];
+ 708 baseprodpos[i] =
new bool[dim];
+
+ 710 for (uint64_t i=0; i < dim; i++) {
+ 711 for (uint64_t j=0; j < dim; j++) {
+ 712 baseprodabs[i][j] = std::abs(M[i][j]) - 1;
+ 713 baseprodpos[i][j] = (0 < M[i][j]);
+
+
+ 716 for (uint64_t i = 0; i < dim; i++) {
+
+
+
+
+
+
+ 725 for (uint64_t i = 0; i < dim; i++) {
+ 726 delete[] baseprodabs[i];
+ 727 delete[] baseprodpos[i];
+
+ 729 delete[] baseprodabs;
+ 730 delete[] baseprodpos;
+
+
+
+
+
+
+
+ 743 for (uint64_t i=0; i < dim; i++) {
+ 744 for (uint64_t j=0; j < dim; j++) {
+ 745 if (Hypercomplex::baseprodpos[i][j]) {
+ 746 temp[Hypercomplex::baseprodabs[i][j]] =
+ 747 temp[Hypercomplex::baseprodabs[i][j]] + H1[i] * H2[j];
+
+ 749 temp[Hypercomplex::baseprodabs[i][j]] =
+ 750 temp[Hypercomplex::baseprodabs[i][j]] - H1[i] * H2[j];
+
+
+
+
+
+
+
+
+
+
+ 767 throw std::invalid_argument(
"invalid dimension");
+
+ 769 if ((dim & (dim - 1)) != 0) {
+
+ 771 throw std::invalid_argument(
"invalid dimension");
+
+ 773 for (uint64_t i=0; i < dim; i++) arr[i] = ARR[i];
+
+
+
+ 783 for (uint64_t i=0; i < dim; i++) arr[i] = H[i];
-
-
-
- 795 throw std::invalid_argument(
"invalid dimension");
-
- 797 if ((dim & (dim - 1)) != 0) {
-
- 799 throw std::invalid_argument(
"invalid dimension");
-
- 801 for (
unsigned int i=0; i < dim; i++)
- 802 mpfr_init2(arr[i], MPFR_global_precision);
- 803 for (
unsigned int i=0; i < dim; i++)
- 804 mpfr_set(arr[i], ARR[i], MPFR_RNDN);
-
-
-
- 814 for (
unsigned int i=0; i < dim; i++)
- 815 mpfr_init2(arr[i], MPFR_global_precision);
- 816 for (
unsigned int i=0; i < dim; i++)
- 817 mpfr_set(arr[i], H[i], MPFR_RNDN);
-
-
-
-
-
- 823 for (
unsigned int i=0; i < dim; i++) mpfr_clear(arr[i]);
-
-
-
- 830 unsigned int _()
const {
return dim; }
-
-
-
- 843 mpfr_init2(temp, MPFR_global_precision);
- 844 mpfr_set_zero(
norm, 0);
- 845 for (
unsigned int i=0; i < dim; i++) {
- 846 mpfr_mul(temp, arr[i], arr[i], MPFR_RNDN);
- 847 mpfr_add(
norm,
norm, temp, MPFR_RNDN);
-
-
-
-
-
-
-
-
- 859 mpfr_init2(zero, MPFR_global_precision);
- 860 mpfr_init2(
norm, MPFR_global_precision);
- 861 mpfr_set_zero(zero, 0);
-
- 863 if (mpfr_equal_p(
norm, zero)) {
-
-
- 866 throw std::invalid_argument(
"division by zero");
-
-
- 869 for (
unsigned int i=0; i < dim; i++)
- 870 mpfr_init2(temparr[i], MPFR_global_precision);
-
- 872 mpfr_div(temparr[0], arr[0],
norm, MPFR_RNDN);
- 873 for (
unsigned int i=1; i < dim; i++) {
- 874 mpfr_div(temparr[i], arr[i],
norm, MPFR_RNDN);
- 875 mpfr_sub(temparr[i], zero, temparr[i], MPFR_RNDN);
-
-
-
-
- 880 for (
unsigned int i=0; i < dim; i++) mpfr_clear(temparr[i]);
-
-
-
-
- 891 template <const
unsigned int newdim>
-
- 893 if (newdim <= dim)
throw std::invalid_argument(
"invalid dimension");
- 894 mpfr_t temparr[newdim];
- 895 for (
unsigned int i=0; i < newdim; i++)
- 896 mpfr_init2(temparr[i], MPFR_global_precision);
- 897 for (
unsigned int i=0; i < dim; i++)
- 898 mpfr_set(temparr[i], arr[i], MPFR_RNDN);
- 899 for (
unsigned int i=dim; i < newdim; i++) mpfr_set_zero(temparr[i], 0);
-
- 901 for (
unsigned int i=0; i < newdim; i++) mpfr_clear(temparr[i]);
-
-
-
-
-
- 910 mpfr_init2(zero, MPFR_global_precision);
- 911 mpfr_set_zero(zero, 0);
-
- 913 for (
unsigned int i=0; i < dim; i++)
- 914 mpfr_init2(temparr[i], MPFR_global_precision);
- 915 mpfr_set(temparr[0], arr[0], MPFR_RNDN);
- 916 for (
unsigned int i=1; i < dim; i++)
- 917 mpfr_sub(temparr[i], zero, arr[i], MPFR_RNDN);
-
- 919 for (
unsigned int i=0; i < dim; i++) mpfr_clear(temparr[i]);
-
-
-
-
-
-
- 929 mpfr_init2(zero, MPFR_global_precision);
- 930 mpfr_set_zero(zero, 0);
-
- 932 for (
unsigned int i=0; i < dim; i++)
- 933 mpfr_init2(temparr[i], MPFR_global_precision);
- 934 for (
unsigned int i=0; i < dim; i++)
- 935 mpfr_sub(temparr[i], zero, arr[i], MPFR_RNDN);
-
- 937 for (
unsigned int i=0; i < dim; i++) mpfr_clear(temparr[i]);
-
-
-
-
-
- 947 if (
this == &H)
return *
this;
- 948 for (
unsigned int i=0; i < dim; i++)
- 949 mpfr_set(arr[i], H[i], MPFR_RNDN);
-
-
-
-
- 958 assert(0 <= i && i < dim);
-
-
-
-
- 967 assert(0 <= i && i < dim);
-
-
-
-
-
- 977 for (
unsigned int i=0; i < dim; i++)
- 978 mpfr_set((*
this)[i], result[i], MPFR_RNDN);
-
-
-
-
-
- 988 for (
unsigned int i=0; i < dim; i++)
- 989 mpfr_set((*
this)[i], result[i], MPFR_RNDN);
-
-
-
-
-
- 999 for (
unsigned int i=0; i < dim; i++)
- 1000 mpfr_set((*
this)[i], result[i], MPFR_RNDN);
-
-
-
-
-
- 1010 for (
unsigned int i=0; i < dim; i++)
- 1011 mpfr_set((*
this)[i], result[i], MPFR_RNDN);
-
-
-
-
-
- 1021 for (
unsigned int i=0; i < dim; i++)
- 1022 mpfr_set((*
this)[i], result[i], MPFR_RNDN);
-
-
-
-
- 1032template <const
unsigned int dim>
-
-
-
-
- 1037 for (
unsigned int i=0; i < dim; i++) {
- 1038 if (!mpfr_equal_p(H1[i], H2[i]))
return false;
-
-
-
-
- 1048template <const
unsigned int dim>
-
-
-
-
-
-
-
- 1061template <const
unsigned int dim>
-
-
-
-
- 1066 mpfr_t temparr[dim];
- 1067 for (
unsigned int i=0; i < dim; i++)
- 1068 mpfr_init2(temparr[i], MPFR_global_precision);
- 1069 for (
unsigned int i=0; i < dim; i++)
- 1070 mpfr_add(temparr[i], H1[i], H2[i], MPFR_RNDN);
-
- 1072 for (
unsigned int i=0; i < dim; i++) mpfr_clear(temparr[i]);
-
-
-
- 1081template <const
unsigned int dim>
-
-
-
-
- 1086 mpfr_t temparr[dim];
- 1087 for (
unsigned int i=0; i < dim; i++)
- 1088 mpfr_init2(temparr[i], MPFR_global_precision);
- 1089 for (
unsigned int i=0; i < dim; i++)
- 1090 mpfr_sub(temparr[i], H1[i], H2[i], MPFR_RNDN);
-
- 1092 for (
unsigned int i=0; i < dim; i++) mpfr_clear(temparr[i]);
-
-
-
- 1101template <const
unsigned int dim>
-
-
-
-
-
- 1107 if constexpr (dim == 1) {
-
- 1109 mpfr_init2(result, MPFR_global_precision);
- 1110 mpfr_mul(result, H1[0], H2[0], MPFR_RNDN);
-
- 1112 mpfr_init2(temparr[0], MPFR_global_precision);
- 1113 mpfr_set(temparr[0], result, MPFR_RNDN);
-
-
- 1116 mpfr_clear(temparr[0]);
-
-
-
-
- 1121 const unsigned int halfd = dim / 2;
- 1122 mpfr_t temparr[dim];
- 1123 for (
unsigned int i=0; i < dim; i++)
- 1124 mpfr_init2(temparr[i], MPFR_global_precision);
-
- 1126 for (
unsigned int i=0; i < halfd; i++)
- 1127 mpfr_set(temparr[i], H1[i], MPFR_RNDN);
-
- 1129 for (
unsigned int i=0; i < halfd; i++)
- 1130 mpfr_set(temparr[i], H1[i+halfd], MPFR_RNDN);
-
- 1132 for (
unsigned int i=0; i < halfd; i++)
- 1133 mpfr_set(temparr[i], H2[i], MPFR_RNDN);
-
- 1135 for (
unsigned int i=0; i < halfd; i++)
- 1136 mpfr_set(temparr[i], H2[i+halfd], MPFR_RNDN);
-
-
-
-
-
-
-
-
-
- 1146 for (
unsigned int i=0; i < halfd; i++)
- 1147 mpfr_set(temparr[i], Ha[i], MPFR_RNDN);
- 1148 for (
unsigned int i=0; i < halfd; i++)
- 1149 mpfr_set(temparr[i+halfd], Hb[i], MPFR_RNDN);
-
- 1151 for (
unsigned int i=0; i < dim; i++) mpfr_clear(temparr[i]);
-
-
-
-
- 1161template <const
unsigned int dim>
-
-
- 1164 const unsigned int x
-
-
- 1167 throw std::invalid_argument(
"zero is not a valid argument");
-
-
- 1170 for (
unsigned int i=0; i < x-1; i++) Hx *= H;
-
-
-
-
- 1180template <const
unsigned int dim>
-
-
-
-
-
-
-
-
- 1194template <const
unsigned int dim>
-
-
-
-
- 1199 mpfr_exp_t exponent = 0;
-
- 1201 for (
unsigned int i=0; i < dim - 1; i++) {
- 1202 outstr = mpfr_get_str(NULL, &exponent, 10, 0, H[i], MPFR_RNDN);
- 1203 os << outstr <<
"E" << exponent <<
" ";
- 1204 mpfr_free_str(outstr);
-
- 1206 outstr = mpfr_get_str(NULL, &exponent, 10, 0, H[dim - 1], MPFR_RNDN);
- 1207 os << outstr <<
"E" << exponent;
- 1208 mpfr_free_str(outstr);
-
-
-
- 1216template <const
unsigned int dim>
-
-
- 1219 for (
unsigned int i=1; i < dim; i++) mpfr_set_zero(result[i], 0);
-
-
-
- 1227template <const
unsigned int dim>
-
-
- 1230 mpfr_set_zero(result[0], 0);
-
-
-
- 1238template <const
unsigned int dim>
-
-
- 1241 mpfr_t zero, norm, expreal;
- 1242 mpfr_init2(zero, MPFR_global_precision);
- 1243 mpfr_init2(norm, MPFR_global_precision);
- 1244 mpfr_init2(expreal, MPFR_global_precision);
- 1245 mpfr_set_zero(zero, 0);
-
- 1247 mpfr_exp(expreal, H[0], MPFR_RNDN);
-
- 1249 if (mpfr_equal_p(norm, zero)) {
- 1250 mpfr_set(result[0], expreal, MPFR_RNDN);
- 1251 for (
unsigned int i=1; i < dim; i++) mpfr_set_zero(result[i], 0);
-
-
- 1254 mpfr_init2(sinv_v, MPFR_global_precision);
- 1255 mpfr_sin(sinv_v, norm, MPFR_RNDN);
- 1256 mpfr_div(sinv_v, sinv_v, norm, MPFR_RNDN);
- 1257 for (
unsigned int i=0; i < dim; i++) {
- 1258 mpfr_mul(result[i], result[i], sinv_v, MPFR_RNDN);
-
- 1260 mpfr_cos(norm, norm, MPFR_RNDN);
- 1261 mpfr_add(result[0], result[0], norm, MPFR_RNDN);
- 1262 for (
unsigned int i=0; i < dim; i++) {
- 1263 mpfr_mul(result[i], result[i], expreal, MPFR_RNDN);
-
-
-
-
-
- 1269 mpfr_clear(expreal);
-
+
+
+
+
+
+
+ 795 uint64_t
_()
const {
return dim; }
+
+ 797 #ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+
+
+
+
+ 806 for (uint64_t i=0; i < dim; i++) {
+ 807 norm2 = norm2 + arr[i] * arr[i];
+
+
+
+
+ 818 template <const u
int64_t newdim>
+
+ 820 if (newdim <= dim)
throw std::invalid_argument(
"invalid dimension");
+
+
+ 823 for (uint64_t i=0; i < dim; i++) temparr[i] = arr[i];
+ 824 for (uint64_t i=dim; i < newdim; i++) temparr[i] = zero;
+
+
+
+
+
+ 834 assert(0 <= i && i < dim);
+
+
+
+
+ 843 assert(0 <= i && i < dim);
+
+
+
+
+
+
+ 853 for (uint64_t i=1; i < dim; i++) temparr[i] = -arr[i];
+
+
+
+
+
+
+ 863 for (uint64_t i=0; i < dim; i++) temparr[i] = -arr[i];
+
+
+
+
+
+ 873 if (
this == &H)
return *
this;
+ 874 for (uint64_t i=0; i < dim; i++) arr[i] = H[i];
+
+
+
+
+
+ 884 for (uint64_t i=0; i < dim; i++) (*
this)[i] = result[i];
+
+
+
+
+
+ 894 for (uint64_t i=0; i < dim; i++) (*
this)[i] = result[i];
+
+
+
+
+
+
+ 905 for (uint64_t i=0; i < dim; i++) (*
this)[i] = result[i];
+
+
+
+
+
+ 915 for (uint64_t i=0; i < dim; i++) (*
this)[i] = result[i];
+
+
+
+
+
+ 925 for (uint64_t i=0; i < dim; i++) (*
this)[i] = result[i];
+
+
+
+
+
+ 935 for (uint64_t i=0; i < dim; i++) (*
this)[i] = result[i];
+
+
+
+ 939 #ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+
+
+
+ 949template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+ 954 for (uint64_t i=0; i < dim; i++) {
+ 955 if (H1[i] != H2[i])
return false;
+
+
+
+
+ 965template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+
+
+ 978template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+ 984 for (uint64_t i=0; i < dim; i++) temparr[i] = H1[i] + H2[i];
+
+
+
+
+ 994template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+ 1000 for (uint64_t i=0; i < dim; i++) temparr[i] = H1[i] - H2[i];
+
+
+
+
+
+ 1006#ifndef DOXYGEN_SHOULD_SKIP_THIS
+ 1007template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+
+ 1019template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+ 1024 for (uint64_t i=0; i < dim - 1; i++) os << H[i] << std::endl;
+
+
+
+
+ 1034template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+ 1040 for (uint64_t i=0; i < dim; i++) temparr[i] = x * H[i];
+
+
+
+
+ 1050template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+ 1056 for (uint64_t i=0; i < dim; i++) temparr[i] = H[i] % mod;
+
+
+
+
+ 1066template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+ 1072 if constexpr (dim == 1) {
+
+
+
+
+
+
+ 1079 const uint64_t halfd = dim / 2;
+
+
+ 1082 for (uint64_t i=0; i < halfd; i++) temparr[i] = H1[i];
+
+ 1084 for (uint64_t i=0; i < halfd; i++) temparr[i] = H1[i+halfd];
+
+ 1086 for (uint64_t i=0; i < halfd; i++) temparr[i] = H2[i];
+
+ 1088 for (uint64_t i=0; i < halfd; i++) temparr[i] = H2[i+halfd];
+
+
+
+
+
+
+
+
+
+ 1098 for (uint64_t i=0; i < halfd; i++) temparr[i] = Ha[i];
+ 1099 for (uint64_t i=0; i < halfd; i++) temparr[i+halfd] = Hb[i];
+
+
+
+
+
+ 1110template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+ 1116 throw std::invalid_argument(
"zero is not a valid argument");
+
+
+ 1119 for (uint64_t i=0; i < x-1; i++) Hx = Hx * H;
+
+
+
+
+ 1128template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+ 1133 for (uint64_t i=1; i < dim; i++) result[i] = Polynomial<MaxDeg>();
+
+
+
+ 1141template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+
+
+
+
+ 1151#ifndef DOXYGEN_SHOULD_SKIP_THIS
+ 1152template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+ 1162template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+ 1167 for (uint64_t i=0; i < dim; i++)
CenteredLift(&(*H)[i], mod);
+
+
+ 1175template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+
+
+ 1183 temparr[0] = H[0] * ringinverse % mod;
+ 1184 for (uint64_t i=1; i < dim; i++)
+ 1185 temparr[i] = -H[i] * ringinverse % mod;
+
+
+
+
+
+
+ 1192 assert(result[0] == unity);
+ 1193 for (uint64_t i=1; i < dim; i++) assert(result[i] == zero);
+
+
+
+
+
+
+
+
+
+
+
+
+ 1212template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+
+
+
+
+
+
+ 1232template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+
+
+
+
+
+
+
+ 1252template <const u
int64_t MaxDeg, const u
int64_t dim>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
- 1283template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
- 1287 static inline uint64_t** baseprodabs;
- 1288 static inline bool** baseprodpos;
-
-
-
- 1294 int64_t** M =
new int64_t*[dim];
- 1295 for (
unsigned int i = 0; i < dim; i++) M[i] =
new int64_t[dim];
-
-
-
- 1299 for (
unsigned int i=0; i < n; i++) {
- 1300 for (
unsigned int j=0; j < n; j++) {
- 1301 M[i][n+j] = M[j][i] > 0 ? M[j][i] + n : M[j][i] - n;
- 1302 M[i+n][j] = M[i][j] > 0 ? M[i][j] + n : M[i][j] - n;
- 1303 M[i+n][j] = M[i+n][j] * (j ? -1 : 1);
- 1304 M[i+n][j+n] = -M[j][i] * (j ? -1 : 1);
-
-
-
-
- 1309 baseprodabs =
new uint64_t*[dim];
- 1310 baseprodpos =
new bool*[dim];
- 1311 for (
unsigned int i = 0; i < dim; i++) {
- 1312 baseprodabs[i] =
new uint64_t[dim];
- 1313 baseprodpos[i] =
new bool[dim];
-
- 1315 for (
unsigned int i=0; i < dim; i++) {
- 1316 for (
unsigned int j=0; j < dim; j++) {
- 1317 baseprodabs[i][j] = std::abs(M[i][j]) - 1;
- 1318 baseprodpos[i][j] = (0 < M[i][j]);
-
-
- 1321 for (
unsigned int i = 0; i < dim; i++) {
-
-
-
-
-
-
- 1330 for (
unsigned int i = 0; i < dim; i++) {
- 1331 delete[] baseprodabs[i];
- 1332 delete[] baseprodpos[i];
-
- 1334 delete[] baseprodabs;
- 1335 delete[] baseprodpos;
-
-
-
-
-
-
-
- 1348 for (
unsigned int i=0; i < dim; i++) {
- 1349 for (
unsigned int j=0; j < dim; j++) {
- 1350 if (Hypercomplex::baseprodpos[i][j]) {
- 1351 temp[Hypercomplex::baseprodabs[i][j]] =
- 1352 temp[Hypercomplex::baseprodabs[i][j]] + H1[i] * H2[j];
-
- 1354 temp[Hypercomplex::baseprodabs[i][j]] =
- 1355 temp[Hypercomplex::baseprodabs[i][j]] - H1[i] * H2[j];
-
-
-
-
-
-
-
-
-
-
- 1372 throw std::invalid_argument(
"invalid dimension");
-
- 1374 if ((dim & (dim - 1)) != 0) {
-
- 1376 throw std::invalid_argument(
"invalid dimension");
-
- 1378 for (
unsigned int i=0; i < dim; i++) arr[i] = ARR[i];
-
-
-
- 1388 for (
unsigned int i=0; i < dim; i++) arr[i] = H[i];
-
-
-
-
-
-
-
-
- 1400 unsigned int _()
const {
return dim; }
-
- 1402 #ifndef DOXYGEN_SHOULD_SKIP_THIS
-
-
-
-
-
- 1411 for (
unsigned int i=0; i < dim; i++) {
- 1412 norm2 = norm2 + arr[i] * arr[i];
-
-
-
-
- 1423 template <const
unsigned int newdim>
-
- 1425 if (newdim <= dim)
throw std::invalid_argument(
"invalid dimension");
-
-
- 1428 for (
unsigned int i=0; i < dim; i++) temparr[i] = arr[i];
- 1429 for (
unsigned int i=dim; i < newdim; i++) temparr[i] = zero;
-
-
-
-
-
- 1439 assert(0 <= i && i < dim);
-
-
-
-
- 1448 assert(0 <= i && i < dim);
-
-
-
-
-
- 1457 temparr[0] = arr[0];
- 1458 for (
unsigned int i=1; i < dim; i++) temparr[i] = -arr[i];
-
-
-
-
-
-
- 1468 for (
unsigned int i=0; i < dim; i++) temparr[i] = -arr[i];
-
-
-
-
-
- 1478 if (
this == &H)
return *
this;
- 1479 for (
unsigned int i=0; i < dim; i++) arr[i] = H[i];
-
-
-
-
-
- 1489 for (
unsigned int i=0; i < dim; i++) (*
this)[i] = result[i];
-
-
-
-
-
- 1499 for (
unsigned int i=0; i < dim; i++) (*
this)[i] = result[i];
-
-
-
-
-
-
- 1510 for (
unsigned int i=0; i < dim; i++) (*
this)[i] = result[i];
-
-
-
-
-
- 1520 for (
unsigned int i=0; i < dim; i++) (*
this)[i] = result[i];
-
-
-
-
-
- 1530 for (
unsigned int i=0; i < dim; i++) (*
this)[i] = result[i];
-
-
-
-
-
- 1540 for (
unsigned int i=0; i < dim; i++) (*
this)[i] = result[i];
-
-
-
- 1544 #ifndef DOXYGEN_SHOULD_SKIP_THIS
-
-
-
-
- 1554template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
- 1559 for (
unsigned int i=0; i < dim; i++) {
- 1560 if (H1[i] != H2[i])
return false;
-
-
-
-
- 1570template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
-
-
- 1583template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
- 1589 for (
unsigned int i=0; i < dim; i++) temparr[i] = H1[i] + H2[i];
-
-
-
-
- 1599template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
- 1605 for (
unsigned int i=0; i < dim; i++) temparr[i] = H1[i] - H2[i];
-
-
-
-
-
- 1611#ifndef DOXYGEN_SHOULD_SKIP_THIS
- 1612template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
-
- 1624template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
- 1629 for (
unsigned int i=0; i < dim - 1; i++) os << H[i] << std::endl;
-
-
-
-
- 1639template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
- 1645 for (
unsigned int i=0; i < dim; i++) temparr[i] = x * H[i];
-
-
-
-
- 1655template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
- 1661 for (
unsigned int i=0; i < dim; i++) temparr[i] = H[i] % mod;
-
-
-
-
- 1671template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
- 1677 if constexpr (dim == 1) {
-
-
-
-
-
-
- 1684 const unsigned int halfd = dim / 2;
-
-
- 1687 for (
unsigned int i=0; i < halfd; i++) temparr[i] = H1[i];
-
- 1689 for (
unsigned int i=0; i < halfd; i++) temparr[i] = H1[i+halfd];
-
- 1691 for (
unsigned int i=0; i < halfd; i++) temparr[i] = H2[i];
-
- 1693 for (
unsigned int i=0; i < halfd; i++) temparr[i] = H2[i+halfd];
-
-
-
-
-
-
-
-
-
- 1703 for (
unsigned int i=0; i < halfd; i++) temparr[i] = Ha[i];
- 1704 for (
unsigned int i=0; i < halfd; i++) temparr[i+halfd] = Hb[i];
-
-
-
-
-
- 1715template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
- 1718 const unsigned int x
-
-
- 1721 throw std::invalid_argument(
"zero is not a valid argument");
-
-
- 1724 for (
unsigned int i=0; i < x-1; i++) Hx = Hx * H;
-
-
-
-
- 1733template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
- 1738 for (
unsigned int i=1; i < dim; i++) result[i] = Polynomial<MaxDeg>();
-
-
-
- 1746template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
-
-
-
-
- 1756#ifndef DOXYGEN_SHOULD_SKIP_THIS
- 1757template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
- 1767template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
- 1772 for (
unsigned int i=0; i < dim; i++)
CenteredLift(&(*H)[i], mod);
-
-
- 1780template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
-
-
- 1788 temparr[0] = H[0] * ringinverse % mod;
- 1789 for (
unsigned int i=1; i < dim; i++)
- 1790 temparr[i] = -H[i] * ringinverse % mod;
-
-
-
-
-
-
- 1797 assert(result[0] == unity);
- 1798 for (
unsigned int i=1; i < dim; i++) assert(result[i] == zero);
-
-
-
-
-
-
-
-
-
-
-
-
- 1817template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
-
-
-
-
-
-
- 1837template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
-
-
-
-
-
-
-
- 1857template <const
unsigned int MaxDeg, const
unsigned int dim>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Hypercomplex< T, dim > operator-(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Subtraction operator.
Definition: Hypercomplex.hpp:491
-void set_mpfr_precision(unsigned int n)
Setter for the global precision of the MPFR variables.
Definition: Hypercomplex.hpp:679
-Hypercomplex< T, dim > Re(const Hypercomplex< T, dim > &H)
Real part of a hypercomplex number.
Definition: Hypercomplex.hpp:627
-Hypercomplex< Polynomial< MaxDeg >, dim > DECRYPT(const Hypercomplex< Polynomial< MaxDeg >, dim > &F, const Hypercomplex< Polynomial< MaxDeg >, dim > &E, const int64_t &p, const int64_t &q)
Decrypt a message via the cryptosystem.
Definition: Hypercomplex.hpp:1858
-bool operator==(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Equality operator.
Definition: Hypercomplex.hpp:458
-bool operator!=(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Inequality operator.
Definition: Hypercomplex.hpp:470
-void clear_mpfr_memory()
Wrapper for MPFR memory cleanup.
Definition: Hypercomplex.hpp:685
-Hypercomplex< T, dim > operator+(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Addition operator.
Definition: Hypercomplex.hpp:479
-Hypercomplex< Polynomial< MaxDeg >, dim > PUBLICKEY(const Hypercomplex< Polynomial< MaxDeg >, dim > &F, const Hypercomplex< Polynomial< MaxDeg >, dim > &G, const int64_t &q)
Generate public key of the cryptosystem.
Definition: Hypercomplex.hpp:1818
-Hypercomplex< Polynomial< MaxDeg >, dim > RingInverse(const Hypercomplex< Polynomial< MaxDeg >, dim > &H, const int64_t &mod)
Hypercomplex inverse in a modular quotient ring.
Definition: Hypercomplex.hpp:1781
-Hypercomplex< Polynomial< MaxDeg >, dim > ENCRYPT(const Hypercomplex< Polynomial< MaxDeg >, dim > &H, const Hypercomplex< Polynomial< MaxDeg >, dim > &M, const Hypercomplex< Polynomial< MaxDeg >, dim > &PHI, const int64_t &p, const int64_t &q)
Encrypt a message via the cryptosystem.
Definition: Hypercomplex.hpp:1838
-void CenteredLift(Hypercomplex< Polynomial< MaxDeg >, dim > *H, const int64_t &mod)
Center-lift hypercomplex elements in a modular quotient ring.
Definition: Hypercomplex.hpp:1768
-Hypercomplex< T, dim > operator*(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Multiplication operator.
Definition: Hypercomplex.hpp:503
-unsigned int get_mpfr_precision()
Getter for the global precision of the MPFR variables.
Definition: Hypercomplex.hpp:672
-std::ostream & operator<<(std::ostream &os, const Hypercomplex< T, dim > &H)
Print operator.
Definition: Hypercomplex.hpp:619
-Hypercomplex< T, dim > Im(const Hypercomplex< T, dim > &H)
Imaginary part of a hypercomplex number.
Definition: Hypercomplex.hpp:635
-Hypercomplex< Polynomial< MaxDeg >, dim > operator%(const Hypercomplex< Polynomial< MaxDeg >, dim > &H, const int64_t &mod)
Modular reduction operator.
Definition: Hypercomplex.hpp:1656
-Hypercomplex< T, dim > exp(const Hypercomplex< T, dim > &H)
Exponentiation operation on a hypercomplex number.
Definition: Hypercomplex.hpp:643
-Hypercomplex< T, dim > operator/(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Division operator.
Definition: Hypercomplex.hpp:558
-Hypercomplex< T, dim > operator^(const Hypercomplex< T, dim > &H, const unsigned int x)
Power operator.
Definition: Hypercomplex.hpp:543
+
+
+
+
+
+
+Hypercomplex< T, dim > operator-(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Subtraction operator.
Definition: Hypercomplex.hpp:500
+Hypercomplex< T, dim > Re(const Hypercomplex< T, dim > &H)
Real part of a hypercomplex number.
Definition: Hypercomplex.hpp:636
+Hypercomplex< Polynomial< MaxDeg >, dim > DECRYPT(const Hypercomplex< Polynomial< MaxDeg >, dim > &F, const Hypercomplex< Polynomial< MaxDeg >, dim > &E, const int64_t &p, const int64_t &q)
Decrypt a message via the cryptosystem.
Definition: Hypercomplex.hpp:1253
+bool operator==(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Equality operator.
Definition: Hypercomplex.hpp:467
+bool operator!=(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Inequality operator.
Definition: Hypercomplex.hpp:479
+Hypercomplex< T, dim > operator+(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Addition operator.
Definition: Hypercomplex.hpp:488
+Hypercomplex< Polynomial< MaxDeg >, dim > PUBLICKEY(const Hypercomplex< Polynomial< MaxDeg >, dim > &F, const Hypercomplex< Polynomial< MaxDeg >, dim > &G, const int64_t &q)
Generate public key of the cryptosystem.
Definition: Hypercomplex.hpp:1213
+Hypercomplex< Polynomial< MaxDeg >, dim > RingInverse(const Hypercomplex< Polynomial< MaxDeg >, dim > &H, const int64_t &mod)
Hypercomplex inverse in a modular quotient ring.
Definition: Hypercomplex.hpp:1176
+Hypercomplex< Polynomial< MaxDeg >, dim > ENCRYPT(const Hypercomplex< Polynomial< MaxDeg >, dim > &H, const Hypercomplex< Polynomial< MaxDeg >, dim > &M, const Hypercomplex< Polynomial< MaxDeg >, dim > &PHI, const int64_t &p, const int64_t &q)
Encrypt a message via the cryptosystem.
Definition: Hypercomplex.hpp:1233
+void CenteredLift(Hypercomplex< Polynomial< MaxDeg >, dim > *H, const int64_t &mod)
Center-lift hypercomplex elements in a modular quotient ring.
Definition: Hypercomplex.hpp:1163
+Hypercomplex< T, dim > operator*(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Multiplication operator.
Definition: Hypercomplex.hpp:512
+std::ostream & operator<<(std::ostream &os, const Hypercomplex< T, dim > &H)
Print operator.
Definition: Hypercomplex.hpp:628
+Hypercomplex< T, dim > operator^(const Hypercomplex< T, dim > &H, const uint64_t x)
Power operator.
Definition: Hypercomplex.hpp:552
+Hypercomplex< T, dim > Im(const Hypercomplex< T, dim > &H)
Imaginary part of a hypercomplex number.
Definition: Hypercomplex.hpp:644
+Hypercomplex< Polynomial< MaxDeg >, dim > operator%(const Hypercomplex< Polynomial< MaxDeg >, dim > &H, const int64_t &mod)
Modular reduction operator.
Definition: Hypercomplex.hpp:1051
+Hypercomplex< T, dim > exp(const Hypercomplex< T, dim > &H)
Exponentiation operation on a hypercomplex number.
Definition: Hypercomplex.hpp:652
+Hypercomplex< T, dim > operator/(const Hypercomplex< T, dim > &H1, const Hypercomplex< T, dim > &H2)
Division operator.
Definition: Hypercomplex.hpp:567
+
-static void init()
Basis multiplication table initialiser.
Definition: Hypercomplex.hpp:1293
-Hypercomplex(const Polynomial< MaxDeg > *ARR)
This is the main constructor.
Definition: Hypercomplex.hpp:1369
-Hypercomplex< Polynomial< MaxDeg >, newdim > expand() const
Cast a number into a higher dimension.
Definition: Hypercomplex.hpp:1424
-static void clear()
Cleanup function: free all memory.
Definition: Hypercomplex.hpp:1329
-static Hypercomplex MUL(const Hypercomplex &H1, const Hypercomplex &H2)
Optimised multiplication function.
Definition: Hypercomplex.hpp:1343
-unsigned int _() const
Dimensionality getter.
Definition: Hypercomplex.hpp:1400
-Hypercomplex(const Hypercomplex &H)
This is the copy constructor.
Definition: Hypercomplex.hpp:1387
-Polynomial< MaxDeg > norm2() const
Calculate squared Euclidean norm of a number.
Definition: Hypercomplex.hpp:1409
-static void clear()
Cleanup function: free all memory.
Definition: Hypercomplex.hpp:738
-Hypercomplex(const Hypercomplex &H)
This is the copy constructor.
Definition: Hypercomplex.hpp:813
-Hypercomplex inv() const
Calculate inverse of a given number.
Definition: Hypercomplex.hpp:857
-unsigned int _() const
Dimensionality getter.
Definition: Hypercomplex.hpp:830
-int norm(mpfr_t norm) const
Calculate Euclidean norm of a number.
Definition: Hypercomplex.hpp:841
-Hypercomplex(const mpfr_t *ARR)
This is the main constructor.
Definition: Hypercomplex.hpp:792
-Hypercomplex< mpfr_t, newdim > expand() const
Cast a number into a higher dimension.
Definition: Hypercomplex.hpp:892
-static Hypercomplex MUL(const Hypercomplex &H1, const Hypercomplex &H2)
Optimised multiplication function.
Definition: Hypercomplex.hpp:752
-static void init()
Basis multiplication table initialiser.
Definition: Hypercomplex.hpp:702
-Definition: Hypercomplex.hpp:39
-static void init()
Basis multiplication table initialiser.
Definition: Hypercomplex.hpp:48
-Hypercomplex & operator+=(const Hypercomplex &H)
Addition-Assignment operator.
Definition: Hypercomplex.hpp:569
-Hypercomplex operator~() const
Create a complex conjugate.
Definition: Hypercomplex.hpp:412
-Hypercomplex & operator/=(const Hypercomplex &H)
Division-Assignment operator.
Definition: Hypercomplex.hpp:609
-Hypercomplex & operator=(const Hypercomplex &H)
Assignment operator.
Definition: Hypercomplex.hpp:431
-T norm() const
Calculate Euclidean norm of a number.
Definition: Hypercomplex.hpp:375
-unsigned int _() const
Dimensionality getter.
Definition: Hypercomplex.hpp:144
-static Hypercomplex MUL(const Hypercomplex &H1, const Hypercomplex &H2)
Optimised multiplication function.
Definition: Hypercomplex.hpp:98
-Hypercomplex operator-() const
Create an additive inverse of a given number.
Definition: Hypercomplex.hpp:422
-Hypercomplex & operator^=(const unsigned int x)
Power-Assignment operator.
Definition: Hypercomplex.hpp:599
-Hypercomplex & operator*=(const Hypercomplex &H)
Multiplication-Assignment operator.
Definition: Hypercomplex.hpp:589
-Hypercomplex & operator-=(const Hypercomplex &H)
Subtraction-Assignment operator.
Definition: Hypercomplex.hpp:579
-static void clear()
Cleanup function: free all memory.
Definition: Hypercomplex.hpp:84
-T const & operator[](const unsigned int i) const
Access operator (const)
Definition: Hypercomplex.hpp:444
-Hypercomplex inv() const
Calculate inverse of a given number.
Definition: Hypercomplex.hpp:383
-Hypercomplex< T, newdim > expand() const
Cast a number into a higher dimension.
Definition: Hypercomplex.hpp:401
+static void init()
Basis multiplication table initialiser.
Definition: Hypercomplex.hpp:688
+Hypercomplex(const Polynomial< MaxDeg > *ARR)
This is the main constructor.
Definition: Hypercomplex.hpp:764
+Hypercomplex< Polynomial< MaxDeg >, newdim > expand() const
Cast a number into a higher dimension.
Definition: Hypercomplex.hpp:819
+static void clear()
Cleanup function: free all memory.
Definition: Hypercomplex.hpp:724
+static Hypercomplex MUL(const Hypercomplex &H1, const Hypercomplex &H2)
Optimised multiplication function.
Definition: Hypercomplex.hpp:738
+uint64_t _() const
Dimensionality getter.
Definition: Hypercomplex.hpp:795
+Hypercomplex(const Hypercomplex &H)
This is the copy constructor.
Definition: Hypercomplex.hpp:782
+Polynomial< MaxDeg > norm2() const
Calculate squared Euclidean norm of a number.
Definition: Hypercomplex.hpp:804
+Definition: Hypercomplex.hpp:48
+Hypercomplex & operator^=(const uint64_t x)
Power-Assignment operator.
Definition: Hypercomplex.hpp:608
+static void init()
Basis multiplication table initialiser.
Definition: Hypercomplex.hpp:57
+Hypercomplex & operator+=(const Hypercomplex &H)
Addition-Assignment operator.
Definition: Hypercomplex.hpp:578
+Hypercomplex operator~() const
Create a complex conjugate.
Definition: Hypercomplex.hpp:421
+Hypercomplex & operator/=(const Hypercomplex &H)
Division-Assignment operator.
Definition: Hypercomplex.hpp:618
+Hypercomplex & operator=(const Hypercomplex &H)
Assignment operator.
Definition: Hypercomplex.hpp:440
+T norm() const
Calculate Euclidean norm of a number.
Definition: Hypercomplex.hpp:384
+T const & operator[](const uint64_t i) const
Access operator (const)
Definition: Hypercomplex.hpp:453
+static Hypercomplex MUL(const Hypercomplex &H1, const Hypercomplex &H2)
Optimised multiplication function.
Definition: Hypercomplex.hpp:107
+uint64_t _() const
Dimensionality getter.
Definition: Hypercomplex.hpp:153
+Hypercomplex operator-() const
Create an additive inverse of a given number.
Definition: Hypercomplex.hpp:431
+Hypercomplex & operator*=(const Hypercomplex &H)
Multiplication-Assignment operator.
Definition: Hypercomplex.hpp:598
+Hypercomplex & operator-=(const Hypercomplex &H)
Subtraction-Assignment operator.
Definition: Hypercomplex.hpp:588
+static void clear()
Cleanup function: free all memory.
Definition: Hypercomplex.hpp:93
+Hypercomplex inv() const
Calculate inverse of a given number.
Definition: Hypercomplex.hpp:392
+Hypercomplex< T, newdim > expand() const
Cast a number into a higher dimension.
Definition: Hypercomplex.hpp:410
Definition: Polynomial.hpp:41
diff --git a/docs/html/_hypercomplex___m_p_f_r_8hpp.html b/docs/html/_hypercomplex___m_p_f_r_8hpp.html
new file mode 100644
index 0000000..f28c5be
--- /dev/null
+++ b/docs/html/_hypercomplex___m_p_f_r_8hpp.html
@@ -0,0 +1,616 @@
+
+
+
+
+
+
+
+Hypercomplex: hypercomplex/Hypercomplex_MPFR.hpp File Reference
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Hypercomplex
+
+ Abstract & fast header-only C++ template library for lattice-based cryptosystems in high-dimensional algebras
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+
+
+
+
+
+
+
Go to the source code of this file.
+
+ |
+uint64_t | get_mpfr_precision () |
+ | Getter for the global precision of the MPFR variables. More...
|
+ |
+void | set_mpfr_precision (uint64_t n) |
+ | Setter for the global precision of the MPFR variables. More...
|
+ |
+
+void | clear_mpfr_memory () |
+ | Wrapper for MPFR memory cleanup.
|
+ |
+template<const uint64_t dim> |
+bool | operator== (const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2) |
+ | Equality operator. More...
|
+ |
+template<const uint64_t dim> |
+bool | operator!= (const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2) |
+ | Inequality operator. More...
|
+ |
+template<const uint64_t dim> |
+Hypercomplex< mpfr_t, dim > | operator+ (const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2) |
+ | Addition operator. More...
|
+ |
+template<const uint64_t dim> |
+Hypercomplex< mpfr_t, dim > | operator- (const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2) |
+ | Subtraction operator. More...
|
+ |
+template<const uint64_t dim> |
+Hypercomplex< mpfr_t, dim > | operator* (const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2) |
+ | Multiplication operator. More...
|
+ |
+template<const uint64_t dim> |
+Hypercomplex< mpfr_t, dim > | operator^ (const Hypercomplex< mpfr_t, dim > &H, const uint64_t x) |
+ | Power operator. More...
|
+ |
+template<const uint64_t dim> |
+Hypercomplex< mpfr_t, dim > | operator/ (const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2) |
+ | Division operator. More...
|
+ |
+template<const uint64_t dim> |
+std::ostream & | operator<< (std::ostream &os, const Hypercomplex< mpfr_t, dim > &H) |
+ | Print operator. More...
|
+ |
+template<const uint64_t dim> |
+Hypercomplex< mpfr_t, dim > | Re (const Hypercomplex< mpfr_t, dim > &H) |
+ | Real part of a hypercomplex number. More...
|
+ |
+template<const uint64_t dim> |
+Hypercomplex< mpfr_t, dim > | Im (const Hypercomplex< mpfr_t, dim > &H) |
+ | Imaginary part of a hypercomplex number. More...
|
+ |
+template<const uint64_t dim> |
+Hypercomplex< mpfr_t, dim > | exp (const Hypercomplex< mpfr_t, dim > &H) |
+ | Exponentiation operation on a hypercomplex number. More...
|
+ |
+
+
+
+
◆ exp()
+
+
+
+
+template<const uint64_t dim>
+
+
+
+
Exponentiation operation on a hypercomplex number.
+
- Parameters
-
+
+ [in] | H | existing class instance |
+
+
+
+
- Returns
- new class instance
+
+
+
+
+
◆ get_mpfr_precision()
+
+
+
+
+
+ uint64_t get_mpfr_precision |
+ ( |
+ | ) |
+ |
+
+
+
+
+
Getter for the global precision of the MPFR variables.
+
- Returns
- precision in bits
+
+
+
+
+
◆ Im()
+
+
+
+
+template<const uint64_t dim>
+
+
+
+
Imaginary part of a hypercomplex number.
+
- Parameters
-
+
+ [in] | H | existing class instance |
+
+
+
+
- Returns
- new class instance
+
+
+
+
+
◆ operator!=()
+
+
+
+
+template<const uint64_t dim>
+
+
+ bool operator!= |
+ ( |
+ const Hypercomplex< mpfr_t, dim > & |
+ H1, |
+
+
+ |
+ |
+ const Hypercomplex< mpfr_t, dim > & |
+ H2 |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+
Inequality operator.
+
- Parameters
-
+
+ [in] | H1 | LHS operand |
+ [in] | H2 | RHS operand |
+
+
+
+
- Returns
- boolean value after the comparison
+
+
+
+
+
◆ operator*()
+
+
+
+
+template<const uint64_t dim>
+
+
+
+
Multiplication operator.
+
- Parameters
-
+
+ [in] | H1 | LHS operand |
+ [in] | H2 | RHS operand |
+
+
+
+
- Returns
- new class instance
+
+
+
+
+
◆ operator+()
+
+
+
+
+template<const uint64_t dim>
+
+
+
+
Addition operator.
+
- Parameters
-
+
+ [in] | H1 | LHS operand |
+ [in] | H2 | RHS operand |
+
+
+
+
- Returns
- new class instance
+
+
+
+
+
◆ operator-()
+
+
+
+
+template<const uint64_t dim>
+
+
+
+
Subtraction operator.
+
- Parameters
-
+
+ [in] | H1 | LHS operand |
+ [in] | H2 | RHS operand |
+
+
+
+
- Returns
- new class instance
+
+
+
+
+
◆ operator/()
+
+
+
+
+template<const uint64_t dim>
+
+
+
+
Division operator.
+
- Parameters
-
+
+ [in] | H1 | LHS operand |
+ [in] | H2 | RHS operand |
+
+
+
+
- Returns
- new class instance
+
+
+
+
+
◆ operator<<()
+
+
+
+
+template<const uint64_t dim>
+
+
+ std::ostream & operator<< |
+ ( |
+ std::ostream & |
+ os, |
+
+
+ |
+ |
+ const Hypercomplex< mpfr_t, dim > & |
+ H |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+
Print operator.
+
- Parameters
-
+
+ [in,out] | os | output stream |
+ [in] | H | existing class instance |
+
+
+
+
- Returns
- output stream
+
+
+
+
+
◆ operator==()
+
+
+
+
+template<const uint64_t dim>
+
+
+ bool operator== |
+ ( |
+ const Hypercomplex< mpfr_t, dim > & |
+ H1, |
+
+
+ |
+ |
+ const Hypercomplex< mpfr_t, dim > & |
+ H2 |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+
Equality operator.
+
- Parameters
-
+
+ [in] | H1 | LHS operand |
+ [in] | H2 | RHS operand |
+
+
+
+
- Returns
- boolean value after the comparison
+
+
+
+
+
◆ operator^()
+
+
+
+
+template<const uint64_t dim>
+
+
+ Hypercomplex< mpfr_t, dim > operator^ |
+ ( |
+ const Hypercomplex< mpfr_t, dim > & |
+ H, |
+
+
+ |
+ |
+ const uint64_t |
+ x |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+
Power operator.
+
- Parameters
-
+
+ [in] | H | LHS operand |
+ [in] | x | RHS operand |
+
+
+
+
- Returns
- new class instance
+
+
+
+
+
◆ Re()
+
+
+
+
+template<const uint64_t dim>
+
+
+
+
Real part of a hypercomplex number.
+
- Parameters
-
+
+ [in] | H | existing class instance |
+
+
+
+
- Returns
- new class instance
+
+
+
+
+
◆ set_mpfr_precision()
+
+
+
+
+
+ void set_mpfr_precision |
+ ( |
+ uint64_t |
+ n | ) |
+ |
+
+
+
+
+
Setter for the global precision of the MPFR variables.
+
- Parameters
-
+
+ [in] | n | positive integer (precision in bits) |
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/html/_hypercomplex___m_p_f_r_8hpp_source.html b/docs/html/_hypercomplex___m_p_f_r_8hpp_source.html
new file mode 100644
index 0000000..3a27906
--- /dev/null
+++ b/docs/html/_hypercomplex___m_p_f_r_8hpp_source.html
@@ -0,0 +1,616 @@
+
+
+
+
+
+
+
+Hypercomplex: hypercomplex/Hypercomplex_MPFR.hpp Source File
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Hypercomplex
+
+ Abstract & fast header-only C++ template library for lattice-based cryptosystems in high-dimensional algebras
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+
+
+
+
+
+
Go to the documentation of this file.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
19#ifndef HYPERCOMPLEX_HYPERCOMPLEX_MPFR_HPP_
+
20#define HYPERCOMPLEX_HYPERCOMPLEX_MPFR_HPP_
+
+
+
+
24static uint64_t MPFR_global_precision;
+
+
+
30 return MPFR_global_precision;
+
+
+
+
37 MPFR_global_precision = n;
+
+
+
+
+
44 assert(!mpfr_mp_memory_cleanup());
+
+
+
49template <const u
int64_t dim>
+
+
+
52 mpfr_t* arr =
new mpfr_t[dim];
+
53 static inline uint64_t** baseprodabs;
+
54 static inline bool** baseprodpos;
+
+
+
+
60 int64_t** M =
new int64_t*[dim];
+
61 for (uint64_t i = 0; i < dim; i++) M[i] =
new int64_t[dim];
+
+
+
+
65 for (uint64_t i=0; i < n; i++) {
+
66 for (uint64_t j=0; j < n; j++) {
+
67 M[i][n+j] = M[j][i] > 0 ? M[j][i] + n : M[j][i] - n;
+
68 M[i+n][j] = M[i][j] > 0 ? M[i][j] + n : M[i][j] - n;
+
69 M[i+n][j] = M[i+n][j] * (j ? -1 : 1);
+
70 M[i+n][j+n] = -M[j][i] * (j ? -1 : 1);
+
+
+
+
+
75 baseprodabs =
new uint64_t*[dim];
+
76 baseprodpos =
new bool*[dim];
+
77 for (uint64_t i = 0; i < dim; i++) {
+
78 baseprodabs[i] =
new uint64_t[dim];
+
79 baseprodpos[i] =
new bool[dim];
+
+
81 for (uint64_t i=0; i < dim; i++) {
+
82 for (uint64_t j=0; j < dim; j++) {
+
83 baseprodabs[i][j] = std::abs(M[i][j]) - 1;
+
84 baseprodpos[i][j] = (0 < M[i][j]);
+
+
+
87 for (uint64_t i = 0; i < dim; i++) {
+
+
+
+
+
+
+
96 for (uint64_t i = 0; i < dim; i++) {
+
97 delete[] baseprodabs[i];
+
98 delete[] baseprodpos[i];
+
+
100 delete[] baseprodabs;
+
101 delete[] baseprodpos;
+
+
+
+
+
+
+
+
114 mpfr_init2(prod, MPFR_global_precision);
+
+
116 for (uint64_t i=0; i < dim; i++)
+
117 mpfr_init2(temparr[i], MPFR_global_precision);
+
118 for (uint64_t i=0; i < dim; i++) mpfr_set_zero(temparr[i], 0);
+
119 for (uint64_t i=0; i < dim; i++) {
+
120 for (uint64_t j=0; j < dim; j++) {
+
121 mpfr_mul(prod, H1[i], H2[j], MPFR_RNDN);
+
122 if (Hypercomplex::baseprodpos[i][j]) {
+
+
124 temparr[Hypercomplex::baseprodabs[i][j]],
+
125 temparr[Hypercomplex::baseprodabs[i][j]],
+
+
+
+
+
130 temparr[Hypercomplex::baseprodabs[i][j]],
+
131 temparr[Hypercomplex::baseprodabs[i][j]],
+
+
+
+
+
+
+
138 for (uint64_t i=0; i < dim; i++) mpfr_clear(temparr[i]);
+
+
+
+
+
+
+
+
152 throw std::invalid_argument(
"invalid dimension");
+
+
154 if ((dim & (dim - 1)) != 0) {
+
+
156 throw std::invalid_argument(
"invalid dimension");
+
+
158 for (uint64_t i=0; i < dim; i++)
+
159 mpfr_init2(arr[i], MPFR_global_precision);
+
160 for (uint64_t i=0; i < dim; i++)
+
161 mpfr_set(arr[i], ARR[i], MPFR_RNDN);
+
+
+
+
171 for (uint64_t i=0; i < dim; i++)
+
172 mpfr_init2(arr[i], MPFR_global_precision);
+
173 for (uint64_t i=0; i < dim; i++)
+
174 mpfr_set(arr[i], H[i], MPFR_RNDN);
+
+
+
+
+
+
180 for (uint64_t i=0; i < dim; i++) mpfr_clear(arr[i]);
+
+
+
+
187 uint64_t
_()
const {
return dim; }
+
+
+
+
200 mpfr_init2(temp, MPFR_global_precision);
+
201 mpfr_set_zero(
norm, 0);
+
202 for (uint64_t i=0; i < dim; i++) {
+
203 mpfr_mul(temp, arr[i], arr[i], MPFR_RNDN);
+
204 mpfr_add(
norm,
norm, temp, MPFR_RNDN);
+
+
+
+
+
+
+
+
+
216 mpfr_init2(zero, MPFR_global_precision);
+
217 mpfr_init2(
norm, MPFR_global_precision);
+
218 mpfr_set_zero(zero, 0);
+
+
220 if (mpfr_equal_p(
norm, zero)) {
+
+
+
223 throw std::invalid_argument(
"division by zero");
+
+
+
226 for (uint64_t i=0; i < dim; i++)
+
227 mpfr_init2(temparr[i], MPFR_global_precision);
+
+
229 mpfr_div(temparr[0], arr[0],
norm, MPFR_RNDN);
+
230 for (uint64_t i=1; i < dim; i++) {
+
231 mpfr_div(temparr[i], arr[i],
norm, MPFR_RNDN);
+
232 mpfr_sub(temparr[i], zero, temparr[i], MPFR_RNDN);
+
+
+
+
+
237 for (uint64_t i=0; i < dim; i++) mpfr_clear(temparr[i]);
+
+
+
+
+
248 template <const u
int64_t newdim>
+
+
250 if (newdim <= dim)
throw std::invalid_argument(
"invalid dimension");
+
251 mpfr_t temparr[newdim];
+
252 for (uint64_t i=0; i < newdim; i++)
+
253 mpfr_init2(temparr[i], MPFR_global_precision);
+
254 for (uint64_t i=0; i < dim; i++)
+
255 mpfr_set(temparr[i], arr[i], MPFR_RNDN);
+
256 for (uint64_t i=dim; i < newdim; i++) mpfr_set_zero(temparr[i], 0);
+
+
258 for (uint64_t i=0; i < newdim; i++) mpfr_clear(temparr[i]);
+
+
+
+
+
+
267 mpfr_init2(zero, MPFR_global_precision);
+
268 mpfr_set_zero(zero, 0);
+
+
270 for (uint64_t i=0; i < dim; i++)
+
271 mpfr_init2(temparr[i], MPFR_global_precision);
+
272 mpfr_set(temparr[0], arr[0], MPFR_RNDN);
+
273 for (uint64_t i=1; i < dim; i++)
+
274 mpfr_sub(temparr[i], zero, arr[i], MPFR_RNDN);
+
+
276 for (uint64_t i=0; i < dim; i++) mpfr_clear(temparr[i]);
+
+
+
+
+
+
+
286 mpfr_init2(zero, MPFR_global_precision);
+
287 mpfr_set_zero(zero, 0);
+
+
289 for (uint64_t i=0; i < dim; i++)
+
290 mpfr_init2(temparr[i], MPFR_global_precision);
+
291 for (uint64_t i=0; i < dim; i++)
+
292 mpfr_sub(temparr[i], zero, arr[i], MPFR_RNDN);
+
+
294 for (uint64_t i=0; i < dim; i++) mpfr_clear(temparr[i]);
+
+
+
+
+
+
304 if (
this == &H)
return *
this;
+
305 for (uint64_t i=0; i < dim; i++)
+
306 mpfr_set(arr[i], H[i], MPFR_RNDN);
+
+
+
+
+
315 assert(0 <= i && i < dim);
+
+
+
+
+
324 assert(0 <= i && i < dim);
+
+
+
+
+
+
334 for (uint64_t i=0; i < dim; i++)
+
335 mpfr_set((*
this)[i], result[i], MPFR_RNDN);
+
+
+
+
+
+
345 for (uint64_t i=0; i < dim; i++)
+
346 mpfr_set((*
this)[i], result[i], MPFR_RNDN);
+
+
+
+
+
+
356 for (uint64_t i=0; i < dim; i++)
+
357 mpfr_set((*
this)[i], result[i], MPFR_RNDN);
+
+
+
+
+
+
367 for (uint64_t i=0; i < dim; i++)
+
368 mpfr_set((*
this)[i], result[i], MPFR_RNDN);
+
+
+
+
+
+
378 for (uint64_t i=0; i < dim; i++)
+
379 mpfr_set((*
this)[i], result[i], MPFR_RNDN);
+
+
+
+
+
389template <const u
int64_t dim>
+
+
+
+
+
394 for (uint64_t i=0; i < dim; i++) {
+
395 if (!mpfr_equal_p(H1[i], H2[i]))
return false;
+
+
+
+
+
405template <const u
int64_t dim>
+
+
+
+
+
+
+
+
418template <const u
int64_t dim>
+
+
+
+
+
+
424 for (uint64_t i=0; i < dim; i++)
+
425 mpfr_init2(temparr[i], MPFR_global_precision);
+
426 for (uint64_t i=0; i < dim; i++)
+
427 mpfr_add(temparr[i], H1[i], H2[i], MPFR_RNDN);
+
+
429 for (uint64_t i=0; i < dim; i++) mpfr_clear(temparr[i]);
+
+
+
+
438template <const u
int64_t dim>
+
+
+
+
+
+
444 for (uint64_t i=0; i < dim; i++)
+
445 mpfr_init2(temparr[i], MPFR_global_precision);
+
446 for (uint64_t i=0; i < dim; i++)
+
447 mpfr_sub(temparr[i], H1[i], H2[i], MPFR_RNDN);
+
+
449 for (uint64_t i=0; i < dim; i++) mpfr_clear(temparr[i]);
+
+
+
+
458template <const u
int64_t dim>
+
+
+
+
+
+
464 if constexpr (dim == 1) {
+
+
466 mpfr_init2(result, MPFR_global_precision);
+
467 mpfr_mul(result, H1[0], H2[0], MPFR_RNDN);
+
+
469 mpfr_init2(temparr[0], MPFR_global_precision);
+
470 mpfr_set(temparr[0], result, MPFR_RNDN);
+
+
+
473 mpfr_clear(temparr[0]);
+
+
+
+
+
478 const uint64_t halfd = dim / 2;
+
+
480 for (uint64_t i=0; i < dim; i++)
+
481 mpfr_init2(temparr[i], MPFR_global_precision);
+
+
483 for (uint64_t i=0; i < halfd; i++)
+
484 mpfr_set(temparr[i], H1[i], MPFR_RNDN);
+
+
486 for (uint64_t i=0; i < halfd; i++)
+
487 mpfr_set(temparr[i], H1[i+halfd], MPFR_RNDN);
+
+
489 for (uint64_t i=0; i < halfd; i++)
+
490 mpfr_set(temparr[i], H2[i], MPFR_RNDN);
+
+
492 for (uint64_t i=0; i < halfd; i++)
+
493 mpfr_set(temparr[i], H2[i+halfd], MPFR_RNDN);
+
+
+
+
+
+
+
+
+
+
503 for (uint64_t i=0; i < halfd; i++)
+
504 mpfr_set(temparr[i], Ha[i], MPFR_RNDN);
+
505 for (uint64_t i=0; i < halfd; i++)
+
506 mpfr_set(temparr[i+halfd], Hb[i], MPFR_RNDN);
+
+
508 for (uint64_t i=0; i < dim; i++) mpfr_clear(temparr[i]);
+
+
+
+
+
518template <const u
int64_t dim>
+
+
+
+
+
+
524 throw std::invalid_argument(
"zero is not a valid argument");
+
+
+
527 for (uint64_t i=0; i < x-1; i++) Hx *= H;
+
+
+
+
+
537template <const u
int64_t dim>
+
+
+
+
+
+
+
+
+
551template <const u
int64_t dim>
+
+
+
+
+
556 mpfr_exp_t exponent = 0;
+
+
558 for (uint64_t i=0; i < dim - 1; i++) {
+
559 outstr = mpfr_get_str(NULL, &exponent, 10, 0, H[i], MPFR_RNDN);
+
560 os << outstr <<
"E" << exponent <<
" ";
+
561 mpfr_free_str(outstr);
+
+
563 outstr = mpfr_get_str(NULL, &exponent, 10, 0, H[dim - 1], MPFR_RNDN);
+
564 os << outstr <<
"E" << exponent;
+
565 mpfr_free_str(outstr);
+
+
+
+
573template <const u
int64_t dim>
+
+
+
576 for (uint64_t i=1; i < dim; i++) mpfr_set_zero(result[i], 0);
+
+
+
+
584template <const u
int64_t dim>
+
+
+
587 mpfr_set_zero(result[0], 0);
+
+
+
+
595template <const u
int64_t dim>
+
+
+
598 mpfr_t zero, norm, expreal;
+
599 mpfr_init2(zero, MPFR_global_precision);
+
600 mpfr_init2(norm, MPFR_global_precision);
+
601 mpfr_init2(expreal, MPFR_global_precision);
+
602 mpfr_set_zero(zero, 0);
+
+
604 mpfr_exp(expreal, H[0], MPFR_RNDN);
+
+
606 if (mpfr_equal_p(norm, zero)) {
+
607 mpfr_set(result[0], expreal, MPFR_RNDN);
+
608 for (uint64_t i=1; i < dim; i++) mpfr_set_zero(result[i], 0);
+
+
+
611 mpfr_init2(sinv_v, MPFR_global_precision);
+
612 mpfr_sin(sinv_v, norm, MPFR_RNDN);
+
613 mpfr_div(sinv_v, sinv_v, norm, MPFR_RNDN);
+
614 for (uint64_t i=0; i < dim; i++) {
+
615 mpfr_mul(result[i], result[i], sinv_v, MPFR_RNDN);
+
+
617 mpfr_cos(norm, norm, MPFR_RNDN);
+
618 mpfr_add(result[0], result[0], norm, MPFR_RNDN);
+
619 for (uint64_t i=0; i < dim; i++) {
+
620 mpfr_mul(result[i], result[i], expreal, MPFR_RNDN);
+
+
+
+
+
+
+
+
+
+
+
+
std::ostream & operator<<(std::ostream &os, const Hypercomplex< mpfr_t, dim > &H)
Print operator.
Definition: Hypercomplex_MPFR.hpp:552
+
uint64_t get_mpfr_precision()
Getter for the global precision of the MPFR variables.
Definition: Hypercomplex_MPFR.hpp:29
+
Hypercomplex< mpfr_t, dim > Re(const Hypercomplex< mpfr_t, dim > &H)
Real part of a hypercomplex number.
Definition: Hypercomplex_MPFR.hpp:574
+
void clear_mpfr_memory()
Wrapper for MPFR memory cleanup.
Definition: Hypercomplex_MPFR.hpp:42
+
bool operator!=(const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2)
Inequality operator.
Definition: Hypercomplex_MPFR.hpp:406
+
bool operator==(const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2)
Equality operator.
Definition: Hypercomplex_MPFR.hpp:390
+
Hypercomplex< mpfr_t, dim > operator/(const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2)
Division operator.
Definition: Hypercomplex_MPFR.hpp:538
+
Hypercomplex< mpfr_t, dim > exp(const Hypercomplex< mpfr_t, dim > &H)
Exponentiation operation on a hypercomplex number.
Definition: Hypercomplex_MPFR.hpp:596
+
void set_mpfr_precision(uint64_t n)
Setter for the global precision of the MPFR variables.
Definition: Hypercomplex_MPFR.hpp:36
+
Hypercomplex< mpfr_t, dim > operator+(const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2)
Addition operator.
Definition: Hypercomplex_MPFR.hpp:419
+
Hypercomplex< mpfr_t, dim > Im(const Hypercomplex< mpfr_t, dim > &H)
Imaginary part of a hypercomplex number.
Definition: Hypercomplex_MPFR.hpp:585
+
Hypercomplex< mpfr_t, dim > operator-(const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2)
Subtraction operator.
Definition: Hypercomplex_MPFR.hpp:439
+
Hypercomplex< mpfr_t, dim > operator^(const Hypercomplex< mpfr_t, dim > &H, const uint64_t x)
Power operator.
Definition: Hypercomplex_MPFR.hpp:519
+
Hypercomplex< mpfr_t, dim > operator*(const Hypercomplex< mpfr_t, dim > &H1, const Hypercomplex< mpfr_t, dim > &H2)
Multiplication operator.
Definition: Hypercomplex_MPFR.hpp:459
+
static void clear()
Cleanup function: free all memory.
Definition: Hypercomplex_MPFR.hpp:95
+
Hypercomplex(const Hypercomplex &H)
This is the copy constructor.
Definition: Hypercomplex_MPFR.hpp:170
+
Hypercomplex inv() const
Calculate inverse of a given number.
Definition: Hypercomplex_MPFR.hpp:214
+
Hypercomplex(const mpfr_t *ARR)
This is the main constructor.
Definition: Hypercomplex_MPFR.hpp:149
+
Hypercomplex< mpfr_t, newdim > expand() const
Cast a number into a higher dimension.
Definition: Hypercomplex_MPFR.hpp:249
+
static Hypercomplex MUL(const Hypercomplex &H1, const Hypercomplex &H2)
Optimised multiplication function.
Definition: Hypercomplex_MPFR.hpp:109
+
static void init()
Basis multiplication table initialiser.
Definition: Hypercomplex_MPFR.hpp:59
+
int32_t norm(mpfr_t norm) const
Calculate Euclidean norm of a number.
Definition: Hypercomplex_MPFR.hpp:198
+
uint64_t _() const
Dimensionality getter.
Definition: Hypercomplex_MPFR.hpp:187
+
Definition: Hypercomplex.hpp:48
+
Hypercomplex & operator^=(const uint64_t x)
Power-Assignment operator.
Definition: Hypercomplex.hpp:608
+
Hypercomplex & operator+=(const Hypercomplex &H)
Addition-Assignment operator.
Definition: Hypercomplex.hpp:578
+
Hypercomplex operator~() const
Create a complex conjugate.
Definition: Hypercomplex.hpp:421
+
Hypercomplex & operator/=(const Hypercomplex &H)
Division-Assignment operator.
Definition: Hypercomplex.hpp:618
+
Hypercomplex & operator=(const Hypercomplex &H)
Assignment operator.
Definition: Hypercomplex.hpp:440
+
T norm() const
Calculate Euclidean norm of a number.
Definition: Hypercomplex.hpp:384
+
T const & operator[](const uint64_t i) const
Access operator (const)
Definition: Hypercomplex.hpp:453
+
Hypercomplex operator-() const
Create an additive inverse of a given number.
Definition: Hypercomplex.hpp:431
+
Hypercomplex & operator*=(const Hypercomplex &H)
Multiplication-Assignment operator.
Definition: Hypercomplex.hpp:598
+
Hypercomplex & operator-=(const Hypercomplex &H)
Subtraction-Assignment operator.
Definition: Hypercomplex.hpp:588
+
Hypercomplex inv() const
Calculate inverse of a given number.
Definition: Hypercomplex.hpp:392
+
+
+
+
+
diff --git a/docs/html/_polynomial_8hpp.html b/docs/html/_polynomial_8hpp.html
index d0bb2e7..179be77 100644
--- a/docs/html/_polynomial_8hpp.html
+++ b/docs/html/_polynomial_8hpp.html
@@ -102,43 +102,43 @@
int64_t | RingInverse (const int64_t x, const int64_t mod) |
| Integer multiplicative inverse in a modular ring. More...
|
|
-template<const unsigned int MaxDeg> |
+template<const uint64_t MaxDeg> |
bool | operator== (const Polynomial< MaxDeg > &P1, const Polynomial< MaxDeg > &P2) |
| Equality operator. More...
|
|
-template<const unsigned int MaxDeg> |
+template<const uint64_t MaxDeg> |
bool | operator!= (const Polynomial< MaxDeg > &P1, const Polynomial< MaxDeg > &P2) |
| Inequality operator. More...
|
|
-template<const unsigned int MaxDeg> |
+template<const uint64_t MaxDeg> |
std::ostream & | operator<< (std::ostream &os, const Polynomial< MaxDeg > &P) |
| Print operator. More...
|
|
-template<const unsigned int MaxDeg> |
+template<const uint64_t MaxDeg> |
Polynomial< MaxDeg > | operator* (const int64_t x, const Polynomial< MaxDeg > &P) |
| Multiplication-by-scalar operator. More...
|
|
-template<const unsigned int MaxDeg> |
+template<const uint64_t MaxDeg> |
Polynomial< MaxDeg > | operator+ (const Polynomial< MaxDeg > &P1, const Polynomial< MaxDeg > &P2) |
| Addition operator. More...
|
|
-template<const unsigned int MaxDeg> |
+template<const uint64_t MaxDeg> |
Polynomial< MaxDeg > | operator- (const Polynomial< MaxDeg > &P1, const Polynomial< MaxDeg > &P2) |
| Subtraction operator. More...
|
|
-template<const unsigned int MaxDeg> |
+template<const uint64_t MaxDeg> |
Polynomial< MaxDeg > | operator* (const Polynomial< MaxDeg > &P1, const Polynomial< MaxDeg > &P2) |
| Convolution multiplication in a polynomial quotient ring operator. More...
|
|
-template<const unsigned int MaxDeg> |
+template<const uint64_t MaxDeg> |
Polynomial< MaxDeg > | operator% (const Polynomial< MaxDeg > &P, const int64_t x) |
| Coefficient reduction modulo a scalar. More...
|
|
-template<const unsigned int MaxDeg> |
+template<const uint64_t MaxDeg> |
void | CenteredLift (Polynomial< MaxDeg > *P, const int64_t mod) |
| Center-lift polynomial in a modular quotient ring. More...
|
|
-template<const unsigned int MaxDeg> |
+template<const uint64_t MaxDeg> |
Polynomial< MaxDeg > | RingInverse (const Polynomial< MaxDeg > &P, const int64_t &mod) |
| Inverse polynomial in a modular quotient ring. More...
|
|
@@ -150,7 +150,7 @@
-template<const unsigned int MaxDeg>
+template<const uint64_t MaxDeg>
void CenteredLift |
@@ -189,7 +189,7 @@
-template<const unsigned int MaxDeg>
+template<const uint64_t MaxDeg>
bool operator!= |
@@ -229,7 +229,7 @@
-template<const unsigned int MaxDeg>
+template<const uint64_t MaxDeg>
Polynomial< MaxDeg > operator% |
@@ -269,7 +269,7 @@
-template<const unsigned int MaxDeg>
+template<const uint64_t MaxDeg>
Polynomial< MaxDeg > operator* |
@@ -309,7 +309,7 @@
-template<const unsigned int MaxDeg>
+template<const uint64_t MaxDeg>
Polynomial< MaxDeg > operator* |
@@ -349,7 +349,7 @@
-template<const unsigned int MaxDeg>
+template<const uint64_t MaxDeg>
Polynomial< MaxDeg > operator+ |
@@ -389,7 +389,7 @@
-template<const unsigned int MaxDeg>
+template<const uint64_t MaxDeg>
Polynomial< MaxDeg > operator- |
@@ -429,7 +429,7 @@
-template<const unsigned int MaxDeg>
+template<const uint64_t MaxDeg>
std::ostream & operator<< |
@@ -469,7 +469,7 @@
-template<const unsigned int MaxDeg>
+template<const uint64_t MaxDeg>
bool operator== |
@@ -547,7 +547,7 @@
-template<const unsigned int MaxDeg>
+template<const uint64_t MaxDeg>
Polynomial< MaxDeg > RingInverse |
diff --git a/docs/html/_polynomial_8hpp_source.html b/docs/html/_polynomial_8hpp_source.html
index 620ea05..6fde3f0 100644
--- a/docs/html/_polynomial_8hpp_source.html
+++ b/docs/html/_polynomial_8hpp_source.html
@@ -109,28 +109,28 @@
- 32 for (
unsigned int i=1; i < mod; i++) {
+ 32 for (uint64_t i=1; i < mod; i++) {
33 if ((y*i) % mod == 1)
return i;
35 throw std::invalid_argument(
"non-invertible element");
- 40template <const
unsigned int MaxDeg>
+ 40template <const u
int64_t MaxDeg>
43 int64_t* coefficients =
new int64_t[MaxDeg+1];
- 53 for (
unsigned int i=0; i <= MaxDeg; i++) coefficients[i] = arr[i];
+ 53 for (uint64_t i=0; i <= MaxDeg; i++) coefficients[i] = arr[i];
- 63 for (
unsigned int i=0; i <= MaxDeg; i++) coefficients[i] = P[i];
+ 63 for (uint64_t i=0; i <= MaxDeg; i++) coefficients[i] = P[i];
- 72 for (
unsigned int i=0; i <= MaxDeg; i++) coefficients[i] = 0;
+ 72 for (uint64_t i=0; i <= MaxDeg; i++) coefficients[i] = 0;
@@ -141,41 +141,41 @@
85 if (
this == &P)
return *
this;
- 87 for (
unsigned int i=0; i <= MaxDeg; i++) coefficients[i] = P[i];
+ 87 for (uint64_t i=0; i <= MaxDeg; i++) coefficients[i] = P[i];
96 int64_t temparr[MaxDeg+1];
- 97 for (
unsigned int i=0; i <= MaxDeg; i++) temparr[i] = -coefficients[i];
+ 97 for (uint64_t i=0; i <= MaxDeg; i++) temparr[i] = -coefficients[i];
-
+
107 assert(0 <= i && i <= MaxDeg);
108 return coefficients[i];
-
+
116 assert(0 <= i && i <= MaxDeg);
117 return coefficients[i];
- 126template <const
unsigned int MaxDeg>
+ 126template <const u
int64_t MaxDeg>
- 131 for (
unsigned int i=0; i <= MaxDeg; i++) {
+ 131 for (uint64_t i=0; i <= MaxDeg; i++) {
132 if (P1[i] != P2[i])
return false;
- 142template <const
unsigned int MaxDeg>
+ 142template <const u
int64_t MaxDeg>
@@ -183,65 +183,65 @@
- 155template <const
unsigned int MaxDeg>
+ 155template <const u
int64_t MaxDeg>
- 157 for (
unsigned int i=0; i < MaxDeg; i++) os << P[i] <<
",";
+ 157 for (uint64_t i=0; i < MaxDeg; i++) os << P[i] <<
",";
- 167template <const
unsigned int MaxDeg>
+ 167template <const u
int64_t MaxDeg>
169 int64_t temparr[MaxDeg+1];
- 170 for (
unsigned int i=0; i <= MaxDeg; i++) temparr[i] = P[i] * x;
+ 170 for (uint64_t i=0; i <= MaxDeg; i++) temparr[i] = P[i] * x;
- 180template <const
unsigned int MaxDeg>
+ 180template <const u
int64_t MaxDeg>
185 int64_t temparr[MaxDeg+1];
- 186 for (
unsigned int i=0; i <= MaxDeg; i++) temparr[i] = P1[i] + P2[i];
+ 186 for (uint64_t i=0; i <= MaxDeg; i++) temparr[i] = P1[i] + P2[i];
- 196template <const
unsigned int MaxDeg>
+ 196template <const u
int64_t MaxDeg>
201 int64_t temparr[MaxDeg+1];
- 202 for (
unsigned int i=0; i <= MaxDeg; i++) temparr[i] = P1[i] - P2[i];
+ 202 for (uint64_t i=0; i <= MaxDeg; i++) temparr[i] = P1[i] - P2[i];
- 212template <const
unsigned int MaxDeg>
+ 212template <const u
int64_t MaxDeg>
217 int64_t prod[2*MaxDeg+1];
218 int64_t conv[MaxDeg+1];
- 219 for (
unsigned int i=0; i < 2*MaxDeg+1; i++) prod[i] = 0;
- 220 for (
unsigned int i=0; i <= MaxDeg; i++) conv[i] = 0;
- 221 for (
unsigned int i=0; i <= MaxDeg; i++) {
- 222 for (
unsigned int j=0; j <= MaxDeg; j++)
+ 219 for (uint64_t i=0; i < 2*MaxDeg+1; i++) prod[i] = 0;
+ 220 for (uint64_t i=0; i <= MaxDeg; i++) conv[i] = 0;
+ 221 for (uint64_t i=0; i <= MaxDeg; i++) {
+ 222 for (uint64_t j=0; j <= MaxDeg; j++)
223 prod[i+j] += P1[i]*P2[j];
- 225 for (
unsigned int i=0; i < 2*MaxDeg+1; i++) conv[i%(MaxDeg+1)] += prod[i];
+ 225 for (uint64_t i=0; i < 2*MaxDeg+1; i++) conv[i%(MaxDeg+1)] += prod[i];
- 235template <const
unsigned int MaxDeg>
+ 235template <const u
int64_t MaxDeg>
237 int64_t temparr[MaxDeg+1];
- 238 for (
unsigned int i=0; i <= MaxDeg; i++) {
+ 238 for (uint64_t i=0; i <= MaxDeg; i++) {
239 temparr[i] = P[i] % x;
240 if (temparr[i] < 0) temparr[i] += x;
@@ -249,11 +249,11 @@
- 250template <const
unsigned int MaxDeg>
+ 250template <const u
int64_t MaxDeg>
252 int64_t lower = -mod/2;
253 int64_t upper = mod/2;
- 254 for (
unsigned int i = 0; i <= MaxDeg; i++) {
+ 254 for (uint64_t i = 0; i <= MaxDeg; i++) {
256 if ((*P)[i] < lower) (*P)[i] = (*P)[i] + mod;
257 if ((*P)[i] > upper) (*P)[i] = (*P)[i] - mod;
@@ -264,7 +264,7 @@
- 270template <const
unsigned int MaxDeg>
+ 270template <const u
int64_t MaxDeg>
@@ -284,11 +284,11 @@
- 290 unsigned int deg_r = MaxDeg+1;
- 291 for (
unsigned int i=0; i <= MaxDeg; i++) temp[i] = P_[i];
+ 290 uint64_t deg_r = MaxDeg+1;
+ 291 for (uint64_t i=0; i <= MaxDeg; i++) temp[i] = P_[i];
- 293 unsigned int deg_newr = 0;
- 294 for (
unsigned int i=0; i <= MaxDeg+1; i++) {
+ 293 uint64_t deg_newr = 0;
+ 294 for (uint64_t i=0; i <= MaxDeg+1; i++) {
295 if (newr[i]) deg_newr = i;
@@ -296,15 +296,15 @@
299 while (deg_newr > 0) {
301 while (deg_r >= deg_newr) {
- 302 for (
unsigned int i=0; i <= MaxDeg+1; i++) temp[i] = 0;
- 303 for (
unsigned int i=0; i <= deg_newr; i++)
+ 302 for (uint64_t i=0; i <= MaxDeg+1; i++) temp[i] = 0;
+ 303 for (uint64_t i=0; i <= deg_newr; i++)
304 temp[i + deg_r - deg_newr] = newr[i];
305 q[deg_r - deg_newr] =
- 307 for (
unsigned int i=0; i <= deg_r; i++)
+ 307 for (uint64_t i=0; i <= deg_r; i++)
308 temp[i] = (temp[i] * q[deg_r - deg_newr]) % mod;
- 310 for (
unsigned int i=0; i <= deg_r; i++) r[i] = r[i] - temp[i];
+ 310 for (uint64_t i=0; i <= deg_r; i++) r[i] = r[i] - temp[i];
@@ -319,11 +319,11 @@
- 325 for (
unsigned int i=0; i <= MaxDeg+1; i++) q[i] = 0;
- 326 for (
unsigned int i=0; i <= MaxDeg+1; i++) {
+ 325 for (uint64_t i=0; i <= MaxDeg+1; i++) q[i] = 0;
+ 326 for (uint64_t i=0; i <= MaxDeg+1; i++) {
327 if (newr[i]) deg_newr = i;
- 329 for (
unsigned int i=0; i <= MaxDeg+1; i++) {
+ 329 for (uint64_t i=0; i <= MaxDeg+1; i++) {
@@ -334,7 +334,7 @@
- 340 for (
unsigned int i=0; i <= MaxDeg; i++) inverse[i] = newt[i];
+ 340 for (uint64_t i=0; i <= MaxDeg; i++) inverse[i] = newt[i];
341 inverse = (multiplier * inverse) % mod;
@@ -357,12 +357,12 @@
Polynomial< MaxDeg > operator%(const Polynomial< MaxDeg > &P, const int64_t x)
Coefficient reduction modulo a scalar.
Definition: Polynomial.hpp:236
Definition: Polynomial.hpp:41
Polynomial()
This is the default constructor.
Definition: Polynomial.hpp:71
-int64_t const & operator[](const unsigned int i) const
Access operator (const)
Definition: Polynomial.hpp:106
-int64_t & operator[](const unsigned int i)
Access operator (non-const)
Definition: Polynomial.hpp:115
Polynomial operator-() const
Create an additive inverse of a given polynomial.
Definition: Polynomial.hpp:95
Polynomial(const Polynomial &P)
This is the copy constructor.
Definition: Polynomial.hpp:62
Polynomial(const int64_t *arr)
This is the main constructor.
Definition: Polynomial.hpp:52
+int64_t const & operator[](const uint64_t i) const
Access operator (const)
Definition: Polynomial.hpp:106
Polynomial & operator=(const Polynomial &P)
Assignment operator.
Definition: Polynomial.hpp:83
+int64_t & operator[](const uint64_t i)
Access operator (non-const)
Definition: Polynomial.hpp:115
-template<typename T, const unsigned int dim>
+
template<typename T, const uint64_t dim>
class Hypercomplex< T, dim >
Main class of the library
@@ -163,7 +163,7 @@