<commit_before>//
//
//

#include <stdio.h>

#include "../src/filter.h"
#include "../src/firdes.h"
#include "../../random/src/random.h"

#define DEBUG 1
#define DEBUG_FILENAME "firdes_kaiser_example.m"

int main() {
    // options
    unsigned int h_len=37;
    float fc=0.4f;
    float slsl=40.0f;

    unsigned int i;
    float h[h_len];
    fir_kaiser_window(h_len,fc,slsl,h);

#if DEBUG
    FILE*fid = fopen(DEBUG_FILENAME,"w");
    fprintf(fid,"%% fir_filter_example.m: auto-generated file\n\n");
    fprintf(fid,"clear all;\nclose all;\n\n");
    fprintf(fid,"h_len=%u;\n",h_len);
    fprintf(fid,"fc=%12.4e;\n",fc);
    fprintf(fid,"slsl=%12.4e;\n",slsl);

    for (i=0; i<h_len; i++)
        fprintf(fid,"h(%4u) = %12.4e;\n", i+1, h[i]);
#endif

    for (i=0; i<h_len; i++) {
        printf("h(%4u) = %12.4e;\n", i+1, h[i]);
#if DEBUG
        fprintf(fid,"h(%4u) = %12.4e;\n", i+1, h[i]);
#endif
    }   

#if DEBUG
    fprintf(fid,"nfft=1024;\n");
    fprintf(fid,"H=20*log10(abs(fftshift(fft(h*fc,nfft))));\n");
    fprintf(fid,"f=[0:(nfft-1)]/nfft-0.5;\n");
    fprintf(fid,"figure; plot(f,H,'Color',[0 0.5 0.25],'LineWidth',2);\n");
    fprintf(fid,"grid on;\n");
    fprintf(fid,"xlabel('normalized frequency');\n");
    fprintf(fid,"ylabel('PSD [dB]');\n");
    fprintf(fid,"title(['Filter design/Kaiser window f_c: %f, S_L: %f, h: %u']);\n",
            fc, -slsl, h_len);
    fprintf(fid,"axis([-0.5 0.5 -slsl-40 20]);\n");

    fclose(fid);
    printf("results written to %s\n", DEBUG_FILENAME);
#endif

    printf("done.\n");
    return 0;
}

<commit_msg>firdes_kaiser_example: cleaning up example (printed filter taps twice, wrong filename in comment, changing axis bounds)<commit_after>//
//
//

#include <stdio.h>

#include "../src/filter.h"
#include "../src/firdes.h"
#include "../../random/src/random.h"

#define DEBUG 1
#define DEBUG_FILENAME "firdes_kaiser_example.m"

int main() {
    // options
    unsigned int h_len=37;
    float fc=0.4f;
    float slsl=40.0f;

    unsigned int i;
    float h[h_len];
    fir_kaiser_window(h_len,fc,slsl,h);

#if DEBUG
    FILE*fid = fopen(DEBUG_FILENAME,"w");
    fprintf(fid,"%% %s: auto-generated file\n\n", DEBUG_FILENAME);
    fprintf(fid,"clear all;\nclose all;\n\n");
    fprintf(fid,"h_len=%u;\n",h_len);
    fprintf(fid,"fc=%12.4e;\n",fc);
    fprintf(fid,"slsl=%12.4e;\n",slsl);
#endif

    for (i=0; i<h_len; i++) {
        printf("h(%4u) = %12.4e;\n", i+1, h[i]);
#if DEBUG
        fprintf(fid,"h(%4u) = %12.4e;\n", i+1, h[i]);
#endif
    }   

#if DEBUG
    fprintf(fid,"nfft=1024;\n");
    fprintf(fid,"H=20*log10(abs(fftshift(fft(h*fc,nfft))));\n");
    fprintf(fid,"f=[0:(nfft-1)]/nfft-0.5;\n");
    fprintf(fid,"figure; plot(f,H,'Color',[0 0.5 0.25],'LineWidth',2);\n");
    fprintf(fid,"grid on;\n");
    fprintf(fid,"xlabel('normalized frequency');\n");
    fprintf(fid,"ylabel('PSD [dB]');\n");
    fprintf(fid,"title(['Filter design/Kaiser window f_c: %f, S_L: %f, h: %u']);\n",
            fc, -slsl, h_len);
    fprintf(fid,"axis([-0.5 0.5 -slsl-40 10]);\n");

    fclose(fid);
    printf("results written to %s\n", DEBUG_FILENAME);
#endif

    printf("done.\n");
    return 0;
}


{'fraction_non_alphanumeric': 0.23650142090306284, 'fraction_numerical': 0.03536469845279444, 'mean_word_length': 3.4307692307692306, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2001483', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1408, 'n_words': 227}