Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: assert of convolution #142

Merged
merged 3 commits into from
Mar 15, 2023
Merged

Conversation

TumoiYorozu
Copy link
Contributor

@TumoiYorozu TumoiYorozu commented May 31, 2022

Add assert for length of input $|a| + |b|$ in convolution_ll and convolution_fft.

https://github.com/atcoder/ac-library/blob/master/document_en/convolution.md?plain=1#L37

The following code should fail on assert

#include <vector>
#include <iostream>
#include <atcoder/convolution>
using namespace std;
using namespace atcoder;


void conv(const int n){
    vector<long long> a(n, 1);
    vector<long long> b(n, 1);

    auto res = convolution<998244353>(a, b);

    for(int i = 0; i < 100; ++i) {
        cout << i << ": " << res[i] << endl;
    }
}


void ll(const int n){
    vector<long long> a(n, 1);
    vector<long long> b(n, 1);

    auto res = convolution_ll(a, b);

    for(int i = 0; i < 100; ++i) {
        cout << i << ": " << res[i] << endl;
    }
}

int main(){
    conv(1 << 23);
    ll(1 << 24);
}

@TumoiYorozu TumoiYorozu changed the title add: assert of convolution_ll add: assert of convolution May 31, 2022
@yosupo06 yosupo06 closed this Mar 7, 2023
@yosupo06 yosupo06 reopened this Mar 7, 2023
@TumoiYorozu
Copy link
Contributor Author

static_assert の第2引数を省略すると C++17 が要求されるのですね。コメントを入れればC++11で大丈夫なようなので追加します。
I see that if I omit the second argument to static_assert, C++17 is required. I'll add a comment so that C++11 will be ok.

@yosupo06 yosupo06 merged commit 3fcd51e into atcoder:master Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants