<commit_before>//
// modem_arb_example.c
//
// This example demonstrates the functionality of the arbitrary
// modem, a digital modulator/demodulator object with signal
// constellation points chosen arbitrarily.  A simple bit-error
// rate simulation is then run to test the performance of the
// modem.  The results are written to a file.
// SEE ALSO: modem_example.c
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <getopt.h>

#include "liquid.h"

#define OUTPUT_FILENAME "modem_arb_example.m"

// print usage/help message
void usage()
{
    printf("modem_arb_example [options]\n");
    printf("  u/h   : print usage\n");
    printf("  p     : modulation depth (default 4 bits/symbol)\n");
    printf("  f     : input constellation file name\n");
}

int main(int argc, char*argv[])
{
    // options
    unsigned int bps=6;         // bits per symbol
    unsigned int n=1024;        // number of data points to evaluate
    char filename[256] = "";
    filename[255] = '\0';

    int dopt;
    while ((dopt = getopt(argc,argv,"uhp:f:")) != EOF) {
        switch (dopt) {
        case 'u':
        case 'h': usage(); return 0;
        case 'p': bps = atoi(optarg); break;
        case 'f': strncpy(filename,optarg,255); break;
        default:
            fprintf(stderr,"error: modem_example, unknown option\n");
            usage();
            return 1;
        }
    }

    // validate input
    if (bps == 0) {
        fprintf(stderr,"error: %s, bits/symbol must be greater than zero\n", argv[0]);
        exit(1);
    }

    // derived values
    unsigned int i;
    unsigned int M = 1<<bps;    // constellation size

    // create mod/demod objects
    modem mod   = modem_create(MOD_ARB, bps);
    modem demod = modem_create(MOD_ARB, bps);

    // initialize mod/demod objects (NOTE: arbitrary modem
    // objects MUST be initialized before use)
    if ( strncmp(filename,"",256)==0 ) {
        float complex constellation[M];

#if 0
        // initialize constellation (spiral)
        for (i=0; i<M; i++) {
            float r   = (float)i / logf((float)M);
            float phi = (float)i / logf((float)M);
            constellation[i] = r * cexpf(_Complex_I*phi);
        }
#else
        // initialize constellation (random)
        for (i=0; i<M; i++)
            constellation[i] = randnf() * cexpf(_Complex_I*M_PI*randf());
#endif

        modem_arb_init(mod,  constellation,M);
        modem_arb_init(demod,constellation,M);<commit_msg>modem_arb_example: setting default constellation to spiral<commit_after>//
// modem_arb_example.c
//
// This example demonstrates the functionality of the arbitrary
// modem, a digital modulator/demodulator object with signal
// constellation points chosen arbitrarily.  A simple bit-error
// rate simulation is then run to test the performance of the
// modem.  The results are written to a file.
// SEE ALSO: modem_example.c
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <getopt.h>

#include "liquid.h"

#define OUTPUT_FILENAME "modem_arb_example.m"

// print usage/help message
void usage()
{
    printf("modem_arb_example [options]\n");
    printf("  u/h   : print usage\n");
    printf("  p     : modulation depth (default 4 bits/symbol)\n");
    printf("  f     : input constellation file name\n");
}

int main(int argc, char*argv[])
{
    // options
    unsigned int bps=6;         // bits per symbol
    unsigned int n=1024;        // number of data points to evaluate
    char filename[256] = "";
    filename[255] = '\0';

    int dopt;
    while ((dopt = getopt(argc,argv,"uhp:f:")) != EOF) {
        switch (dopt) {
        case 'u':
        case 'h': usage(); return 0;
        case 'p': bps = atoi(optarg); break;
        case 'f': strncpy(filename,optarg,255); break;
        default:
            fprintf(stderr,"error: modem_example, unknown option\n");
            usage();
            return 1;
        }
    }

    // validate input
    if (bps == 0) {
        fprintf(stderr,"error: %s, bits/symbol must be greater than zero\n", argv[0]);
        exit(1);
    }

    // derived values
    unsigned int i;
    unsigned int M = 1<<bps;    // constellation size

    // create mod/demod objects
    modem mod   = modem_create(MOD_ARB, bps);
    modem demod = modem_create(MOD_ARB, bps);

    // initialize mod/demod objects (NOTE: arbitrary modem
    // objects MUST be initialized before use)
    if ( strncmp(filename,"",256)==0 ) {
        float complex constellation[M];
#if 0
        // initialize constellation (random)
        for (i=0; i<M; i++)
            constellation[i] = randnf() * cexpf(_Complex_I*M_PI*randf());
#else
        // initialize constellation (spiral)
        for (i=0; i<M; i++) {
            float r   = (float)i / logf((float)M) + 4.0f;
            float phi = (float)i / logf((float)M);
            constellation[i] = r * cexpf(_Complex_I*phi);
        }
#endif
        modem_arb_init(mod,  constellation,M);
        modem_arb_init(demod,constellation,M);
{'fraction_non_alphanumeric': 0.13540840602696272, 'fraction_numerical': 0.011895321173671689, 'mean_word_length': 2.4673539518900345, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 13, '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': '6173269', 'n_tokens_mistral': 1714, 'n_tokens_neox': 1611, 'n_words': 465}