1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-09 17:29:36 +00:00

Removers Factors.hpp; now this is a C++17 project.

This commit is contained in:
Thomas Harte 2020-01-19 23:18:59 -05:00
parent 1b4b6b0aee
commit 98daad45c7
6 changed files with 3 additions and 40 deletions

View File

@ -1,32 +0,0 @@
//
// Factors.hpp
// Clock Signal
//
// Created by Thomas Harte on 29/07/2016.
// Copyright 2016 Thomas Harte. All rights reserved.
//
#ifndef Factors_hpp
#define Factors_hpp
#include <numeric>
#include <utility>
namespace Numeric {
/*!
@returns The greatest common divisor of @c a and @c b.
*/
template<class T> T greatest_common_divisor(T a, T b) {
return std::gcd(a, b);
}
/*!
@returns The least common multiple of @c a and @c b computed indirectly via the greatest
common divisor.
*/
template<class T> T least_common_multiple(T a, T b) {
return std::lcm(a, b);
}
}
#endif /* Factors_hpp */

View File

@ -8,8 +8,6 @@
#include "DiskController.hpp"
#include "../../../Numeric/Factors.hpp"
using namespace Storage::Disk;
Controller::Controller(Cycles clock_rate) :

View File

@ -7,7 +7,6 @@
//
#include "PCMTrack.hpp"
#include "../../../Numeric/Factors.hpp"
#include "../../../Outputs/Log.hpp"
using namespace Storage::Disk;

View File

@ -9,10 +9,10 @@
#ifndef Storage_hpp
#define Storage_hpp
#include "../Numeric/Factors.hpp"
#include <cmath>
#include <cstdint>
#include <limits>
#include <numeric>
namespace Storage {
@ -39,7 +39,7 @@ struct Time {
and @c clock_rate.
*/
void simplify() {
unsigned int common_divisor = Numeric::greatest_common_divisor(length, clock_rate);
unsigned int common_divisor = std::gcd(length, clock_rate);
length /= common_divisor;
clock_rate /= common_divisor;
}
@ -229,7 +229,7 @@ struct Time {
}
if(long_length > std::numeric_limits<unsigned int>::max() || long_clock_rate > std::numeric_limits<unsigned int>::max()) {
uint64_t common_divisor = Numeric::greatest_common_divisor(long_length, long_clock_rate);
uint64_t common_divisor = std::gcd(long_length, long_clock_rate);
long_length /= common_divisor;
long_clock_rate /= common_divisor;

View File

@ -7,7 +7,6 @@
//
#include "Tape.hpp"
#include "../../Numeric/Factors.hpp"
using namespace Storage::Tape;

View File

@ -7,7 +7,6 @@
//
#include "TimedEventLoop.hpp"
#include "../Numeric/Factors.hpp"
#include <algorithm>
#include <cassert>