Skip to content

Commit 4de5db0

Browse files
committed
feat: add SquareRoot class
1 parent f320035 commit 4de5db0

13 files changed

+86
-12
lines changed

cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-7fe4562857c3c44c0391.json renamed to cmake-build-debug/.cmake/api/v1/reply/codemodel-v2-46151d9b3e10798965b3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
{
175175
"directoryIndex" : 0,
176176
"id" : "sqrt_higher_precision::@6890427a1f51a3e7e1df",
177-
"jsonFile" : "target-sqrt_higher_precision-Debug-4785e5d5f0a3ae90fd05.json",
177+
"jsonFile" : "target-sqrt_higher_precision-Debug-f2d0a4e2cb43ec13e779.json",
178178
"name" : "sqrt_higher_precision",
179179
"projectIndex" : 0
180180
},

cmake-build-debug/.cmake/api/v1/reply/index-2025-07-07T19-17-43-0796.json renamed to cmake-build-debug/.cmake/api/v1/reply/index-2025-07-07T19-22-12-0488.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"objects" :
2727
[
2828
{
29-
"jsonFile" : "codemodel-v2-7fe4562857c3c44c0391.json",
29+
"jsonFile" : "codemodel-v2-46151d9b3e10798965b3.json",
3030
"kind" : "codemodel",
3131
"version" :
3232
{
@@ -86,7 +86,7 @@
8686
},
8787
"codemodel-v2" :
8888
{
89-
"jsonFile" : "codemodel-v2-7fe4562857c3c44c0391.json",
89+
"jsonFile" : "codemodel-v2-46151d9b3e10798965b3.json",
9090
"kind" : "codemodel",
9191
"version" :
9292
{

cmake-build-debug/.cmake/api/v1/reply/target-sqrt_higher_precision-Debug-4785e5d5f0a3ae90fd05.json renamed to cmake-build-debug/.cmake/api/v1/reply/target-sqrt_higher_precision-Debug-f2d0a4e2cb43ec13e779.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
},
226226
{
227227
"backtrace" : 2,
228-
"path" : "src/SquareRoot.h",
228+
"path" : "include/SquareRoot.hpp",
229229
"sourceGroupIndex" : 1
230230
}
231231
],

cmake-build-debug/.ninja_log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
3403 5540 1751912983146386994 CMakeFiles/tests.dir/src/Fraction.cpp.o 3ba60287f76f7835
33
10248 10716 1751912989994138331 lib/libgtest.a 420031dcbb4fe737
44
9 3402 1751912979754511207 CMakeFiles/tests.dir/tests/test_main.cpp.o 1e6c51daf976c9b7
5-
3 2189 1751915863774248080 build.ninja 987febbd8cf80e9
5+
3 2189 1751916132468692012 build.ninja 987febbd8cf80e9
66
3291 6861 1751912983034391081 CMakeFiles/tests.dir/tests/test_fraction.cpp.o f1589e1738c4b19f
77
806 954 1751899218603008212 sqrt_higher_precision f11af3d351234e3e
88
8 3290 1751912979754511207 _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o 2f55321897389349

cmake-build-debug/CMakeFiles/clion-Debug-log.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ The package mpfr can be imported via CMake FindPkgConfig module:
3737

3838
target_link_libraries(main PRIVATE PkgConfig::mpfr)
3939

40-
All requested installations completed successfully in: 122 us
40+
All requested installations completed successfully in: 197 us
4141
-- Running vcpkg install - done
42-
-- Configuring done (3.2s)
42+
-- Configuring done (3.6s)
4343
-- Generating done (0.0s)
4444
-- Build files have been written to: /home/abega/Documents/Computer_Science_works/sqrt-higher-precision/cmake-build-debug
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Start testing: Jul 07 22:17 EAT
1+
Start testing: Jul 07 22:22 EAT
22
----------------------------------------------------------
3-
End testing: Jul 07 22:17 EAT
3+
End testing: Jul 07 22:22 EAT

cmake-build-debug/vcpkg-manifest-install.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ The package mpfr can be imported via CMake FindPkgConfig module:
3535

3636
target_link_libraries(main PRIVATE PkgConfig::mpfr)
3737

38-
All requested installations completed successfully in: 122 us
38+
All requested installations completed successfully in: 197 us

include/Approximator.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ class Approximator : public Sequence {
77
unsigned long square_deviation;
88

99
public:
10+
[[nodiscard]] unsigned long get_root_value() const;
11+
[[nodiscard]] unsigned long get_root_value_squared() const;
12+
[[nodiscard]] unsigned long get_square_deviation() const;
1013
explicit Approximator(unsigned long number);
1114
Fraction k_th_value(unsigned long k) override;
1215
};

include/Fraction.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Fraction {
77
mpz_class den;
88

99
public:
10-
explicit Fraction(long numerator);
10+
explicit Fraction(unsigned long numerator);
1111
Fraction(const std::string& numerator, const std::string& denominator);
1212
Fraction(mpz_class numerator, mpz_class denominator);
1313

@@ -19,6 +19,8 @@ class Fraction {
1919
void simplify();
2020
void normalize_sign();
2121

22+
[[nodiscard]] Fraction inverse() const;
23+
[[nodiscard]] Fraction negate() const;
2224
[[nodiscard]] Fraction pow(int n) const;
2325

2426
Fraction operator+(const Fraction& other) const;

include/SquareRoot.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
#include "Sequence.hpp"
3+
4+
class SquareRoot final : public Sequence {
5+
public:
6+
explicit SquareRoot(unsigned long numerator);
7+
[[nodiscard]] Fraction k_th_value(unsigned long k) override;
8+
};

0 commit comments

Comments
 (0)