mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-04 19:20:17 +08:00
[cpp fixes] tidied up code based on error reports by clang-tidy (#950)
* tidied up code based on error reports by clang-tidy * added doc for activation function
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#define EPSILON 1e-10 ///< system accuracy limit
|
||||
#define MAX_ITERATIONS INT16_MAX ///< Maximum number of iterations to check
|
||||
constexpr double EPSILON = 1e-10; ///< system accuracy limit
|
||||
constexpr int16_t MAX_ITERATIONS = INT16_MAX; ///< Maximum number of iterations
|
||||
|
||||
/** define \f$f(x)\f$ to find root for.
|
||||
* Currently defined as:
|
||||
@@ -44,8 +44,8 @@ static double eq_der(double i) {
|
||||
int main() {
|
||||
std::srand(std::time(nullptr)); // initialize randomizer
|
||||
|
||||
double z, c = std::rand() % 100, m, n;
|
||||
int i;
|
||||
double z = NAN, c = std::rand() % 100, m = NAN, n = NAN;
|
||||
int i = 0;
|
||||
|
||||
std::cout << "\nInitial approximation: " << c;
|
||||
|
||||
@@ -57,8 +57,9 @@ int main() {
|
||||
z = c - (m / n);
|
||||
c = z;
|
||||
|
||||
if (std::abs(m) < EPSILON) // stoping criteria
|
||||
if (std::abs(m) < EPSILON) { // stoping criteria
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "\n\nRoot: " << z << "\t\tSteps: " << i << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user