NTLib - Number Theory Library 0.9
Loading...
Searching...
No Matches
lucas_sequence.cpp File Reference

Primary module interface unit for modlue lucas_sequence. More...

#include <cassert>
#include <utility>
import modulo;
import matrix;
import base;
Include dependency graph for lucas_sequence.cpp:

Functions

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.

Detailed Description

Primary module interface unit for modlue lucas_sequence.

Function Documentation

◆ 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
NAn integer-like type.
SA signed integer-like type.
Parameters
nWhich term to compute.
PParameter \(P\).
QParameter \(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
NAn integer-like type.
SA signed integer-like type.
Parameters
nWhich term to compute.
PParameter \(P\).
QParameter \(Q\).
mThe 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.