Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c47117c

Browse files
chore: use iwyu on math/**.cpp
1 parent c3897d3 commit c47117c

23 files changed

+102
-88
lines changed

math/area.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
* @author [Focusucof](https://github.com/Focusucof)
1010
*/
1111
#define _USE_MATH_DEFINES
12-
#include <cassert> /// for assert
13-
#include <cmath> /// for M_PI definition and pow()
14-
#include <cmath>
15-
#include <cstdint> /// for uint16_t datatype
16-
#include <iostream> /// for IO operations
12+
#include <cassert> // for assert
13+
#include <cmath> // for NAN, M_PI, pow
14+
#include <cstdint> // for uint16_t
15+
#include <iostream> // for basic_ostream, operator<<, char_traits, endl, cout
1716

1817
/**
1918
* @namespace math

math/check_prime.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
* @author [ewd00010](https://github.com/ewd00010)
1515
*/
1616

17-
#include <cassert> /// for assert
18-
#include <iostream> /// for IO operations
17+
#include <stdint.h> // for int64_t
18+
#include <cassert> // for assert
19+
#include <iostream> // for char_traits, basic_ostream, operator<<, cout, endl
1920

2021
/**
2122
* @brief Mathematical algorithms

math/complex_numbers.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
* operators overloaded to accommodate (mathematical) field operations.
88
*/
99

10-
#include <cassert>
11-
#include <cmath>
12-
#include <complex>
13-
#include <ctime>
14-
#include <iostream>
15-
#include <stdexcept>
10+
#include <cassert> // for assert
11+
#include <cmath> // for atan2, cos, sin, sqrt
12+
#include <complex> // for complex, abs, arg, conj, operator*, operator+
13+
#include <ctime> // for time
14+
#include <iostream> // for basic_ostream, operator<<, char_traits, cout, endl
15+
#include <stdexcept> // for invalid_argument
16+
#include <cstdlib> // for rand, srand
1617

1718
/**
1819
* \brief Class Complex to represent complex numbers as a field.

math/eratosthenes.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
* @author [Keval Kapdee](https://github.com/thechubbypanda)
1414
*/
1515

16-
#include <cassert> /// For assert
17-
#include <chrono> /// For timing the sieve
18-
#include <iostream> /// For IO operations
19-
#include <string> /// For string handling
20-
#include <vector> /// For std::vector
16+
#include <bits/chrono.h> // for duration, duration_cast, high_resolution_clock
17+
#include <stdint.h> // for uint64_t
18+
#include <cassert> // for assert
19+
#include <iostream> // for basic_ostream, operator<<, cout, endl
20+
#include <string> // for char_traits, basic_string, operator==, string
21+
#include <vector> // for vector
22+
#include <ratio> // for ratio
2123

2224
/**
2325
* @namespace math

math/extended_euclid_algorithm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* multiplicative inverse of a number. (A * B)%M == 1 Here B is the MMI of A for
1010
* given M, so extendedEuclid (A, M) gives B.
1111
*/
12-
#include <algorithm> // for swap function
13-
#include <iostream>
14-
#include <cstdint>
12+
#include <iostream> // for char_traits, basic_ostream, basic_ostream::opera...
13+
#include <cstdint> // for uint32_t, int32_t
14+
#include <utility> // for swap
1515

1616
/**
1717
* function to update the coefficients per iteration

math/factorial.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
* @author [Akshay Gupta](https://github.com/Akshay1910)
1212
*/
1313

14-
#include <cassert> /// for assert
15-
#include <cstdint> /// for integral typedefs
16-
#include <iostream> /// for I/O operations
14+
#include <cassert> // for assert
15+
#include <cstdint> // for uint64_t, uint8_t
16+
#include <iostream> // for operator<<, basic_ostream, cout
17+
#include <stdexcept> // for invalid_argument
18+
1719
/**
1820
* @namespace
1921
* @brief Mathematical algorithms

math/fibonacci_fast.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
* @see fibonacci_large.cpp, fibonacci.cpp, string_fibonacci.cpp
1616
*/
1717

18-
#include <cinttypes>
19-
#include <cstdio>
20-
#include <iostream>
18+
#include <cinttypes> // for uint64_t
19+
#include <iostream> // for char_traits, basic_ostream, operator<<, cerr, cout
2120

2221
/**
2322
* maximum number that can be computed - The result after 93 cannot be stored

math/fibonacci_large.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
* @see fibonacci.cpp, fibonacci_fast.cpp, string_fibonacci.cpp
1212
*/
1313

14-
#include <cinttypes>
15-
#include <ctime>
16-
#include <iostream>
14+
#include <stdlib.h> // for strtoull
15+
#include <cinttypes> // for uint64_t
16+
#include <ctime> // for clock, clock_t, CLOCKS_PER_SEC, NULL
17+
#include <iostream> // for basic_ostream, char_traits, operator<<
1718

