From 724d9edf66e9ab257605e7bb312e581482c34b1e Mon Sep 17 00:00:00 2001 From: Andy Zhang Date: Fri, 3 Jan 2025 06:09:50 +0800 Subject: [PATCH 01/12] Added some stub files. --- CMakeLists.txt | 1 + lib/CMakeLists.txt | 2 +- lib/test.py | 25 ++++++++++ setup.py | 3 ++ steppyble/__init__.pyi | 24 ++++++++++ steppyble/fraction.pyi | 79 ++++++++++++++++++++++++++++++++ steppyble/number.pyi | 86 +++++++++++++++++++++++++++++++++++ tools/add_copyright_header.py | 3 +- 8 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 lib/test.py create mode 100644 steppyble/__init__.pyi create mode 100644 steppyble/fraction.pyi create mode 100644 steppyble/number.pyi diff --git a/CMakeLists.txt b/CMakeLists.txt index a258e0685..957beba96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ PROJECT(Steppable) # Ensure that Python is available to run the development scripts, and build with bindings. SET(Python_FIND_VIRTUALENV FIRST) +SET(Python3_FIND_VIRTUALENV FIRST) FIND_PACKAGE( Python diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 4e00e0522..53b737e06 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -25,7 +25,7 @@ if(NOT ${STP_NO_BINDINGS}) # Only create the bindings if needed # Detect the installed nanobind package and import it into CMake execute_process( - COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir + COMMAND "${Python3_EXECUTABLE}" -m nanobind --cmake_dir OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NB_DIR) message(TRACE "Found nanobind: ${NB_DIR}") diff --git a/lib/test.py b/lib/test.py new file mode 100644 index 000000000..869ef9950 --- /dev/null +++ b/lib/test.py @@ -0,0 +1,25 @@ +##################################################################################################### +# Copyright (c) 2023-2025 NWSOFT # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy # +# of this software and associated documentation files (the "Software"), to deal # +# in the Software without restriction, including without limitation the rights # +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # +# copies of the Software, and to permit persons to whom the Software is # +# furnished to do so, subject to the following conditions: # +# # +# The above copyright notice and this permission notice shall be included in all # +# copies or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # +# SOFTWARE. # +##################################################################################################### + +import steppyble + +steppyble.Number() diff --git a/setup.py b/setup.py index ffb2ff205..462309b18 100644 --- a/setup.py +++ b/setup.py @@ -80,6 +80,7 @@ def build_extension(self, ext: CMakeExtension) -> None: f"-DPython_EXECUTABLE={sys.executable}", f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm f"-DSTP_BUILD_COMPONENT_EXECUTABLE=True", # not used on MSVC, but no harm + f"-DSTP_NO_BINDINGS=False", # Build bindings for Python ] build_args = [] # Adding CMake arguments set as environment variable @@ -188,6 +189,8 @@ def build_extension(self, ext: CMakeExtension) -> None: long_description="Python bindings for Steppable, written using nanobind.", ext_modules=[CMakeExtension("steppyble")], include_package_data=True, + packages=["steppyble"], + package_data={"steppyble": ["__init__.pyi", "fraction.pyi", "number.pyi"]}, cmdclass={"build_ext": CMakeBuild}, zip_safe=False, extras_require={"test": ["pytest>=6.0"]}, diff --git a/steppyble/__init__.pyi b/steppyble/__init__.pyi new file mode 100644 index 000000000..6f5e9d6ba --- /dev/null +++ b/steppyble/__init__.pyi @@ -0,0 +1,24 @@ +##################################################################################################### +# Copyright (c) 2023-2025 NWSOFT # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy # +# of this software and associated documentation files (the "Software"), to deal # +# in the Software without restriction, including without limitation the rights # +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # +# copies of the Software, and to permit persons to whom the Software is # +# furnished to do so, subject to the following conditions: # +# # +# The above copyright notice and this permission notice shall be included in all # +# copies or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # +# SOFTWARE. # +##################################################################################################### + +from .number import * +from .fraction import * diff --git a/steppyble/fraction.pyi b/steppyble/fraction.pyi new file mode 100644 index 000000000..489a420df --- /dev/null +++ b/steppyble/fraction.pyi @@ -0,0 +1,79 @@ +##################################################################################################### +# Copyright (c) 2023-2025 NWSOFT # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy # +# of this software and associated documentation files (the "Software"), to deal # +# in the Software without restriction, including without limitation the rights # +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # +# copies of the Software, and to permit persons to whom the Software is # +# furnished to do so, subject to the following conditions: # +# # +# The above copyright notice and this permission notice shall be included in all # +# copies or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # +# SOFTWARE. # +##################################################################################################### + +import steppyble + + +class Fraction: + def __init__(self, top: str = "1", bottom: str = "1") -> None: + ... + + def __repr__(self) -> str: + ... + + def __add__(self, _: steppyble.Fraction, /) -> steppyble.Fraction: + ... + + def __iadd__(self, _: steppyble.Fraction, /) -> steppyble.Fraction: + ... + + def __sub__(self, _: steppyble.Fraction, /) -> steppyble.Fraction: + ... + + def __isub__(self, _: steppyble.Fraction, /) -> steppyble.Fraction: + ... + + def __mul__(self, _: steppyble.Fraction, /) -> steppyble.Fraction: + ... + + def __imul__(self, _: steppyble.Fraction, /) -> steppyble.Fraction: + ... + + def __truediv__(self, _: steppyble.Fraction, /) -> steppyble.Fraction: + ... + + def __itruediv__(self, _: steppyble.Fraction, /) -> steppyble.Fraction: + ... + + def __pow__(self, _: steppyble.Fraction, /) -> steppyble.Fraction: + ... + + def __ipow__(self, _: steppyble.Fraction, /) -> steppyble.Fraction: + ... + + def __eq__(self, _: object, /) -> bool: + ... + + def __ne__(self, _: object, /) -> bool: + ... + + def __ge__(self, _: steppyble.Fraction, /) -> bool: + ... + + def __gt__(self, _: steppyble.Fraction, /) -> bool: + ... + + def __le__(self, _: steppyble.Fraction, /) -> bool: + ... + + def __lt__(self, _: steppyble.Fraction, /) -> bool: + ... diff --git a/steppyble/number.pyi b/steppyble/number.pyi new file mode 100644 index 000000000..3e2c8b5e9 --- /dev/null +++ b/steppyble/number.pyi @@ -0,0 +1,86 @@ +##################################################################################################### +# Copyright (c) 2023-2025 NWSOFT # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy # +# of this software and associated documentation files (the "Software"), to deal # +# in the Software without restriction, including without limitation the rights # +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # +# copies of the Software, and to permit persons to whom the Software is # +# furnished to do so, subject to the following conditions: # +# # +# The above copyright notice and this permission notice shall be included in all # +# copies or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # +# SOFTWARE. # +##################################################################################################### + +import steppyble + + +class Number: + """A Steppable number, which performs exactly like a Python number, allowing add, subtract, multiply...""" + + def __init__( + self, + value: str = "0", + prec: int = 5, + roundingMode: steppyble.RoundingMode = steppyble.RoundingMode.USE_CURRENT_PREC, + ) -> None: + ... + + def __repr__(self) -> str: + ... + + def __add__(self, _: steppyble.Number, /) -> steppyble.Number: + ... + + def __iadd__(self, _: steppyble.Number, /) -> steppyble.Number: + ... + + def __sub__(self, _: steppyble.Number, /) -> steppyble.Number: + ... + + def __isub__(self, _: steppyble.Number, /) -> steppyble.Number: + ... + + def __mul__(self, _: steppyble.Number, /) -> steppyble.Number: + ... + + def __imul__(self, _: steppyble.Number, /) -> steppyble.Number: + ... + + def __truediv__(self, _: steppyble.Number, /) -> steppyble.Number: + ... + + def __itruediv__(self, _: steppyble.Number, /) -> steppyble.Number: + ... + + def __pow__(self, _: steppyble.Number, /) -> steppyble.Number: + ... + + def __ipow__(self, _: steppyble.Number, /) -> steppyble.Number: + ... + + def __eq__(self, _: object, /) -> bool: + ... + + def __ne__(self, _: object, /) -> bool: + ... + + def __ge__(self, _: steppyble.Number, /) -> bool: + ... + + def __gt__(self, _: steppyble.Number, /) -> bool: + ... + + def __le__(self, _: steppyble.Number, /) -> bool: + ... + + def __lt__(self, _: steppyble.Number, /) -> bool: + ... diff --git a/tools/add_copyright_header.py b/tools/add_copyright_header.py index bbcf8a6c2..a38528d9c 100644 --- a/tools/add_copyright_header.py +++ b/tools/add_copyright_header.py @@ -186,7 +186,7 @@ def process(file: Path) -> None: with open(file, "w", encoding="utf-8") as f: f.write(contents) elif ( - file.suffix == ".py" + file.suffix in (".py", ".pyi") or file.name == "CMakeLists.txt" or ".stp_" in file.suffix # Steppable configuration files ): # Python File or CMake file @@ -235,3 +235,4 @@ def walk_into_directory(path: Path) -> None: walk_into_directory(PROJECT_PATH / "src") walk_into_directory(PROJECT_PATH / "tests") walk_into_directory(PROJECT_PATH / "tools") + walk_into_directory(PROJECT_PATH / "steppyble") From 64d2679bfbc5cf039726379e66e63fbfa972f538 Mon Sep 17 00:00:00 2001 From: Andy Zhang Date: Fri, 3 Jan 2025 06:35:10 +0800 Subject: [PATCH 02/12] Added stubs for `rounding_mode` --- steppyble/__init__.pyi | 1 + steppyble/rounding_mode.pyi | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 steppyble/rounding_mode.pyi diff --git a/steppyble/__init__.pyi b/steppyble/__init__.pyi index 6f5e9d6ba..a62e1732d 100644 --- a/steppyble/__init__.pyi +++ b/steppyble/__init__.pyi @@ -22,3 +22,4 @@ from .number import * from .fraction import * +from .rounding_mode import * diff --git a/steppyble/rounding_mode.pyi b/steppyble/rounding_mode.pyi new file mode 100644 index 000000000..238532f34 --- /dev/null +++ b/steppyble/rounding_mode.pyi @@ -0,0 +1,42 @@ +##################################################################################################### +# Copyright (c) 2023-2025 NWSOFT # +# # +# Permission is hereby granted, free of charge, to any person obtaining a copy # +# of this software and associated documentation files (the "Software"), to deal # +# in the Software without restriction, including without limitation the rights # +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # +# copies of the Software, and to permit persons to whom the Software is # +# furnished to do so, subject to the following conditions: # +# # +# The above copyright notice and this permission notice shall be included in all # +# copies or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # +# SOFTWARE. # +##################################################################################################### + +import enum + + +class RoundingMode(enum.Enum): + """Specifies how Steppable should round the number in operations.""" + + USE_MAXIMUM_PREC = 0xFF + """Use the higher precision whenever possible.""" + + USE_MINIMUM_PREC = 0x01 + """Use the lower precision whenever possible.""" + + USE_CURRENT_PREC = 0x02 + """Use the current precision.""" + + USE_OTHER_PREC = 0x03 + """Use the other number's precision.""" + + DISCARD_ALL_DECIMALS = 0x00 + """Do not append any decimal places.""" From ca346858fed47346fb5d48a54df1fd8ae37165ae Mon Sep 17 00:00:00 2001 From: Andy Zhang Date: Fri, 17 Jan 2025 09:17:38 +0800 Subject: [PATCH 03/12] Rename `steppable::__internals::arithmetic` steppable::__internals::arithmetic -> steppable::__internals::calc --- .idea/vcs.xml | 3 --- include/fn/calc.hpp | 2 +- include/fn/root.hpp | 2 +- questions | 30 ---------------------- src/base/baseConvert/baseConvert.cpp | 4 +-- src/base/decimalConvert/decimalConvert.cpp | 4 +-- src/calc/abs/abs.cpp | 4 +-- src/calc/add/add.cpp | 4 +-- src/calc/atan2/atan2.cpp | 4 +-- src/calc/comparison/comparison.cpp | 4 +-- src/calc/division/division.cpp | 4 +-- src/calc/division/divisionReport.cpp | 2 +- src/calc/factorial/factorial.cpp | 4 +-- src/calc/factorial/factorialReport.cpp | 2 +- src/calc/hyp/hyp.cpp | 2 +- src/calc/log/log.cpp | 4 +-- src/calc/multiply/multiply.cpp | 4 +-- src/calc/power/power.cpp | 4 +-- src/calc/power/powerReport.cpp | 2 +- src/calc/root/root.cpp | 4 +-- src/calc/subtract/subtract.cpp | 4 +-- src/calc/trig/trig.cpp | 2 +- src/calculus/nInt/nInt.cpp | 2 +- src/factors.cpp | 2 +- src/fraction.cpp | 2 +- src/number.cpp | 2 +- src/rounding.cpp | 6 ++--- tests/testAbs.cpp | 2 +- tests/testAdd.cpp | 2 +- tests/testComparison.cpp | 2 +- tests/testDecimalConvert.cpp | 2 +- tests/testDivision.cpp | 2 +- tests/testFactorial.cpp | 2 +- tests/testHyp.cpp | 2 +- tests/testLog.cpp | 2 +- tests/testMultiply.cpp | 2 +- tests/testNInt.cpp | 2 +- tests/testPower.cpp | 2 +- tests/testRoot.cpp | 6 ++--- tests/testSubtract.cpp | 2 +- tests/testTrig.cpp | 2 +- 41 files changed, 56 insertions(+), 89 deletions(-) delete mode 100644 questions diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 148151638..3e8841d96 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -8,8 +8,5 @@ - - - \ No newline at end of file diff --git a/include/fn/calc.hpp b/include/fn/calc.hpp index 230ce309f..aa8b99418 100644 --- a/include/fn/calc.hpp +++ b/include/fn/calc.hpp @@ -46,7 +46,7 @@ using namespace std::literals; * @namespace steppable::__internals * @brief The namespace containing internal functions for the Steppable library. */ -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { /** * @brief Represents the quotient and remainder of a division operation. diff --git a/include/fn/root.hpp b/include/fn/root.hpp index 82e65557b..a079196f2 100644 --- a/include/fn/root.hpp +++ b/include/fn/root.hpp @@ -24,7 +24,7 @@ #include -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { /** * @brief A struct to represent a surd. diff --git a/questions b/questions deleted file mode 100644 index d7b9f1f89..000000000 --- a/questions +++ /dev/null @@ -1,30 +0,0 @@ -1. why you guys decide to do this -2. how long have you been working on this -3. what are your goals / objectives -4. what can i benefit from sponsoring you -5. why is it meaningful for me to sponsor -6. how do you handle failure of this competition -7. what risks are there for me -8. how much do i need to provide -9. how do you spend my money -10. what is so special about your car design and why do you think it will win -11. what are your other sponsors -12. who are your competitors? how much is your advantage? -13. introduce yourself (should be the first, i forgot) -14. why isn’t there a co-founder (yes this is a real question) -15. can i see your finished product? -16. what are your biggest weaknesses -17. what are your biggest strengths -18. how do you describe your product to other sponsors? -19. how do i give you money (answer is to give that to my bank account) -20. if everything goes right, where do you see your team in a year? -21. what if you’re forced to stop doing this? -22. do you have passion and determination? -23. what if you run out of money -24. how do you handle unexpected situations -25. what do you need that you don’t have -26. Do you need regulatory approval or any accreditation? -27. what are the problems you’re facing? -28. why the name “pandurance” -29. how can i find more about you -30. what are you doing to attract more sponsors? \ No newline at end of file diff --git a/src/base/baseConvert/baseConvert.cpp b/src/base/baseConvert/baseConvert.cpp index b3841848f..45303a2b1 100644 --- a/src/base/baseConvert/baseConvert.cpp +++ b/src/base/baseConvert/baseConvert.cpp @@ -41,7 +41,7 @@ using namespace std::literals; using namespace steppable::__internals::stringUtils; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::__internals::symbols; using namespace steppable::localization; using namespace steppable::output; @@ -62,7 +62,7 @@ namespace steppable::prettyPrint::printers } } // namespace steppable::prettyPrint::printers -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { /** * @brief Represents a number using alphabets and numberals. diff --git a/src/base/decimalConvert/decimalConvert.cpp b/src/base/decimalConvert/decimalConvert.cpp index 6663e1385..ce9a5f716 100644 --- a/src/base/decimalConvert/decimalConvert.cpp +++ b/src/base/decimalConvert/decimalConvert.cpp @@ -40,9 +40,9 @@ using namespace steppable::__internals::utils; using namespace steppable::__internals::symbols; using namespace steppable::output; using namespace steppable::localization; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { /** * @brief Converts a numeral character to a number string. diff --git a/src/calc/abs/abs.cpp b/src/calc/abs/abs.cpp index a027616b1..f3087b9d5 100644 --- a/src/calc/abs/abs.cpp +++ b/src/calc/abs/abs.cpp @@ -38,10 +38,10 @@ #include using namespace steppable::__internals::utils; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::localization; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string abs(const std::string& _number, const int steps) { diff --git a/src/calc/add/add.cpp b/src/calc/add/add.cpp index 32cfb5ab9..bde388218 100644 --- a/src/calc/add/add.cpp +++ b/src/calc/add/add.cpp @@ -41,11 +41,11 @@ using namespace steppable::__internals::numUtils; using namespace steppable::__internals::utils; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::__internals::symbols; using namespace steppable::localization; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string add(const std::string& a, const std::string& b, diff --git a/src/calc/atan2/atan2.cpp b/src/calc/atan2/atan2.cpp index e38d14143..e6799f8b8 100644 --- a/src/calc/atan2/atan2.cpp +++ b/src/calc/atan2/atan2.cpp @@ -41,12 +41,12 @@ #include using namespace std::literals; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::__internals::numUtils; using namespace steppable::localization; using namespace steppable::output; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string atan2(const std::string& y, const std::string& x, const size_t decimals = 10) { diff --git a/src/calc/comparison/comparison.cpp b/src/calc/comparison/comparison.cpp index 5dfa0de61..e2c3f5bbe 100644 --- a/src/calc/comparison/comparison.cpp +++ b/src/calc/comparison/comparison.cpp @@ -39,10 +39,10 @@ using namespace steppable::__internals::numUtils; using namespace steppable::__internals::symbols; using namespace steppable::__internals::utils; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::localization; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string compare(const std::string& _a, const std::string& _b, const int steps) { diff --git a/src/calc/division/division.cpp b/src/calc/division/division.cpp index ef1a37aee..3f15c1bf0 100644 --- a/src/calc/division/division.cpp +++ b/src/calc/division/division.cpp @@ -46,9 +46,9 @@ using namespace steppable::__internals::numUtils; using namespace steppable::__internals::stringUtils; using namespace steppable::output; using namespace steppable::localization; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { QuotientRemainder getQuotientRemainder(const auto& _currentRemainder, const auto& divisor) { diff --git a/src/calc/division/divisionReport.cpp b/src/calc/division/divisionReport.cpp index 99b9bdbb0..02d6cbb03 100644 --- a/src/calc/division/divisionReport.cpp +++ b/src/calc/division/divisionReport.cpp @@ -40,7 +40,7 @@ using namespace std::literals; using namespace steppable::__internals::stringUtils; using namespace steppable::__internals::symbols; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; std::string reportDivision(std::stringstream& tempFormattedAns, const std::string& temp, diff --git a/src/calc/factorial/factorial.cpp b/src/calc/factorial/factorial.cpp index f1f19bf48..fca4c2ca0 100644 --- a/src/calc/factorial/factorial.cpp +++ b/src/calc/factorial/factorial.cpp @@ -40,13 +40,13 @@ using namespace steppable::__internals::numUtils; using namespace steppable::__internals::utils; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::__internals::symbols; using namespace steppable::output; using namespace steppable::localization; using namespace std::literals; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string factorial(const std::string& _number, const int steps) { diff --git a/src/calc/factorial/factorialReport.cpp b/src/calc/factorial/factorialReport.cpp index ce324f6fa..9e5fbcf2b 100644 --- a/src/calc/factorial/factorialReport.cpp +++ b/src/calc/factorial/factorialReport.cpp @@ -28,7 +28,7 @@ #include #include -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::__internals::symbols; std::string reportFactorial(const std::string& number, const std::string& result, int steps) diff --git a/src/calc/hyp/hyp.cpp b/src/calc/hyp/hyp.cpp index 66479601e..1cf7c74df 100644 --- a/src/calc/hyp/hyp.cpp +++ b/src/calc/hyp/hyp.cpp @@ -47,7 +47,7 @@ using namespace steppable::localization; using namespace steppable::__internals::utils; using namespace steppable::__internals::numUtils; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string sinh(const std::string& x, const int decimals) { diff --git a/src/calc/log/log.cpp b/src/calc/log/log.cpp index cb753dc73..ac1b38183 100644 --- a/src/calc/log/log.cpp +++ b/src/calc/log/log.cpp @@ -38,12 +38,12 @@ #include #include -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::__internals::utils; using namespace steppable::localization; using namespace std::literals; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string _log(const std::string& x, const size_t _decimals) { diff --git a/src/calc/multiply/multiply.cpp b/src/calc/multiply/multiply.cpp index 7a541cde8..e761807ac 100644 --- a/src/calc/multiply/multiply.cpp +++ b/src/calc/multiply/multiply.cpp @@ -43,9 +43,9 @@ using namespace steppable::__internals::numUtils; using namespace steppable::__internals::stringUtils; using namespace steppable::output; using namespace steppable::localization; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string multiply(const std::string& _a, const std::string& _b, const int steps) { diff --git a/src/calc/power/power.cpp b/src/calc/power/power.cpp index fb5b29397..f1fa24a3d 100644 --- a/src/calc/power/power.cpp +++ b/src/calc/power/power.cpp @@ -40,7 +40,7 @@ using namespace steppable::__internals::numUtils; using namespace steppable::output; using namespace steppable::localization; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; namespace steppable::prettyPrint::printers { @@ -57,7 +57,7 @@ namespace steppable::prettyPrint::printers } } // namespace steppable::prettyPrint::printers -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string power(const std::string& _number, const std::string& _raiseTo, const int steps) { diff --git a/src/calc/power/powerReport.cpp b/src/calc/power/powerReport.cpp index 70183765f..aae68ac4d 100644 --- a/src/calc/power/powerReport.cpp +++ b/src/calc/power/powerReport.cpp @@ -44,7 +44,7 @@ using namespace steppable::output; using namespace steppable::localization; using namespace steppable::prettyPrint; using namespace steppable::__internals::symbols; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; std::string reportPowerRoot(const std::string& _number, const std::string& raiseTo, diff --git a/src/calc/root/root.cpp b/src/calc/root/root.cpp index 652cbba0b..ec771c1d7 100644 --- a/src/calc/root/root.cpp +++ b/src/calc/root/root.cpp @@ -47,7 +47,7 @@ #undef min #endif -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::__internals::utils; using namespace steppable::__internals::stringUtils; using namespace steppable::__internals::numUtils; @@ -87,7 +87,7 @@ namespace steppable::prettyPrint::printers } } // namespace steppable::prettyPrint::printers -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string rootIntPart(const std::string& _number, const std::string& base) { diff --git a/src/calc/subtract/subtract.cpp b/src/calc/subtract/subtract.cpp index 6d98c57e8..652bf6d57 100644 --- a/src/calc/subtract/subtract.cpp +++ b/src/calc/subtract/subtract.cpp @@ -45,9 +45,9 @@ using namespace steppable::__internals::numUtils; using namespace steppable::output; using namespace steppable::localization; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string subtract(const std::string& a, const std::string& b, const int steps, const bool noMinus) { diff --git a/src/calc/trig/trig.cpp b/src/calc/trig/trig.cpp index 3aa51d10e..b4fc2f984 100644 --- a/src/calc/trig/trig.cpp +++ b/src/calc/trig/trig.cpp @@ -47,7 +47,7 @@ using namespace steppable::localization; using namespace steppable::__internals::utils; using namespace steppable::__internals::numUtils; -namespace steppable::__internals::arithmetic +namespace steppable::__internals::calc { std::string degToRad(const std::string& _deg) { diff --git a/src/calculus/nInt/nInt.cpp b/src/calculus/nInt/nInt.cpp index 78613351d..53d26a608 100644 --- a/src/calculus/nInt/nInt.cpp +++ b/src/calculus/nInt/nInt.cpp @@ -31,7 +31,7 @@ #include #include -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::__internals::numUtils; using namespace steppable::__internals::utils; using namespace std::literals; diff --git a/src/factors.cpp b/src/factors.cpp index dfa585cd3..f112a1943 100644 --- a/src/factors.cpp +++ b/src/factors.cpp @@ -28,7 +28,7 @@ #include #include -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::types; namespace steppable::__internals::numUtils diff --git a/src/fraction.cpp b/src/fraction.cpp index 9d822689f..018b1f248 100644 --- a/src/fraction.cpp +++ b/src/fraction.cpp @@ -44,7 +44,7 @@ #undef min #endif -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace steppable::__internals::numUtils; namespace steppable::prettyPrint::printers diff --git a/src/number.cpp b/src/number.cpp index 00ca97358..3c0e66741 100644 --- a/src/number.cpp +++ b/src/number.cpp @@ -40,7 +40,7 @@ namespace steppable { - using namespace steppable::__internals::arithmetic; + using namespace steppable::__internals::calc; Number::Number() : prec(8), value("0") {} diff --git a/src/rounding.cpp b/src/rounding.cpp index 1fa2d7c2d..68ae2152e 100644 --- a/src/rounding.cpp +++ b/src/rounding.cpp @@ -53,7 +53,7 @@ namespace steppable::__internals::numUtils auto integer = splitNumberResult[0]; auto decimal = splitNumberResult[1]; // Return the integer part if (decimal.front() > '5') - integer = arithmetic::add(integer, "1", 0); + integer = calc::add(integer, "1", 0); return integer; } @@ -77,7 +77,7 @@ namespace steppable::__internals::numUtils // Modify the integer part if the digit is greater than 5 if (decimal.front() >= '5' and digits == 0) { - integer = arithmetic::add(integer, "1", 0); + integer = calc::add(integer, "1", 0); return integer; } auto newDecimal = decimal.substr(0, digits); @@ -94,7 +94,7 @@ namespace steppable::__internals::numUtils { newDecimal[i] = '0'; if (i == newDecimal.length() - 1) - integer = arithmetic::add(integer, "1", 0); + integer = calc::add(integer, "1", 0); } else { diff --git a/tests/testAbs.cpp b/tests/testAbs.cpp index 3bac52a3f..bed133324 100644 --- a/tests/testAbs.cpp +++ b/tests/testAbs.cpp @@ -31,7 +31,7 @@ TEST_START() -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; SECTION(Absolute value with positive number) const std::string& a = "6453.55"; diff --git a/tests/testAdd.cpp b/tests/testAdd.cpp index 27afa8813..fdc0ed7b7 100644 --- a/tests/testAdd.cpp +++ b/tests/testAdd.cpp @@ -31,7 +31,7 @@ TEST_START() -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; SECTION(Addition with multiple digits of different length) const std::string& a = "6453.55"; diff --git a/tests/testComparison.cpp b/tests/testComparison.cpp index 9a790155a..1a05421e5 100644 --- a/tests/testComparison.cpp +++ b/tests/testComparison.cpp @@ -31,7 +31,7 @@ TEST_START() -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; SECTION(Comparison at integer) const std::string &a = "6453.55"; diff --git a/tests/testDecimalConvert.cpp b/tests/testDecimalConvert.cpp index 7e36a992b..5649c34b4 100644 --- a/tests/testDecimalConvert.cpp +++ b/tests/testDecimalConvert.cpp @@ -31,7 +31,7 @@ TEST_START() -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; SECTION(Decimal Convert without letters) const std::string &a = "46432231133131"; diff --git a/tests/testDivision.cpp b/tests/testDivision.cpp index 531a6f5fa..5d3a75b65 100644 --- a/tests/testDivision.cpp +++ b/tests/testDivision.cpp @@ -31,7 +31,7 @@ TEST_START() -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; SECTION(Integer division) // A gogol divided by 50 diff --git a/tests/testFactorial.cpp b/tests/testFactorial.cpp index 75caa21bf..0461eda71 100644 --- a/tests/testFactorial.cpp +++ b/tests/testFactorial.cpp @@ -29,7 +29,7 @@ #include #include -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; TEST_START() SECTION(Factorial) diff --git a/tests/testHyp.cpp b/tests/testHyp.cpp index 02f64d95e..9e1be5e8f 100644 --- a/tests/testHyp.cpp +++ b/tests/testHyp.cpp @@ -31,7 +31,7 @@ TEST_START() -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; SECTION(Test hyperbolic sine) _.assertIsEqual(sinh("10", 3), "11013.233"); diff --git a/tests/testLog.cpp b/tests/testLog.cpp index e94b3fb9d..0eafdeaaa 100644 --- a/tests/testLog.cpp +++ b/tests/testLog.cpp @@ -30,7 +30,7 @@ #include TEST_START() -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; SECTION(Test natural logarithm) _.assertIsEqual(ln("5.3", 4), "1.6677"); diff --git a/tests/testMultiply.cpp b/tests/testMultiply.cpp index 1b1ee0e3a..4586f827c 100644 --- a/tests/testMultiply.cpp +++ b/tests/testMultiply.cpp @@ -31,7 +31,7 @@ TEST_START() -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; SECTION(Multiplication without carry) const std::string &a = "2"; diff --git a/tests/testNInt.cpp b/tests/testNInt.cpp index 9dae516f2..7e3568d6d 100644 --- a/tests/testNInt.cpp +++ b/tests/testNInt.cpp @@ -31,7 +31,7 @@ #include using namespace steppable::__internals::calculus; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; TEST_START() diff --git a/tests/testPower.cpp b/tests/testPower.cpp index d30779bdc..69bf47178 100644 --- a/tests/testPower.cpp +++ b/tests/testPower.cpp @@ -32,7 +32,7 @@ TEST_START() -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; SECTION(Power) const std::string number = "47"; diff --git a/tests/testRoot.cpp b/tests/testRoot.cpp index 6f181b7ba..8d020743e 100644 --- a/tests/testRoot.cpp +++ b/tests/testRoot.cpp @@ -31,17 +31,17 @@ TEST_START() SECTION(Root with a sqare number) -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; _.assertIsEqual(root("4", "2", 0), "2"); SECTION_END() SECTION(Root with a decimal index) -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; _.assertIsEqual(root("4", "0.5", 0), "16"); SECTION_END() SECTION(Surds) -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; auto surd = rootSurd("27", "2"); _.assertIsEqual(surd.multiplier, "3"); _.assertIsEqual(surd.radicand, "3"); diff --git a/tests/testSubtract.cpp b/tests/testSubtract.cpp index 3cbe06d74..ddd65017c 100644 --- a/tests/testSubtract.cpp +++ b/tests/testSubtract.cpp @@ -31,7 +31,7 @@ TEST_START() -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; SECTION(Subtraction with multiple digits of different length) const std::string &a = "54329.334"; diff --git a/tests/testTrig.cpp b/tests/testTrig.cpp index fb6998eed..a53272632 100644 --- a/tests/testTrig.cpp +++ b/tests/testTrig.cpp @@ -30,7 +30,7 @@ #include TEST_START() -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; // We can just test the basics of the trigonometric functions, as the rest are based on them. SECTION(Test sine and cosine) From 00448432bd67452e849ac3dab45ee820af558c14 Mon Sep 17 00:00:00 2001 From: Andy Zhang Date: Tue, 28 Jan 2025 22:02:04 +0800 Subject: [PATCH 04/12] Rename `steppable::__internals::arithmetic` steppable::__internals::arithmetic -> steppable::__internals::calc --- include/fn/calc.hpp | 2 +- include/fn/root.hpp | 2 +- lib/bindings.cpp | 4 ++-- src/base/baseConvert/baseConvert.cpp | 2 +- src/base/decimalConvert/decimalConvert.cpp | 2 +- src/calc/abs/abs.cpp | 2 +- src/calc/add/add.cpp | 2 +- src/calc/atan2/atan2.cpp | 2 +- src/calc/comparison/comparison.cpp | 2 +- src/calc/division/division.cpp | 2 +- src/calc/factorial/factorial.cpp | 2 +- src/calc/hyp/hyp.cpp | 26 +++++++++++----------- src/calc/log/log.cpp | 10 ++++----- src/calc/multiply/multiply.cpp | 2 +- src/calc/power/power.cpp | 2 +- src/calc/root/root.cpp | 2 +- src/calc/subtract/subtract.cpp | 2 +- src/calc/trig/trig.cpp | 26 +++++++++++----------- 18 files changed, 47 insertions(+), 47 deletions(-) diff --git a/include/fn/calc.hpp b/include/fn/calc.hpp index aa8b99418..e88a1e645 100644 --- a/include/fn/calc.hpp +++ b/include/fn/calc.hpp @@ -572,4 +572,4 @@ namespace steppable::__internals::calc } } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc diff --git a/include/fn/root.hpp b/include/fn/root.hpp index a079196f2..062be5e49 100644 --- a/include/fn/root.hpp +++ b/include/fn/root.hpp @@ -38,4 +38,4 @@ namespace steppable::__internals::calc /// @brief The multiplier of the surd. std::string multiplier; }; -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc diff --git a/lib/bindings.cpp b/lib/bindings.cpp index 83fffe876..59c933330 100644 --- a/lib/bindings.cpp +++ b/lib/bindings.cpp @@ -31,7 +31,7 @@ #include namespace nb = nanobind; -using namespace steppable::__internals::arithmetic; +using namespace steppable::__internals::calc; using namespace nb::literals; NB_MODULE(steppyble, mod) // NOLINT @@ -91,7 +91,7 @@ NB_MODULE(steppyble, mod) // NOLINT mod.doc() = "The Python bindings for Steppable."; internals.def("abs", - &steppable::__internals::arithmetic::abs, + &steppable::__internals::calc::abs, "a"_a, "steps"_a = 2, "Internal function that takes the absolute value of a number."); diff --git a/src/base/baseConvert/baseConvert.cpp b/src/base/baseConvert/baseConvert.cpp index 45303a2b1..8db33c1fe 100644 --- a/src/base/baseConvert/baseConvert.cpp +++ b/src/base/baseConvert/baseConvert.cpp @@ -126,7 +126,7 @@ namespace steppable::__internals::calc return reportBaseConvert(numberOrig, static_cast(baseStr), digits, steps); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(const int _argc, const char* _argv[]) diff --git a/src/base/decimalConvert/decimalConvert.cpp b/src/base/decimalConvert/decimalConvert.cpp index ce9a5f716..8a4621b4d 100644 --- a/src/base/decimalConvert/decimalConvert.cpp +++ b/src/base/decimalConvert/decimalConvert.cpp @@ -100,7 +100,7 @@ namespace steppable::__internals::calc ss << reportDecimalConvert(_inputString, baseString, converted, steps); return ss.str(); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN diff --git a/src/calc/abs/abs.cpp b/src/calc/abs/abs.cpp index f3087b9d5..47f53f2f8 100644 --- a/src/calc/abs/abs.cpp +++ b/src/calc/abs/abs.cpp @@ -48,7 +48,7 @@ namespace steppable::__internals::calc std::string number = static_cast(_number); return reportAbs(number, steps); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(const int _argc, const char* _argv[]) diff --git a/src/calc/add/add.cpp b/src/calc/add/add.cpp index bde388218..591565dc4 100644 --- a/src/calc/add/add.cpp +++ b/src/calc/add/add.cpp @@ -161,7 +161,7 @@ namespace steppable::__internals::calc return reportAdd( aInteger, aDecimal, bInteger, bDecimal, sumDigits, carries, resultIsNegative, steps, properlyFormat); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(const int _argc, const char* _argv[]) diff --git a/src/calc/atan2/atan2.cpp b/src/calc/atan2/atan2.cpp index e6799f8b8..39462f020 100644 --- a/src/calc/atan2/atan2.cpp +++ b/src/calc/atan2/atan2.cpp @@ -107,7 +107,7 @@ namespace steppable::__internals::calc // Will never be executed. Just here for Clangd. return "Impossible! How did you get here?"; } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(int _argc, const char* _argv[]) diff --git a/src/calc/comparison/comparison.cpp b/src/calc/comparison/comparison.cpp index e2c3f5bbe..959687a77 100644 --- a/src/calc/comparison/comparison.cpp +++ b/src/calc/comparison/comparison.cpp @@ -120,7 +120,7 @@ namespace steppable::__internals::calc } return "2"; } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(int _argc, const char** _argv) diff --git a/src/calc/division/division.cpp b/src/calc/division/division.cpp index 3f15c1bf0..cd0121577 100644 --- a/src/calc/division/division.cpp +++ b/src/calc/division/division.cpp @@ -305,7 +305,7 @@ namespace steppable::__internals::calc // The GCD is the absolute value of a return abs(a, 0); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(const int _argc, const char* _argv[]) diff --git a/src/calc/factorial/factorial.cpp b/src/calc/factorial/factorial.cpp index fca4c2ca0..94bf65a64 100644 --- a/src/calc/factorial/factorial.cpp +++ b/src/calc/factorial/factorial.cpp @@ -84,7 +84,7 @@ namespace steppable::__internals::calc return reportFactorial(_number, result, steps); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(const int _argc, const char* _argv[]) diff --git a/src/calc/hyp/hyp.cpp b/src/calc/hyp/hyp.cpp index 1cf7c74df..5b7cb8182 100644 --- a/src/calc/hyp/hyp.cpp +++ b/src/calc/hyp/hyp.cpp @@ -229,7 +229,7 @@ namespace steppable::__internals::calc return ln(lnArg, decimals); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(int _argc, const char* _argv[]) @@ -253,31 +253,31 @@ int main(int _argc, const char* _argv[]) // Basic trigonometric functions if (command == "sinh") - function = arithmetic::sinh; + function = calc::sinh; else if (command == "cosh") - function = arithmetic::cosh; + function = calc::cosh; else if (command == "tanh") - function = arithmetic::tanh; + function = calc::tanh; // Reciprocal trigonometric functions else if (command == "csch") - function = arithmetic::csch; + function = calc::csch; else if (command == "sech") - function = arithmetic::sech; + function = calc::sech; else if (command == "coth") - function = arithmetic::coth; + function = calc::coth; // Inverse trigonometric functions else if (command == "asinh") - function = arithmetic::asinh; + function = calc::asinh; else if (command == "acosh") - function = arithmetic::acosh; + function = calc::acosh; else if (command == "atanh") - function = arithmetic::atanh; + function = calc::atanh; else if (command == "acsch") - function = arithmetic::acsch; + function = calc::acsch; else if (command == "acoth") - function = arithmetic::acoth; + function = calc::acoth; else if (command == "asech") - function = arithmetic::asech; + function = calc::asech; // Invalid command else { diff --git a/src/calc/log/log.cpp b/src/calc/log/log.cpp index ac1b38183..660759401 100644 --- a/src/calc/log/log.cpp +++ b/src/calc/log/log.cpp @@ -139,7 +139,7 @@ namespace steppable::__internals::calc checkDecimalArg(&_decimals); return _log(_number, _decimals); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(int _argc, const char* _argv[]) @@ -163,13 +163,13 @@ int main(int _argc, const char* _argv[]) using namespace steppable::output; if (command == "logb") - std::cout << arithmetic::logb(arg, base, decimals) << "\n"; + std::cout << calc::logb(arg, base, decimals) << "\n"; else if (command == "log10") - std::cout << arithmetic::log10(arg, decimals) << "\n"; + std::cout << calc::log10(arg, decimals) << "\n"; else if (command == "log2") - std::cout << arithmetic::log2(arg, decimals) << "\n"; + std::cout << calc::log2(arg, decimals) << "\n"; else if (command == "ln") - std::cout << arithmetic::ln(arg, decimals) << "\n"; + std::cout << calc::ln(arg, decimals) << "\n"; else { error("log"s, $("log", "0fc4245a-fee9-4e99-bbbd-378d091c5143", { command })); diff --git a/src/calc/multiply/multiply.cpp b/src/calc/multiply/multiply.cpp index e761807ac..ba149cfb5 100644 --- a/src/calc/multiply/multiply.cpp +++ b/src/calc/multiply/multiply.cpp @@ -190,7 +190,7 @@ namespace steppable::__internals::calc resultIsNegative, steps); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(const int _argc, const char* _argv[]) diff --git a/src/calc/power/power.cpp b/src/calc/power/power.cpp index f1fa24a3d..24ad6b6f2 100644 --- a/src/calc/power/power.cpp +++ b/src/calc/power/power.cpp @@ -137,7 +137,7 @@ namespace steppable::__internals::calc return power(exp(divide(x, "4", 0, decimals)), "4", 0); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(const int _argc, const char* _argv[]) diff --git a/src/calc/root/root.cpp b/src/calc/root/root.cpp index ec771c1d7..e677b6017 100644 --- a/src/calc/root/root.cpp +++ b/src/calc/root/root.cpp @@ -201,7 +201,7 @@ namespace steppable::__internals::calc return _root(_number, base, _decimals, steps); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN // NOLINTNEXTLINE(bugprone-exception-escape) diff --git a/src/calc/subtract/subtract.cpp b/src/calc/subtract/subtract.cpp index 652bf6d57..576352e5c 100644 --- a/src/calc/subtract/subtract.cpp +++ b/src/calc/subtract/subtract.cpp @@ -187,7 +187,7 @@ namespace steppable::__internals::calc resultIsNegative, noMinus); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(int _argc, const char* _argv[]) diff --git a/src/calc/trig/trig.cpp b/src/calc/trig/trig.cpp index b4fc2f984..bb57d72c1 100644 --- a/src/calc/trig/trig.cpp +++ b/src/calc/trig/trig.cpp @@ -475,7 +475,7 @@ namespace steppable::__internals::calc // x return atan(divide("1", x, 0, decimals), decimals, mode); } -} // namespace steppable::__internals::arithmetic +} // namespace steppable::__internals::calc #ifndef NO_MAIN int main(int _argc, const char* _argv[]) @@ -501,31 +501,31 @@ int main(int _argc, const char* _argv[]) // Basic trigonometric functions if (command == "sin") - function = arithmetic::sin; + function = calc::sin; else if (command == "cos") - function = arithmetic::cos; + function = calc::cos; else if (command == "tan") - function = arithmetic::tan; + function = calc::tan; // Reciprocal trigonometric functions else if (command == "csc") - function = arithmetic::csc; + function = calc::csc; else if (command == "sec") - function = arithmetic::sec; + function = calc::sec; else if (command == "cot") - function = arithmetic::cot; + function = calc::cot; // Inverse trigonometric functions else if (command == "atan") - function = arithmetic::atan; + function = calc::atan; else if (command == "asin") - function = arithmetic::asin; + function = calc::asin; else if (command == "acos") - function = arithmetic::acos; + function = calc::acos; else if (command == "asec") - function = arithmetic::asec; + function = calc::asec; else if (command == "acsc") - function = arithmetic::acsc; + function = calc::acsc; else if (command == "acot") - function = arithmetic::acot; + function = calc::acot; // Invalid command else { From 881e26bf8f17234ffe09351a2605ab6d442b72cc Mon Sep 17 00:00:00 2001 From: Andy Zhang Date: Thu, 30 Jan 2025 08:53:41 +0800 Subject: [PATCH 05/12] Started using `Result` to replace std::string. --- .idea/editor.xml | 10 +++-- .idea/inspectionProfiles/Project_Default.xml | 1 + include/factors.hpp | 4 +- include/types/data.hpp | 42 +++++++++++++++++ include/types/result.hpp | 47 +++++++++++++++----- include/util.hpp | 36 +++++++++++++++ src/calc/abs/abs.cpp | 12 +++-- src/factors.cpp | 16 ++++--- 8 files changed, 141 insertions(+), 27 deletions(-) create mode 100644 include/types/data.hpp diff --git a/.idea/editor.xml b/.idea/editor.xml index bde9249e6..6e4282015 100644 --- a/.idea/editor.xml +++ b/.idea/editor.xml @@ -1,7 +1,6 @@ - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 8e10ee14e..e4bdb3203 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -5,6 +5,7 @@ +