Skip to content

Commit c3897d3

Browse files
chore: use iwyu on machine_learning/**.cpp
1 parent 0c6611a commit c3897d3

File tree

5 files changed

+55
-43
lines changed

5 files changed

+55
-43
lines changed

machine_learning/a_star_search.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@
1919
* values having minimum F(state).
2020
* @author [Ashish Daulatabad](https://github.com/AshishYUO)
2121
*/
22-
#include <algorithm> /// for `std::reverse` function
23-
#include <array> /// for `std::array`, representing `EightPuzzle` board
24-
#include <cassert> /// for `assert`
25-
#include <functional> /// for `std::function` STL
26-
#include <iostream> /// for IO operations
27-
#include <map> /// for `std::map` STL
28-
#include <memory> /// for `std::shared_ptr`
29-
#include <set> /// for `std::set` STL
30-
#include <vector> /// for `std::vector` STL
22+
#include <stdint.h> // for uint32_t, int8_t
23+
24+
#include <algorithm> // for max, min
25+
#include <array> // for array, operator==
26+
#include <cassert> // for assert
27+
#include <cstddef> // for size_t
28+
#include <functional> // for function
29+
#include <iostream> // for operator<<, basic_ostream, char_traits, cout
30+
#include <map> // for operator!=, map, operator==
31+
#include <memory> // for shared_ptr, make_shared, operator!=
32+
#include <set> // for set
33+
#include <tuple> // for tie, tuple
34+
#include <utility> // for pair, move, make_pair, swap
35+
#include <vector> // for vector
36+
3137
/**
3238
* @namespace machine_learning
3339
* @brief Machine learning algorithms

machine_learning/adaline_learning.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@
2626
* computed using stochastic gradient descent method.
2727
*/
2828

29-
#include <array>
30-
#include <cassert>
31-
#include <climits>
32-
#include <cmath>
33-
#include <cstdlib>
34-
#include <ctime>
35-
#include <iostream>
36-
#include <numeric>
37-
#include <vector>
29+
#include <bits/std_abs.h> // for abs
30+
#include <array> // for array
31+
#include <cassert> // for assert
32+
#include <cstdlib> // for rand, exit, srand, strtof, EXIT_FAILURE
33+
#include <ctime> // for time
34+
#include <iostream> // for basic_ostream, operator<<, char_traits, cout
35+
#include <numeric> // for inner_product
36+
#include <vector> // for vector
3837

3938
/** Maximum number of iterations to learn */
4039
constexpr int MAX_ITER = 500; // INT_MAX

machine_learning/k_nearest_neighbors.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
* the K-nearest neighbors.
1010
*/
1111

12-
#include <algorithm> /// for std::transform and std::sort
13-
#include <cassert> /// for assert
14-
#include <cmath> /// for std::pow and std::sqrt
15-
#include <iostream> /// for std::cout
16-
#include <numeric> /// for std::accumulate
17-
#include <unordered_map> /// for std::unordered_map
18-
#include <vector> /// for std::vector
12+
#include <algorithm> // for sort, transform
13+
#include <cassert> // for assert
14+
#include <cmath> // for sqrt, pow
15+
#include <cstddef> // for size_t
16+
#include <iostream> // for basic_ostream, operator<<, char_traits, cout
17+
#include <iterator> // for back_inserter
18+
#include <numeric> // for accumulate
19+
#include <unordered_map> // for unordered_map, _Node_iterator
20+
#include <utility> // for pair
21+
#include <vector> // for vector
1922

2023
/**
2124
* @namespace machine_learning
@@ -65,7 +68,7 @@ class Knn {
6568
* @param Y labels vector
6669
*/
6770
explicit Knn(std::vector<std::vector<double>>& X, std::vector<int>& Y)
68-
: X_(X), Y_(Y){};
71+
: X_(X), Y_(Y) {};
6972

7073
/**
7174
* Copy Constructor for class Knn.

machine_learning/neural_network.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,20 @@
2727
* MSE as loss function. Bias is also not included.
2828
*/
2929

30-
#include <algorithm>
31-
#include <cassert>
32-
#include <chrono>
33-
#include <cmath>
34-
#include <fstream>
35-
#include <iostream>
36-
#include <sstream>
37-
#include <string>
38-
#include <valarray>
39-
#include <vector>
40-
41-
#include "vector_ops.hpp" // Custom header file for vector operations
30+
#include <bits/chrono.h> // for duration, duration_cast, high_resolution_c...
31+
#include <algorithm> // for max, min
32+
#include <cassert> // for assert
33+
#include <cmath> // for exp
34+
#include <fstream> // for basic_ostream, operator<<, endl, basic_ist...
35+
#include <iostream> // for cerr, cout
36+
#include <sstream> // for basic_stringstream
37+
#include <string> // for char_traits, basic_string, operator<<, ope...
38+
#include <valarray> // for valarray
39+
#include <vector> // for vector
40+
#include <cstdlib> // for exit, size_t, EXIT_FAILURE
41+
#include <utility> // for pair, make_pair
42+
43+
#include "vector_ops.hpp" // for argmax, apply_function, get_shape, multiply
4244

4345
/** \namespace machine_learning
4446
* \brief Machine learning algorithms

machine_learning/ordinary_least_squares_regressor.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
*
1010
* \author [Krishna Vedala](https://github.com/kvedala)
1111
*/
12-
#include <cassert>
13-
#include <cmath> // for std::abs
14-
#include <iomanip> // for print formatting
15-
#include <iostream>
16-
#include <vector>
12+
#include <bits/std_abs.h> // for abs
13+
14+
#include <cassert> // for assert
15+
#include <cstddef> // for size_t
16+
#include <iomanip> // for operator<<, setfill, setw, _Setfill, _Setw
17+
#include <iostream> // for basic_ostream, operator<<, char_traits, cout
18+
#include <vector> // for vector
1719

1820
/**
1921
* operator to print a matrix

0 commit comments

Comments
 (0)