[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:
Krishna Vedala
2020-07-13 07:52:38 -04:00
committed by GitHub
parent 1f32b4e412
commit 8ab9a2ae93
6 changed files with 243 additions and 172 deletions

View File

@@ -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;