18-
#include "./large_number.h"
19+
#include "./large_number.h" // for large_number, operator<<, operator==
1920

2021
/** Compute fibonacci numbers using the relation
2122
* \f[f(n)=f(n-1)+f(n-2)\f]

math/gcd_recursive_euclidean.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
*
77
* @see gcd_iterative_euclidean.cpp, gcd_of_n_numbers.cpp
88
*/
9-
#include <iostream>
9+
#include <iostream> // for basic_ostream, char_traits, operator<<, basic_o...
10+
#include <stdexcept> // for domain_error
1011

1112
/**
1213
* algorithm

math/integral_approximation2.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
*/
2323

2424
#define _USE_MATH_DEFINES /// for M_PI on windows
25-
#include <cmath> /// for math functions
26-
#include <cstdint> /// for fixed size data types
27-
#include <ctime> /// for time to initialize rng
28-
#include <functional> /// for function pointers
29-
#include <iostream> /// for std::cout
30-
#include <random> /// for random number generation
31-
#include <vector> /// for std::vector
25+
#include <cmath> // for exp, M_PI, sin, sqrt
26+
#include <cstdint> // for uint32_t
27+
#include <ctime> // for time
28+
#include <functional> // for function
29+
#include <iostream> // for basic_ostream, char_traits, operator<<, endl
30+
#include <random> // for normal_distribution, uniform_real_distribution
31+
#include <vector> // for vector
32+
#include <algorithm> // for min
3233

3334
/**
3435
* @namespace math

math/inv_sqrt.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
* This algorithm is used to calculate shadows in Quake III Arena.
99
*/
1010

11-
#include <cassert> /// for assert
12-
#include <cmath> /// for `std::sqrt`
13-
#include <cstdint> /// for integral typedefs
14-
#include <iostream> /// for IO operations
15-
#include <limits> /// for numeric_limits
11+
#include <cassert> // for assert
12+
#include <cmath> // for fabs, sqrt
13+
#include <cstdint> // for int32_t, int64_t
14+
#include <iostream> // for basic_ostream, char_traits, operator<<, cout
15+
#include <type_traits> // for conditional
16+
1617
/**
1718
* @brief This is the function that calculates the fast inverse square root.
1819
* The following code is the fast inverse square root implementation from

math/iterative_factorial.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
*
2626
*/
2727

28-
#include <cassert> /// for assert
29-
#include <cstdint> /// for integral types
30-
#include <exception> /// for std::invalid_argument
31-
#include <iostream> /// for std::cout
28+
#include <cassert> // for assert
29+
#include <cstdint> // for uint64_t, uint8_t
30+
#include <iostream> // for operator<<, basic_ostream, cout
31+
#include <stdexcept> // for invalid_argument
3232

3333
/**
3434
* @namespace

math/large_factorial.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
* \author [Krishna Vedala](https://github.com/kvedala)
66
* @see factorial.cpp
77
*/
8-
#include <cstring>
9-
#include <ctime>
10-
#include <iostream>
8+
#include <stdlib.h> // for atoi
9+
#include <cstring> // for strlen, size_t
10+
#include <ctime> // for clock, clock_t, CLOCKS_PER_SEC
11+
#include <iostream> // for basic_ostream, char_traits, operator<<
1112

12-
#include "./large_number.h"
13+
#include "./large_number.h" // for large_number, operator<<
1314

1415
/** Test implementation for 10! Result must be 3628800.
1516
* @returns True if test pass else False

math/linear_recurrence_matrix.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
* here](https://en.wikipedia.org/wiki/Exponentiation_by_squaring).
1818
* @author [Ashish Daulatabad](https://github.com/AshishYUO)
1919
*/
20-
#include <cassert> /// for assert
21-
#include <cstdint> /// for integral typedefs
22-
#include <iostream> /// for IO operations
23-
#include <vector> /// for std::vector STL
20+
#include <cassert> // for assert
21+
#include <cstdint> // for int64_t, uint32_t, uint64_t
22+
#include <vector> // for vector
2423

2524
/**
2625
* @namespace math

math/modular_inverse_fermat_little_theorem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
* (as \f$a\times a^{-1} = 1\f$)
4444
*/
4545

46-
#include <iostream>
47-
#include <vector>
46+
#include <stdint.h> // for int64_t
47+
#include <iostream> // for char_traits, basic_ostream, operator<<, cout, endl
4848

4949
/** Recursive function to calculate exponent in \f$O(\log n)\f$ using binary
5050
* exponent.

math/n_bonacci.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
* @author [Swastika Gupta](https://github.com/Swastyy)
1616
*/
1717

