diff --git a/.codecov.yml b/.codecov.yml index 2050e87..e65aa79 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -4,3 +4,4 @@ ignore: - "doc/**" - "external/**" - "test/**" + "bench/**" diff --git a/.gitignore b/.gitignore index 76ec543..09f38b7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ CMakeFiles/ CMakeScripts/ CTestTestfile.cmake cmake_install.cmake +.vscode/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 3827831..a36f644 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,4 +58,4 @@ matrix: - os: osx script: - - cmake -DBENCH=OFF -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" . && make && make test + - cmake -DCMAKE_BUILD_TYPE=Debug -DREAL_BENCH=OFF -G "Unix Makefiles" . && make -j`nproc` && make -j`nproc` test diff --git a/CMakeLists.txt b/CMakeLists.txt index 5415334..8f470ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ IF(CMAKE_BUILD_TYPE MATCHES Debug) message("debug mode adding coverage report tools and flags") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules") include(CodeCoverage) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} -Wall -g -O0 -fprofile-arcs -ftest-coverage") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} -Wall -g -O0 -fsanitize=address -fno-omit-frame-pointer -fprofile-arcs -ftest-coverage") ENDIF(CMAKE_BUILD_TYPE MATCHES Debug) # Check for standard to use @@ -20,34 +20,31 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic --std=c++1z") endif() -#Detect Boost.Test framework -set(Boost_USE_MULTITHREADED OFF) -find_package(Boost COMPONENTS unit_test_framework REQUIRED) - -include_directories(include external/include test/include ${Boost_INCLUDE_DIRS}) +include_directories(include external/include ${Boost_INCLUDE_DIRS}) # add Boost.Real as a 'linkable' target add_library(Boost.Real INTERFACE) -# Unit tests -enable_testing() -FILE(GLOB TestSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test/*_test.cpp) -foreach(testSrc ${TestSources}) - get_filename_component(testName ${testSrc} NAME_WE) - add_executable(${testName} test/main-test.cpp ${testSrc}) - add_test(${testName} ${testName}) -endforeach(testSrc) #Library Headers add_executable(Boost.Real_headers include) set_target_properties(Boost.Real_headers PROPERTIES EXCLUDE_FROM_ALL TRUE EXCLUDE_FROM_DEFAULT_BUILD TRUE - LINKER_LANGUAGE CXX) - -#Google Benchmark, turn on/off with -DBENCH=ON or OFF -find_package(Threads REQUIRED) -option(BENCH "Build benchmarks" ON) -if(BENCH) + LINKER_LANGUAGE CXX + ) +# Unit tests +option(REAL_TEST "Build tests" ON) +if(REAL_TEST) + enable_testing() + #Detect Boost.Test framework + set(Boost_USE_MULTITHREADED OFF) + find_package(Boost COMPONENTS unit_test_framework REQUIRED) + add_subdirectory(test) +endif() + +#Google Benchmark, turn on/off with -DREAL_BENCH=ON or OFF +option(REAL_BENCH "Build benchmarks" OFF) +if(REAL_BENCH) add_subdirectory(bench) endif() diff --git a/bench/CMakeLists.txt b/bench/CMakeLists.txt index 65015d2..79d271e 100644 --- a/bench/CMakeLists.txt +++ b/bench/CMakeLists.txt @@ -1,18 +1,19 @@ set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Suppressing benchmark's tests" FORCE) add_subdirectory(benchmark) -include_directories(benchmark/include - include) -set(bench_list - addition_bench.cpp +# remember to add src's here +set(benchSrcs + operation_tree_bench.cpp + main_bench.cpp ) - -add_executable(main_bench ${bench_list}) - - -target_link_libraries(main_bench - benchmark - Boost.Real - ${CMAKE_THREAD_LIBS_INIT} +# to run a subset of benchmarks, use: +# ./main_bench --benchmark_filter= +add_executable(main_bench ${benchSrcs}) +target_include_directories(main_bench + PRIVATE ./include + ) +target_link_libraries(main_bench + PUBLIC Boost.Real + PUBLIC benchmark ) diff --git a/bench/addition_bench.cpp b/bench/addition_bench.cpp deleted file mode 100644 index 6cd1fa6..0000000 --- a/bench/addition_bench.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include -#include - -// this process uses an absurd amount of memory -// sums 10,000 reals, then evaluates. -static void BM_RealAddition10000(benchmark::State& state) { - boost::real::real a ("1.2"); - boost::real::real c ("0"); - - for (auto i : state) - for (int i = 0; i < 10000; i++) - c += a; - std::cout << c << '\n'; -} -BENCHMARK(BM_RealAddition10000); - -BENCHMARK_MAIN(); diff --git a/bench/include/benchmark_helpers.hpp b/bench/include/benchmark_helpers.hpp new file mode 100644 index 0000000..c873a32 --- /dev/null +++ b/bench/include/benchmark_helpers.hpp @@ -0,0 +1,17 @@ +#include + + +class NullBuffer : public std::streambuf +{ + public: + int overflow(int c) { return c; } +}; + +class NullStream: public std::ostream +{ + public: + NullStream() : std::ostream(&sb) {} + + private: + NullBuffer sb; +}; diff --git a/bench/include/bench_helpers.hpp b/bench/main_bench.cpp similarity index 56% rename from bench/include/bench_helpers.hpp rename to bench/main_bench.cpp index 2043a3d..4805d5f 100644 --- a/bench/include/bench_helpers.hpp +++ b/bench/main_bench.cpp @@ -1,10 +1,7 @@ -#ifndef BOOST_REAL_BENCH_HELPERS_HPP -#define BOOST_REAL_BENCH_HELPERS_HPP - - +#include #include unsigned int boost::real::real::maximum_precision = 10; unsigned int boost::real::real_algorithm::maximum_precision = 10; -#endif //BOOST_REAL_BENCH_HELPERS_HPP +BENCHMARK_MAIN(); diff --git a/bench/operation_tree_bench.cpp b/bench/operation_tree_bench.cpp new file mode 100644 index 0000000..d74b60c --- /dev/null +++ b/bench/operation_tree_bench.cpp @@ -0,0 +1,52 @@ +#include +#include +#include + +/** @file benchmark the operation trees, + * with different kinds of leaves, and/or a large number of nodes. + */ + +// constants used in the benchmarks +const int MIN_TREE_SIZE = 8; +const int MAX_TREE_SIZE = 16; + +// used to force evaluation, without console output +NullStream null_stream; + +// trees between MIN_TREE_SIZE and MAX_TREE_SIZE of single operations +static void BM_RealAdditionTree(benchmark::State& state) { + boost::real::real a ("1.2"); + boost::real::real c ("0"); + + for (auto i : state) + for (int i = 0; i < state.range(0); i++) + c += a; + null_stream << c << '\n'; +} +BENCHMARK(BM_RealAdditionTree)->Range(MIN_TREE_SIZE,MAX_TREE_SIZE)->Unit(benchmark::kMillisecond); + +static void BM_RealSubtractionTree(benchmark::State& state) { + boost::real::real a ("1"); + boost::real::real c ("9999"); + + for (auto i : state) + { + for (int i = 0; i < state.range(0); i++) + c -= a; + null_stream << c << '\n'; + } +} +BENCHMARK(BM_RealSubtractionTree)->Range(MIN_TREE_SIZE,MAX_TREE_SIZE)->Unit(benchmark::kMillisecond); + +static void BM_RealMultiplicationTree(benchmark::State& state) { + boost::real::real a ("1"); + boost::real::real c ("9"); + + for (auto i : state) + { + for (int i = 0; i < state.range(0); i++) + c *= a; + null_stream << c << '\n'; + } +} +BENCHMARK(BM_RealMultiplicationTree)->Range(MIN_TREE_SIZE,MAX_TREE_SIZE)->Unit(benchmark::kMillisecond); diff --git a/include/real/boundary.hpp b/include/real/boundary.hpp index 55628d6..dfe9d45 100644 --- a/include/real/boundary.hpp +++ b/include/real/boundary.hpp @@ -52,7 +52,7 @@ namespace boost { if (this->positive) { if (this->exponent == other.exponent) { - return boost::real::helper::aligned_vectors_is_lower(this->digits, + return boost::real::boundary_helper::aligned_vectors_is_lower(this->digits, other.digits); } @@ -60,7 +60,7 @@ namespace boost { } if (this->exponent == other.exponent) { - return boost::real::helper::aligned_vectors_is_lower(other.digits, + return boost::real::boundary_helper::aligned_vectors_is_lower(other.digits, this->digits); } @@ -82,14 +82,14 @@ namespace boost { if (this->positive) { if (this->exponent == other.exponent) { - return boost::real::helper::aligned_vectors_is_lower(other.digits, this->digits); + return boost::real::boundary_helper::aligned_vectors_is_lower(other.digits, this->digits); } return this->exponent > other.exponent; } if (this->exponent == other.exponent) { - return boost::real::helper::aligned_vectors_is_lower(this->digits, other.digits); + return boost::real::boundary_helper::aligned_vectors_is_lower(this->digits, other.digits); } return other.exponent > this->exponent; @@ -194,7 +194,7 @@ namespace boost { * @param digit - The new digit to add. */ void push_front(int digit) { - this->digits.insert(this->digits.begin(), digit); + this->digits.insert(this->digits.cbegin(), digit); } /** @@ -203,7 +203,7 @@ namespace boost { */ void normalize() { while (this->digits.size() > 1 && this->digits.front() == 0) { - this->digits.erase(this->digits.begin()); + this->digits.erase(this->digits.cbegin()); this->exponent--; } @@ -224,7 +224,7 @@ namespace boost { */ void normalize_left() { while (this->digits.size() > 1 && this->digits.front() == 0) { - this->digits.erase(this->digits.begin()); + this->digits.erase(this->digits.cbegin()); this->exponent--; } } diff --git a/include/real/boundary_helper.hpp b/include/real/boundary_helper.hpp index ae4b242..b886e5d 100644 --- a/include/real/boundary_helper.hpp +++ b/include/real/boundary_helper.hpp @@ -2,11 +2,12 @@ #define BOOST_REAL_BOUNDARY_HELPER_HPP #include -#include "interval.hpp" +#include namespace boost { namespace real { - namespace helper { + class boundary_helper { + public: /** * @author Laouen Mayal Louan Belloli @@ -22,7 +23,7 @@ namespace boost { * @return a bool that is true if and only if, the number represented by lsh is lower than * the represented number by rhs. */ - bool aligned_vectors_is_lower(const std::vector &lhs, const std::vector &rhs) { + static bool aligned_vectors_is_lower(const std::vector &lhs, const std::vector &rhs) { // Check if lhs is lower than rhs auto lhs_it = lhs.cbegin(); @@ -42,7 +43,7 @@ namespace boost { return lhs_all_zero && !rhs_all_zero; } - } + }; } } diff --git a/include/real/const_precision_iterator.hpp b/include/real/const_precision_iterator.hpp new file mode 100644 index 0000000..678a1a2 --- /dev/null +++ b/include/real/const_precision_iterator.hpp @@ -0,0 +1,395 @@ +#ifndef BOOST_CONST_PRECISION_ITERATOR_HPP +#define BOOST_CONST_PRECISION_ITERATOR_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { + namespace real{ + /** + * @file The const_precision_iterator provides the functionality to iterate through precision intervals + * of all three kinds of reals + * + * @note variant and visit/visitors are used extensively in this implementation + * @TODO: consider doing traversals to lower the demands of recursion + * @sa documention on std::variant, std::visit + */ + template struct overloaded : Ts... { using Ts::operator()...; }; + template overloaded(Ts...) -> overloaded; + // fwd decl + class real; + + // same typedef is also found in real_data.hpp + typedef std::variant real_number; + + /// the default max precision to use if the user hasn't provided one. + const unsigned int DEFAULT_MAX_PRECISION = 10; + + class const_precision_iterator { + public: + /** + * @brief Determines the maximum precision to use + */ + static std::optional maximum_precision; + + /// @TODO look into STL-style iterators + // typedef std::forward_iterator_tag iterator_category; + // typedef void difference_type (?); + // typedef ??? value_type + // typedef const value_type& reference (?) not necessary because const + // typedef const value_type* pointer + + private: + /** + * @brief this holds a ptr to explicit number, algorithmic number, or real_operation + */ + // raw pointer here is ok, precision iterator is always attached to the variant it points to + // (refer to real_data.hpp). Any time the variant is destroyed, so is this pointer. + real_number * _real_ptr; + + /// current iterator precision + int _precision; + + /// local max precision, is used if set to > 0 by user + unsigned int _maximum_precision = 0; + + interval _approximation_interval; + + void check_and_swap_boundaries() { + std::visit( overloaded { // perform operation on whatever is held in variant + [this] (real_explicit& real) { + if (!real.positive()) { + this->_approximation_interval.swap_bounds(); + } + }, + [this] (real_algorithm& real) { + if (!real.positive()) { + this->_approximation_interval.swap_bounds(); + } + }, + [] (real_operation& real) { + throw boost::real::bad_variant_access_exception(); + }, + [] (auto& real) { + throw boost::real::bad_variant_access_exception(); + } + }, *_real_ptr); + } + + public: + /** + * @brief Returns the maximum allowed precision, if that precision is reached and an + * operator needs more precision, a precision_exception should be thrown. + * + * @return an unsigned integer with the maximum allowed precision, which was either + * given by the user, or some default value. + * + * @details The user may set the maximum precision for any specific precision iterator. + * They may also set a general maximum precision (the static optional value). + * Preference is given: _maximum_precision > maximum_precision > DEFAULT_MAX_PRECISION + */ + unsigned int max_precision() const { + if((_maximum_precision == 0) && !(maximum_precision)) + return DEFAULT_MAX_PRECISION; + else if (_maximum_precision == 0) + return maximum_precision.value(); + else + return _maximum_precision; + } + + void set_maximum_precision(unsigned int maximum_precision) { + this->_maximum_precision = maximum_precision; + } + + /** + * @brief *Default constructor:* + * Constructs an empty real::const_precision_iterator that points to nullptr. + */ + const_precision_iterator() = default; + + /** + * @brief *Copy constructor:* Construct a new real::const_precision_iterator + * which is a copy of the other iterator. + * + * @param other - the real::const_precision_iterator to copy. + */ + const_precision_iterator(const const_precision_iterator& other) = default; + + + // fwd decl'd. Definition found in real_data.hpp + void update_operation_boundaries(real_operation &ro); + + /** + * @brief Constructor for the least precise precision iterator + */ + explicit const_precision_iterator(real_number * a) : _real_ptr(a), _precision(1) { + std::visit( overloaded { // perform operation on whatever is held in variant + [this] (real_explicit& real) { + this->_approximation_interval.lower_bound.exponent = real.exponent(); + this->_approximation_interval.upper_bound.exponent = real.exponent(); + this->_approximation_interval.lower_bound.positive = real.positive(); + this->_approximation_interval.upper_bound.positive = real.positive(); + + int first_digit = real.digits()[0]; + this->_approximation_interval.lower_bound.digits.push_back(first_digit); + + if (first_digit == 9) { + this->_approximation_interval.upper_bound.digits.push_back(1); + this->_approximation_interval.upper_bound.exponent++; + } else if (this->_precision < (int)real.digits().size()) { + this->_approximation_interval.upper_bound.digits.push_back(first_digit + 1); + } else { + this->_approximation_interval.upper_bound.digits.push_back(first_digit); + } + this->check_and_swap_boundaries(); + }, + + [this] (real_algorithm& real) { + this->_approximation_interval.lower_bound.exponent = real.exponent(); + this->_approximation_interval.upper_bound.exponent = real.exponent(); + this->_approximation_interval.lower_bound.positive = real.positive(); + this->_approximation_interval.upper_bound.positive = real.positive(); + + int first_digit = real[0]; + this->_approximation_interval.lower_bound.digits.push_back(first_digit); + + if (first_digit == 9) { + this->_approximation_interval.upper_bound.digits.push_back(1); + this->_approximation_interval.upper_bound.exponent++; + } else { + this->_approximation_interval.upper_bound.digits.push_back(first_digit + 1); + } + this->check_and_swap_boundaries(); + }, + + [this] (real_operation& real) { + // we don't need to init operands here - they *SHOULD* already be at cbegin or > + update_operation_boundaries(real); + }, + [] (auto& real) { + throw boost::real::bad_variant_access_exception(); + } + }, *_real_ptr); + } + + // fwd decl, defined in real_data.hpp + void init_operation_itr(real_operation &ro, bool cend); + + /** + * @brief Constructor for max_precision precision iterator, from real_number + */ + explicit const_precision_iterator(real_number * a, bool cend) : _real_ptr(a) { + if (cend) { + std::visit( overloaded { // perform operation on whatever is held in variant + [this, &a] (real_explicit& real) { + *this = const_precision_iterator(a); + this->iterate_n_times((int)real.digits().size() + 1); + }, + [this, &a] (real_algorithm& real) { + *this = const_precision_iterator(a); + this->iterate_n_times(this->max_precision() - 1); + }, + [this] (real_operation& real) { + init_operation_itr(real, true); + update_operation_boundaries(real); + }, + [] (auto & real) { + throw boost::real::bad_variant_access_exception(); + } + }, *_real_ptr); + } else { + *this = const_precision_iterator(a); + } + } + + const_precision_iterator cbegin() const { + return const_precision_iterator(_real_ptr); + } + + /** + * @brief Construct a new boost::real::const_precision_iterator that iterates the number + * approximation intervals in increasing order according to the approximation precision. + * + * The iterator starts pointing the interval with the maximum allowed precision. + * + * @return a boost::real::const_precision_iterator of the number. + */ + const_precision_iterator cend() const { + const_precision_iterator it(*this); + it.iterate_n_times(this->max_precision() - 1); + return it; + } + + interval get_interval() const { + return _approximation_interval; + } + + // fwd decl, defined in real_data.hpp + void operation_iterate(real_operation &ro); + + /** + * @brief It recalculates the approximation interval boundaries increasing the used + * precision, the new pointed approximation interval is smaller than the current one. + */ + void operator++() { + std::visit( overloaded { // perform operation on whatever is held in variant + [this] (real_explicit& real) { + this->iterate_n_times(1); + }, + [this] (real_algorithm& real) { + this->iterate_n_times(1); + }, + [this] (real_operation& real) { + operation_iterate(real); + }, + [] (auto& real) { + throw boost::real::bad_variant_access_exception(); + } + }, *_real_ptr); + } + + // fwd decl, defined in real_data.hpp + void operation_iterate_n_times(real_operation &ro, int n); + + void iterate_n_times(int n) { + std::visit( overloaded { // perform operation on whatever is held in variant + [this, &n] (real_explicit& real) { + if (this->_precision >= (int)real.digits().size()) { + return; + } + + // If the number is negative, boundaries are interpreted as mirrored: + // First, the operation is made as positive, and after boundary calculation + // boundaries are swapped to come back to the negative representation. + this->check_and_swap_boundaries(); + + // If the explicit number just reaches the full precision (the end) + // then set both boundaries are equals. + if (this->_precision + n >= (int)real.digits().size()) { + + for(int i = this->_precision; i < (int)real.digits().size(); i++) { + this->_approximation_interval.lower_bound.push_back(real.digits()[i]); + } + this->_approximation_interval.upper_bound = this->_approximation_interval.lower_bound; + + + } else { + + // If the explicit number didn't reaches the full precision (the end) + // then the number interval is defined by truncation. + + for(int i = 0; i < n; i++) { + this->_approximation_interval.lower_bound.push_back(real.digits()[this->_precision]); + } + + this->_approximation_interval.upper_bound.clear(); + this->_approximation_interval.upper_bound.digits.resize(this->_approximation_interval.lower_bound.size()); + + int carry = 1; + for (int i = (int)this->_approximation_interval.lower_bound.size() - 1; i >= 0; --i) { + if (this->_approximation_interval.lower_bound[i] + carry == 10) { + this->_approximation_interval.upper_bound[i] = 0; + } else { + this->_approximation_interval.upper_bound[i] = this->_approximation_interval.lower_bound[i] + carry; + carry = 0; + } + } + + if (carry > 0) { + this->_approximation_interval.upper_bound.push_front(carry); + this->_approximation_interval.upper_bound.exponent = this->_approximation_interval.lower_bound.exponent + 1; + } else { + this->_approximation_interval.upper_bound.exponent = this->_approximation_interval.lower_bound.exponent; + } + } + + // Left normalization of boundaries representation + this->_approximation_interval.lower_bound.normalize_left(); + this->_approximation_interval.upper_bound.normalize_left(); + + this->check_and_swap_boundaries(); + this->_precision = std::min(this->_precision + n, (int)real.digits().size()); + }, + [this, &n] (real_algorithm& real) { + // If the number is negative, bounds are interpreted as mirrored: + // First, the operation is made as positive, and after bound calculation + // bounds are swapped to come back to the negative representation. + this->check_and_swap_boundaries(); + + for (int i = 0; i < n; i++) { + this->_approximation_interval.lower_bound.push_back((real)[this->_precision + i]); + } + + this->_approximation_interval.upper_bound.clear(); + this->_approximation_interval.upper_bound.digits.resize(this->_approximation_interval.lower_bound.size()); + int carry = 1; + for (int i = (int)this->_approximation_interval.lower_bound.size() - 1; i >= 0; --i) { + if (this->_approximation_interval.lower_bound[i] + carry == 10) { + this->_approximation_interval.upper_bound[i] = 0; + } else { + this->_approximation_interval.upper_bound[i] = this->_approximation_interval.lower_bound[i] + carry; + carry = 0; + } + } + + if (carry > 0) { + this->_approximation_interval.upper_bound.push_front(carry); + this->_approximation_interval.upper_bound.exponent = this->_approximation_interval.lower_bound.exponent + 1; + } else { + this->_approximation_interval.upper_bound.exponent = this->_approximation_interval.lower_bound.exponent; + } + + // Left normalization of boundaries representation + this->_approximation_interval.lower_bound.normalize_left(); + this->_approximation_interval.upper_bound.normalize_left(); + + this->check_and_swap_boundaries(); + this->_precision += n; + }, + [this, &n] (real_operation& real) { + operation_iterate_n_times(real, n); + }, + [] (auto & real) { + throw boost::real::bad_variant_access_exception(); + } + }, *_real_ptr); + } + + /** + * @brief It compares by value equality; two real::const_precision_iterators + * are equals if they are pointing to the same real number and are in the same precision iteration. + * + * @param other - A real::const_precision_iterator that is the right side operand + * @return a bool that is true if and only if both iterators are equals. + */ + bool operator==(const const_precision_iterator& other) const{ + // uninitialized iterators are never equals + if (this->_real_ptr == nullptr || other._real_ptr == nullptr) { + return false; + } + + return (other._real_ptr == this->_real_ptr) && (other._approximation_interval == this->_approximation_interval); + } + + /** + * @brief It compares by value not equal; two real::const_precision_iterators. + * + * @param other - A real::const_precision_iterator that is the right side operand + * @return a bool that is true if and only if both iterators are not equals. + */ + bool operator!=(const const_precision_iterator& other) const { + return !(*this == other); + } + }; + } +} + +#endif // BOOST_CONST_PRECISION_ITERATOR_HPP diff --git a/include/real/interval.hpp b/include/real/interval.hpp index d4b9151..18fc48a 100644 --- a/include/real/interval.hpp +++ b/include/real/interval.hpp @@ -118,12 +118,14 @@ namespace boost { bool is_a_number() const { return this->lower_bound == this->upper_bound; } + + friend std::ostream& operator<<(std::ostream& os, const boost::real::interval& interval) { + return os << interval.as_string(); + } + }; } } -std::ostream& operator<<(std::ostream& os, const boost::real::interval& interval) { - return os << interval.as_string(); -} #endif //BOOST_REAL_INTERVAL_HPP diff --git a/include/real/real.hpp b/include/real/real.hpp index a9adccd..fd139bd 100644 --- a/include/real/real.hpp +++ b/include/real/real.hpp @@ -1,17 +1,21 @@ -#ifndef BOOST_REAL_REAL_HPP -#define BOOST_REAL_REAL_HPP +#ifndef BOOST_REAL_HPP +#define BOOST_REAL_HPP #include #include #include -#include #include #include +#include // shared_ptr +#include #include #include #include #include +#include +#include +#include namespace boost { @@ -52,377 +56,17 @@ namespace boost { * operator "==" but for those cases where the class is not able to decide the value of the * result before reaching the maximum precision, a precision_exception is thrown. */ - class real { - - // Available operations - enum class OPERATION {ADDITION, SUBTRACT, MULTIPLICATION}; - enum class KIND {EXPLICIT, OPERATION, ALGORITHM}; - - KIND _kind; - - // Explicit number - real_explicit _explicit_number; - - // Algorithmic number - real_algorithm _algorithmic_number; - - // Composed number - OPERATION _operation; - real* _lhs_ptr = nullptr; - real* _rhs_ptr = nullptr; + - // Precision - unsigned int _maximum_precision = 0; - - void copy_operands(const real& other) { - if (other._lhs_ptr != nullptr) { - this->_lhs_ptr = new real(*other._lhs_ptr); - } - - if (other._rhs_ptr != nullptr) { - this->_rhs_ptr = new real(*other._rhs_ptr); - } - } + class real { + private: + std::shared_ptr _real_p; + public: - /** - * @brief Determines the maximum precision to use - */ - static std::optional maximum_precision; - - /** - * @author Laouen Mayal Louan Belloli - * - * @brief is a forward iterator that iterates a boost::real::real number approximation - * intervals. The iterator calculates the initial interval with the initial precision and - * then it increases the precision in each iteration (++) and recalculates the interval. - */ - class const_precision_iterator { - private: - - // Internal number to iterate - real const* _real_ptr = nullptr; - - // Explicit number iterator - boost::real::real_explicit::const_precision_iterator _explicit_it; - - // Algorithmic number iterator - boost::real::real_algorithm::const_precision_iterator _algorithmic_it; - - // If the number is a composition, the const_precision_iterator uses the operand iterators - const_precision_iterator* _lhs_it_ptr = nullptr; - const_precision_iterator* _rhs_it_ptr = nullptr; - - void calculate_operation_boundaries() { - - switch (this->_real_ptr->_operation) { - - case OPERATION::ADDITION: - boost::real::helper::add_boundaries( - this->_lhs_it_ptr->approximation_interval.lower_bound, - this->_rhs_it_ptr->approximation_interval.lower_bound, - this->approximation_interval.lower_bound - ); - - boost::real::helper::add_boundaries( - this->_lhs_it_ptr->approximation_interval.upper_bound, - this->_rhs_it_ptr->approximation_interval.upper_bound, - this->approximation_interval.upper_bound - ); - break; - - - case OPERATION::SUBTRACT: - boost::real::helper::subtract_boundaries( - this->_lhs_it_ptr->approximation_interval.lower_bound, - this->_rhs_it_ptr->approximation_interval.upper_bound, - this->approximation_interval.lower_bound - ); - - boost::real::helper::subtract_boundaries( - this->_lhs_it_ptr->approximation_interval.upper_bound, - this->_rhs_it_ptr->approximation_interval.lower_bound, - this->approximation_interval.upper_bound - ); - break; - - - case OPERATION::MULTIPLICATION: { - bool lhs_positive = this->_lhs_it_ptr->approximation_interval.positive(); - bool rhs_positive = this->_rhs_it_ptr->approximation_interval.positive(); - bool lhs_negative = this->_lhs_it_ptr->approximation_interval.negative(); - bool rhs_negative = this->_rhs_it_ptr->approximation_interval.negative(); - - if (lhs_positive && rhs_positive) { // Positive - Positive - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.lower_bound, - this->_rhs_it_ptr->approximation_interval.lower_bound, - this->approximation_interval.lower_bound - ); - - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.upper_bound, - this->_rhs_it_ptr->approximation_interval.upper_bound, - this->approximation_interval.upper_bound - ); - - } else if (lhs_negative && rhs_negative) { // Negative - Negative - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.upper_bound, - this->_rhs_it_ptr->approximation_interval.upper_bound, - this->approximation_interval.lower_bound - ); - - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.lower_bound, - this->_rhs_it_ptr->approximation_interval.lower_bound, - this->approximation_interval.upper_bound - ); - } else if (lhs_negative && rhs_positive) { // Negative - Positive - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.lower_bound, - this->_rhs_it_ptr->approximation_interval.upper_bound, - this->approximation_interval.lower_bound - ); - - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.upper_bound, - this->_rhs_it_ptr->approximation_interval.lower_bound, - this->approximation_interval.upper_bound - ); - - } else if (lhs_positive && rhs_negative) { // Positive - Negative - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.upper_bound, - this->_rhs_it_ptr->approximation_interval.lower_bound, - this->approximation_interval.lower_bound - ); - - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.lower_bound, - this->_rhs_it_ptr->approximation_interval.upper_bound, - this->approximation_interval.upper_bound - ); - - } else { // One is around zero all possible combinations are be tested - - boundary current_boundary; - - // Lower * Lower - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.lower_bound, - this->_rhs_it_ptr->approximation_interval.lower_bound, - current_boundary - ); - - this->approximation_interval.lower_bound = current_boundary; - this->approximation_interval.upper_bound = current_boundary; - - // Upper * upper - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.upper_bound, - this->_rhs_it_ptr->approximation_interval.upper_bound, - current_boundary - ); - - if (current_boundary < this->approximation_interval.lower_bound) { - this->approximation_interval.lower_bound = current_boundary; - } - - if (this->approximation_interval.upper_bound < current_boundary) { - this->approximation_interval.upper_bound = current_boundary; - } - - // Lower * upper - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.lower_bound, - this->_rhs_it_ptr->approximation_interval.upper_bound, - current_boundary - ); - - if (current_boundary < this->approximation_interval.lower_bound) { - this->approximation_interval.lower_bound = current_boundary; - } - - if (this->approximation_interval.upper_bound < current_boundary) { - this->approximation_interval.upper_bound = current_boundary; - } - - // Upper * lower - boost::real::helper::multiply_boundaries( - this->_lhs_it_ptr->approximation_interval.upper_bound, - this->_rhs_it_ptr->approximation_interval.lower_bound, - current_boundary - ); - - if (current_boundary < this->approximation_interval.lower_bound) { - this->approximation_interval.lower_bound = current_boundary; - } - - if (this->approximation_interval.upper_bound < current_boundary) { - this->approximation_interval.upper_bound = current_boundary; - } - } - break; - } - - default: - throw boost::real::none_operation_exception(); - } - } - - public: - - // Number approximation_interval boundaries - boost::real::interval approximation_interval; - - /** - * @brief *Default constructor:* - * Constructs an empty boost::real::real::const_precision_iterator that points to nullptr. - */ - const_precision_iterator() = default; - - /** - * @brief *Copy constructor:* Construct a new boost::real::real::const_precision_iterator - * which is a copy of the other iterator. - * - * @param other - the boost::real::real::const_precision_iterator to copy. - */ - const_precision_iterator(const const_precision_iterator& other) = default; - - /** - * @brief *Pointer constructor:* Construct a new boost::real::real::const_precision_iterator - * pointing to the boost::real::real number to iterate the number approximation intervals. - * - * The iterator will start pointing to the lowest precision interval. - * - * @param real_number - the boost::real::real number to iterate. - */ - explicit const_precision_iterator(real const* real_number) : _real_ptr(real_number) { - - switch (this->_real_ptr->_kind) { - - case KIND::EXPLICIT: - this->_explicit_it = this->_real_ptr->_explicit_number.cbegin(); - this->approximation_interval = this->_explicit_it.approximation_interval; - break; - - case KIND::ALGORITHM: - this->_algorithmic_it = this->_real_ptr->_algorithmic_number.cbegin(); - this->approximation_interval = this->_algorithmic_it.approximation_interval; - break; - - case KIND::OPERATION: - this->_lhs_it_ptr = new const_precision_iterator(this->_real_ptr->_lhs_ptr->cbegin()); - this->_rhs_it_ptr = new const_precision_iterator(this->_real_ptr->_rhs_ptr->cbegin()); - this->calculate_operation_boundaries(); - break; - } - } - - /** - * @brief *Pointer constructor for cend:* Construct a new boost::real::real::const_precision_iterator - * pointing to the boost::real::real number real_number to iterate the number - * approximation intervals. - * - * If the cend parameter is set to true, the iterator will point to the highest - * precision interval allowed by the maximum precision. If is set to false, this - * constructor is equivalent to the Pointer constructor. - * - * @param real_number - the boost::real::real number to iterate. - * @param cend - a bool indicating if the iterator must point the lowest of highest - * precision interval. - */ - explicit const_precision_iterator(real const* real_number, bool cend) : _real_ptr(real_number) { - - switch (this->_real_ptr->_kind) { - - case KIND::EXPLICIT: - if (cend) { - this->_explicit_it = this->_real_ptr->_explicit_number.cend(); - } else { - this->_explicit_it = this->_real_ptr->_explicit_number.cbegin(); - } - this->approximation_interval = this->_explicit_it.approximation_interval; - break; - - case KIND::ALGORITHM: - if (cend) { - this->_algorithmic_it = this->_real_ptr->_algorithmic_number.cend(); - } else { - this->_algorithmic_it = this->_real_ptr->_algorithmic_number.cbegin(); - } - this->approximation_interval = this->_algorithmic_it.approximation_interval; - break; - - case KIND::OPERATION: - this->_lhs_it_ptr = new const_precision_iterator(this->_real_ptr->_lhs_ptr, cend); - this->_rhs_it_ptr = new const_precision_iterator(this->_real_ptr->_rhs_ptr, cend); - this->calculate_operation_boundaries(); - break; - } - } - - /** - * @brief It recalculates the approximation interval boundaries increasing the used - * precision, the new pointed approximation interval is smaller than the current one. - */ - void operator++() { - - switch (this->_real_ptr->_kind) { - - case KIND::EXPLICIT: - ++this->_explicit_it; - this->approximation_interval = this->_explicit_it.approximation_interval; - break; - - case KIND::ALGORITHM: - ++this->_algorithmic_it; - this->approximation_interval = this->_algorithmic_it.approximation_interval; - break; - - case KIND::OPERATION: - // Composed number iteration - this->approximation_interval.lower_bound.clear(); - this->approximation_interval.upper_bound.clear(); - - // Recursive iteration of the operands - ++(*this->_lhs_it_ptr); - ++(*this->_rhs_it_ptr); - - // Final bound calculation - this->calculate_operation_boundaries(); - break; - } - }; - - /** - * @brief It compares by value equality; two boost::real::real::const_precision_iterators - * are equals if they are pointing to the same real number and are in the same precision iteration. - * - * @param other - A boost::real::real::const_precision_iterator that is the right side operand - * @return a bool that is true if and only if both iterators are equals. - */ - bool operator==(const const_precision_iterator& other) const { - // uninitialized iterators are never equals - if (this->_real_ptr == nullptr || other._real_ptr == nullptr) { - return false; - } - - return (other._real_ptr == this->_real_ptr) && (other.approximation_interval == this->approximation_interval); - } - - /** - * @brief It compares by value not equal; two boost::real::real::const_precision_iterators. - * - * @param other - A boost::real::real::const_precision_iterator that is the right side operand - * @return a bool that is true if and only if both iterators are not equals. - */ - bool operator!=(const const_precision_iterator& other) const { - return !(*this == other); - } - }; + /// @TODO: Move constructors to move directly from the ctors in real_explicit to the values in real_data + /// @TODO add ctors for integral / numeric types. Template with enable_if, perhaps? /** * @brief *Default constructor:* Construct a boost::real::real with undefined representation @@ -433,39 +77,31 @@ namespace boost { real() = default; /** - * @brief *Copy constructor:* Creates a copy of the boost::real::real number other, - * if the number is an operation, then, the constructor recursively creates new - * copies of the other operands. + * @brief *Copy constructor:* Creates a copy of the boost::real::real number other * * @param other - the boost::real::real instance to copy. */ - real(const real& other) : - _kind(other._kind), - _explicit_number(other._explicit_number), - _algorithmic_number(other._algorithmic_number), - _operation(other._operation) { this->copy_operands(other); }; + real(const real& other) : _real_p(other._real_p) {}; /** - * @brief *String constructor:* Creates a boost::real::real instance by parsing - * the string. The string must have a valid number, in other case, the constructor - * will throw an boost::real::invalid_string_number exception. + * @brief String constructor * * @param number - a valid string representing a number. * - * @throws boost::real::invalid_string_number exception + * @throws boost::real::invalid_string_number exception if string doesn't represent a valid number */ - real(const std::string& number) - : _kind(KIND::EXPLICIT), _explicit_number(number) {} + real(const std::string& number) : _real_p(std::make_shared(real_explicit(number))) + {}; + /** - * @brief *Initializer list constructor:* Creates a boost::real::real_explicit instance - * that represents an integer number where all the digits parameter numbers are from - * the integer part in the same order. The number is set as positive. + * @brief Initializer list constructor * * @param digits - a initializer_list that represents the number digits. */ real(std::initializer_list digits) - : _kind(KIND::EXPLICIT), _explicit_number(digits, digits.size()) {} + : _real_p(std::make_shared(real_explicit(digits, digits.size()))) + {}; /** @@ -479,7 +115,8 @@ namespace boost { * the number is positive, otherwise is negative. */ real(std::initializer_list digits, bool positive) - : _kind(KIND::EXPLICIT), _explicit_number(digits, digits.size(), positive) {} + : _real_p(std::make_shared(real_explicit(digits, digits.size(), positive))) + {}; /** * @brief *Initializer list constructor with exponent:* Creates a boost::real::real @@ -491,7 +128,8 @@ namespace boost { * @param exponent - an integer representing the number exponent. */ real(std::initializer_list digits, int exponent) - : _kind(KIND::EXPLICIT), _explicit_number(digits, exponent) {}; + : _real_p(std::make_shared(real_explicit(digits, exponent))) + {}; /** * @brief *Initializer list constructor with exponent and sign:* Creates a boost::real::real instance @@ -504,8 +142,9 @@ namespace boost { * @param positive - a bool that represent the number sign. If positive is set to true, * the number is positive, otherwise is negative. */ - real(std::initializer_list digits, int exponent, bool positive) - : _kind(KIND::EXPLICIT), _explicit_number(digits, exponent, positive) {}; + real(::std::initializer_list digits, int exponent, bool positive) + : _real_p(std::make_shared(real_explicit(digits, exponent, positive))) + {}; /** * @brief *Lambda function constructor with exponent:* Creates a boost::real::real @@ -518,7 +157,8 @@ namespace boost { * @param exponent - an integer representing the number exponent. */ real(int (*get_nth_digit)(unsigned int), int exponent) - : _kind(KIND::ALGORITHM), _algorithmic_number(get_nth_digit, exponent) {} + : _real_p(std::make_shared(real_algorithm(get_nth_digit, exponent))) + {}; /** * @brief *Lambda function constructor with exponent and sign:* Creates a boost::real::real instance @@ -533,77 +173,44 @@ namespace boost { * @param positive - a bool that represent the number sign. If positive is set to true, * the number is positive, otherwise is negative. */ - real(int (*get_nth_digit)(unsigned int), - int exponent, - bool positive) - : _kind(KIND::ALGORITHM), - _algorithmic_number(get_nth_digit, exponent, positive) {} + real(int (*get_nth_digit)(unsigned int), int exponent, bool positive) + : _real_p(::std::make_shared(real_algorithm(get_nth_digit, exponent, positive))) {}; + + // ctors from the 3 underlying types + real(real_explicit x) : _real_p(std::make_shared(x)) {}; + real(real_algorithm x) : _real_p(std::make_shared(x)) {}; + real(real_operation x) : _real_p(std::make_shared(x)) {}; /** - * @brief *Default destructor:* If the number is an operator, the destructor destroys its operands. + * @brief Default destructor */ - ~real() { - delete this->_lhs_ptr; - this->_lhs_ptr = nullptr; + ~real() = default; - delete this->_rhs_ptr; - this->_rhs_ptr = nullptr; + const real_number& get_real_number() { + return _real_p->get_real_number(); + } + + const_precision_iterator get_real_itr() const { + return _real_p->get_precision_itr(); } /** - * @brief Returns te maximum allowed precision, if that precision is reached and an + * @brief Returns the maximum allowed precision, if that precision is reached and an * operator need more precision, a precision_exception should be thrown. * * @return and integer with the maximum allowed precision. */ unsigned int max_precision() const { - if (this->_maximum_precision == 0) { - if(!boost::real::real::maximum_precision) - throw boost::real::undefined_max_precision_exception(); - return boost::real::real::maximum_precision.value(); - } - - return this->_maximum_precision; + return get_real_itr().max_precision(); } - /** - * @brief Set a new maximum precision for the instance. - * - * @note Setting zero as the maximum precision causes the instance to use the default - * static unsigned int boost::real::real::maximum_precision. - * - * @param maximum_precision - an unsigned int to set as the new precision. - */ + /// set max precision for the underlying iterator void set_maximum_precision(unsigned int maximum_precision) { - this->_maximum_precision = maximum_precision; - } - - /** - * @brief Construct a new boost::real::real::con_precision_iterator that iterates the number - * approximation intervals from in increasing order according to the approximation precision. - * - * The iterator starts pointing the interval with the minimum precision. - * - * @return a boost::real::real::const_precision_iterator of the number. - */ - const_precision_iterator cbegin() const { - return const_precision_iterator(this); - } - - /** - * @brief Construct a new boost::real::real::con_precision_iterator that iterates the number - * approximation intervals from in increasing order according to the approximation precision. - * - * The iterator starts pointing the interval with the maximum allowed precision. - * - * @return a boost::real::real::const_precision_iterator of the number. - */ - const_precision_iterator cend() const { - return const_precision_iterator(this, true); + this->_real_p->get_precision_itr().set_maximum_precision(maximum_precision); } /************** Operators ******************/ - + /** * @brief If the number is an explicit or algorithm number it returns the n-th digit * of the represented number. If the number is an operation it throws an invalid_representation_exception @@ -614,140 +221,131 @@ namespace boost { * @throws boost::real::invalid_representation_exception */ int operator[](unsigned int n) const { - int result; - - switch (this->_kind) { - - case KIND::EXPLICIT: - result = this->_explicit_number[n]; - break; - - case KIND::ALGORITHM: - result = this->_algorithmic_number[n]; - break; - - case KIND::OPERATION: - throw boost::real::invalid_representation_exception(); - break; - } - - return result; - }; + int ret; + + std::visit( overloaded { // perform operation on whatever is held in variant + [&n, &ret] (const real_explicit& real) { + ret = real[n]; + }, + [&n, &ret] (const real_algorithm& real) { + ret = real[n]; + }, + [] (const real_operation& real) { + throw boost::real::bad_variant_access_exception(); + }, + [] (auto& real) { + throw boost::real::bad_variant_access_exception(); + } + }, _real_p->get_real_number()); + return ret; + } /** - * @brief Convert the number from its current representation to an operation number - * representation where the operands are copies of the other and this numbers (before the conversion). - * The new number represent the addition operation between *this and other. + * @brief Sets this real_data to that of the operation between this previous + * real_data and other real_data. + * + * If this is being pointed to by another operation, a copy of this is created. * * @param other - the right side operand boost::real::real number. - * @return A reference to the new boost::real::real number representation. */ - real& operator+=(const real& other) { - this->_lhs_ptr = new real(*this); - this->_rhs_ptr = new real(other); - this->_kind = KIND::OPERATION; - this->_operation = OPERATION::ADDITION; - return *this; + void operator+=(real& other) { + // do not want to overwrite *this->_real_p if others are pointing to it + // if others are pointing to it, point to a copy in newly allocated memory, then create operation + if(this->_real_p.use_count() > 1) { + this->_real_p = std::make_shared(real_data(*this->_real_p)); + } + this->_real_p = + std::make_shared(real_operation(this->_real_p, other._real_p, OPERATION::ADDITION)); } /** - * @brief Creates a new boost::real::real representing an operation number where the operands - * are copies of the other and this numbers. The number represent the addition operation - * between *this and other. + * @brief Creates a new boost::real::real_operation representing the sum of the + * two numbers, using pointers to each operands' data. * * @param other - the right side operand boost::real::real number. - * @return A reference to the new boost::real::real number representation. + * @return A copy of the new boost::real::real number representation. */ - real operator+(const real& other) const { - real result = *this; - result += other; - return result; + real operator+(real other) { + return real(real_operation(this->_real_p, other._real_p, OPERATION::ADDITION)); } /** - * @brief Convert the number from its current representation to an operation number - * representation where the operands are copies of the other and this numbers (before the conversion). - * The new number representation represent the subtraction operation between *this and other. + * @brief Sets this real_data to that of the operation between this previous + * real_data and other real_data. * * @param other - the right side operand boost::real::real number. - * @return A reference to the new boost::real::real number representation. */ - real& operator-=(const real& other) { - this->_lhs_ptr = new real(*this); - this->_rhs_ptr = new real(other); - this->_kind = KIND::OPERATION; - this->_operation = OPERATION::SUBTRACT; - return *this; + void operator-=(real& other) { + if(this->_real_p.use_count() > 1) { + // if others are pointing to it, point to a copy in newly allocated memory, then create operation + this->_real_p = std::make_shared(real_data(*this->_real_p)); + } + this->_real_p = + std::make_shared(real_operation(this->_real_p, other._real_p, OPERATION::SUBTRACTION)); } /** - * @brief Creates a new boost::real::real representing an operation number where the operands - * are copies of the other and this numbers. The number represent the subtraction operation - * between *this and other. + * @brief Creates a new boost::real::real representing the subtraction + * between *this and other * * @param other - the right side operand boost::real::real number. - * @return A reference to the new boost::real::real number representation. + * @return A copy of the new boost::real::real number representation. */ - real operator-(const real& other) const { - real result = *this; - result -= other; - return result; + real operator-(real other) { + return real(real_operation(this->_real_p, other._real_p, OPERATION::SUBTRACTION)); } /** - * @brief Convert the number from its current representation to an operation number - * representation where the operands are copies of the other and this numbers (before the conversion). - * The new number represent the multiplication between *this and other. + * @brief Sets this real_data to that of the operation between + * this previous real_data and other real_data. * * @param other - the right side operand boost::real::real number. - * @return A reference to the new boost::real::real number representation. */ - real& operator*=(const real& other) { - this->_lhs_ptr = new real(*this); - this->_rhs_ptr = new real(other); - this->_kind = KIND::OPERATION; - this->_operation = OPERATION::MULTIPLICATION; - return *this; + void operator*=(real& other) { + if(this->_real_p.use_count() > 1) { + this->_real_p = std::make_shared(real_data(*this->_real_p)); + } + this->_real_p = + std::make_shared(real_operation(this->_real_p, other._real_p, OPERATION::MULTIPLICATION)); } /** - * @brief Creates a new boost::real::real representing an operation number where the operands - * are copies of the other and this numbers. The number represent the multiplication - * operation between *this and other. + * @brief Creates a new boost::real::real representing the product + * of *this and other * * @param other - the right side operand boost::real::real number. - * @return A reference to the new boost::real::real number representation. + * @return A copy of the new boost::real::real number representation. */ - real operator*(const real& other) const { - real result = *this; - result *= other; - return result; + real operator*(real other) { + return real(real_operation(this->_real_p, other._real_p, OPERATION::MULTIPLICATION)); } /** - * @brief It assigns a new copy of the other boost::real::real number in the *this boost::real::real number. - * + * @brief Assigns *this to other * @param other - the boost::real::real number to copy. - * @return a reference of *this with the new represented number. */ - real& operator=(const real& other) { - this->_kind = other._kind; - this->_explicit_number = other._explicit_number; - this->_operation = other._operation; - this->copy_operands(other); - return *this; + void operator=(real& other) { + if(this->_real_p.use_count() > 1) { + // if this is being referenced to, point to new memory before assigning + // i.e., if A = B + B, and we do B = D, we first make B point elsewhere. + // so that A != D + D + this->_real_p = std::make_shared(); + } + this->_real_p = + std::make_shared(*other._real_p); } /** - * @brief It constructs a boost::real::real number from the std::string and assigns it - * to the *this boost::real::real number. - * + * @brief Assigns *this to the real number represented by the string number * @param number - a valid string representing a number. - * @return a reference of *this with the new represented number. */ - real& operator=(const std::string& number) { - *this = real(number); - return *this; + void operator=(const std::string& number) { + if(this->_real_p.use_count() > 1) { + // if this is being referenced to, point to new memory before assigning + this->_real_p = std::make_shared(); + } + this->_real_p = + std::make_shared(real_explicit(number)); } /** @@ -762,8 +360,11 @@ namespace boost { * @throws boost::real::precision_exception */ bool operator<(const real& other) const { - auto this_it = this->cbegin(); - auto other_it = other.cbegin(); + auto this_it = this->_real_p->get_precision_itr().cbegin(); + auto other_it = other._real_p->get_precision_itr().cbegin(); + + if (this_it == other_it) + return false; unsigned int current_precision = std::max(this->max_precision(), other.max_precision()); for (unsigned int p = 0; p < current_precision; ++p) { @@ -771,17 +372,17 @@ namespace boost { ++this_it; ++other_it; - bool this_full_precision = this_it.approximation_interval.is_a_number(); - bool other_full_precision = other_it.approximation_interval.is_a_number(); + bool this_full_precision = this_it.get_interval().is_a_number(); + bool other_full_precision = other_it.get_interval().is_a_number(); if (this_full_precision && other_full_precision) { - return this_it.approximation_interval < other_it.approximation_interval; + return this_it.get_interval() < other_it.get_interval(); } - if (this_it.approximation_interval < other_it.approximation_interval) { + if (this_it.get_interval()< other_it.get_interval()) { return true; } - if (other_it.approximation_interval < this_it.approximation_interval) { + if (other_it.get_interval()< this_it.get_interval()) { return false; } } @@ -803,8 +404,11 @@ namespace boost { * @throws boost::real::precision_exception */ bool operator>(const real& other) const { - auto this_it = this->cbegin(); - auto other_it = other.cbegin(); + auto this_it = this->_real_p->get_precision_itr().cbegin(); + auto other_it = other._real_p->get_precision_itr().cbegin(); + + if (this_it == other_it) + return false; unsigned int current_precision = std::max(this->max_precision(), other.max_precision()); for (unsigned int p = 0; p < current_precision; ++p) { @@ -812,17 +416,17 @@ namespace boost { ++this_it; ++other_it; - bool this_full_precision = this_it.approximation_interval.is_a_number(); - bool other_full_precision = other_it.approximation_interval.is_a_number(); + bool this_full_precision = this_it.get_interval().is_a_number(); + bool other_full_precision = other_it.get_interval().is_a_number(); if (this_full_precision && other_full_precision) { - return this_it.approximation_interval > other_it.approximation_interval; + return this_it.get_interval()> other_it.get_interval(); } - if (this_it.approximation_interval > other_it.approximation_interval) { + if (this_it.get_interval()> other_it.get_interval()) { return true; } - if (other_it.approximation_interval > this_it.approximation_interval) { + if (other_it.get_interval()> this_it.get_interval()) { return false; } } @@ -844,8 +448,8 @@ namespace boost { * @throws boost::real::precision_exception */ bool operator==(const real& other) const { - auto this_it = this->cbegin(); - auto other_it = other.cbegin(); + auto this_it = _real_p->get_precision_itr().cbegin(); + auto other_it = other._real_p->get_precision_itr().cbegin(); unsigned int current_precision = std::max(this->max_precision(), other.max_precision()); for (unsigned int p = 0; p < current_precision; ++p) { @@ -853,14 +457,14 @@ namespace boost { ++this_it; ++other_it; - bool this_full_precision = this_it.approximation_interval.is_a_number(); - bool other_full_precision = other_it.approximation_interval.is_a_number(); + bool this_full_precision = this_it.get_interval().is_a_number(); + bool other_full_precision = other_it.get_interval().is_a_number(); if (this_full_precision && other_full_precision) { - return this_it.approximation_interval == other_it.approximation_interval; + return this_it.get_interval()== other_it.get_interval(); } - bool this_is_lower = this_it.approximation_interval < other_it.approximation_interval; - bool other_is_lower = other_it.approximation_interval < this_it.approximation_interval; + bool this_is_lower = this_it.get_interval()< other_it.get_interval(); + bool other_is_lower = other_it.get_interval()< this_it.get_interval(); if (this_is_lower || other_is_lower) { return false; } @@ -870,32 +474,36 @@ namespace boost { // we cannot know if they are equals or not. throw boost::real::precision_exception(); } - }; + /********* END OPERATORS *********/ + + /** + * @brief overload of the << operator for std::ostream and boost::real::real + * + * @param os - The std::ostream object where to print the r number. + * @param r - the boost::real::real number to print + * @return a reference of the modified os object. + */ + friend std::ostream& operator<<(std::ostream& os, real r) { + os << r.get_real_itr().cend().get_interval(); + return os; + } + + }; // end real class } } -boost::real::real operator "" _r(long double x) { +inline boost::real::real operator "" _r(long double x) { return boost::real::real(std::to_string(x)); } -boost::real::real operator "" _r(unsigned long long x) { +inline boost::real::real operator "" _r(unsigned long long x) { return boost::real::real(std::to_string(x)); } -boost::real::real operator "" _r(const char* x, size_t len) { +inline boost::real::real operator "" _r(const char* x, size_t len) { return boost::real::real(x); } -/** - * @bief overload of the << operator for std::ostream and boost::real::real - * - * @param os - The std::ostream object where to print the r number. - * @param r - the boost::real::real number to print - * @return a reference of the modified os object. - */ -std::ostream& operator<<(std::ostream& os, const boost::real::real& r) { - os << r.cend().approximation_interval; - return os; -} -#endif //BOOST_REAL_REAL_HPP + +#endif //BOOST_REAL_HPP diff --git a/include/real/real_algorithm.hpp b/include/real/real_algorithm.hpp index 4993983..4b5a324 100644 --- a/include/real/real_algorithm.hpp +++ b/include/real/real_algorithm.hpp @@ -1,14 +1,10 @@ #ifndef BOOST_REAL_REAL_ALGORITHM_HPP #define BOOST_REAL_REAL_ALGORITHM_HPP -#include - #include -#include -namespace boost { +namespace boost { namespace real { - /** * @author Laouen Mayal Louan Belloli * @@ -19,6 +15,7 @@ namespace boost { * digits on demand, numbers with infinite representations as the irrational numbers can be * represented using this class. */ + class real_algorithm { // Number representation as a function that returns the number digits @@ -27,162 +24,7 @@ namespace boost { int _exponent; bool _positive; - // Precision - unsigned int _maximum_precision = 0; - - public: - - static std::optional maximum_precision; - - /** - * @author Laouen Mayal Louan Belloli - * - * @brief is a forward iterator that iterates a boost::real::real_algorithm number approximation - * intervals. The iterator calculates the initial interval with the initial precision and - * then it increases the precision in each iteration (++) and recalculates the interval. - */ - class const_precision_iterator { - private: - - // Iterator precision - int _n = 0; - - // Internal number to iterate - real_algorithm const* _real_ptr = nullptr; - - void check_and_swap_boundaries() { - if (!this->_real_ptr->_positive) { - this->approximation_interval.swap_bounds(); - } - } - public: - - // Number approximation_interval boundaries - boost::real::interval approximation_interval; - - /** - * @brief **Default constructor:** Constructs an empty - * boost::real::real_algorithm::const_precision_iterator that points to nullptr. - */ - const_precision_iterator() = default; - - /** - * @brief **Copy constructor:** - * Construct a new boost::real::real_algorithm::const_precision_iterator which is - * a copy of the other iterator. - * - * @param other - the boost::real::real::const_precision_iterator to copy. - */ - const_precision_iterator(const const_precision_iterator& other) = default; - - /** - * @brief *Pointer constructor:* Construct a new boost::real::real_algorithm::const_precision_iterator - * pointing to the boost::real::real_algorithm number to iterate the number approximation intervals. - * - * The iterator will start pointing to the lowest precision interval. - * - * @param real_number - the boost::real::real number to iterate. - */ - explicit const_precision_iterator(real_algorithm const* real_number) : _n(1), _real_ptr(real_number) { - - this->approximation_interval.lower_bound.exponent = this->_real_ptr->_exponent; - this->approximation_interval.upper_bound.exponent = this->_real_ptr->_exponent; - this->approximation_interval.lower_bound.positive = this->_real_ptr->_positive; - this->approximation_interval.upper_bound.positive = this->_real_ptr->_positive; - - int first_digit = (*this->_real_ptr)[0]; - this->approximation_interval.lower_bound.digits.push_back(first_digit); - - if (first_digit == 9) { - this->approximation_interval.upper_bound.digits.push_back(1); - this->approximation_interval.upper_bound.exponent++; - } else { - this->approximation_interval.upper_bound.digits.push_back(first_digit + 1); - } - - this->check_and_swap_boundaries(); - } - - /** - * @brief It recalculates the approximation interval boundaries increasing the used - * precision, the new pointed approximation interval is smaller than the current one. - */ - void operator++() { - this->iterate_n_times(1); - } - - /** - * @brief It recalculates the approximation interval boundaries increasing the used - * precision n times, the new pointed approximation interval is smaller than the current one. - */ - void iterate_n_times(int n) { - - // If the number is negative, bounds are interpreted as mirrored: - // First, the operation is made as positive, and after bound calculation - // bounds are swapped to come back to the negative representation. - this->check_and_swap_boundaries(); - - for (int i = 0; i < n; i++) { - this->approximation_interval.lower_bound.push_back((*this->_real_ptr)[this->_n + i]); - } - - this->approximation_interval.upper_bound.clear(); - this->approximation_interval.upper_bound.digits.resize(this->approximation_interval.lower_bound.size()); - int carry = 1; - for (int i = (int)this->approximation_interval.lower_bound.size() - 1; i >= 0; --i) { - if (this->approximation_interval.lower_bound[i] + carry == 10) { - this->approximation_interval.upper_bound[i] = 0; - } else { - this->approximation_interval.upper_bound[i] = this->approximation_interval.lower_bound[i] + carry; - carry = 0; - } - } - - if (carry > 0) { - this->approximation_interval.upper_bound.push_front(carry); - this->approximation_interval.upper_bound.exponent = this->approximation_interval.lower_bound.exponent + 1; - } else { - this->approximation_interval.upper_bound.exponent = this->approximation_interval.lower_bound.exponent; - } - - // Left normalization of boundaries representation - this->approximation_interval.lower_bound.normalize_left(); - this->approximation_interval.upper_bound.normalize_left(); - - this->check_and_swap_boundaries(); - this->_n += n; - } - - /** - * @brief It compares by value equality; two boost::real::real_algorithm::const_precision_iterators - * are equals if they are pointing to the same real number and are in the same precision iteration. - * - * @param other - A boost::real::real_algorithm::const_precision_iterator that is the right side operand - * @return a bool that is true if and only if both iterators are equals. - */ - bool operator==(const const_precision_iterator& other) const { - // uninitialized iterators are never equals - if (this->_real_ptr == nullptr || other._real_ptr == nullptr) { - return false; - } - - return (other._real_ptr == this->_real_ptr) && - (other._n == this->_n) && - (other.approximation_interval == this->approximation_interval); - } - - /** - * @brief It compares by value not equal; two boost::real::real_algorithm::const_precision_iterators. - * - * @param other - A boost::real::real_algorithm::const_precision_iterator that is the right side operand - * @return a bool that is true if and only if both iterators are not equals. - */ - bool operator!=(const const_precision_iterator& other) const { - return !(*this == other); - } - }; - /** * @brief *Default constructor:* Construct an empty boost::real::real_algorithm with * undefined representation and behaviour. @@ -227,28 +69,8 @@ namespace boost { bool positive) : _get_nth_digit(get_nth_digit), _exponent(exponent), - _positive(positive) {} - - /** - * @brief Returns the maximum allowed precision, if that precision is reached and an - * operator need more precision, a precision_exception should be thrown. - * - * @return an integer with the maximum allowed precision. - */ - unsigned int max_precision() const { - if(!boost::real::real_algorithm::maximum_precision) - throw boost::real::undefined_max_precision_exception(); - return boost::real::real_algorithm::maximum_precision.value(); - } - - /** - * @brief Set a new maximum precision for the instance. - * - * @param maximum_precision - an unsigned int to set as the new precision. - */ - void set_maximum_precision(unsigned int maximum_precision) { - this->_maximum_precision = maximum_precision; - } + _positive(positive) + {}; /** * @return An integer with the number exponent @@ -264,34 +86,6 @@ namespace boost { return this->_positive; } - /** - * @brief Construct a new boost::real::real_algorithm::con_precision_iterator that iterates the number - * approximation intervals in increasing order according to the approximation precision. - * - * The iterator starts pointing the interval with the minimum precision. - * - * @return a boost::real::real_algorithm::const_precision_iterator of the number. - */ - const_precision_iterator cbegin() const { - return const_precision_iterator(this); - } - - /** - * @brief Construct a new boost::real::real_algorithm::con_precision_iterator that iterates the number - * approximation intervals in increasing order according to the approximation precision. - * - * The iterator starts pointing the interval with the maximum allowed precision. - * - * @return a boost::real::real_algorithm::const_precision_iterator of the number. - */ - const_precision_iterator cend() const { - if(!boost::real::real_algorithm::maximum_precision) - throw boost::real::undefined_max_precision_exception(); - const_precision_iterator it(this); - it.iterate_n_times(boost::real::real_algorithm::maximum_precision.value() - 1); - return it; - } - /** * @brief Returns the n-th digit the number. * @@ -311,20 +105,5 @@ namespace boost { } } -/** - * @bief overload of the << operator for std::ostream and boost::real::real_algorithm - * - * @param os - The std::ostream object where to print the r number. - * @param r - the boost::real::real_algorithm number to print - * @return a reference of the modified os object. - */ -std::ostream& operator<<(std::ostream& os, const boost::real::real_algorithm& r) { - auto it = r.cbegin(); - for (unsigned int i = 0; i <= r.max_precision(); i++) { - ++it; - } - os << it.approximation_interval; - return os; -} #endif //BOOST_REAL_REAL_ALGORITHM_HPP diff --git a/include/real/real_data.hpp b/include/real/real_data.hpp new file mode 100644 index 0000000..ed766d6 --- /dev/null +++ b/include/real/real_data.hpp @@ -0,0 +1,261 @@ +#ifndef BOOST_REAL_REAL_DATA_HPP +#define BOOST_REAL_REAL_DATA_HPP + +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace boost { + namespace real{ + + class real_data { + real_number _real; + const_precision_iterator _precision_itr; + + public: + /// @TODO: use move constructors, if possible + + real_data() = default; + + /// copy ctor - constructs real_data from other real_data + real_data(const real_data &other) : _real(other._real), _precision_itr(other._precision_itr) {}; + + // construct from the three different reals + real_data(real_explicit x) :_real(x), _precision_itr(&_real) {}; + real_data(real_algorithm x) : _real(x), _precision_itr(&_real) {}; + real_data(real_operation x) : _real(x), _precision_itr(&_real) {}; + + const real_number& get_real_number() const { + return _real; + } + + const_precision_iterator& get_precision_itr() { + return _precision_itr; + } + }; + + // Now that real_data and const_precision_iterator have been defined, we may now define the following. + + /* const_precision_iterator member functions */ + /// determines a real_operation's approximation interval from its operands' + void const_precision_iterator::update_operation_boundaries(real_operation &ro) { + switch (ro.get_operation()) { + case OPERATION::ADDITION: + boost::real::real_helper::add_boundaries( + ro.get_lhs_itr().get_interval().lower_bound, + ro.get_rhs_itr().get_interval().lower_bound, + this->_approximation_interval.lower_bound + ); + + boost::real::real_helper::add_boundaries( + ro.get_lhs_itr().get_interval().upper_bound, + ro.get_rhs_itr().get_interval().upper_bound, + this->_approximation_interval.upper_bound + ); + break; + + + case OPERATION::SUBTRACTION: + boost::real::real_helper::subtract_boundaries( + ro.get_lhs_itr().get_interval().lower_bound, + ro.get_rhs_itr().get_interval().upper_bound, + this->_approximation_interval.lower_bound + ); + + boost::real::real_helper::subtract_boundaries( + ro.get_lhs_itr().get_interval().upper_bound, + ro.get_rhs_itr().get_interval().lower_bound, + this->_approximation_interval.upper_bound + ); + break; + + + case OPERATION::MULTIPLICATION: { + bool lhs_positive = ro.get_lhs_itr().get_interval().positive(); + bool rhs_positive = ro.get_rhs_itr().get_interval().positive(); + bool lhs_negative = ro.get_lhs_itr().get_interval().negative(); + bool rhs_negative = ro.get_rhs_itr().get_interval().negative(); + + if (lhs_positive && rhs_positive) { // Positive - Positive + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().lower_bound, + ro.get_rhs_itr().get_interval().lower_bound, + this->_approximation_interval.lower_bound + ); + + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().upper_bound, + ro.get_rhs_itr().get_interval().upper_bound, + this->_approximation_interval.upper_bound + ); + + } else if (lhs_negative && rhs_negative) { // Negative - Negative + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().upper_bound, + ro.get_rhs_itr().get_interval().upper_bound, + this->_approximation_interval.lower_bound + ); + + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().lower_bound, + ro.get_rhs_itr().get_interval().lower_bound, + this->_approximation_interval.upper_bound + ); + } else if (lhs_negative && rhs_positive) { // Negative - Positive + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().lower_bound, + ro.get_rhs_itr().get_interval().upper_bound, + this->_approximation_interval.lower_bound + ); + + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().upper_bound, + ro.get_rhs_itr().get_interval().lower_bound, + this->_approximation_interval.upper_bound + ); + + } else if (lhs_positive && rhs_negative) { // Positive - Negative + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().upper_bound, + ro.get_rhs_itr().get_interval().lower_bound, + this->_approximation_interval.lower_bound + ); + + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().lower_bound, + ro.get_rhs_itr().get_interval().upper_bound, + this->_approximation_interval.upper_bound + ); + + } else { // One is around zero all possible combinations are be tested + + boundary current_boundary; + + // Lower * Lower + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().lower_bound, + ro.get_rhs_itr().get_interval().lower_bound, + current_boundary + ); + + this->_approximation_interval.lower_bound = current_boundary; + this->_approximation_interval.upper_bound = current_boundary; + + // Upper * upper + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().upper_bound, + ro.get_rhs_itr().get_interval().upper_bound, + current_boundary + ); + + if (current_boundary < this->_approximation_interval.lower_bound) { + this->_approximation_interval.lower_bound = current_boundary; + } + + if (this->_approximation_interval.upper_bound < current_boundary) { + this->_approximation_interval.upper_bound = current_boundary; + } + + // Lower * upper + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().lower_bound, + ro.get_rhs_itr().get_interval().upper_bound, + current_boundary + ); + + if (current_boundary < this->_approximation_interval.lower_bound) { + this->_approximation_interval.lower_bound = current_boundary; + } + + if (this->_approximation_interval.upper_bound < current_boundary) { + this->_approximation_interval.upper_bound = current_boundary; + } + + // Upper * lower + boost::real::real_helper::multiply_boundaries( + ro.get_lhs_itr().get_interval().upper_bound, + ro.get_rhs_itr().get_interval().lower_bound, + current_boundary + ); + + if (current_boundary < this->_approximation_interval.lower_bound) { + this->_approximation_interval.lower_bound = current_boundary; + } + + if (this->_approximation_interval.upper_bound < current_boundary) { + this->_approximation_interval.upper_bound = current_boundary; + } + } + break; + } + + default: + throw boost::real::none_operation_exception(); + } + } + + // remember to update afterwards + // inits the precision of the real_operation, depending on those of its operands, to either + // cbegin or cend. + void const_precision_iterator::init_operation_itr(real_operation &ro, bool cend){ + if (cend) { + ro.get_lhs_itr() = const_precision_iterator(ro.get_lhs_itr().cend()); + ro.get_rhs_itr() = const_precision_iterator(ro.get_rhs_itr().cend()); + } else { + ro.get_lhs_itr() = const_precision_iterator(ro.get_lhs_itr().cbegin()); + ro.get_rhs_itr() = const_precision_iterator(ro.get_rhs_itr().cbegin()); + } + } + + void const_precision_iterator::operation_iterate_n_times(real_operation &ro, int n) { + /// @warning there could be issues if operands have different precisions/max precisions + + if (ro.get_lhs_itr()._precision < this->_precision + n) + ro.get_lhs_itr().iterate_n_times(n); + + if (ro.get_rhs_itr()._precision < this->_precision + n) + ro.get_rhs_itr().iterate_n_times(n); + + this->_precision += n; + + update_operation_boundaries(ro); + } + + void const_precision_iterator::operation_iterate(real_operation &ro) { + // only iterate if we must. If operand precision < this precision, then it must have + // hit its maximum_precision. If operand precision == this precision, we try iterating. Otherwise, + // it is == this->_precision + 1 (from being iterated elsewhere in the operation tree) and + // we do not iterate again. + + if (ro.get_lhs_itr()._precision == this->_precision) + ++(ro.get_lhs_itr()); + + if (ro.get_rhs_itr()._precision == this->_precision) + ++(ro.get_rhs_itr()); + + (this->_precision)++; + + update_operation_boundaries(ro); + } + + /* real_operation member functions */ + + // note that we return a reference. It is necessary, for now, since iterating operands + // (see operation_iterate, above) REQUIRES modifying the operands' precision iterators + const_precision_iterator& real_operation::get_lhs_itr() { + return _lhs->get_precision_itr(); + } + + const_precision_iterator& real_operation::get_rhs_itr() { + return _rhs->get_precision_itr(); + } + } +} + +#endif // BOOST_REAL_REAL_DATA_HPP diff --git a/include/real/real_exception.hpp b/include/real/real_exception.hpp index eab6022..527c9f7 100644 --- a/include/real/real_exception.hpp +++ b/include/real/real_exception.hpp @@ -33,10 +33,10 @@ namespace boost { } }; - struct undefined_max_precision_exception : public std::exception { + struct bad_variant_access_exception: public std::exception { const char * what () const throw () override { - return "The maximum precision for boost::real has not been defined"; + return "Cannot perform this method on this real variant type"; } }; } diff --git a/include/real/real_explicit.hpp b/include/real/real_explicit.hpp index fc511a0..49df045 100644 --- a/include/real/real_explicit.hpp +++ b/include/real/real_explicit.hpp @@ -20,6 +20,7 @@ namespace boost { * @brief boost::real::real_explicit is a C++ class that fully represents real numbers as * a vector of digits, a sign and an exponent. */ + class real_explicit { // Number representation as a vector of digits with an integer part and a sign (+/-) @@ -31,184 +32,9 @@ namespace boost { // The number max precision is the same as the explicit number digits size. unsigned int _maximum_precision = 1; + public: - /** - * @author Laouen Mayal Louan Belloli - * - * @brief is a forward iterator that iterates a boost::real::real_explicit number approximation - * intervals. The iterator calculates the initial interval with the initial precision and - * then it increases the precision in each iteration (++) and recalculates the interval. - */ - class const_precision_iterator { - private: - - // Iterator precision - int _n; - - // Internal number to iterate - real_explicit const* _real_ptr = nullptr; - - void check_and_swap_boundaries() { - if (!this->_real_ptr->_positive) { - this->approximation_interval.swap_bounds(); - } - } - - public: - - // Number approximation_interval boundaries - boost::real::interval approximation_interval; - - /** - * @brief **Default constructor:** Constructs an empty - * boost::real::real_explicit::const_precision_iterator that points to nullptr. - */ - const_precision_iterator() = default; - - /** - * @brief **Copy constructor:** - * Construct a new boost::real::real_explicit::const_precision_iterator which is - * a copy of the other iterator. - * - * @param other - the boost::real::real::const_precision_iterator to copy. - */ - const_precision_iterator(const const_precision_iterator& other) = default; - - /** - * @brief *Pointer constructor:* Construct a new boost::real::real_explicit::const_precision_iterator - * pointing to the boost::real::real_explicit number to iterate the number approximation intervals. - * - * The iterator will start pointing the lowest precision interval. - * - * @param real_number - the boost::real::real number to iterate. - */ - explicit const_precision_iterator(real_explicit const* real_number) : _n(1), _real_ptr(real_number) { - this->approximation_interval.lower_bound.exponent = this->_real_ptr->_exponent; - this->approximation_interval.upper_bound.exponent = this->_real_ptr->_exponent; - this->approximation_interval.lower_bound.positive = this->_real_ptr->_positive; - this->approximation_interval.upper_bound.positive = this->_real_ptr->_positive; - - int first_digit = this->_real_ptr->_digits[0]; - this->approximation_interval.lower_bound.digits.push_back(first_digit); - - if (first_digit == 9) { - this->approximation_interval.upper_bound.digits.push_back(1); - this->approximation_interval.upper_bound.exponent++; - } else if (this->_n < (int)this->_real_ptr->_digits.size()) { - this->approximation_interval.upper_bound.digits.push_back(first_digit + 1); - } else { - this->approximation_interval.upper_bound.digits.push_back(first_digit); - } - - this->check_and_swap_boundaries(); - } - - /** - * @brief It recalculates the approximation interval boundaries increasing the used - * precision, the new pointed approximation interval is smaller than the current one. - */ - void operator++() { - this->iterate_n_times(1); - } - - /** - * @brief It recalculates the approximation interval boundaries increasing the used - * precision n times, the new pointed approximation interval is smaller than the current one. - */ - void iterate_n_times(int n) { - // If the explicit number full precision has been already reached (the end) - // is the end of the iterator - if (this->_n >= (int)this->_real_ptr->_digits.size()) { - // TODO: Remove commented lines that are depreciated code - //this->approximation_interval.lower_bound.push_back(0); - //this->approximation_interval.upper_bound.push_back(0); - //this->_n++; - return; - } - - // If the number is negative, boundaries are interpreted as mirrored: - // First, the operation is made as positive, and after boundary calculation - // boundaries are swapped to come back to the negative representation. - this->check_and_swap_boundaries(); - - // If the explicit number just reaches the full precision (the end) - // then set both boundaries are equals. - if (this->_n + n >= (int)this->_real_ptr->_digits.size()) { - - for(int i = this->_n; i < (int)this->_real_ptr->_digits.size(); i++) { - this->approximation_interval.lower_bound.push_back(this->_real_ptr->_digits[i]); - } - this->approximation_interval.upper_bound = this->approximation_interval.lower_bound; - - - } else { - - // If the explicit number didn't reaches the full precision (the end) - // then the number interval is defined by truncation. - - for(int i = 0; i < n; i++) { - this->approximation_interval.lower_bound.push_back(this->_real_ptr->_digits[this->_n]); - } - - this->approximation_interval.upper_bound.clear(); - this->approximation_interval.upper_bound.digits.resize(this->approximation_interval.lower_bound.size()); - - int carry = 1; - for (int i = (int)this->approximation_interval.lower_bound.size() - 1; i >= 0; --i) { - if (this->approximation_interval.lower_bound[i] + carry == 10) { - this->approximation_interval.upper_bound[i] = 0; - } else { - this->approximation_interval.upper_bound[i] = this->approximation_interval.lower_bound[i] + carry; - carry = 0; - } - } - - if (carry > 0) { - this->approximation_interval.upper_bound.push_front(carry); - this->approximation_interval.upper_bound.exponent = this->approximation_interval.lower_bound.exponent + 1; - } else { - this->approximation_interval.upper_bound.exponent = this->approximation_interval.lower_bound.exponent; - } - } - - // Left normalization of boundaries representation - this->approximation_interval.lower_bound.normalize_left(); - this->approximation_interval.upper_bound.normalize_left(); - - this->check_and_swap_boundaries(); - this->_n = std::min(this->_n + n, (int)this->_real_ptr->_digits.size()); - } - - /** - * @brief It compares by value equality; two boost::real::real_explicit::const_precision_iterators - * are equals if they are pointing to the same real number and are in the same precision iteration. - * - * @param other - A boost::real::real_explicit::const_precision_iterator that is the right side operand - * @return a bool that is true if and only if both iterators are equals. - */ - bool operator==(const const_precision_iterator& other) const { - // uninitialized iterators are never equals - if (this->_real_ptr == nullptr || other._real_ptr == nullptr) { - return false; - } - - return (other._real_ptr == this->_real_ptr) && - (other._n == this->_n) && - (other.approximation_interval == this->approximation_interval); - } - - /** - * @brief It compares by value not equal; two boost::real::real_explicit::const_precision_iterators. - * - * @param other - A boost::real::real_explicit::const_precision_iterator that is the right side operand - * @return a bool that is true if and only if both iterators are not equals. - */ - bool operator!=(const const_precision_iterator& other) const { - return !(*this == other); - } - }; - /** * @brief *Default constructor:* Constructs an empty boost::real::real_explicit with * undefined representation and behaviour. @@ -318,25 +144,6 @@ namespace boost { _maximum_precision((int)this->_digits.size()) {}; - /** - * @brief Returns the maximum allowed precision, if that precision is reached and an - * operator needs more precision, a precision_exception should be thrown. - * - * @return an integer with the maximum allowed precision. - */ - unsigned int max_precision() const { - return this->_maximum_precision; - } - - /** - * @brief Set a new maximum precision for the instance. - * - * @param maximum_precision - an unsigned int to set as the new precision. - */ - void set_maximum_precision(unsigned int maximum_precision) { - this->_maximum_precision = maximum_precision; - } - /** * @return An integer with the number exponent */ @@ -358,18 +165,6 @@ namespace boost { return this->_digits; } - /** - * @brief Construct a new boost::real::real_explicit::const_precision_iterator that iterates the number - * approximation intervals in increasing order according to the approximation precision. - * - * The iterator starts pointing to the interval with the minimum precision. - * - * @return a boost::real::real_explicit::const_precision_iterator of the number. - */ - const_precision_iterator cbegin() const { - return const_precision_iterator(this); - } - /** * @brief Constructs a new boost::real::real_explicit::const_precision_iterator that iterates the number * approximation intervals in increasing order according to the approximation precision. @@ -378,11 +173,6 @@ namespace boost { * * @return a boost::real::real_explicit::const_precision_iterator of the number. */ - const_precision_iterator cend() const { - const_precision_iterator it(this); - it.iterate_n_times((int)this->_digits.size() + 1); - return it; - } /** * @brief Returns the n-th digit the number. @@ -409,21 +199,6 @@ namespace boost { } } -/** - * @bief overload of the << operator for std::ostream and boost::real::real_explicit - * - * @param os - The std::ostream object where to print the r number. - * @param r - the boost::real::real_explicit number to print - * @return a reference of the modified os object. - */ -std::ostream& operator<<(std::ostream& os, const boost::real::real_explicit& r) { - auto it = r.cbegin(); - for (unsigned int i = 0; i <= r.max_precision(); i++) { - ++it; - } - os << it.approximation_interval; - return os; -} #endif //BOOST_REAL_REAL_EXPLICIT_HPP diff --git a/include/real/real_helpers.hpp b/include/real/real_helpers.hpp index d362d3a..dd3b837 100644 --- a/include/real/real_helpers.hpp +++ b/include/real/real_helpers.hpp @@ -8,9 +8,10 @@ namespace boost { namespace real { - namespace helper { + class real_helper { + public: - boundary abs(const boundary& b) { + static boundary abs(const boundary& b) { boundary result = b; result.positive = true; return result; @@ -30,13 +31,14 @@ namespace boost { * @param result - a std::vector that is used to store the result. * @return a integer representing the exponent of the result. */ - int add_vectors(const std::vector &lhs, + static int add_vectors(const std::vector &lhs, int lhs_exponent, const std::vector &rhs, int rhs_exponent, std::vector &result) { + if (!result.empty()) result.clear(); int carry = 0; - + std::vector temp; int fractional_length = std::max((int)lhs.size() - lhs_exponent, (int)rhs.size() - rhs_exponent); int integral_length = std::max(lhs_exponent, rhs_exponent); @@ -62,14 +64,13 @@ namespace boost { carry = 0; } - result.insert(result.begin(), digit); - } - + temp.insert(temp.cbegin(), digit); + } if (carry == 1) { - result.insert(result.begin(), 1); + temp.insert(temp.cbegin(), 1); integral_length++; } - + result = temp; return integral_length; } @@ -89,15 +90,15 @@ namespace boost { * @param result - a std::vector that is used to store the result. * @return a integer representing the exponent of the result. */ - int subtract_vectors(const std::vector &lhs, + static int subtract_vectors(const std::vector &lhs, int lhs_exponent, const std::vector &rhs, int rhs_exponent, std::vector &result) { - + if (!result.empty()) result.clear(); + std::vector temp; int fractional_length = std::max((int)lhs.size() - lhs_exponent, (int)rhs.size() - rhs_exponent); int integral_length = std::max(lhs_exponent, rhs_exponent); - int borrow = 0; // we walk the numbers from the lowest to the highest digit for (int i = fractional_length - 1; i >= -integral_length; i--) { @@ -124,8 +125,9 @@ namespace boost { borrow++; } - result.insert(result.begin(), lhs_digit - rhs_digit); + temp.insert(temp.cbegin(), lhs_digit - rhs_digit); } + result = temp; return lhs_exponent; } @@ -144,30 +146,29 @@ namespace boost { * @param result - a std::vector that is used to store the result. * @return a integer representing the exponent of the result. */ - int multiply_vectors( + static int multiply_vectors( const std::vector& lhs, int lhs_exponent, const std::vector& rhs, int rhs_exponent, std::vector& result ) { - + if (!result.empty()) result.clear(); // will keep the result number in vector in reverse order // Digits: .123 | Exponent: -3 | .000123 <--- Number size is the Digits size less the exponent // Digits: .123 | Exponent: 2 | 12.3 + std::vector temp; size_t new_size = lhs.size() + rhs.size(); if (lhs_exponent < 0) new_size -= lhs_exponent; // <--- Less the exponent if (rhs_exponent < 0) new_size -= rhs_exponent; // <--- Less the exponent - if (!result.empty()) result.clear(); - for (int i = 0; i < (int)new_size; i++) result.push_back(0); + for (int i = 0; i < (int)new_size; i++) temp.push_back(0); // TODO: Check why the assign method crashes. //result.assign(new_size, 0); // Below two indexes are used to find positions // in result. - auto i_n1 = (int) result.size() - 1; - + auto i_n1 = (int) temp.size() - 1; // Go from right to left in lhs for (int i = (int)lhs.size()-1; i>=0; i--) { int carry = 0; @@ -181,20 +182,20 @@ namespace boost { // Multiply current digit of second number with current digit of first number // and add result to previously stored result at current position. - int sum = lhs[i]*rhs[j] + result[i_n1 - i_n2] + carry; + int sum = lhs[i]*rhs[j] + temp[i_n1 - i_n2] + carry; // Carry for next iteration carry = sum / 10; // Store result - result[i_n1 - i_n2] = sum % 10; + temp[i_n1 - i_n2] = sum % 10; i_n2++; } // store carry in next cell if (carry > 0) { - result[i_n1 - i_n2] += carry; + temp[i_n1 - i_n2] += carry; } // To shift position to left after every @@ -203,8 +204,9 @@ namespace boost { } int fractional_part = ((int)lhs.size() - lhs_exponent) + ((int)rhs.size() - rhs_exponent); - int result_exponent = (int)result.size() - fractional_part; - + int result_exponent = (int)temp.size() - fractional_part; + + result = temp; return result_exponent; } @@ -217,9 +219,11 @@ namespace boost { * @param rhs - a boost::real::boundary representing the right operand. * @param result - a boost::real::boundary to store the result. */ - void add_boundaries(const boundary &lhs, + static void add_boundaries(const boundary &lhs, const boundary &rhs, boundary &result) { + if (!result.digits.empty()) result.clear(); + if (lhs.positive == rhs.positive) { result.exponent = add_vectors(lhs.digits, lhs.exponent, @@ -255,9 +259,11 @@ namespace boost { * @param rhs - a boost::real::boundary representing the right operand. * @param result - a boost::real::boundary to store the result. */ - void subtract_boundaries(const boundary &lhs, + static void subtract_boundaries(const boundary &lhs, const boundary &rhs, boundary &result) { + if (!result.digits.empty()) result.clear(); + if (lhs.positive != rhs.positive) { result.exponent = add_vectors(lhs.digits, lhs.exponent, @@ -296,7 +302,7 @@ namespace boost { * @param rhs - a boost::real::boundary representing the right operand. * @param result - a boost::real::boundary to store the result. */ - void multiply_boundaries(const boundary &lhs, + static void multiply_boundaries(const boundary &lhs, const boundary &rhs, boundary &result) { @@ -309,7 +315,7 @@ namespace boost { result.normalize(); } - } + }; } } diff --git a/include/real/real_operation.hpp b/include/real/real_operation.hpp new file mode 100644 index 0000000..7efffcd --- /dev/null +++ b/include/real/real_operation.hpp @@ -0,0 +1,53 @@ +#ifndef BOOST_REAL_REAL_OPERATION +#define BOOST_REAL_REAL_OPERATION + +#include // shared_ptr + +#include +#include + +namespace boost{ + namespace real{ + + // fwd decl needed + class real_data; + class const_precision_iterator; + + /* + * @brief real_operation is a (very unbalanced) binary tree representation of operations, where + * the leaves are the operands and the nodes store the type of operation + * + * @warning due to the recursive nature of real_operation, destruction may cause stack overflow + */ + enum class OPERATION{ADDITION, SUBTRACTION, MULTIPLICATION}; + + class real_operation{ + private: + std::shared_ptr _lhs; + std::shared_ptr _rhs; + OPERATION _operation; + + public: + + /* + * @brief Constructor from two operands and an operation + * @param lhs - left operand + * @param rhs - right operand + * @param op - operation between the operands + */ + real_operation(std::shared_ptr &lhs, std::shared_ptr &rhs, OPERATION op) : _lhs(lhs), _rhs(rhs), _operation(op) {}; + + OPERATION get_operation() { + return _operation; + } + + /// fwd decl'd, defined in real_data + const_precision_iterator& get_lhs_itr(); + + /// fwd decl'd, defined in real_data + const_precision_iterator& get_rhs_itr(); + }; + } +} + +#endif // BOOST_REAL_REAL_OPERATION diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..ae8157f --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,36 @@ +# FILE(GLOB TestSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_test.cpp) +set(TestSources + real_algorithm_iterator_unit_test.cpp + real_eq_operator_test.cpp + real_greater_than_operator_test.cpp + real_lower_than_operator_test.cpp + real_explicit_constructors_unit_test.cpp + real_explicit_iterator_unit_test.cpp + real_iterator_addition_addition_test.cpp + real_iterator_addition_multiplication_test.cpp + real_iterator_addition_subtraction_test.cpp + real_iterator_addition_test.cpp + real_iterator_multiplication_addition_test.cpp + real_iterator_multiplication_multiplication_test.cpp + real_iterator_multiplication_subtraction_test.cpp + real_iterator_multiplication_test.cpp + real_iterator_subtraction_addition_test.cpp + real_iterator_subtraction_multiplication_test.cpp + real_iterator_subtraction_subtraction_test.cpp + real_iterator_subtraction_test.cpp + vector_helpers_test.cpp + ) + +foreach(testSrc ${TestSources}) + get_filename_component(testName ${testSrc} NAME_WE) + add_executable(${testName} main-test.cpp ${testSrc}) + add_test(${testName} ${testName}) + target_include_directories(${testName} + PRIVATE ./include + PUBLIC ${CMAKE_SOURCE_DIR}/external/include/catch2 + # add other dependencies here, when needed for testing + ) + target_link_libraries(${testName} + PUBLIC Boost.Real + ) +endforeach(testSrc) diff --git a/test/include/test_helpers.hpp b/test/include/test_helpers.hpp index 4e46d3e..4a5cbd0 100644 --- a/test/include/test_helpers.hpp +++ b/test/include/test_helpers.hpp @@ -1,20 +1,16 @@ #ifndef BOOST_REAL_TEST_HELPERS_HPP #define BOOST_REAL_TEST_HELPERS_HPP -#include #include -#include #include -std::optional boost::real::real::maximum_precision = 10; -std::optional boost::real::real_algorithm::maximum_precision = 10; +std::optional boost::real::const_precision_iterator::maximum_precision = 10; namespace Catch { template<> struct StringMaker { - static std::string convert( boost::real::interval const& value ) { + static std::string convert( boost::real::interval value ) { return value.as_string(); - } }; } @@ -22,9 +18,8 @@ namespace Catch { namespace Catch { template<> struct StringMaker { - static std::string convert( boost::real::real const& value ) { - return value.cend().approximation_interval.as_string(); - + static std::string convert( boost::real::real value ) { + return value.get_real_itr().cend().get_interval().as_string(); } }; } diff --git a/test/real_algorithm_iterator_unit_test.cpp b/test/real_algorithm_iterator_unit_test.cpp index cf947eb..a31229f 100644 --- a/test/real_algorithm_iterator_unit_test.cpp +++ b/test/real_algorithm_iterator_unit_test.cpp @@ -5,42 +5,20 @@ #include -TEST_CASE("Check whether max precision for real::algorithm and real is declared") { - - SECTION("Checking if real precision is declared") { - REQUIRE(boost::real::real::maximum_precision); - } - - SECTION("Checking if real::algorithm precision is declared") { - REQUIRE(boost::real::real_algorithm::maximum_precision); - } - -} - TEST_CASE("Iterate boost::real_algorithm::const_precision_iterator until full precision is reached") { - - SECTION("Undefined maximum precision error") { - boost::real::real_algorithm::maximum_precision.reset(); //Simulating undefined maximum precision - boost::real::real_algorithm a([](unsigned int n) -> int { return 3; }, 0); - - CHECK_THROWS_AS(a.cend(), boost::real::undefined_max_precision_exception); - - boost::real::real_algorithm::maximum_precision = 10; //Redefining maximum precision for further tests - } - SECTION("Positive numbers") { SECTION("Without carry in the boundary calculations") { SECTION("Testing for number 0.333333...") { + boost::real::real a([](unsigned int n) -> int { return 3; }, 0); + auto approximation_it = a.get_real_itr().cbegin(); - boost::real::real_algorithm a([](unsigned int n) -> int { return 3; }, 0); - boost::real::real_algorithm::const_precision_iterator approximation_it = a.cbegin(); boost::real::interval expected_interval; - expected_interval.lower_bound.exponent = a.exponent(); - expected_interval.lower_bound.positive = a.positive(); - expected_interval.upper_bound.exponent = a.exponent(); - expected_interval.upper_bound.positive = a.positive(); + expected_interval.lower_bound.exponent = approximation_it.get_interval().lower_bound.exponent; + expected_interval.lower_bound.positive = approximation_it.get_interval().lower_bound.positive; + expected_interval.upper_bound.exponent = approximation_it.get_interval().upper_bound.exponent; + expected_interval.upper_bound.positive = approximation_it.get_interval().upper_bound.positive; for (int i = 0; i < 11; i++) { if (i > 0) { @@ -49,30 +27,30 @@ TEST_CASE("Iterate boost::real_algorithm::const_precision_iterator until full pr expected_interval.lower_bound.push_back(a[i]); expected_interval.upper_bound.push_back(a[i] + 1); - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } } } SECTION("With carry in the upper boundary calculation, number 1.99999999989999999998999...") { - boost::real::real_algorithm a( + boost::real::real a( [](unsigned int n) -> int { if (n == 0) return 1; else if (n == 10 || n == 20) return 8; else return 9; }, 3); - boost::real::real_algorithm::const_precision_iterator approximation_it = a.cbegin(); + auto approximation_it = boost::real::real(a).get_real_itr().cbegin(); boost::real::interval expected_interval; - expected_interval.lower_bound.exponent = a.exponent(); - expected_interval.lower_bound.positive = a.positive(); - expected_interval.upper_bound.exponent = a.exponent(); - expected_interval.upper_bound.positive = a.positive(); + expected_interval.lower_bound.exponent = approximation_it.get_interval().lower_bound.exponent; + expected_interval.lower_bound.positive = approximation_it.get_interval().lower_bound.positive; + expected_interval.upper_bound.exponent = approximation_it.get_interval().upper_bound.exponent; + expected_interval.upper_bound.positive = approximation_it.get_interval().upper_bound.positive; expected_interval.upper_bound.push_back(2); for (int i = 0; i < 10; i++) { expected_interval.lower_bound.push_back(a[i]); - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } @@ -81,7 +59,7 @@ TEST_CASE("Iterate boost::real_algorithm::const_precision_iterator until full pr for (int i = 10; i < 20; i++) { expected_interval.lower_bound.push_back(a[i]); - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } @@ -90,7 +68,7 @@ TEST_CASE("Iterate boost::real_algorithm::const_precision_iterator until full pr for (int i = 20; i < 50; i++) { expected_interval.lower_bound.push_back(a[i]); - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } } @@ -100,13 +78,13 @@ TEST_CASE("Iterate boost::real_algorithm::const_precision_iterator until full pr SECTION("Testing for number -0.333333...") { - boost::real::real_algorithm a([](unsigned int n) -> int { return 3; }, 0, false); - boost::real::real_algorithm::const_precision_iterator approximation_it = a.cbegin(); + boost::real::real a([](unsigned int n) -> int { return 3; }, 0, false); + auto approximation_it = boost::real::real(a).get_real_itr().cbegin(); boost::real::interval expected_interval; - expected_interval.lower_bound.exponent = a.exponent(); - expected_interval.lower_bound.positive = a.positive(); - expected_interval.upper_bound.exponent = a.exponent(); - expected_interval.upper_bound.positive = a.positive(); + expected_interval.lower_bound.exponent = approximation_it.get_interval().lower_bound.exponent; + expected_interval.lower_bound.positive = approximation_it.get_interval().lower_bound.positive; + expected_interval.upper_bound.exponent = approximation_it.get_interval().upper_bound.exponent; + expected_interval.upper_bound.positive = approximation_it.get_interval().upper_bound.positive; for (int i = 0; i < 11; i++) { if (i > 0) { @@ -115,30 +93,30 @@ TEST_CASE("Iterate boost::real_algorithm::const_precision_iterator until full pr expected_interval.upper_bound.push_back(a[i]); expected_interval.lower_bound.push_back(a[i] + 1); - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } } SECTION("With carry in the upper boundary calculation, number -1.99999999989999999998999...") { - boost::real::real_algorithm a( + boost::real::real a( [](unsigned int n) -> int { if (n == 0) return 1; else if (n == 10 || n == 20) return 8; else return 9; }, 3, false); - boost::real::real_algorithm::const_precision_iterator approximation_it = a.cbegin(); + auto approximation_it = boost::real::real(a).get_real_itr().cbegin(); boost::real::interval expected_interval; - expected_interval.lower_bound.exponent = a.exponent(); - expected_interval.lower_bound.positive = a.positive(); - expected_interval.upper_bound.exponent = a.exponent(); - expected_interval.upper_bound.positive = a.positive(); + expected_interval.lower_bound.exponent = approximation_it.get_interval().lower_bound.exponent; + expected_interval.lower_bound.positive = approximation_it.get_interval().lower_bound.positive; + expected_interval.upper_bound.exponent = approximation_it.get_interval().upper_bound.exponent; + expected_interval.upper_bound.positive = approximation_it.get_interval().upper_bound.positive; expected_interval.lower_bound.push_back(2); for (int i = 0; i < 10; i++) { expected_interval.upper_bound.push_back(a[i]); - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } @@ -147,7 +125,7 @@ TEST_CASE("Iterate boost::real_algorithm::const_precision_iterator until full pr for (int i = 10; i < 20; i++) { expected_interval.upper_bound.push_back(a[i]); - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } @@ -156,7 +134,7 @@ TEST_CASE("Iterate boost::real_algorithm::const_precision_iterator until full pr for (int i = 20; i < 50; i++) { expected_interval.upper_bound.push_back(a[i]); - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } } @@ -165,9 +143,9 @@ TEST_CASE("Iterate boost::real_algorithm::const_precision_iterator until full pr TEST_CASE("Iterator cend") { - boost::real::real_algorithm a([](unsigned int n) -> int { return 3; }, 0); - boost::real::real_algorithm::const_precision_iterator approximation_it = a.cbegin(); - boost::real::real_algorithm::const_precision_iterator end_it = a.cend(); + boost::real::real a([](unsigned int n) -> int { return 3; }, 0); + auto approximation_it = boost::real::real(a).get_real_itr().cbegin(); + auto end_it = boost::real::real(a).get_real_itr().cend(); SECTION("Iterate until the maximum set precision returns the end of the iterator") { @@ -181,8 +159,8 @@ TEST_CASE("Iterator cend") { SECTION("Iterate cend() returns an interval with the lower boundary digit amount as the maximum precision") { - CHECK( end_it.approximation_interval.lower_bound.digits.size() == a.max_precision() ); - CHECK( end_it.approximation_interval.lower_bound.positive == a.positive() ); - CHECK( end_it.approximation_interval.lower_bound.exponent == a.exponent() ); + CHECK( end_it.get_interval().lower_bound.digits.size() == boost::real::real(a).max_precision() ); + CHECK( end_it.get_interval().lower_bound.positive == approximation_it.get_interval().lower_bound.positive); + CHECK( end_it.get_interval().lower_bound.exponent == approximation_it.get_interval().lower_bound.exponent); } } diff --git a/test/real_eq_operator_test.cpp b/test/real_eq_operator_test.cpp index 8bb5a97..abd3d40 100644 --- a/test/real_eq_operator_test.cpp +++ b/test/real_eq_operator_test.cpp @@ -20,7 +20,7 @@ TEST_CASE("Operator ==") { boost::real::real c("0.5"); boost::real::real d = b + c; - CHECK(a == d); + CHECK(a == d); } SECTION("Explicit == Subtraction") { @@ -941,7 +941,7 @@ TEST_CASE("Operator ==") { } } - SECTION("Testing UDL") { +SECTION("Testing UDL") { SECTION("explicit == explicit") { SECTION("integer == integer") { auto a = 123_r; diff --git a/test/real_explicit_iterator_unit_test.cpp b/test/real_explicit_iterator_unit_test.cpp index 161ab9b..0406295 100644 --- a/test/real_explicit_iterator_unit_test.cpp +++ b/test/real_explicit_iterator_unit_test.cpp @@ -19,28 +19,31 @@ TEST_CASE("Iterate boost::real_explicit::const_precision_iterator until full pre for (auto number : numbers) { SECTION("Testing for number " + number) { - boost::real::real_explicit a(number); - boost::real::real_explicit::const_precision_iterator approximation_it = a.cbegin(); + boost::real::real a(number); + boost::real::const_precision_iterator approximation_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval; - expected_interval.lower_bound.exponent = a.exponent(); - expected_interval.lower_bound.positive = a.positive(); - expected_interval.upper_bound.exponent = a.exponent(); - expected_interval.upper_bound.positive = a.positive(); + + expected_interval.lower_bound.exponent = approximation_it.get_interval().lower_bound.exponent; + expected_interval.lower_bound.positive = approximation_it.get_interval().lower_bound.positive; + expected_interval.upper_bound.exponent = approximation_it.get_interval().upper_bound.exponent; + expected_interval.upper_bound.positive = approximation_it.get_interval().upper_bound.positive; + for (int i = 0; i < 11; i++) { expected_interval.upper_bound.clear(); for (auto d : expected_interval.lower_bound.digits) { expected_interval.upper_bound.push_back(d); } - if (i < (int)a.digits().size() - 1) { + if (i < std::get(a.get_real_number()).digits().size() - 1) { expected_interval.lower_bound.push_back(a[i]); expected_interval.upper_bound.push_back(a[i] + 1); - } else if (i == (int)a.digits().size() - 1) { + } else if (i == + std::get(a.get_real_number()).digits().size() - 1) { expected_interval.lower_bound.push_back(a[i]); expected_interval.upper_bound.push_back(a[i]); } - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } } @@ -48,29 +51,29 @@ TEST_CASE("Iterate boost::real_explicit::const_precision_iterator until full pre } SECTION("With carry in the upper boundary calculation") { - boost::real::real_explicit a("1.99999998"); - boost::real::real_explicit::const_precision_iterator approximation_it = a.cbegin(); + boost::real::real a("1.99999998"); + boost::real::const_precision_iterator approximation_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval; - expected_interval.lower_bound.exponent = a.exponent(); - expected_interval.lower_bound.positive = a.positive(); - expected_interval.upper_bound.exponent = a.exponent(); - expected_interval.upper_bound.positive = a.positive(); + expected_interval.lower_bound.exponent = approximation_it.get_interval().lower_bound.exponent; + expected_interval.lower_bound.positive = approximation_it.get_interval().lower_bound.positive; + expected_interval.upper_bound.exponent = approximation_it.get_interval().upper_bound.exponent; + expected_interval.upper_bound.positive = approximation_it.get_interval().upper_bound.positive; expected_interval.upper_bound.push_back(2); for (int i = 0; i < 11; i++) { - if (i < (int)a.digits().size()) { + if (i < std::get(a.get_real_number()).digits().size()) { expected_interval.lower_bound.push_back(a[i]); } - if (i == (int)a.digits().size() - 1) { + if (i == std::get(a.get_real_number()).digits().size() - 1) { expected_interval.upper_bound.clear(); for (auto d : expected_interval.lower_bound.digits) { expected_interval.upper_bound.push_back(d); } } - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } } @@ -92,13 +95,13 @@ TEST_CASE("Iterate boost::real_explicit::const_precision_iterator until full pre for (auto number : numbers) { SECTION("Testing for number " + number) { - boost::real::real_explicit a(number); - boost::real::real_explicit::const_precision_iterator approximation_it = a.cbegin(); + boost::real::real a(number); + boost::real::const_precision_iterator approximation_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval; - expected_interval.lower_bound.exponent = a.exponent(); - expected_interval.lower_bound.positive = a.positive(); - expected_interval.upper_bound.exponent = a.exponent(); - expected_interval.upper_bound.positive = a.positive(); + expected_interval.lower_bound.exponent = approximation_it.get_interval().lower_bound.exponent; + expected_interval.lower_bound.positive = approximation_it.get_interval().lower_bound.positive; + expected_interval.upper_bound.exponent = approximation_it.get_interval().upper_bound.exponent; + expected_interval.upper_bound.positive = approximation_it.get_interval().lower_bound.positive; // Boundaries are mirrored for (int i = 0; i < 11; i++) { @@ -107,15 +110,15 @@ TEST_CASE("Iterate boost::real_explicit::const_precision_iterator until full pre expected_interval.lower_bound.push_back(d); } - if (i < (int)a.digits().size() - 1) { + if (i < std::get(a.get_real_number()).digits().size() - 1) { expected_interval.upper_bound.push_back(a[i]); expected_interval.lower_bound.push_back(a[i] + 1); - } else if (i == (int)a.digits().size() - 1) { + } else if (i == std::get(a.get_real_number()).digits().size() - 1) { expected_interval.upper_bound.push_back(a[i]); expected_interval.lower_bound.push_back(a[i]); } - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } } @@ -123,29 +126,30 @@ TEST_CASE("Iterate boost::real_explicit::const_precision_iterator until full pre } SECTION("With carry in the upper boundary calculation") { - boost::real::real_explicit a("-1.99999998"); - boost::real::real_explicit::const_precision_iterator approximation_it = a.cbegin(); + boost::real::real a("-1.99999998"); + boost::real::const_precision_iterator approximation_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval; - expected_interval.lower_bound.exponent = a.exponent(); - expected_interval.lower_bound.positive = a.positive(); - expected_interval.upper_bound.exponent = a.exponent(); - expected_interval.upper_bound.positive = a.positive(); + expected_interval.lower_bound.exponent = approximation_it.get_interval().lower_bound.exponent; + expected_interval.lower_bound.positive = approximation_it.get_interval().lower_bound.positive; + expected_interval.upper_bound.exponent = approximation_it.get_interval().upper_bound.exponent; + expected_interval.upper_bound.positive = approximation_it.get_interval().upper_bound.positive; + expected_interval.lower_bound.push_back(2); for (int i = 0; i < 11; i++) { - if (i < (int)a.digits().size()) { + if (i < std::get(a.get_real_number()).digits().size()) { expected_interval.upper_bound.push_back(a[i]); } - if (i == (int)a.digits().size() - 1) { + if (i == std::get(a.get_real_number()).digits().size() - 1) { expected_interval.lower_bound.clear(); for (auto d : expected_interval.upper_bound.digits) { expected_interval.lower_bound.push_back(d); } } - CHECK( approximation_it.approximation_interval == expected_interval ); + CHECK( approximation_it.get_interval() == expected_interval ); ++approximation_it; } } @@ -154,9 +158,9 @@ TEST_CASE("Iterate boost::real_explicit::const_precision_iterator until full pre TEST_CASE("Iterator cend") { - boost::real::real_explicit a("-1.99999998"); - boost::real::real_explicit::const_precision_iterator approximation_it = a.cbegin(); - boost::real::real_explicit::const_precision_iterator end_it = a.cend(); + boost::real::real a("-1.99999998"); + boost::real::const_precision_iterator approximation_it = a.get_real_itr().cbegin(); + boost::real::const_precision_iterator end_it = a.get_real_itr().cend(); SECTION("Iterate until the full explicit number digit amount returns the end of the iterator") { @@ -172,9 +176,12 @@ TEST_CASE("Iterator cend") { SECTION("Iterate cend() returns an interval with both boundaries equal to the number") { - CHECK( end_it.approximation_interval.lower_bound == end_it.approximation_interval.upper_bound ); - CHECK( end_it.approximation_interval.lower_bound.digits == a.digits() ); - CHECK( end_it.approximation_interval.lower_bound.positive == a.positive() ); - CHECK( end_it.approximation_interval.lower_bound.exponent == a.exponent() ); + CHECK( end_it.get_interval().lower_bound == end_it.get_interval().upper_bound); + CHECK( end_it.get_interval().lower_bound.digits == + std::get(a.get_real_number()).digits()); + CHECK( end_it.get_interval().lower_bound.positive == + std::get(a.get_real_number()).positive()); + CHECK( end_it.get_interval().lower_bound.exponent == + std::get(a.get_real_number()).exponent()); } } \ No newline at end of file diff --git a/test/real_iterator_addition_addition_test.cpp b/test/real_iterator_addition_addition_test.cpp index 12e302e..885c1b6 100644 --- a/test/real_iterator_addition_addition_test.cpp +++ b/test/real_iterator_addition_addition_test.cpp @@ -18,7 +18,7 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { SECTION("(a + b) + c") { boost::real::real result = (a + b) + c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] + [1, 2]) + [1, 2] // [2, 4] + [1, 2] @@ -29,7 +29,7 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] + [1.1, 1.2]) + [1.1, 1.2] // [2.2, 2.4] + [1.1, 1.2] @@ -37,7 +37,7 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {3,3}; expected_interval.upper_bound.digits = {3,6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.19, 1.19] + [1.19, 1.19]) + [1.19, 1.19] // [3.38, 3.38] + [1.19, 1.19] @@ -45,17 +45,17 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {3,5,7}; expected_interval.upper_bound.digits = {3,5,7}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a + (b + c)") { boost::real::real result = a + (b + c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] + ([1, 2] + [1, 2]) // [1, 2] + [2, 4] @@ -66,7 +66,7 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] + ([1.1, 1.2] + [1.1, 1.2]) // [1.1, 1.2] + [2.2, 2.4] @@ -74,7 +74,7 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {3,3}; expected_interval.upper_bound.digits = {3,6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.19, 1.19] + ([1.19, 1.19] + [1.19, 1.19]) // [1.19, 1.19] + [3.8, 3.8] @@ -82,11 +82,11 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {3,5,7}; expected_interval.upper_bound.digits = {3,5,7}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } @@ -100,7 +100,7 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { SECTION("(a + b) + c") { boost::real::real result = (a + b) + c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] + [1, 2]) + [1, 2] // [2, 4] + [1, 2] @@ -111,7 +111,7 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] + [1.1, 1.2]) + [1.1, 1.2] // [2.2, 2.4] + [1.1, 1.2] @@ -119,7 +119,7 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {3,3}; expected_interval.upper_bound.digits = {3,6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.11, 1.11] + [1.11, 1.11]) + [1.11, 1.11] // [2.22, 2.22] + [1.11, 1.11] @@ -127,17 +127,17 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {3,3,3}; expected_interval.upper_bound.digits = {3,3,3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a + (b + c)") { boost::real::real result = a + (b + c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] + ([1, 2] + [1, 2]) // [1, 2] + [2, 4] @@ -148,7 +148,7 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] + ([1.1, 1.2] + [1.1, 1.2]) // [1.1, 1.2] + [2.2, 2.4] @@ -156,7 +156,7 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {3,3}; expected_interval.upper_bound.digits = {3,6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.11, 1.11] + ([1.11, 1.11] + [1.11, 1.11]) // [1.11, 1.11] + [2.22, 2.22] @@ -164,11 +164,11 @@ TEST_CASE("Operators + + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {3,3,3}; expected_interval.upper_bound.digits = {3,3,3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } } \ No newline at end of file diff --git a/test/real_iterator_addition_multiplication_test.cpp b/test/real_iterator_addition_multiplication_test.cpp index 8337a7b..35aabe4 100644 --- a/test/real_iterator_addition_multiplication_test.cpp +++ b/test/real_iterator_addition_multiplication_test.cpp @@ -17,7 +17,7 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { SECTION("(a + b) * c") { boost::real::real result = (a + b) * c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] + [1, 2]) * [1, 2] // [2, 4] * [1, 2] @@ -28,7 +28,7 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] + [1.1, 1.2]) * [1.1, 1.2] // [2.2, 2.4] * [1.1, 1.2] @@ -36,7 +36,7 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,4,2}; expected_interval.upper_bound.digits = {2,8,8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.19, 1.19] + [1.19, 1.19]) * [1.19, 1.19] // [2.38, 2.38] * [1.19, 1.19] @@ -44,17 +44,17 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,8,3,2,2}; expected_interval.upper_bound.digits = {2,8,3,2,2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a + (b * c)") { boost::real::real result = a + (b * c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] + ([1, 2] * [1, 2]) // [1, 2] + [1, 4] @@ -65,7 +65,7 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] + ([1.1, 1.2]) * [1.1, 1.2]) // [1.1, 1.2] + [1.21, 1.44] @@ -73,7 +73,7 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,3,1}; expected_interval.upper_bound.digits = {2,6,4}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.19, 1.19] + ([1.19, 1.19] * [1.19, 1.19]) // [1.19, 1.19] + [1.4161, 1.4161] @@ -81,11 +81,11 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,6,0,6,1}; expected_interval.upper_bound.digits = {2,6,0,6,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } @@ -99,7 +99,7 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { SECTION("(a + b) * c") { boost::real::real result = (a + b) * c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] + [1, 2]) * [1, 2] // [2, 4] * [1, 2] @@ -110,7 +110,7 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] + [1.1, 1.2]) * [1.1, 1.2] // [2.2, 2.4] * [1.1, 1.2] @@ -118,7 +118,7 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,4,2}; expected_interval.upper_bound.digits = {2,8,8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.11, 1.11] + [1.11, 1.11]) * [1.11, 1.11] // [2.22, 2.22] * [1.11, 1.11] @@ -126,17 +126,17 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,4,6,4,2}; expected_interval.upper_bound.digits = {2,4,6,4,2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a + (b * c)") { boost::real::real result = a + (b * c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] + ([1, 2] * [1, 2]) // [1, 2] + [1, 4] @@ -147,7 +147,7 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] + ([1.1, 1.2]) * [1.1, 1.2]) // [1.1, 1.2] + [1.21, 1.44] @@ -155,7 +155,7 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,3,1}; expected_interval.upper_bound.digits = {2,6,4}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.11, 1.11] + ([1.11, 1.11] * [1.11, 1.11]) // [1.11, 1.11] + [1.2321, 1.2321] @@ -163,11 +163,11 @@ TEST_CASE("Operators + * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,3,4,2,1}; expected_interval.upper_bound.digits = {2,3,4,2,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } } \ No newline at end of file diff --git a/test/real_iterator_addition_subtraction_test.cpp b/test/real_iterator_addition_subtraction_test.cpp index dcbb8bc..a9653bd 100644 --- a/test/real_iterator_addition_subtraction_test.cpp +++ b/test/real_iterator_addition_subtraction_test.cpp @@ -17,7 +17,7 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { SECTION("(a + b) - c") { boost::real::real result = (a + b) - c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] + [1, 2]) - [1, 2] // [2, 4] - [1, 2] @@ -28,7 +28,7 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] + [1.1, 1.2]) - [1.1, 1.2] // [2.2, 2.4] - [1.1, 1.2] @@ -37,7 +37,7 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { expected_interval.lower_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1,3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.19, 1.19] + [1.19, 1.19]) - [1.19, 1.19] // [2.38, 2.38] - [1.19, 1.19] @@ -45,17 +45,17 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,9}; expected_interval.upper_bound.digits = {1,1,9}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a + (b - c)") { boost::real::real result = a + (b - c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] + ([1, 2] - [1, 2]) // [1, 2] - [-1, 1] @@ -66,7 +66,7 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] + ([1.1, 1.2] - [1.1, 1.2]) // [1.1, 1.2] - [-0.1, 0.1] @@ -75,7 +75,7 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { expected_interval.lower_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1,3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.19, 1.19] + ([1.19, 1.19] - [1.19, 1.19]) // [1.19, 1.19] - [0, 0] @@ -83,11 +83,11 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,9}; expected_interval.upper_bound.digits = {1,1,9}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } @@ -101,7 +101,7 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { SECTION("(a + b) - c") { boost::real::real result = (a + b) - c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] + [1, 2]) - [1, 2] // [2, 4] - [1, 2] @@ -112,7 +112,7 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] + [1.1, 1.2]) - [1.1, 1.2] // [2.2, 2.4] - [1.1, 1.2] @@ -121,7 +121,7 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { expected_interval.lower_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1,3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.11, 1.11] + [1.11, 1.11]) - [1.11, 1.11] // [2.22, 2.22] - [1.11, 1.11] @@ -129,17 +129,17 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,1}; expected_interval.upper_bound.digits = {1,1,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a + (b - c)") { boost::real::real result = a + (b - c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] + ([1, 2] - [1, 2]) // [1, 2] - [-1, 1] @@ -150,7 +150,7 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] + ([1.1, 1.2] - [1.1, 1.2]) // [1.1, 1.2] - [-0.1, 0.1] @@ -159,7 +159,7 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { expected_interval.lower_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1,3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.11, 1.11] + ([1.11, 1.11] - [1.11, 1.11]) // [1.11, 1.11] - [0, 0] @@ -167,11 +167,11 @@ TEST_CASE("Operators + - boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,1}; expected_interval.upper_bound.digits = {1,1,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } } \ No newline at end of file diff --git a/test/real_iterator_addition_test.cpp b/test/real_iterator_addition_test.cpp index f6882b2..9eaa715 100644 --- a/test/real_iterator_addition_test.cpp +++ b/test/real_iterator_addition_test.cpp @@ -25,7 +25,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { boost::real::real a = numbers["E(+1.9)"] + numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -35,27 +35,27 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3, 8}; expected_interval.upper_bound.digits = {3, 9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3, 8, 9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3, 8, 9, 9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["E(+1.1)"] + numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -65,29 +65,29 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 2}; expected_interval.upper_bound.digits = {2, 3}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 2, 1}; expected_interval.upper_bound.digits = {2, 2, 2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 2, 1, 1}; expected_interval.upper_bound.digits = {2, 2, 1, 2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["E(+1.9)"] + numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -97,29 +97,29 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {3,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,0,1}; expected_interval.upper_bound.digits = {3,0,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,0,1,1}; expected_interval.upper_bound.digits = {3,0,1,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(+1.9)"] + numbers["E(+1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -129,25 +129,25 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,8}; expected_interval.upper_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(+1.1)"] + numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -157,25 +157,25 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2}; expected_interval.upper_bound.digits = {2,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, No]") { boost::real::real a = numbers["E(+1.9)"] + numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -185,25 +185,25 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {3}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(+1.99..)"] + numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -213,26 +213,26 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,9,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,9,9,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(+1.11..)"] + numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -242,29 +242,29 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2}; expected_interval.upper_bound.digits = {2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,2}; expected_interval.upper_bound.digits = {2,2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,2,2}; expected_interval.upper_bound.digits = {2,2,2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["A(+1.99..)"] + numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -274,22 +274,22 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {3,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,1}; expected_interval.upper_bound.digits = {3,1,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,1,1}; expected_interval.upper_bound.digits = {3,1,1,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } @@ -299,7 +299,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { boost::real::real a = numbers["E(-1.9)"] + numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -309,27 +309,27 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3, 9}; expected_interval.upper_bound.digits = {3, 8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3, 8, 9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3, 8, 9, 9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] + numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -339,22 +339,22 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 3}; expected_interval.upper_bound.digits = {2, 2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 2, 2}; expected_interval.upper_bound.digits = {2, 2, 1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 2, 1, 2}; expected_interval.upper_bound.digits = {2, 2, 1, 1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } @@ -362,7 +362,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { boost::real::real a = numbers["E(-1.9)"] + numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -372,29 +372,29 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,1}; expected_interval.upper_bound.digits = {3}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,0,2}; expected_interval.upper_bound.digits = {3,0,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,0,1,2}; expected_interval.upper_bound.digits = {3,0,1,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(-1.9)"] + numbers["E(-1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -404,25 +404,25 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,8}; expected_interval.upper_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] + numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -432,25 +432,25 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2}; expected_interval.upper_bound.digits = {2,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, No]") { boost::real::real a = numbers["E(-1.9)"] + numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -460,25 +460,25 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {3}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(-1.99..)"] + numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -488,26 +488,26 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,9,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,9,9,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(-1.11..)"] + numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -517,29 +517,31 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,4}; expected_interval.upper_bound.digits = {2,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); + //failing, a_it was iterated twice. this is because operation has + // two pointers to the same number. Hmmm ++a_it; expected_interval.lower_bound.digits = {2,2,4}; expected_interval.upper_bound.digits = {2,2,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,2,4}; expected_interval.upper_bound.digits = {2,2,2,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["A(-1.99..)"] + numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -549,22 +551,22 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,2}; expected_interval.upper_bound.digits = {3}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,1,2}; expected_interval.upper_bound.digits = {3,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,1,1,2}; expected_interval.upper_bound.digits = {3,1,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } @@ -573,7 +575,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { boost::real::real a = numbers["E(-1.9)"] + numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); expected_interval.lower_bound.positive = false; @@ -584,7 +586,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -593,23 +595,23 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.lower_bound.digits = {9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {9,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] + numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); expected_interval.lower_bound.positive = false; @@ -618,7 +620,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -626,26 +628,26 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.upper_bound.exponent = -1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,1}; expected_interval.upper_bound.digits = {1,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["E(-1.9)"] + numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); expected_interval.lower_bound.positive = false; @@ -654,7 +656,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.upper_bound.digits = {1}; expected_interval.lower_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.positive = false; @@ -662,24 +664,24 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {8}; expected_interval.upper_bound.digits = {7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {7,9}; expected_interval.upper_bound.digits = {7,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {7,8,9}; expected_interval.upper_bound.digits = {7,8,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(-1.9)"] + numbers["E(+1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -689,7 +691,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -697,20 +699,20 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] + numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -720,7 +722,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -728,20 +730,20 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, No]") { boost::real::real a = numbers["E(-1.9)"] + numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); expected_interval.lower_bound.positive = false; @@ -750,7 +752,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.upper_bound.digits = {1}; expected_interval.lower_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.positive = false; @@ -758,20 +760,20 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {8}; expected_interval.upper_bound.digits = {8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(-1.99..)"] + numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -781,31 +783,31 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = 0; expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.upper_bound.exponent = -1; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -2; expected_interval.upper_bound.exponent = -2; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(-1.11..)"] + numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -815,29 +817,29 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = 0; expected_interval.upper_bound.exponent = 0; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.upper_bound.exponent = -1; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -2; expected_interval.upper_bound.exponent = -2; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["A(-1.99..)"] + numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -847,7 +849,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.upper_bound.digits = {1}; expected_interval.lower_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.positive = false; @@ -855,17 +857,17 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {9}; expected_interval.upper_bound.digits = {7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {8,9}; expected_interval.upper_bound.digits = {8,7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {8,8,9}; expected_interval.upper_bound.digits = {8,8,7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } @@ -876,7 +878,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { boost::real::real a = numbers["A(+1.99..)"] + numbers["E(-1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -886,7 +888,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -895,23 +897,23 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.lower_bound.digits = {9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {9,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["A(+1.11..)"] + numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); expected_interval.lower_bound.positive = false; @@ -920,7 +922,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -928,26 +930,26 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.upper_bound.exponent = -1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,1}; expected_interval.upper_bound.digits = {1,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Explicit] - overflow: [No, Yes]") { boost::real::real a = numbers["A(+1.11..)"] + numbers["E(-1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); expected_interval.lower_bound.positive = false; @@ -956,7 +958,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.upper_bound.digits = {1}; expected_interval.lower_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.positive = false; @@ -964,24 +966,24 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {8}; expected_interval.upper_bound.digits = {7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {7,9}; expected_interval.upper_bound.digits = {7,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {7,8,9}; expected_interval.upper_bound.digits = {7,8,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(+1.9)"] + numbers["E(-1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -991,7 +993,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -999,20 +1001,20 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(+1.1)"] + numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1022,7 +1024,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -1030,20 +1032,20 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, Yes]") { boost::real::real a = numbers["E(+1.1)"] + numbers["E(-1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); expected_interval.lower_bound.positive = false; @@ -1052,7 +1054,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.upper_bound.digits = {1}; expected_interval.lower_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.positive = false; @@ -1060,20 +1062,20 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {8}; expected_interval.upper_bound.digits = {8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(+1.99..)"] + numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1083,31 +1085,31 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = 0; expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.upper_bound.exponent = -1; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -2; expected_interval.upper_bound.exponent = -2; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(+1.11..)"] + numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1117,29 +1119,29 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = 0; expected_interval.upper_bound.exponent = 0; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.upper_bound.exponent = -1; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -2; expected_interval.upper_bound.exponent = -2; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, Yes]") { boost::real::real a = numbers["A(+1.11..)"] + numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1149,7 +1151,7 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.upper_bound.digits = {1}; expected_interval.lower_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.positive = false; @@ -1157,17 +1159,17 @@ TEST_CASE("Operator + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {9}; expected_interval.upper_bound.digits = {7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {8,9}; expected_interval.upper_bound.digits = {8,7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {8,8,9}; expected_interval.upper_bound.digits = {8,8,7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } } \ No newline at end of file diff --git a/test/real_iterator_multiplication_addition_test.cpp b/test/real_iterator_multiplication_addition_test.cpp index e3a8448..e2e169b 100644 --- a/test/real_iterator_multiplication_addition_test.cpp +++ b/test/real_iterator_multiplication_addition_test.cpp @@ -17,7 +17,7 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { SECTION("(a * b) + c") { boost::real::real result = (a * b) + c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] * [1, 2]) + [1, 2] // [1, 4] + [1, 2] @@ -28,7 +28,7 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] * [1.1, 1.2]) + [1.1, 1.2] // [1.21, 1.44] + [1.1, 1.2] @@ -36,7 +36,7 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,3,1}; expected_interval.upper_bound.digits = {2,6,4}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.19, 1.19] * [1.19, 1.19]) + [1.19, 1.19] // [1.4161, 1.4161] + [1.19, 1.19] @@ -44,17 +44,17 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,6,0,6,1}; expected_interval.upper_bound.digits = {2,6,0,6,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a * (b + c)") { boost::real::real result = a * (b + c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] * ([1, 2] + [1, 2]) // [1, 2] * [2, 4] @@ -65,7 +65,7 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] * ([1.1, 1.2]) + [1.1, 1.2]) // [1.1, 1.2] * [2.2, 2.4] @@ -73,7 +73,7 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,4,2}; expected_interval.upper_bound.digits = {2,8,8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.19, 1.19] * ([1.19, 1.19] + [1.19, 1.19]) // [1.19, 1.19] * [2.38, 2.38] @@ -81,11 +81,11 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,8,3,2,2}; expected_interval.upper_bound.digits = {2,8,3,2,2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } @@ -99,7 +99,7 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { SECTION("(a * b) + c") { boost::real::real result = (a * b) + c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] * [1, 2]) + [1, 2] // [1, 4] + [1, 2] @@ -110,7 +110,7 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {6}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] * [1.1, 1.2]) + [1.1, 1.2] // [1.21, 1.44] + [1.1, 1.2] @@ -118,7 +118,7 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,3,1}; expected_interval.upper_bound.digits = {2,6,4}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.11, 1.11] * [1.11, 1.11]) + [1.11, 1.11] // [1.2321, 1.2321] + [1.11, 1.11] @@ -126,17 +126,17 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,3,4,2,1}; expected_interval.upper_bound.digits = {2,3,4,2,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a * (b + c)") { boost::real::real result = a * (b + c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] * ([1, 2] + [1, 2]) // [1, 2] * [2, 4] @@ -147,7 +147,7 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] * ([1.1, 1.2]) + [1.1, 1.2]) // [1.1, 1.2] * [2.2, 2.4] @@ -155,7 +155,7 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,4,2}; expected_interval.upper_bound.digits = {2,8,8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.11, 1.11] * ([1.11, 1.11] + [1.11, 1.11]) // [1.11, 1.11] * [2.22, 2.22] @@ -163,11 +163,11 @@ TEST_CASE("Operators * + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {2,4,6,4,2}; expected_interval.upper_bound.digits = {2,4,6,4,2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } } \ No newline at end of file diff --git a/test/real_iterator_multiplication_multiplication_test.cpp b/test/real_iterator_multiplication_multiplication_test.cpp index 9c07d7d..e0e5131 100644 --- a/test/real_iterator_multiplication_multiplication_test.cpp +++ b/test/real_iterator_multiplication_multiplication_test.cpp @@ -17,7 +17,7 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { SECTION("(a * b) * c") { boost::real::real result = (a * b) * c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] * [1, 2]) * [1, 2] // [1, 4] * [1, 2] @@ -28,7 +28,7 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] * [1.1, 1.2]) * [1.1, 1.2] // [1.21, 1.44] * [1.1, 1.2] @@ -36,7 +36,7 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,3,3,1}; expected_interval.upper_bound.digits = {1,7,2,8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.19, 1.19] * [1.19, 1.19]) * [1.19, 1.19] // [1.4161, 1.4161] * [1.19, 1.19] @@ -44,17 +44,17 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,6,8,5,1,5,9}; expected_interval.upper_bound.digits = {1,6,8,5,1,5,9}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a * (b * c)") { boost::real::real result = a * (b * c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] * ([1, 2] * [1, 2]) // [1, 2] * [1, 4] @@ -65,7 +65,7 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] * ([1.1, 1.2] * [1.1, 1.2]) // [1.1, 1.2] * [1.21, 1.44] @@ -73,7 +73,7 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,3,3,1}; expected_interval.upper_bound.digits = {1,7,2,8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.19, 1.19] * ([1.19, 1.19] * [1.19, 1.19]) // [1.19, 1.19] * [1.4161, 1.4161] @@ -81,11 +81,11 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,6,8,5,1,5,9}; expected_interval.upper_bound.digits = {1,6,8,5,1,5,9}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } @@ -99,7 +99,7 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { SECTION("(a * b) * c") { boost::real::real result = (a * b) * c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] * [1, 2]) * [1, 2] // [1, 4] * [1, 2] @@ -110,7 +110,7 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] * [1.1, 1.2]) * [1.1, 1.2] // [1.21, 1.44] * [1.1, 1.2] @@ -118,7 +118,7 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,3,3,1}; expected_interval.upper_bound.digits = {1,7,2,8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.11, 1.11] * [1.11, 1.11]) * [1.11, 1.11] // [1.2321, 1.2321] * [1.11, 1.11] @@ -126,17 +126,17 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,3,6,7,6,3,1}; expected_interval.upper_bound.digits = {1,3,6,7,6,3,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a * (b * c)") { boost::real::real result = a * (b * c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] * ([1, 2] * [1, 2]) // [1, 2] * [1, 4] @@ -147,7 +147,7 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] * ([1.1, 1.2] * [1.1, 1.2]) // [1.1, 1.2] * [1.21, 1.44] @@ -155,7 +155,7 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,3,3,1}; expected_interval.upper_bound.digits = {1,7,2,8}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.11, 1.11] * ([1.11, 1.11] * [1.11, 1.11]) // [1.11, 1.11] * [1.2321, 1.2321] @@ -163,11 +163,11 @@ TEST_CASE("Operators * * boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,3,6,7,6,3,1}; expected_interval.upper_bound.digits = {1,3,6,7,6,3,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } } \ No newline at end of file diff --git a/test/real_iterator_multiplication_subtraction_test.cpp b/test/real_iterator_multiplication_subtraction_test.cpp index bf05b2a..ca7e9ef 100644 --- a/test/real_iterator_multiplication_subtraction_test.cpp +++ b/test/real_iterator_multiplication_subtraction_test.cpp @@ -17,7 +17,7 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { SECTION("(a * b) - c") { boost::real::real result = (a * b) - c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] * [1, 2]) - [1, 2] // [1, 4] - [1, 2] @@ -28,7 +28,7 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] * [1.1, 1.2]) - [1.1, 1.2] // [1.21, 1.44] - [1.1, 1.2] @@ -39,7 +39,7 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {3,4}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.19, 1.19] * [1.19, 1.19]) - [1.19, 1.19] // [1.4161, 1.4161] - [1.19, 1.19] @@ -48,17 +48,17 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.lower_bound.exponent = 0; expected_interval.lower_bound.digits = {2,2,6,1}; expected_interval.upper_bound.digits = {2,2,6,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a * (b - c)") { boost::real::real result = a * (b - c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] * ([1, 2] - [1, 2]) // [1, 2] * [-1, 1] @@ -69,7 +69,7 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] * ([1.1, 1.2]) - [1.1, 1.2]) // [1.1, 1.2] * [-0.1, 0.1] @@ -79,7 +79,7 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1,2}; expected_interval.upper_bound.digits = {1,2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.19, 1.19] * ([1.19, 1.19] - [1.19, 1.19]) // [1.19, 1.19] * [0, 0] @@ -88,11 +88,11 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.lower_bound.positive = true; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } @@ -106,7 +106,7 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { SECTION("(a * b) - c") { boost::real::real result = (a * b) - c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] * [1, 2]) - [1, 2] // [1, 4] - [1, 2] @@ -117,7 +117,7 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] * [1.1, 1.2]) - [1.1, 1.2] // [1.21, 1.44] - [1.1, 1.2] @@ -128,7 +128,7 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {3,4}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.11, 1.11] * [1.11, 1.11]) - [1.11, 1.11] // [1.2321, 1.2321] - [1.11, 1.11] @@ -137,17 +137,17 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.lower_bound.exponent = 0; expected_interval.lower_bound.digits = {1,2,2,1}; expected_interval.upper_bound.digits = {1,2,2,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a * (b - c)") { boost::real::real result = a * (b - c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] * ([1, 2] - [1, 2]) // [1, 2] * [-1, 1] @@ -158,7 +158,7 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] * ([1.1, 1.2]) - [1.1, 1.2]) // [1.1, 1.2] * [-0.1, 0.1] @@ -168,7 +168,7 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1,2}; expected_interval.upper_bound.digits = {1,2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.11, 1.11] * ([1.11, 1.11] - [1.11, 1.11]) // [1.11, 1.11] * [0, 0] @@ -177,11 +177,11 @@ TEST_CASE("Operators * - boost::real::const_precision_iterator") { expected_interval.lower_bound.positive = true; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } } \ No newline at end of file diff --git a/test/real_iterator_multiplication_test.cpp b/test/real_iterator_multiplication_test.cpp index 8b78380..c137b52 100644 --- a/test/real_iterator_multiplication_test.cpp +++ b/test/real_iterator_multiplication_test.cpp @@ -25,7 +25,7 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { boost::real::real a = numbers["E(+1.9)"] * numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -35,27 +35,27 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,6,1}; expected_interval.upper_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,7,8,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,7,9,8,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["E(+1.1)"] * numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -65,29 +65,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,1}; expected_interval.upper_bound.digits = {1,3,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,2,1}; expected_interval.upper_bound.digits = {1,2,3,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,2,2,1}; expected_interval.upper_bound.digits = {1,2,2,3,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["E(+1.9)"] * numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -97,29 +97,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,0,9}; expected_interval.upper_bound.digits = {2,2,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,1,0,9}; expected_interval.upper_bound.digits = {2,1,2,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,1,1,0,9}; expected_interval.upper_bound.digits = {2,1,1,2,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(+1.9)"] * numbers["E(+1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -129,25 +129,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,6,1}; expected_interval.upper_bound.digits = {3,6,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(+1.1)"] * numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -157,25 +157,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,1}; expected_interval.upper_bound.digits = {1,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, No]") { boost::real::real a = numbers["E(+1.9)"] * numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -185,25 +185,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,0,9}; expected_interval.upper_bound.digits = {2,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(+1.99..)"] * numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -213,26 +213,26 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,6,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,9,6,0,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,9,9,6,0,0,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(+1.11..)"] * numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -242,29 +242,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,1}; expected_interval.upper_bound.digits = {1,4,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,3,2,1}; expected_interval.upper_bound.digits = {1,2,5,4,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,3,4,3,2,1}; expected_interval.upper_bound.digits = {1,2,3,6,5,4,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["A(+1.99..)"] * numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -274,22 +274,22 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,0,9}; expected_interval.upper_bound.digits = {2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,0,8,9}; expected_interval.upper_bound.digits = {2,2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,2,0,8,8,9}; expected_interval.upper_bound.digits = {2,2,2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } @@ -299,7 +299,7 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { boost::real::real a = numbers["E(-1.9)"] * numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -309,27 +309,27 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,6,1}; expected_interval.upper_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,7,8,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,7,9,8,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] * numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -339,29 +339,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,1}; expected_interval.upper_bound.digits = {1,3,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,2,1}; expected_interval.upper_bound.digits = {1,2,3,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,2,2,1}; expected_interval.upper_bound.digits = {1,2,2,3,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["E(-1.9)"] * numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -371,29 +371,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,0,9}; expected_interval.upper_bound.digits = {2,2,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,1,0,9}; expected_interval.upper_bound.digits = {2,1,2,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,1,1,0,9}; expected_interval.upper_bound.digits = {2,1,1,2,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(-1.9)"] * numbers["E(-1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -403,25 +403,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,6,1}; expected_interval.upper_bound.digits = {3,6,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] * numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -431,25 +431,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,1}; expected_interval.upper_bound.digits = {1,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, No]") { boost::real::real a = numbers["E(-1.9)"] * numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -459,25 +459,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,0,9}; expected_interval.upper_bound.digits = {2,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(-1.99..)"] * numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -487,26 +487,26 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,6,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,9,6,0,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,9,9,6,0,0,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(-1.11..)"] * numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -516,29 +516,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,1}; expected_interval.upper_bound.digits = {1,4,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,3,2,1}; expected_interval.upper_bound.digits = {1,2,5,4,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,3,4,3,2,1}; expected_interval.upper_bound.digits = {1,2,3,6,5,4,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["A(-1.99..)"] * numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -548,22 +548,22 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,0,9}; expected_interval.upper_bound.digits = {2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,0,8,9}; expected_interval.upper_bound.digits = {2,2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,2,0,8,8,9}; expected_interval.upper_bound.digits = {2,2,2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } @@ -572,7 +572,7 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { boost::real::real a = numbers["E(-1.9)"] * numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -582,27 +582,27 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,6,1}; expected_interval.lower_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,7,8,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,7,9,8,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] * numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -612,29 +612,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,3,2}; expected_interval.upper_bound.digits = {1,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,3,2}; expected_interval.upper_bound.digits = {1,2,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,2,3,2}; expected_interval.upper_bound.digits = {1,2,2,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["E(-1.9)"] * numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -644,29 +644,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,8}; expected_interval.upper_bound.digits = {2,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,1,2,8}; expected_interval.upper_bound.digits = {2,1,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,1,1,2,8}; expected_interval.upper_bound.digits = {2,1,1,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(-1.9)"] * numbers["E(+1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -676,25 +676,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,6,1}; expected_interval.upper_bound.digits = {3,6,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] * numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -704,25 +704,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,1}; expected_interval.upper_bound.digits = {1,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, No]") { boost::real::real a = numbers["E(-1.9)"] * numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -732,25 +732,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,0,9}; expected_interval.upper_bound.digits = {2,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(-1.99..)"] * numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -760,26 +760,26 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,6,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,9,6,0,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,9,9,6,0,0,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(-1.11..)"] * numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -789,29 +789,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,4,4}; expected_interval.upper_bound.digits = {1,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,5,4,4}; expected_interval.upper_bound.digits = {1,2,3,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,3,6,5,4,4}; expected_interval.upper_bound.digits = {1,2,3,4,3,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["A(-1.99..)"] * numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -821,22 +821,22 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,4}; expected_interval.upper_bound.digits = {2,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,4}; expected_interval.upper_bound.digits = {2,2,0,8,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,2,4}; expected_interval.upper_bound.digits = {2,2,2,0,8,8,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } @@ -847,7 +847,7 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { boost::real::real a = numbers["E(+1.9)"] * numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -857,27 +857,27 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,6,1}; expected_interval.lower_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,7,8,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,7,9,8,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["E(+1.1)"] * numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -887,29 +887,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,3,2}; expected_interval.upper_bound.digits = {1,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,3,2}; expected_interval.upper_bound.digits = {1,2,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,2,3,2}; expected_interval.upper_bound.digits = {1,2,2,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["E(+1.9)"] * numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -919,29 +919,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,8}; expected_interval.upper_bound.digits = {2,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,1,2,8}; expected_interval.upper_bound.digits = {2,1,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,1,1,2,8}; expected_interval.upper_bound.digits = {2,1,1,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(+1.9)"] * numbers["E(-1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -951,25 +951,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,6,1}; expected_interval.upper_bound.digits = {3,6,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(+1.1)"] * numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -979,25 +979,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,1}; expected_interval.upper_bound.digits = {1,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, No]") { boost::real::real a = numbers["E(+1.9)"] * numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1007,25 +1007,25 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,0,9}; expected_interval.upper_bound.digits = {2,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(+1.99..)"] * numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1035,26 +1035,26 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,6,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,9,6,0,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,9,9,6,0,0,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(+1.11..)"] * numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1064,29 +1064,29 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,4,4}; expected_interval.upper_bound.digits = {1,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,5,4,4}; expected_interval.upper_bound.digits = {1,2,3,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,2,3,6,5,4,4}; expected_interval.upper_bound.digits = {1,2,3,4,3,2,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["A(+1.99..)"] * numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1096,22 +1096,22 @@ TEST_CASE("Operator * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,4}; expected_interval.upper_bound.digits = {2,0,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,4}; expected_interval.upper_bound.digits = {2,2,0,8,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,2,4}; expected_interval.upper_bound.digits = {2,2,2,0,8,8,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } } \ No newline at end of file diff --git a/test/real_iterator_subtraction_addition_test.cpp b/test/real_iterator_subtraction_addition_test.cpp index b0b6ac1..a882c1b 100644 --- a/test/real_iterator_subtraction_addition_test.cpp +++ b/test/real_iterator_subtraction_addition_test.cpp @@ -17,7 +17,7 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { SECTION("(a - b) + c") { boost::real::real result = (a - b) + c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] - [1, 2]) + [1, 2] // [-1, 1] + [1, 2] @@ -28,7 +28,7 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] - [1.1, 1.2]) + [1.1, 1.2] // [-0.1, 0.1] + [1.1, 1.2] @@ -37,7 +37,7 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { expected_interval.lower_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1,3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.19, 1.19] - [1.19, 1.19]) + [1.19, 1.19] // [0, 0] + [1.19, 1.19] @@ -45,17 +45,17 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,9}; expected_interval.upper_bound.digits = {1,1,9}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a - (b + c)") { boost::real::real result = a - (b + c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] - ([1, 2] + [1, 2]) // [1, 2] - [2, 4] @@ -66,7 +66,7 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {0}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] - ([1.1, 1.2] + [1.1, 1.2]) // [1.1, 1.2] - [2.2, 2.4] @@ -76,7 +76,7 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1,3}; expected_interval.upper_bound.digits = {1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.19, 1.19] - ([1.19, 1.19] + [1.19, 1.19]) // [1.19, 1.19] - [2.38, 2.38] @@ -84,11 +84,11 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,9}; expected_interval.upper_bound.digits = {1,1,9}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } @@ -102,7 +102,7 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { SECTION("(a - b) + c") { boost::real::real result = (a - b) + c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] - [1, 2]) + [1, 2] // [-1, 1] + [1, 2] @@ -113,7 +113,7 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] - [1.1, 1.2]) + [1.1, 1.2] // [-0.1, 0.1] + [1.1, 1.2] @@ -122,7 +122,7 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { expected_interval.lower_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1,3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.11, 1.11] - [1.11, 1.11]) + [1.11, 1.11] // [0, 0] + [1.11, 1.11] @@ -130,17 +130,17 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,1}; expected_interval.upper_bound.digits = {1,1,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a - (b + c)") { boost::real::real result = a - (b + c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] - ([1, 2] + [1, 2]) // [1, 2] - [2, 4] @@ -151,7 +151,7 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {0}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] - ([1.1, 1.2] + [1.1, 1.2]) // [1.1, 1.2] - [2.2, 2.4] @@ -161,7 +161,7 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1,3}; expected_interval.upper_bound.digits = {1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.11, 1.11] - ([1.11, 1.11] + [1.11, 1.11]) // [1.11, 1.11] - [2.38, 2.38] @@ -169,11 +169,11 @@ TEST_CASE("Operators - + boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,1}; expected_interval.upper_bound.digits = {1,1,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } } \ No newline at end of file diff --git a/test/real_iterator_subtraction_multiplication_test.cpp b/test/real_iterator_subtraction_multiplication_test.cpp index 030187f..9f511a8 100644 --- a/test/real_iterator_subtraction_multiplication_test.cpp +++ b/test/real_iterator_subtraction_multiplication_test.cpp @@ -17,7 +17,7 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { SECTION("(a - b) * c") { boost::real::real result = (a - b) * c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] - [1, 2]) * [1, 2] // [-1, 1] * [1, 2] @@ -28,7 +28,7 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] - [1.1, 1.2]) * [1.1, 1.2] // [-0.1, 0.1] * [1.1, 1.2] @@ -38,7 +38,7 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1,2}; expected_interval.upper_bound.digits = {1,2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.19, 1.19] - [1.19, 1.19]) * [1.19, 1.19] // [0, 0] * [1.19, 1.19] @@ -47,17 +47,17 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.lower_bound.positive = true; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a - (b * c)") { boost::real::real result = a - (b * c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] - ([1, 2] * [1, 2]) // [1, 2] - [1, 4] @@ -68,7 +68,7 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] - ([1.1, 1.2] * [1.1, 1.2]) // [1.1, 1.2] - [1.21, 1.44] @@ -79,7 +79,7 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = -1; expected_interval.lower_bound.digits = {3,4}; expected_interval.upper_bound.digits = {1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.19, 1.19] - ([1.19, 1.19] * [1.19, 1.19]) // [1.19, 1.19] * [1,4161, 1,4161] @@ -88,11 +88,11 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {2,2,6,1}; expected_interval.upper_bound.digits = {2,2,6,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } @@ -106,7 +106,7 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { SECTION("(a - b) * c") { boost::real::real result = (a - b) * c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] - [1, 2]) * [1, 2] // [-1, 1] * [1, 2] @@ -117,7 +117,7 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] - [1.1, 1.2]) * [1.1, 1.2] // [-0.1, 0.1] * [1.1, 1.2] @@ -127,7 +127,7 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1,2}; expected_interval.upper_bound.digits = {1,2}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.11, 1.11] - [1.11, 1.11]) * [1.11, 1.11] // [0, 0] * [1.11, 1.11] @@ -136,17 +136,17 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.lower_bound.positive = true; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a - (b * c)") { boost::real::real result = a - (b * c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] - ([1, 2] * [1, 2]) // [1, 2] - [1, 4] @@ -157,7 +157,7 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] - ([1.1, 1.2] * [1.1, 1.2]) // [1.1, 1.2] - [1.21, 1.44] @@ -168,7 +168,7 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = -1; expected_interval.lower_bound.digits = {3,4}; expected_interval.upper_bound.digits = {1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.11, 1.11] - ([1.11, 1.11] * [1.11, 1.11]) // [1.11, 1.11] - [1,2321, 1,2321] @@ -177,11 +177,11 @@ TEST_CASE("Operators - * boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1,2,2,1}; expected_interval.upper_bound.digits = {1,2,2,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } } \ No newline at end of file diff --git a/test/real_iterator_subtraction_subtraction_test.cpp b/test/real_iterator_subtraction_subtraction_test.cpp index 10ed375..3b0fc4c 100644 --- a/test/real_iterator_subtraction_subtraction_test.cpp +++ b/test/real_iterator_subtraction_subtraction_test.cpp @@ -17,7 +17,7 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { SECTION("(a - b) - c") { boost::real::real result = (a - b) - c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] - [1, 2]) - [1, 2] // [-1, 1] - [1, 2] @@ -28,7 +28,7 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {0}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] - [1.1, 1.2]) - [1.1, 1.2] // [-0.1, 0.1] - [1.1, 1.2] @@ -38,7 +38,7 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1,3}; expected_interval.upper_bound.digits = {1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.19, 1.19] - [1.19, 1.19]) - [1.19, 1.19] // [0, 0] - [1.19, 1.19] @@ -46,17 +46,17 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,9}; expected_interval.upper_bound.digits = {1,1,9}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a - (b - c)") { boost::real::real result = a - (b - c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] - ([1, 2] - [1, 2]) // [1, 2] - [-1, 1] @@ -67,7 +67,7 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] - ([1.1, 1.2] - [1.1, 1.2]) // [1.1, 1.2] - [-0.1, 0.1] @@ -76,7 +76,7 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { expected_interval.lower_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1,3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.19, 1.19] - ([1.19, 1.19] - [1.19, 1.19]) // [1.19, 1.19] - [0, 0] @@ -84,11 +84,11 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,9}; expected_interval.upper_bound.digits = {1,1,9}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } @@ -102,7 +102,7 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { SECTION("(a - b) - c") { boost::real::real result = (a - b) - c; - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // ([1, 2] - [1, 2]) - [1, 2] // [-1, 1] - [1, 2] @@ -113,7 +113,7 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {0}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.1, 1.2] - [1.1, 1.2]) - [1.1, 1.2] // [-0.1, 0.1] - [1.1, 1.2] @@ -123,7 +123,7 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1,3}; expected_interval.upper_bound.digits = {1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // ([1.11, 1.11] - [1.11, 1.11]) - [1.11, 1.11] // [0, 0] - [1.11, 1.11] @@ -131,17 +131,17 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,1}; expected_interval.upper_bound.digits = {1,1,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } SECTION("a - (b - c)") { boost::real::real result = a - (b - c); - auto result_it = result.cbegin(); + auto result_it = result.get_real_itr().cbegin(); // [1, 2] - ([1, 2] - [1, 2]) // [1, 2] - [-1, 1] @@ -152,7 +152,7 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.1, 1.2] - ([1.1, 1.2] - [1.1, 1.2]) // [1.1, 1.2] - [-0.1, 0.1] @@ -161,7 +161,7 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { expected_interval.lower_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1,3}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // [1.11, 1.11] - ([1.11, 1.11] - [1.11, 1.11]) // [1.11, 1.11] - [0, 0] @@ -169,11 +169,11 @@ TEST_CASE("Operators - - boost::real::const_precision_iterator") { ++result_it; expected_interval.lower_bound.digits = {1,1,1}; expected_interval.upper_bound.digits = {1,1,1}; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); // Full precision reached, no more changes are made ++result_it; - CHECK(expected_interval == result_it.approximation_interval); + CHECK(expected_interval == result_it.get_interval()); } } } \ No newline at end of file diff --git a/test/real_iterator_subtraction_test.cpp b/test/real_iterator_subtraction_test.cpp index 7c2a60c..e6d78ef 100644 --- a/test/real_iterator_subtraction_test.cpp +++ b/test/real_iterator_subtraction_test.cpp @@ -26,7 +26,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { boost::real::real a = numbers["E(+1.9)"] - numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -36,31 +36,31 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = 0; expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.positive = false; expected_interval.upper_bound.exponent = -1; expected_interval.upper_bound.digits = {9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {9,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["E(+1.1)"] - numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -70,7 +70,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; // 1.1 - [1.1, 1.2] @@ -78,7 +78,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; // 1.1 - [1.11, 1.12] @@ -87,7 +87,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = -1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; // 1.1 - [1.111, 1.112] @@ -95,14 +95,14 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = -1; expected_interval.lower_bound.digits = {1,2}; expected_interval.upper_bound.digits = {1,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["E(+1.9)"] - numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -112,7 +112,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -120,24 +120,24 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {7}; expected_interval.upper_bound.digits = {8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {7,8}; expected_interval.upper_bound.digits = {7,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {7,8,8}; expected_interval.upper_bound.digits = {7,8,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(+1.9)"] - numbers["E(+1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -147,7 +147,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -155,20 +155,20 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(+1.1)"] - numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -179,7 +179,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -187,20 +187,20 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, No]") { boost::real::real a = numbers["E(+1.9)"] - numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -210,7 +210,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -218,20 +218,20 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {8}; expected_interval.upper_bound.digits = {8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(+1.99..)"] - numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -241,32 +241,32 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = 0; expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {1}; expected_interval.lower_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.upper_bound.exponent = -1; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -2; expected_interval.upper_bound.exponent = -2; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(+1.11..)"] - numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -276,29 +276,29 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = 0; expected_interval.upper_bound.exponent = 0; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.upper_bound.exponent = -1; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -2; expected_interval.upper_bound.exponent = -2; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["A(+1.99..)"] - numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -308,7 +308,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -316,17 +316,17 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {7}; expected_interval.upper_bound.digits = {9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {8,7}; expected_interval.upper_bound.digits = {8,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {8,8,7}; expected_interval.upper_bound.digits = {8,8,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } @@ -336,7 +336,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { boost::real::real a = numbers["E(-1.9)"] - numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -346,7 +346,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; @@ -354,23 +354,23 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.lower_bound.exponent = 0; expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.lower_bound.digits = {9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {9,9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] - numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -380,26 +380,26 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; expected_interval.lower_bound.exponent = 0; expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.upper_bound.exponent = -1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {1,1}; expected_interval.upper_bound.digits = {1,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } @@ -407,7 +407,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { boost::real::real a = numbers["E(-1.9)"] - numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -417,7 +417,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.positive = false; @@ -425,24 +425,24 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {8}; expected_interval.upper_bound.digits = {7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {7,9}; expected_interval.upper_bound.digits = {7,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {7,8,9}; expected_interval.upper_bound.digits = {7,8,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(-1.9)"] - numbers["E(-1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -452,7 +452,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -461,20 +461,20 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] - numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -484,7 +484,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = true; @@ -493,20 +493,20 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {0}; expected_interval.upper_bound.digits = {0}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, No]") { boost::real::real a = numbers["E(-1.9)"] - numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -516,7 +516,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {1}; expected_interval.upper_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.positive = false; @@ -525,20 +525,20 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {8}; expected_interval.upper_bound.digits = {8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(-1.99..)"] - numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -548,29 +548,29 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.upper_bound.digits = {1}; expected_interval.lower_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = 0; expected_interval.upper_bound.exponent = 0; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.upper_bound.exponent = -1; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -2; expected_interval.upper_bound.exponent = -2; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(-1.11..)"] - numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -580,29 +580,29 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.upper_bound.digits = {1}; expected_interval.lower_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = 0; expected_interval.upper_bound.exponent = 0; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -1; expected_interval.upper_bound.exponent = -1; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.exponent = -2; expected_interval.upper_bound.exponent = -2; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["A(-1.99..)"] - numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -612,7 +612,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.upper_bound.digits = {1}; expected_interval.lower_bound.digits = {1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.positive = false; @@ -620,17 +620,17 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 0; expected_interval.lower_bound.digits = {9}; expected_interval.upper_bound.digits = {7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {8,9}; expected_interval.upper_bound.digits = {8,7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {8,8,9}; expected_interval.upper_bound.digits = {8,8,7}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } @@ -639,7 +639,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { boost::real::real a = numbers["E(-1.9)"] - numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -649,27 +649,27 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3, 9}; expected_interval.upper_bound.digits = {3, 8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3, 8, 9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3, 8, 9, 9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] - numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -679,29 +679,29 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 3}; expected_interval.upper_bound.digits = {2, 2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 2, 2}; expected_interval.upper_bound.digits = {2, 2, 1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 2, 1, 2}; expected_interval.upper_bound.digits = {2, 2, 1, 1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["E(-1.9)"] - numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -711,29 +711,29 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,1}; expected_interval.upper_bound.digits = {3}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,0,2}; expected_interval.upper_bound.digits = {3,0,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,0,1,2}; expected_interval.upper_bound.digits = {3,0,1,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(-1.9)"] - numbers["E(+1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -743,25 +743,25 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,8}; expected_interval.upper_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(-1.1)"] - numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -771,25 +771,25 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2}; expected_interval.upper_bound.digits = {2,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, No]") { boost::real::real a = numbers["E(-1.9)"] - numbers["E(+1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -799,25 +799,25 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {3}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(-1.99..)"] - numbers["A(+1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -827,26 +827,26 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,9,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.upper_bound.digits = {3,9,9,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(-1.11..)"] - numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -856,29 +856,29 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,4}; expected_interval.upper_bound.digits = {2,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,4}; expected_interval.upper_bound.digits = {2,2,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,2,4}; expected_interval.upper_bound.digits = {2,2,2,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["A(-1.99..)"] - numbers["A(+1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -888,22 +888,22 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {4}; expected_interval.upper_bound.digits = {2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,2}; expected_interval.upper_bound.digits = {3}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,1,2}; expected_interval.upper_bound.digits = {3,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,1,1,2}; expected_interval.upper_bound.digits = {3,1,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } @@ -913,7 +913,7 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { boost::real::real a = numbers["E(+1.9)"] - numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -923,27 +923,27 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3, 8}; expected_interval.upper_bound.digits = {3, 9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3, 8, 9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3, 8, 9, 9}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["E(+1.1)"] - numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -953,29 +953,29 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 2}; expected_interval.upper_bound.digits = {2, 3}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 2, 1}; expected_interval.upper_bound.digits = {2, 2, 2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2, 2, 1, 1}; expected_interval.upper_bound.digits = {2, 2, 1, 2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["E(+1.9)"] - numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -985,29 +985,29 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {3,1}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,0,1}; expected_interval.upper_bound.digits = {3,0,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,0,1,1}; expected_interval.upper_bound.digits = {3,0,1,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, Yes]") { boost::real::real a = numbers["E(+1.9)"] - numbers["E(-1.9)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1017,25 +1017,25 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,8}; expected_interval.upper_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [No, No]") { boost::real::real a = numbers["E(+1.1)"] - numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1045,25 +1045,25 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2}; expected_interval.upper_bound.digits = {2,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Explicit, Explicit] - overflow: [Yes, No]") { boost::real::real a = numbers["E(+1.9)"] - numbers["E(-1.1)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1073,25 +1073,25 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {3}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, Yes]") { boost::real::real a = numbers["A(+1.99..)"] - numbers["A(-1.99..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1101,26 +1101,26 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,9,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,9,9,8}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [No, No]") { boost::real::real a = numbers["A(+1.11..)"] - numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1130,29 +1130,29 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2}; expected_interval.upper_bound.digits = {2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,2}; expected_interval.upper_bound.digits = {2,2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {2,2,2,2}; expected_interval.upper_bound.digits = {2,2,2,4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } SECTION("Type: [Algorithm, Algorithm] - overflow: [Yes, No]") { boost::real::real a = numbers["A(+1.99..)"] - numbers["A(-1.11..)"]; - auto a_it = a.cbegin(); + auto a_it = a.get_real_itr().cbegin(); boost::real::interval expected_interval({}); @@ -1162,22 +1162,22 @@ TEST_CASE("Operator - boost::real::const_precision_iterator") { expected_interval.upper_bound.exponent = 1; expected_interval.lower_bound.digits = {2}; expected_interval.upper_bound.digits = {4}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3}; expected_interval.upper_bound.digits = {3,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,1}; expected_interval.upper_bound.digits = {3,1,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); ++a_it; expected_interval.lower_bound.digits = {3,1,1}; expected_interval.upper_bound.digits = {3,1,1,2}; - CHECK(a_it.approximation_interval == expected_interval); + CHECK(a_it.get_interval() == expected_interval); } } } \ No newline at end of file diff --git a/test/vector_helpers_test.cpp b/test/vector_helpers_test.cpp index 4c28f1b..43e24db 100644 --- a/test/vector_helpers_test.cpp +++ b/test/vector_helpers_test.cpp @@ -36,7 +36,7 @@ TEST_CASE( "Addition between vectors", "[vector]" ) { for (int i = 0; i < (int)expected_results.size(); i++) { int exponent = 5 - i; SECTION( "Exponent: " + std::to_string(exponent)) { - int exponent_c = boost::real::helper::add_vectors(a,exponent,b,0,c); + int exponent_c = boost::real::real_helper::add_vectors(a,exponent,b,0,c); CHECK( exponent_c == expected_results[i].first); CHECK( c == expected_results[i].second); } @@ -60,10 +60,10 @@ TEST_CASE( "Addition between vectors", "[vector]" ) { for (int i = 0; i < (int)expected_results.size(); i++) { int exponent = 5 - i; SECTION( "Exponent: " + std::to_string(exponent)) { - int exponent_c = boost::real::helper::add_vectors(b,0,a,exponent,c); + int exponent_c = boost::real::real_helper::add_vectors(b,0,a,exponent,c); CHECK( exponent_c == expected_results[i].first); CHECK( c == expected_results[i].second); } } } -} \ No newline at end of file +}