Primary module interface unit for module pell_equation.
More...
#include <cassert>
#include <tuple>
#include <vector>
import rational;
import continued_fraction;
import base;
|
| template<Integer T> |
| constexpr std::tuple< T, T > | ntlib::pell_fundamental_solution (T D) noexcept |
| | Compute the fundamental solution.
|
| template<Integer T> |
| constexpr std::tuple< T, T > | ntlib::pell_next_solution (T D, const std::tuple< T, T > &initial, const std::tuple< T, T > ¤t) noexcept |
| | Generates the next larger solution to Pell's equation.
|
Primary module interface unit for module pell_equation.
◆ pell_fundamental_solution()
template<Integer T>
| std::tuple< T, T > ntlib::pell_fundamental_solution |
( |
T | D | ) |
|
|
nodiscardconstexprexportnoexcept |
Compute the fundamental solution.
There are infinitely many integer solutions. The fundamental solution is the one minimal in \(x\) (by absolute value) and therefore also in \(y\).
- Template Parameters
-
- Parameters
-
| D | Parameter \(D \in \mathbb{N}\). Must not be a square number. |
- Returns
- Fundamental solution \((x,y)\).
◆ pell_next_solution()
template<Integer T>
| std::tuple< T, T > ntlib::pell_next_solution |
( |
T | D, |
|
|
const std::tuple< T, T > & | initial, |
|
|
const std::tuple< T, T > & | current ) |
|
nodiscardconstexprexportnoexcept |
Generates the next larger solution to Pell's equation.
- Template Parameters
-
- Parameters
-
| D | The parameter \(D\). |
| initial | The fundamental solution, i.e., the one minimal in x by absolute value. |
| current | Any solution. |
- Returns
- The next bigger solution than current (in x, by absolute value).