Skip to content

Commit 8505313

Browse files
committed
Add more documentation comments by iFlow CLI
1 parent 03961c2 commit 8505313

19 files changed

+395
-110
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
[![Actions Status](https://github.com/luk036/ellalgo-cpp/workflows/MacOS/badge.svg)](https://github.com/luk036/ellalgo-cpp/actions)
2-
[![Actions Status](https://github.com/luk036/ellalgo-cpp/workflows/Windows/badge.svg)](https://github.com/luk036/ellalgo-cpp/actions)
3-
[![Actions Status](https://github.com/luk036/ellalgo-cpp/workflows/Ubuntu/badge.svg)](https://github.com/luk036/ellalgo-cpp/actions)
4-
[![Actions Status](https://github.com/luk036/ellalgo-cpp/workflows/Install/badge.svg)](https://github.com/luk036/ellalgo-cpp/actions)
1+
[![MacOS Build Status](https://github.com/luk036/ellalgo-cpp/workflows/MacOS/badge.svg)](https://github.com/luk036/ellalgo-cpp/actions)
2+
[![Windows Build Status](https://github.com/luk036/ellalgo-cpp/workflows/Windows/badge.svg)](https://github.com/luk036/ellalgo-cpp/actions)
3+
[![Ubuntu Build Status](https://github.com/luk036/ellalgo-cpp/workflows/Ubuntu/badge.svg)](https://github.com/luk036/ellalgo-cpp/actions)
4+
[![Install Status](https://github.com/luk036/ellalgo-cpp/workflows/Install/badge.svg)](https://github.com/luk036/ellalgo-cpp/actions)
55
[![codecov](https://codecov.io/gh/luk036/ellalgo-cpp/branch/master/graph/badge.svg)](https://codecov.io/gh/luk036/ellalgo-cpp)
66

77
<p align="center">

documentation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/conf.py ${CMAKE_CURRENT_BINARY_DIR}/con
2424
add_custom_target(
2525
GenerateDocs
2626
${CMAKE_COMMAND} -E make_directory "${DOXYGEN_OUTPUT_DIRECTORY}"
27+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_LIST_DIR}/../ellalgo.svg" "${DOXYGEN_OUTPUT_DIRECTORY}/"
2728
COMMAND "${m.css_SOURCE_DIR}/documentation/doxygen.py" "${CMAKE_CURRENT_BINARY_DIR}/conf.py"
2829
COMMAND echo "Docs written to: ${DOXYGEN_OUTPUT_DIRECTORY}"
2930
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"

documentation/Doxyfile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,4 @@ GENERATE_LATEX = NO
2626
XML_PROGRAMLISTING = NO
2727
CREATE_SUBDIRS = NO
2828

29-
# Include all directories, files and namespaces in the documentation
30-
# Disable to include only explicitly documented objects
31-
# M_SHOW_UNDOCUMENTED = YES
3229

33-
ALIASES += le="≤"
34-
ALIASES += kappa="κ"
35-
ALIASES += pi="π"
36-
ALIASES += omega="ω"
37-
ALIASES += forall="∀"
38-
ALIASES += in="∈"
39-
ALIASES += pm="±"

documentation/conf.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
1-
DOXYFILE = 'Doxyfile'
1+
import warnings
2+
import logging
3+
4+
# Suppress Python deprecation warnings about testing element truth values
5+
warnings.filterwarnings(
6+
"ignore",
7+
category=DeprecationWarning,
8+
message=".*Testing an element's truth value.*",
9+
)
10+
11+
# Suppress warnings about external images not found in XML output
12+
warnings.filterwarnings(
13+
"ignore", message=".*was not found in XML_OUTPUT", category=RuntimeWarning
14+
)
15+
warnings.filterwarnings(
16+
"ignore", message=".*was not found in XML_OUTPUT", category=UserWarning
17+
)
18+
19+
20+
# Suppress the specific logging messages about external images in m.css
21+
class ImageNotFoundFilter(logging.Filter):
22+
def filter(self, record):
23+
# Suppress specific image not found messages
24+
if "was not found in XML_OUTPUT" in record.getMessage():
25+
return False
26+
return True
27+
28+
29+
# Apply the filter to the root logger
30+
logging.getLogger().addFilter(ImageNotFoundFilter())
31+
32+
DOXYFILE = "Doxyfile"
233

334
LINKS_NAVBAR1 = [
4-
(None, 'pages', [(None, 'about')]),
5-
(None, 'namespaces', []),
35+
(None, "pages", [(None, "about")]),
36+
(None, "namespaces", []),
637
]
738

839
# Add your own navbar links using the code below.

include/ellalgo/ell_assert.hpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,44 @@
1+
/**
2+
* @file ell_assert.hpp
3+
* @brief Branch prediction macros for performance optimization
4+
*
5+
* This header provides macros for giving hints to the compiler about
6+
* the likelihood of certain conditions being true or false. This can
7+
* help the CPU generate more efficient code by optimizing branch
8+
* prediction.
9+
*/
10+
111
#pragma once
212

13+
/**
14+
* @def ELL_LIKELY
15+
* @brief Hint that the expression is likely to be true
16+
*
17+
* This macro tells the compiler that the expression is likely to evaluate
18+
* to true, allowing it to optimize the generated code for the common case.
19+
*
20+
* @param x The expression to evaluate
21+
* @return The same expression value
22+
*/
323
#if defined(__clang__) || defined(__GNUC__)
424
# define ELL_LIKELY(x) __builtin_expect(!!(x), 1)
5-
# define ELL_UNLIKELY(x) __builtin_expect(!!(x), 0)
625
#else
726
# define ELL_LIKELY(x) (!!(x))
27+
#endif
28+
29+
/**
30+
* @def ELL_UNLIKELY
31+
* @brief Hint that the expression is unlikely to be true
32+
*
33+
* This macro tells the compiler that the expression is unlikely to evaluate
34+
* to true, allowing it to optimize the generated code for the uncommon case.
35+
* This is typically used for error conditions or exceptional paths.
36+
*
37+
* @param x The expression to evaluate
38+
* @return The same expression value
39+
*/
40+
#if defined(__clang__) || defined(__GNUC__)
41+
# define ELL_UNLIKELY(x) __builtin_expect(!!(x), 0)
42+
#else
843
# define ELL_UNLIKELY(x) (!!(x))
944
#endif

include/ellalgo/ell_config.hpp

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,92 @@
44
#include <utility> // for pair
55

66
/**
7-
* @brief Options
7+
* @brief Configuration options for the ellipsoid algorithm
88
*
9+
* This structure contains the configuration parameters for controlling
10+
* the behavior of the ellipsoid algorithm, including maximum iterations
11+
* and convergence tolerance.
912
*/
1013
struct Options {
11-
size_t max_iters;
12-
double tolerance;
14+
size_t max_iters; ///< Maximum number of iterations allowed
15+
double tolerance; ///< Convergence tolerance for stopping criteria
1316

17+
/**
18+
* @brief Default constructor
19+
*
20+
* Initializes with default values: max_iters = 2000, tolerance = 1e-20
21+
*/
1422
Options() : max_iters{2000}, tolerance{1e-20} {}
23+
24+
/**
25+
* @brief Constructor with custom parameters
26+
*
27+
* @param[in] max_iters Maximum number of iterations
28+
* @param[in] tol Convergence tolerance
29+
*/
1530
Options(size_t max_iters, double tol) : max_iters{max_iters}, tolerance{tol} {}
1631
};
1732

1833
/**
19-
* @brief Cut Status
34+
* @brief Status of cutting plane operations
2035
*
36+
* This enumeration represents the possible outcomes of cutting plane
37+
* operations in the ellipsoid algorithm.
2138
*/
22-
enum class CutStatus { Success, NoSoln, NoEffect, Unknown };
39+
enum class CutStatus {
40+
Success, ///< Cut was successful and ellipsoid was updated
41+
NoSoln, ///< No solution exists (infeasible)
42+
NoEffect, ///< Cut had no effect on ellipsoid
43+
Unknown ///< Unknown status
44+
};
2345

2446
/**
25-
* @brief CInfo
47+
* @brief Information about the computation result
2648
*
49+
* This structure contains information about the computation,
50+
* including feasibility status and number of iterations used.
2751
*/
2852
struct CInfo {
29-
bool feasible;
30-
size_t num_iters;
53+
bool feasible; ///< Whether a feasible solution was found
54+
size_t num_iters; ///< Number of iterations performed
3155
};
3256

57+
/**
58+
* @brief Type alias for the array type used by template parameter T
59+
*
60+
* This type alias extracts the ArrayType nested type from template parameter T.
61+
*
62+
* @tparam T The type containing ArrayType
63+
*/
3364
template <typename T> using ArrayType = typename T::ArrayType;
65+
66+
/**
67+
* @brief Type alias for the cut choice type used by template parameter T
68+
*
69+
* This type alias extracts the CutChoice nested type from template parameter T.
70+
*
71+
* @tparam T The type containing CutChoice
72+
*/
3473
template <typename T> using CutChoice = typename T::CutChoice;
74+
75+
/**
76+
* @brief Type alias for a cutting plane concept
77+
*
78+
* This type alias defines a pair of array and cut choice, representing
79+
* a cutting plane in the algorithm.
80+
*
81+
* @tparam T The template parameter type
82+
*/
3583
template <typename T> using CutConcept = std::pair<ArrayType<T>, CutChoice<T>>;
84+
85+
/**
86+
* @brief Type alias for return type of Q optimization
87+
*
88+
* This type alias defines the return type for Q optimization functions,
89+
* containing cut concept, boolean flags, and array data.
90+
*
91+
* @tparam T The template parameter type
92+
*/
3693
template <typename T> using RetQ = std::tuple<CutConcept<T>, bool, ArrayType<T>, bool>;
3794

3895
#if __cpp_concepts >= 201907L

include/ellalgo/ell_matrix.hpp

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ class Matrix {
9797
* This performs an element-wise multiplication of the matrix by the scalar value alpha.
9898
*
9999
* Example:
100-
* >>> matrix = Matrix(3, 0.0)
101-
* >>> matrix *= 2.0
102-
* >>> matrix
103-
* valarray([0., 0., 0., 0., 0., 0., 0., 0., 0.],
104-
* [3])
100+
* @code{.cpp}
101+
* Matrix matrix(3, 0.0);
102+
* matrix *= 2.0;
103+
* // matrix becomes valarray([0., 0., 0., 0., 0., 0., 0., 0., 0.], [3])
104+
* @endcode
105105
*
106106
* @param[in] alpha - The scalar value to multiply the matrix by.
107107
* @return A new Matrix object containing the result of the multiplication.
@@ -116,11 +116,11 @@ class Matrix {
116116
* all diagonal elements to 1.
117117
*
118118
* Example:
119-
* >>> matrix = Matrix(3, 0.0)
120-
* >>> matrix.identity()
121-
* >>> matrix
122-
* valarray([1., 0., 0., 0., 1., 0., 0., 0., 1.],
123-
* [3])
119+
* @code{.cpp}
120+
* Matrix matrix(3, 0.0);
121+
* matrix.identity();
122+
* // matrix becomes valarray([1., 0., 0., 0., 1., 0., 0., 0., 1.], [3])
123+
* @endcode
124124
*/
125125
void identity() {
126126
this->clear();
@@ -134,12 +134,13 @@ class Matrix {
134134
* where row index equals column index, corresponding to the diagonal.
135135
*
136136
* Example:
137-
* >>> matrix = Matrix(3, 0.0)
138-
* >>> matrix(0, 0) = 1.0
139-
* >>> matrix(1, 1) = 2.0
140-
* >>> matrix(2, 2) = 3.0
141-
* >>> matrix.diagonal()
142-
* valarray([1., 2., 3.], 3)
137+
* @code{.cpp}
138+
* Matrix matrix(3, 0.0);
139+
* matrix(0, 0) = 1.0;
140+
* matrix(1, 1) = 2.0;
141+
* matrix(2, 2) = 3.0;
142+
* // matrix.diagonal() returns valarray([1., 2., 3.], 3)
143+
* @endcode
143144
*
144145
* @return View of the diagonal elements as a slice_array.
145146
*/
@@ -152,12 +153,13 @@ class Matrix {
152153
* where row index + column index equals ndim-1, corresponding to the secondary diagonal.
153154
*
154155
* Example:
155-
* >>> matrix = Matrix(3, 0.0)
156-
* >>> matrix(0, 0) = 1.0
157-
* >>> matrix(1, 1) = 2.0
158-
* >>> matrix(2, 2) = 3.0
159-
* >>> matrix.secondary_diagonal()
160-
* valarray([0., 0.], 2)
156+
* @code{.cpp}
157+
* Matrix matrix(3, 0.0);
158+
* matrix(0, 0) = 1.0;
159+
* matrix(1, 1) = 2.0;
160+
* matrix(2, 2) = 3.0;
161+
* // matrix.secondary_diagonal() returns valarray([0., 0.], 2)
162+
* @endcode
161163
*
162164
* @return View of the secondary diagonal elements as a slice_array.
163165
*/
@@ -172,16 +174,15 @@ class Matrix {
172174
* of the specified row index.
173175
*
174176
* Example:
175-
* >>> matrix = Matrix(3, 0.0)
176-
* >>> matrix(0, 0) = 1.0
177-
* >>> matrix(1, 1) = 2.0
178-
* >>> matrix(2, 2) = 3.0
179-
* >>> matrix.row(0)
180-
* valarray([1., 0., 0.], 3)
181-
* >>> matrix.row(1)
182-
* valarray([0., 2., 0.], 3)
183-
* >>> matrix.row(2)
184-
* valarray([0., 0., 3.], 3)
177+
* @code{.cpp}
178+
* Matrix matrix(3, 0.0);
179+
* matrix(0, 0) = 1.0;
180+
* matrix(1, 1) = 2.0;
181+
* matrix(2, 2) = 3.0;
182+
* // matrix.row(0) returns valarray([1., 0., 0.], 3)
183+
* // matrix.row(1) returns valarray([0., 2., 0.], 3)
184+
* // matrix.row(2) returns valarray([0., 0., 3.], 3)
185+
* @endcode
185186
*
186187
* @param[in] row - The index of the row to extract.
187188
* @return View of the row elements as a slice_array.
@@ -197,16 +198,15 @@ class Matrix {
197198
* of the specified column index.
198199
*
199200
* Example:
200-
* >>> matrix = Matrix(3, 0.0)
201-
* >>> matrix(0, 0) = 1.0
202-
* >>> matrix(1, 1) = 2.0
203-
* >>> matrix(2, 2) = 3.0
204-
* >>> matrix.column(0)
205-
* valarray([1., 0., 0.], 3)
206-
* >>> matrix.column(1)
207-
* valarray([0., 2., 0.], 3)
208-
* >>> matrix.column(2)
209-
* valarray([0., 0., 3.], 3)
201+
* @code{.cpp}
202+
* Matrix matrix(3, 0.0);
203+
* matrix(0, 0) = 1.0;
204+
* matrix(1, 1) = 2.0;
205+
* matrix(2, 2) = 3.0;
206+
* // matrix.column(0) returns valarray([1., 0., 0.], 3)
207+
* // matrix.column(1) returns valarray([0., 2., 0.], 3)
208+
* // matrix.column(2) returns valarray([0., 0., 3.], 3)
209+
* @endcode
210210
*
211211
* @param[in] col - The index of the column to extract.
212212
* @return View of the column elements as a slice_array.
@@ -222,12 +222,13 @@ class Matrix {
222222
* elements, and then summing those elements.
223223
*
224224
* Example:
225-
* >>> matrix = Matrix(3, 0.0)
226-
* >>> matrix(0, 0) = 1.0
227-
* >>> matrix(1, 1) = 2.0
228-
* >>> matrix(2, 2) = 3.0
229-
* >>> matrix.trace()
230-
* 6.0
225+
* @code{.cpp}
226+
* Matrix matrix(3, 0.0);
227+
* matrix(0, 0) = 1.0;
228+
* matrix(1, 1) = 2.0;
229+
* matrix(2, 2) = 3.0;
230+
* // matrix.trace() returns 6.0
231+
* @endcode
231232
*
232233
* @return The trace of the matrix as a double.
233234
*/

0 commit comments

Comments
 (0)