Primary module interface unit for modlue lucas_sequence.
More...
#include <cassert>
#include <utility>
import modulo;
import matrix;
import base;
|
| template<Integer N, Integer S> |
| constexpr std::pair< S, S > | ntlib::lucas_nth_term (N n, S P, S Q) |
| | Compute the \(n\)-th term of the Lucas sequences of the first and second kind.
|
| template<Integer N, Integer S> |
| constexpr std::pair< S, S > | ntlib::mod_lucas_nth_term (N n, S P, S Q, S m) |
| | Compute the \(n\)-th term of the Lucas sequences of the first and second kind modulo some number.
|
Primary module interface unit for modlue lucas_sequence.
◆ lucas_nth_term()
template<Integer N, Integer S>
| std::pair< S, S > ntlib::lucas_nth_term |
( |
N | n, |
|
|
S | P, |
|
|
S | Q ) |
|
nodiscardconstexprexport |
Compute the \(n\)-th term of the Lucas sequences of the first and second kind.
Runtime: \(O(\log(n))\)
- Template Parameters
-
| N | An integer-like type. |
| S | A signed integer-like type. |
- Parameters
-
| n | Which term to compute. |
| P | Parameter \(P\). |
| Q | Parameter \(Q\). |
- Returns
- A std::pair<S,S> containing \(U_n(P,Q)\) as its first element and \(V_n(P,Q)\) as its second element.
◆ mod_lucas_nth_term()
template<Integer N, Integer S>
| std::pair< S, S > ntlib::mod_lucas_nth_term |
( |
N | n, |
|
|
S | P, |
|
|
S | Q, |
|
|
S | m ) |
|
nodiscardconstexprexport |
Compute the \(n\)-th term of the Lucas sequences of the first and second kind modulo some number.
Runtime: \(O(\log(n))\)
- Template Parameters
-
| N | An integer-like type. |
| S | A signed integer-like type. |
- Parameters
-
| n | Which term to compute. |
| P | Parameter \(P\). |
| Q | Parameter \(Q\). |
| m | The modulus. |
- Returns
- A std::pair<T,T> containing \(U_n(P,Q) \mod m\) as its first element and \(V_n(P,Q) \mod m\) as its second element.