mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-13 07:25:42 +08:00
chore: use iwyu on math/**.cpp
This commit is contained in:
@@ -9,11 +9,10 @@
|
||||
* @author [Focusucof](https://github.com/Focusucof)
|
||||
*/
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cassert> /// for assert
|
||||
#include <cmath> /// for M_PI definition and pow()
|
||||
#include <cmath>
|
||||
#include <cstdint> /// for uint16_t datatype
|
||||
#include <iostream> /// for IO operations
|
||||
#include <cassert> // for assert
|
||||
#include <cmath> // for NAN, M_PI, pow
|
||||
#include <cstdint> // for uint16_t
|
||||
#include <iostream> // for basic_ostream, operator<<, char_traits, endl, cout
|
||||
|
||||
/**
|
||||
* @namespace math
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
* @author [ewd00010](https://github.com/ewd00010)
|
||||
*/
|
||||
|
||||
#include <cassert> /// for assert
|
||||
#include <iostream> /// for IO operations
|
||||
#include <stdint.h> // for int64_t
|
||||
#include <cassert> // for assert
|
||||
#include <iostream> // for char_traits, basic_ostream, operator<<, cout, endl
|
||||
|
||||
/**
|
||||
* @brief Mathematical algorithms
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
* operators overloaded to accommodate (mathematical) field operations.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <complex>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <cassert> // for assert
|
||||
#include <cmath> // for atan2, cos, sin, sqrt
|
||||
#include <complex> // for complex, abs, arg, conj, operator*, operator+
|
||||
#include <ctime> // for time
|
||||
#include <iostream> // for basic_ostream, operator<<, char_traits, cout, endl
|
||||
#include <stdexcept> // for invalid_argument
|
||||
#include <cstdlib> // for rand, srand
|
||||
|
||||
/**
|
||||
* \brief Class Complex to represent complex numbers as a field.
|
||||
|
||||
@@ -13,11 +13,13 @@
|
||||
* @author [Keval Kapdee](https://github.com/thechubbypanda)
|
||||
*/
|
||||
|
||||
#include <cassert> /// For assert
|
||||
#include <chrono> /// For timing the sieve
|
||||
#include <iostream> /// For IO operations
|
||||
#include <string> /// For string handling
|
||||
#include <vector> /// For std::vector
|
||||
#include <bits/chrono.h> // for duration, duration_cast, high_resolution_clock
|
||||
#include <stdint.h> // for uint64_t
|
||||
#include <cassert> // for assert
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, endl
|
||||
#include <string> // for char_traits, basic_string, operator==, string
|
||||
#include <vector> // for vector
|
||||
#include <ratio> // for ratio
|
||||
|
||||
/**
|
||||
* @namespace math
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
* multiplicative inverse of a number. (A * B)%M == 1 Here B is the MMI of A for
|
||||
* given M, so extendedEuclid (A, M) gives B.
|
||||
*/
|
||||
#include <algorithm> // for swap function
|
||||
#include <iostream>
|
||||
#include <cstdint>
|
||||
#include <iostream> // for char_traits, basic_ostream, basic_ostream::opera...
|
||||
#include <cstdint> // for uint32_t, int32_t
|
||||
#include <utility> // for swap
|
||||
|
||||
/**
|
||||
* function to update the coefficients per iteration
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
* @author [Akshay Gupta](https://github.com/Akshay1910)
|
||||
*/
|
||||
|
||||
#include <cassert> /// for assert
|
||||
#include <cstdint> /// for integral typedefs
|
||||
#include <iostream> /// for I/O operations
|
||||
#include <cassert> // for assert
|
||||
#include <cstdint> // for uint64_t, uint8_t
|
||||
#include <iostream> // for operator<<, basic_ostream, cout
|
||||
#include <stdexcept> // for invalid_argument
|
||||
|
||||
/**
|
||||
* @namespace
|
||||
* @brief Mathematical algorithms
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
* @see fibonacci_large.cpp, fibonacci.cpp, string_fibonacci.cpp
|
||||
*/
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <cinttypes> // for uint64_t
|
||||
#include <iostream> // for char_traits, basic_ostream, operator<<, cerr, cout
|
||||
|
||||
/**
|
||||
* maximum number that can be computed - The result after 93 cannot be stored
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
* @see fibonacci.cpp, fibonacci_fast.cpp, string_fibonacci.cpp
|
||||
*/
|
||||
|
||||
#include <cinttypes>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <stdlib.h> // for strtoull
|
||||
#include <cinttypes> // for uint64_t
|
||||
#include <ctime> // for clock, clock_t, CLOCKS_PER_SEC, NULL
|
||||
#include <iostream> // for basic_ostream, char_traits, operator<<
|
||||
|
||||
#include "./large_number.h"
|
||||
#include "./large_number.h" // for large_number, operator<<, operator==
|
||||
|
||||
/** Compute fibonacci numbers using the relation
|
||||
* \f[f(n)=f(n-1)+f(n-2)\f]
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
*
|
||||
* @see gcd_iterative_euclidean.cpp, gcd_of_n_numbers.cpp
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <iostream> // for basic_ostream, char_traits, operator<<, basic_o...
|
||||
#include <stdexcept> // for domain_error
|
||||
|
||||
/**
|
||||
* algorithm
|
||||
|
||||
@@ -22,13 +22,14 @@
|
||||
*/
|
||||
|
||||
#define _USE_MATH_DEFINES /// for M_PI on windows
|
||||
#include <cmath> /// for math functions
|
||||
#include <cstdint> /// for fixed size data types
|
||||
#include <ctime> /// for time to initialize rng
|
||||
#include <functional> /// for function pointers
|
||||
#include <iostream> /// for std::cout
|
||||
#include <random> /// for random number generation
|
||||
#include <vector> /// for std::vector
|
||||
#include <cmath> // for exp, M_PI, sin, sqrt
|
||||
#include <cstdint> // for uint32_t
|
||||
#include <ctime> // for time
|
||||
#include <functional> // for function
|
||||
#include <iostream> // for basic_ostream, char_traits, operator<<, endl
|
||||
#include <random> // for normal_distribution, uniform_real_distribution
|
||||
#include <vector> // for vector
|
||||
#include <algorithm> // for min
|
||||
|
||||
/**
|
||||
* @namespace math
|
||||
|
||||
@@ -8,11 +8,12 @@
|
||||
* This algorithm is used to calculate shadows in Quake III Arena.
|
||||
*/
|
||||
|
||||
#include <cassert> /// for assert
|
||||
#include <cmath> /// for `std::sqrt`
|
||||
#include <cstdint> /// for integral typedefs
|
||||
#include <iostream> /// for IO operations
|
||||
#include <limits> /// for numeric_limits
|
||||
#include <cassert> // for assert
|
||||
#include <cmath> // for fabs, sqrt
|
||||
#include <cstdint> // for int32_t, int64_t
|
||||
#include <iostream> // for basic_ostream, char_traits, operator<<, cout
|
||||
#include <type_traits> // for conditional
|
||||
|
||||
/**
|
||||
* @brief This is the function that calculates the fast inverse square root.
|
||||
* The following code is the fast inverse square root implementation from
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cassert> /// for assert
|
||||
#include <cstdint> /// for integral types
|
||||
#include <exception> /// for std::invalid_argument
|
||||
#include <iostream> /// for std::cout
|
||||
#include <cassert> // for assert
|
||||
#include <cstdint> // for uint64_t, uint8_t
|
||||
#include <iostream> // for operator<<, basic_ostream, cout
|
||||
#include <stdexcept> // for invalid_argument
|
||||
|
||||
/**
|
||||
* @namespace
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
* \author [Krishna Vedala](https://github.com/kvedala)
|
||||
* @see factorial.cpp
|
||||
*/
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <stdlib.h> // for atoi
|
||||
#include <cstring> // for strlen, size_t
|
||||
#include <ctime> // for clock, clock_t, CLOCKS_PER_SEC
|
||||
#include <iostream> // for basic_ostream, char_traits, operator<<
|
||||
|
||||
#include "./large_number.h"
|
||||
#include "./large_number.h" // for large_number, operator<<
|
||||
|
||||
/** Test implementation for 10! Result must be 3628800.
|
||||
* @returns True if test pass else False
|
||||
|
||||
@@ -17,10 +17,9 @@
|
||||
* here](https://en.wikipedia.org/wiki/Exponentiation_by_squaring).
|
||||
* @author [Ashish Daulatabad](https://github.com/AshishYUO)
|
||||
*/
|
||||
#include <cassert> /// for assert
|
||||
#include <cstdint> /// for integral typedefs
|
||||
#include <iostream> /// for IO operations
|
||||
#include <vector> /// for std::vector STL
|
||||
#include <cassert> // for assert
|
||||
#include <cstdint> // for int64_t, uint32_t, uint64_t
|
||||
#include <vector> // for vector
|
||||
|
||||
/**
|
||||
* @namespace math
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
* (as \f$a\times a^{-1} = 1\f$)
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <stdint.h> // for int64_t
|
||||
#include <iostream> // for char_traits, basic_ostream, operator<<, cout, endl
|
||||
|
||||
/** Recursive function to calculate exponent in \f$O(\log n)\f$ using binary
|
||||
* exponent.
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
* @author [Swastika Gupta](https://github.com/Swastyy)
|
||||
*/
|
||||
|
||||
#include <cassert> /// for assert
|
||||
#include <cstdint> /// for integral typedefs
|
||||
#include <iostream> /// for std::cout
|
||||
#include <vector> /// for std::vector
|
||||
#include <cassert> // for assert
|
||||
#include <cstdint> // for uint64_t
|
||||
#include <iostream> // for char_traits, basic_ostream, operator<<
|
||||
#include <vector> // for vector, operator==
|
||||
#include <initializer_list> // for initializer_list
|
||||
|
||||
/**
|
||||
* @namespace math
|
||||
* @brief Mathematical algorithms
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
* @author [Kaustubh Damania](https://github.com/KaustubhDamania)
|
||||
*/
|
||||
|
||||
#include <cassert> /// for assert
|
||||
#include <iostream> /// for std::cout
|
||||
#include <vector> /// for std::vector
|
||||
#include <stdint.h> // for int64_t
|
||||
#include <cassert> // for assert
|
||||
#include <iostream> // for char_traits, basic_ostream, operator<<, basic_os...
|
||||
#include <vector> // for vector
|
||||
|
||||
/**
|
||||
* @namespace math
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* @file
|
||||
* @brief Prime factorization of positive integers
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <cstring> // for memset
|
||||
#include <iostream> // for char_traits, basic_ostream, operator<<, basic_os...
|
||||
#include <vector> // for vector
|
||||
#include <utility> // for pair, make_pair
|
||||
|
||||
/** Declaring variables for maintaing prime numbers and to check whether a
|
||||
* number is prime or not
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
* @brief Get list of prime numbers
|
||||
* @see primes_up_to_billion.cpp sieve_of_eratosthenes.cpp
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <cstddef> // for size_t
|
||||
#include <iostream> // for char_traits, basic_ostream, operator<<, cout
|
||||
#include <vector> // for vector
|
||||
|
||||
/** Generate an increasingly large number of primes
|
||||
* and store in a list
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
* @brief Compute prime numbers upto 1 billion
|
||||
* @see prime_numbers.cpp sieve_of_eratosthenes.cpp
|
||||
*/
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <stdint.h> // for int64_t
|
||||
#include <cstring> // for memset
|
||||
#include <iostream> // for operator<<, basic_ostream, cout, basic_istream, cin
|
||||
|
||||
/** array to store the primes */
|
||||
char prime[100000000];
|
||||
|
||||
@@ -28,13 +28,13 @@
|
||||
* (-0.5,0.866025) (-0.5,0.866025)
|
||||
*/
|
||||
|
||||
#include <array> /// std::array
|
||||
#include <cassert> /// assert
|
||||
#include <cmath> /// std::sqrt, std::trunc, std::pow
|
||||
#include <complex> /// std::complex
|
||||
#include <exception> /// std::invalid_argument
|
||||
#include <iomanip> /// std::setprecision
|
||||
#include <iostream> /// std::cout
|
||||
#include <array> // for array, operator==
|
||||
#include <cassert> // for assert
|
||||
#include <cmath> // for round, sqrt, pow
|
||||
#include <complex> // for complex, operator==
|
||||
#include <cstddef> // for size_t
|
||||
#include <iostream> // for operator<<, basic_ostream, cout
|
||||
#include <stdexcept> // for invalid_argument
|
||||
|
||||
/**
|
||||
* @namespace
|
||||
@@ -65,7 +65,7 @@ std::array<std::complex<long double>, 2> quadraticEquation(long double a,
|
||||
solutions[1] = -b * 0.5 / a;
|
||||
return solutions;
|
||||
}
|
||||
|
||||
|
||||
// Complex root (discriminant < 0)
|
||||
// Note that the left term (-b / 2a) is always real. The imaginary part
|
||||
// appears when b^2 - 4ac < 0, so sqrt(b^2 - 4ac) has no real roots. So,
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
* simple enough to be easily implemented in an embedded system.
|
||||
* \author [Krishna Vedala](https://github.com/kvedala)
|
||||
*/
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <bits/std_abs.h> // for abs
|
||||
#include <cassert> // for assert
|
||||
#include <cmath> // for sqrt
|
||||
#include <iostream> // for basic_ostream, char_traits, operator<<, cout
|
||||
|
||||
/**
|
||||
* \namespace statistics
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
* @see fibonacci_large.cpp, fibonacci_fast.cpp, fibonacci.cpp
|
||||
*/
|
||||
|
||||
#include <cstdint> /// for integral typedefs
|
||||
#include <iostream>
|
||||
#include <cstdint> // for uint64_t
|
||||
#include <iostream> // for char_traits, basic_ostream, operator<<, cout
|
||||
#include <string> // for allocator, basic_string, operator+, string, oper...
|
||||
#ifdef _MSC_VER
|
||||
#include <string> // use this for MS Visual C
|
||||
#include <string> // for allocator, basic_string, operator+, string, oper...
|
||||
#else
|
||||
#include <cstring> // otherwise
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user