void Fourier (COMPLEX *in, int n, COMPLEX *out) { unsigned r; if ((r = Radix (n)) < n) split (in, r, n / r, out); join (in, n / r, n, out); }
SuperNumber<integerType>::SuperNumber(const std::string &value, unsigned short radix) : SuperNumber<integerType>() { if (radix > 36) { throw std::out_of_range("The radix was " + std::to_string(radix) + ". That is bigger than 36. The maxiumum radix."); } else if (radix < 2) { throw std::out_of_range("The radix was " + std::to_string(radix) + ". That is less than 2. The minimum radix."); } std::map<char, SuperNumber<integerType>> allowedCharacters; SuperNumber<integerType> minus1(-1); char i; for (i = 0; i < 10; i++) { allowedCharacters['0' + i] = i; } for (i = 10; i < radix; i++) { allowedCharacters['7' + i] = i; allowedCharacters['W' + i] = i; } allowedCharacters['.'] = minus1; std::map<char, SuperNumber<integerType>>::const_iterator it; std::map<char, SuperNumber<integerType>>::const_iterator end(allowedCharacters.end()); size_t stringSize = value.size(); bool commaFound = false; SuperNumber<integerType> Radix(radix); SuperNumber<integerType> Divisor(1); for (size_t i = 0; i < stringSize; i++) { it = allowedCharacters.find(value[i]); if (it != end) { if (commaFound) { if (it->second == minus1) { throw invalid_argument("\"" + value + "\" could not be parsed as a number!"); } Divisor *= Radix; *this += it->second / Divisor; } else { if (it->second == minus1) { commaFound = true; } else{ *this *= Radix; *this += it->second; } } } else { throw invalid_argument("\"" + value + "\" could not be parsed as a number!"); } } }