<commit_before>#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif

#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctgmath>

#include "Tools/Math/matrix.h"
#include "Modulator_CPM.hpp"

template <typename B, typename R, typename Q, proto_max<Q> MAX>
Modulator_CPM<B,R,Q,MAX>
::Modulator_CPM(int  N,
                int  bits_per_symbol,
                int  sampling_factor,
                std::string cpm_std,
                int  cpm_L,
                int  cpm_k,
                int  cpm_p,
                std::string mapping,
                std::string wave_shape,
                R    sigma,
                bool no_sig2,
                int  n_frames,
                const std::string name)
: Modulator<B,R,Q>(N, 0, 0, n_frames, name      ), // TODO: hack
  sigma     (sigma                              ),
  no_sig2   (no_sig2                            ),
  cpm       (cpm_std,
             cpm_L,
             cpm_k,
             cpm_p,
             bits_per_symbol,
             sampling_factor,
             "TOTAL",
             wave_shape                         ),
  cpm_h     ((R)cpm.k/(R)cpm.p                  ),
  T_samp    ((R)1.0  /(R)cpm.s_factor           ),
  baseband  (  cpm.max_wa_id *cpm.s_factor *2, 0),
  projection(cpm.max_wa_id *cpm.s_factor *2,   0),
  n_sy      (N/cpm.n_b_per_s                    ),
  n_sy_tl   (n_sy+cpm.tl                        ),
  cpe       (n_sy, cpm, this->n_frames          ),
  bcjr      (cpm, n_sy_tl                       )
{
	assert(N%bits_per_symbol == 0);

	// write the right buffers sizes
	int* N_mod_writable = const_cast<int*>(&this->N_mod     );
	*N_mod_writable     = get_buffer_size_after_modulation(N);
	int* N_fil_writable = const_cast<int*>(&this->N_fil     );
	*N_fil_writable     = get_buffer_size_after_filtering(N );

	// initialize CPM
	cpe.generate_allowed_states    (cpm.allowed_states               );
	cpe.generate_allowed_wave_forms(cpm.allowed_wave_forms           );

	cpe.generate_mapper            (cpm.transition_to_binary,
	                                cpm.binary_to_transition,
	                                mapping                          );

	cpe.generate_trellis           (cpm.trellis_next_state,
	                                cpm.trellis_related_wave_form    );
	cpe.generate_anti_trellis      (cpm.anti_trellis_original_state,
	                                cpm.anti_trellis_input_transition);

	generate_baseband              (                                 );
	generate_projection            (                                 );<commit_msg>Cosmetics.<commit_after>#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif

#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctgmath>

#include "Tools/Math/matrix.h"
#include "Modulator_CPM.hpp"

template <typename B, typename R, typename Q, proto_max<Q> MAX>
Modulator_CPM<B,R,Q,MAX>
::Modulator_CPM(int  N,
                int  bits_per_symbol,
                int  sampling_factor,
                std::string cpm_std,
                int  cpm_L,
                int  cpm_k,
                int  cpm_p,
                std::string mapping,
                std::string wave_shape,
                R    sigma,
                bool no_sig2,
                int  n_frames,
                const std::string name)
: Modulator<B,R,Q>(N, 0, 0, n_frames, name      ), // TODO: hack
  sigma     (sigma                              ),
  no_sig2   (no_sig2                            ),
  cpm       (cpm_std,
             cpm_L,
             cpm_k,
             cpm_p,
             bits_per_symbol,
             sampling_factor,
             "TOTAL",
             wave_shape                         ),
  cpm_h     ((R)cpm.k/(R)cpm.p                  ),
  T_samp    ((R)1.0  /(R)cpm.s_factor           ),
  baseband  (cpm.max_wa_id * cpm.s_factor *2,  0),
  projection(cpm.max_wa_id * cpm.s_factor *2,  0),
  n_sy      (N/cpm.n_b_per_s                    ),
  n_sy_tl   (n_sy+cpm.tl                        ),
  cpe       (n_sy, cpm, this->n_frames          ),
  bcjr      (cpm, n_sy_tl                       )
{
	assert(N%bits_per_symbol == 0);

	// write the right buffers sizes
	int* N_mod_writable = const_cast<int*>(&this->N_mod     );
	*N_mod_writable     = get_buffer_size_after_modulation(N);
	int* N_fil_writable = const_cast<int*>(&this->N_fil     );
	*N_fil_writable     = get_buffer_size_after_filtering(N );

	// initialize CPM
	cpe.generate_allowed_states    (cpm.allowed_states               );
	cpe.generate_allowed_wave_forms(cpm.allowed_wave_forms           );

	cpe.generate_mapper            (cpm.transition_to_binary,
	                                cpm.binary_to_transition,
	                                mapping                          );

	cpe.generate_trellis           (cpm.trellis_next_state,
	                                cpm.trellis_related_wave_form    );
	cpe.generate_anti_trellis      (cpm.anti_trellis_original_state,
	                                cpm.anti_trellis_input_transition);

	generate_baseband              (                                 );
	generate_projection            (                                 );
{'fraction_non_alphanumeric': 0.09132859065564315, 'fraction_numerical': 0.004614497212074601, 'mean_word_length': 1.3928242870285188, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6708545', 'n_tokens_mistral': 1783, 'n_tokens_neox': 1695, 'n_words': 270}