Skip to content

Commit

Permalink
Precision checks and increased efficiency for _cos (#51)
Browse files Browse the repository at this point in the history
# Precision checks and increased efficiency for `_cos`

This PR addresses issue #50.
  • Loading branch information
ZCG-coder authored Jan 2, 2025
2 parents a7c2c43 + 5c504c4 commit e4f2173
Show file tree
Hide file tree
Showing 190 changed files with 309 additions and 199 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#####################################################################################################
# Copyright (c) 2023-2024 NWSOFT #
# 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 #
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Andy Zhang
Copyright (c) 2023-2025 Andy Zhang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#####################################################################################################
# Copyright (c) 2023-2024 NWSOFT #
# 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 #
Expand Down
2 changes: 1 addition & 1 deletion cpp.hint
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#####################################################################################################
# Copyright (c) 2023-2024 NWSOFT #
# 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 #
Expand Down
2 changes: 1 addition & 1 deletion include/argParse.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/colors.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/constants.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/exceptions.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/factors.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/fn/calc.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/fn/calculus.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/fn/root.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/format.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/fraction.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/getString.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/gui.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/internals.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/logging.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/number.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/output.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/platform.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/rounding.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/symbols.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/testing.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
2 changes: 1 addition & 1 deletion include/types/result.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
32 changes: 31 additions & 1 deletion include/util.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down Expand Up @@ -35,17 +35,22 @@
#pragma once

#include "colors.hpp"
#include "output.hpp"
#include "platform.hpp"

#include <algorithm>
#include <array>
#include <chrono>
#include <clocale>
#include <cstddef>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std::literals;

#ifndef TIC
/**
* @brief Starts a timer for profiling code execution time.
Expand All @@ -72,6 +77,11 @@
}
#endif

#ifndef MAX_DECIMALS
/// @brief The maximum number of decimals to output
#define MAX_DECIMALS 50
#endif

namespace steppable::__internals::utils
{
#ifndef MS_STDLIB_BUGS
Expand Down Expand Up @@ -183,6 +193,26 @@ namespace steppable::__internals::utils
Utf8CodePage() { ; }
};
#endif

/**
* @brief Checks whether the decimal number is correctly specified.
* @details Compares the argument `decimal` to `MAX_DECIMALS`. If too much decimals are requested, prints an error
* and quits the program.
*
* @tparam NumberT Type of the number.
* @param decimal A pointer to the number of decimals.
*/
template<typename NumberT>
void checkDecimalArg(const NumberT* decimal)
{
if (*decimal > MAX_DECIMALS)
{
output::error("checkDecimalArg"s,
"The number of decimals ({0}) is more than the accepted {1} digits."s,
{ std::to_string(*decimal), std::to_string(MAX_DECIMALS) });
programSafeExit(1);
}
}
} // namespace steppable::__internals::utils

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#####################################################################################################
# Copyright (c) 2023-2024 NWSOFT #
# 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 #
Expand Down
2 changes: 1 addition & 1 deletion lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#####################################################################################################
# Copyright (c) 2023-2024 NWSOFT #
# 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 #
Expand Down
2 changes: 1 addition & 1 deletion lib/bindings.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************************************
* Copyright (c) 2023-2024 NWSOFT *
* 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 *
Expand Down
Loading

0 comments on commit e4f2173

Please sign in to comment.