18-
#include <cassert> /// for assert
19-
#include <cstdint> /// for integral typedefs
20-
#include <iostream> /// for std::cout
21-
#include <vector> /// for std::vector
18+
#include <cassert> // for assert
19+
#include <cstdint> // for uint64_t
20+
#include <iostream> // for char_traits, basic_ostream, operator<<
21+
#include <vector> // for vector, operator==
22+
#include <initializer_list> // for initializer_list
23+
2224
/**
2325
* @namespace math
2426
* @brief Mathematical algorithms

math/ncr_modulo_p.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
* @author [Kaustubh Damania](https://github.com/KaustubhDamania)
1010
*/
1111

12-
#include <cassert> /// for assert
13-
#include <iostream> /// for std::cout
14-
#include <vector> /// for std::vector
12+
#include <stdint.h> // for int64_t
13+
#include <cassert> // for assert
14+
#include <iostream> // for char_traits, basic_ostream, operator<<, basic_os...
15+
#include <vector> // for vector
1516

1617
/**
1718
* @namespace math

math/prime_factorization.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* @file
33
* @brief Prime factorization of positive integers
44
*/
5-
#include <algorithm>
6-
#include <cstring>
7-
#include <iostream>
8-
#include <vector>
5+
#include <cstring> // for memset
6+
#include <iostream> // for char_traits, basic_ostream, operator<<, basic_os...
7+
#include <vector> // for vector
8+
#include <utility> // for pair, make_pair
99

1010
/** Declaring variables for maintaing prime numbers and to check whether a
1111
* number is prime or not

math/prime_numbers.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
* @brief Get list of prime numbers
44
* @see primes_up_to_billion.cpp sieve_of_eratosthenes.cpp
55
*/
6-
#include <iostream>
7-
#include <vector>
6+
#include <cstddef> // for size_t
7+
#include <iostream> // for char_traits, basic_ostream, operator<<, cout
8+
#include <vector> // for vector
89

910
/** Generate an increasingly large number of primes
1011
* and store in a list

math/primes_up_to_billion.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
* @brief Compute prime numbers upto 1 billion
44
* @see prime_numbers.cpp sieve_of_eratosthenes.cpp
55
*/
6-
#include <cstring>
7-
#include <iostream>
6+
#include <stdint.h> // for int64_t
7+
#include <cstring> // for memset
8+
#include <iostream> // for operator<<, basic_ostream, cout, basic_istream, cin
89

910
/** array to store the primes */
1011
char prime[100000000];

math/quadratic_equations_complex_numbers.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
* (-0.5,0.866025) (-0.5,0.866025)
2929
*/
3030

31-
#include <array> /// std::array
32-
#include <cassert> /// assert
33-
#include <cmath> /// std::sqrt, std::trunc, std::pow
34-
#include <complex> /// std::complex
35-
#include <exception> /// std::invalid_argument
36-
#include <iomanip> /// std::setprecision
37-
#include <iostream> /// std::cout
31+
#include <array> // for array, operator==
32+
#include <cassert> // for assert
33+
#include <cmath> // for round, sqrt, pow
34+
#include <complex> // for complex, operator==
35+
#include <cstddef> // for size_t
36+
#include <iostream> // for operator<<, basic_ostream, cout
37+
#include <stdexcept> // for invalid_argument
3838

3939
/**
4040
* @namespace
@@ -65,7 +65,7 @@ std::array<std::complex<long double>, 2> quadraticEquation(long double a,
6565
solutions[1] = -b * 0.5 / a;
6666
return solutions;
6767
}
68-
68+
6969
// Complex root (discriminant < 0)
7070
// Note that the left term (-b / 2a) is always real. The imaginary part
7171
// appears when b^2 - 4ac < 0, so sqrt(b^2 - 4ac) has no real roots. So,

math/realtime_stats.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
* simple enough to be easily implemented in an embedded system.
88
* \author [Krishna Vedala](https://github.com/kvedala)
99
*/
10-
#include <cassert>
11-
#include <cmath>
12-
#include <iostream>
10+
#include <bits/std_abs.h> // for abs
11+
#include <cassert> // for assert
12+
#include <cmath> // for sqrt
13+
#include <iostream> // for basic_ostream, char_traits, operator<<, cout
1314

1415
/**
1516
* \namespace statistics

math/string_fibonacci.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
* @see fibonacci_large.cpp, fibonacci_fast.cpp, fibonacci.cpp
99
*/
1010

11-
#include <cstdint> /// for integral typedefs
12-
#include <iostream>
11+
#include <cstdint> // for uint64_t
12+
#include <iostream> // for char_traits, basic_ostream, operator<<, cout
13+
#include <string> // for allocator, basic_string, operator+, string, oper...
1314
#ifdef _MSC_VER
14-
#include <string> // use this for MS Visual C
15+
#include <string> // for allocator, basic_string, operator+, string, oper...
1516
#else
16-
#include <cstring> // otherwise
1717
#endif
1818

1919
/**

0 commit comments

Comments
 (0)