mirror of
https://github.com/TomHarte/CLK.git
synced 2025-03-13 03:31:30 +00:00
Removers Factors.hpp; now this is a C++17 project.
This commit is contained in:
parent
1b4b6b0aee
commit
98daad45c7
@ -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 */
|
@ -8,8 +8,6 @@
|
||||
|
||||
#include "DiskController.hpp"
|
||||
|
||||
#include "../../../Numeric/Factors.hpp"
|
||||
|
||||
using namespace Storage::Disk;
|
||||
|
||||
Controller::Controller(Cycles clock_rate) :
|
||||
|
@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
#include "PCMTrack.hpp"
|
||||
#include "../../../Numeric/Factors.hpp"
|
||||
#include "../../../Outputs/Log.hpp"
|
||||
|
||||
using namespace Storage::Disk;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
#include "Tape.hpp"
|
||||
#include "../../Numeric/Factors.hpp"
|
||||
|
||||
using namespace Storage::Tape;
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
#include "TimedEventLoop.hpp"
|
||||
#include "../Numeric/Factors.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
Loading…
x
Reference in New Issue
Block a user