<commit_before>#ifndef COMPLEX_FIXED_POINT_H
#define COMPLEX_FIXED_POINT_H

#include <complex>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <stdexcept>
#include "FixedPoint.h"


/* TODO: Perhaps throw exceptions in addition to or in place of
 * assertions.
 */

/* TODO: Add support for a binary point. This would necessitate
 * overloading various operations to adjust it. Could also
 * add methods to convert to floating-point types.
 */

class SizeMismatchException : public std::runtime_error
{
public: SizeMismatchException(void) :
	std::runtime_error("Size of lhs and rhs of assignment must match") {};
};

class ComplexFixedPoint : public std::complex<std::int64_t>
{
public:

	ComplexFixedPoint(void)
	{
		ComplexFixedPoint(std::complex<int64_t>(0, 0), DEFAULT_WIDTH, true);
	}

	ComplexFixedPoint(std::int64_t r, std::int64_t i, unsigned int width, bool widthMutable = false)
	{
		ComplexFixedPoint(std::complex<int64_t>(r, i), width, widthMutable);
	}

	ComplexFixedPoint(std::complex<int64_t> &c, unsigned int width, bool widthMutable = false)
		: std::complex<int64_t>(c)
	{
		setWidth(width);
		checkSize();
	}

	static const int MAX_WIDTH = 64;
	static const int DEFAULT_WIDTH = 8;

	int width(void) const { return m_width; }
	int64_t minVal(void) const { return m_minVal; }
	int64_t maxVal(void) const { return m_maxVal; }


	ComplexFixedPoint &operator = (const ComplexFixedPoint &rhs)
	{
		/* Only allow width copy on assignment when default constructor was used */
		if (m_widthMutable)
		{<commit_msg>Fixed bug in constructors: Chaining not allowed<commit_after>#ifndef COMPLEX_FIXED_POINT_H
#define COMPLEX_FIXED_POINT_H

#include <complex>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <stdexcept>
#include "FixedPoint.h"


/* TODO: Perhaps throw exceptions in addition to or in place of
 * assertions.
 */

/* TODO: Add support for a binary point. This would necessitate
 * overloading various operations to adjust it. Could also
 * add methods to convert to floating-point types.
 */

class SizeMismatchException : public std::runtime_error
{
public: SizeMismatchException(void) :
	std::runtime_error("Size of lhs and rhs of assignment must match") {};
};

class ComplexFixedPoint : public std::complex<std::int64_t>
{
public:

	ComplexFixedPoint(void)
		: m_widthMutable(true)
	{
		setWidth(8);
		checkSize();
	}

	ComplexFixedPoint(std::int64_t r, std::int64_t i, unsigned int width, bool widthMutable = false)
		: std::complex<int64_t>(r, i),
		m_widthMutable(widthMutable)
	{
		setWidth(width);
		checkSize();
	}

	ComplexFixedPoint(std::complex<int64_t> &c, unsigned int width, bool widthMutable = false)
		: std::complex<int64_t>(c)
	{
		setWidth(width);
		checkSize();
	}

	static const int MAX_WIDTH = 64;
	static const int DEFAULT_WIDTH = 8;

	int width(void) const { return m_width; }
	int64_t minVal(void) const { return m_minVal; }
	int64_t maxVal(void) const { return m_maxVal; }


	ComplexFixedPoint &operator = (const ComplexFixedPoint &rhs)
	{
		/* Only allow width copy on assignment when default constructor was used */
		if (m_widthMutable)
		{
{'fraction_non_alphanumeric': 0.10763334397955925, 'fraction_numerical': 0.013733631427658896, 'mean_word_length': 5.177514792899408, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, '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': '1178415', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1022, 'n_words': 298}