Code Library Of Others/sgtlaugh/Berlekamp Massey.cpp
vector <int> interpolate(vector <int>& recurrence, long long k, int n){
    using namespace bbl;
    assert(recurrence.size() && (recurrence.size() % 2) == 0);

    vector <int> polynomial;
    int l = berlekamp_massey(recurrence, polynomial);
	reverse(polynomial.begin(), polynomial.begin() + l + 1);
    return interpolate(recurrence, polynomial, k, n);
}
/// Returns consecutive n terms of the recurrence starting from the k'th term
/// MOD must be prime and greater than 2
/// 0.5s for n <= 4000, 4.25s for n <= 16000
Returns consecutive n terms of the recurrence starting from the k'th term
MOD must be prime and greater than 2
0.5s for n <= 4000, 4.25s for n <= 16000
Returns consecutive n terms of the recurrence starting from the k ' th term MOD must be prime and greater than 2 0 . 5s for n < = 4000 4 . 25s for n < = 16000
vector <int> interpolate(vector <int>& recurrence, long long k, int n){
    using namespace bbl;
    assert(recurrence.size() && (recurrence.size() % 2) == 0);
    vector <int> polynomial;
    int l = berlekamp_massey(recurrence, polynomial);
	reverse(polynomial.begin(), polynomial.begin() + l + 1);
    return interpolate(recurrence, polynomial, k, n);
}
vector < int > interpolate ( vector < int > & recurrence , long long k , int n ) { using namespace bbl ; assert ( recurrence . size ( ) && ( recurrence . size ( ) % 2 ) == 0 ) ; vector < int > polynomial ; int l = berlekamp_massey ( recurrence , polynomial ) ; reverse ( polynomial . begin ( ) , polynomial . begin ( ) + l + 1 ) ; return interpolate ( recurrence , polynomial , k , n ) ; }
Returns consecutive n terms of the recurrence starting from the k'th term
MOD must be prime and greater than 2
0.5s for n <= 4000, 4.25s for n <= 16000
Returns consecutive n terms of the recurrence starting from the k ' th term MOD must be prime and greater than 2 0 . 5s for n < = 4000 4 . 25s for n < = 16000