Skip to content

Commit 06734e4

Browse files
committed
Merge branch 'andful/add-formatting-ci' into 'main'
Enforce formatting See merge request computational-modeling/maxpluslib!3
2 parents a232b55 + 28a1af1 commit 06734e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+563
-672
lines changed

.gitlab-ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ before_script:
22
- apt-get update
33
- apt-get install --force-yes -y python lcov
44
- apt remove --purge --auto-remove cmake
5-
- apt install -y software-properties-common lsb-release cmake
5+
- apt install -y software-properties-common lsb-release cmake clang-format
66

77
build:
88
tags:
@@ -17,3 +17,10 @@ build:
1717
when: always
1818
paths:
1919
- ./build/coverage/
20+
21+
format:
22+
tags:
23+
- Ubuntu2004-64bit
24+
script:
25+
- clang-format --dry-run --Werror `find ./ -type f -name "*.h" -o -name "*.cc" -o -name "*.cpp"`
26+

include/maxplus/algebra/maxplus.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@
2121
*
2222
* Permission is hereby granted, free of charge, to any person obtaining
2323
* a copy of this software and associated documentation files (the “Software”),
24-
* to deal in the Software without restriction, including without limitation
25-
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
26-
* and/or sell copies of the Software, and to permit persons to whom the
24+
* to deal in the Software without restriction, including without limitation
25+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
26+
* and/or sell copies of the Software, and to permit persons to whom the
2727
* Software is furnished to do so, subject to the following conditions:
2828
*
29-
* The above copyright notice and this permission notice shall be included
29+
* The above copyright notice and this permission notice shall be included
3030
* in all copies or substantial portions of the Software.
3131
*
3232
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3434
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3838
* SOFTWARE.
3939
*/
4040

include/maxplus/algebra/mpmatrix.h

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ class Vector {
8888

8989
[[nodiscard]] Vector add(MPTime increase) const;
9090

91-
void add(MPTime increase, Vector& result) const;
91+
void add(MPTime increase, Vector &result) const;
9292

93-
void maximum(const Vector& vecB, Vector& result) const;
93+
void maximum(const Vector &vecB, Vector &result) const;
9494

95-
[[nodiscard]] Vector add(const Vector& vecB) const;
95+
[[nodiscard]] Vector add(const Vector &vecB) const;
9696

97-
void add(const Vector& vecB, Vector& res) const;
97+
void add(const Vector &vecB, Vector &res) const;
9898

9999
Vector &operator+=(MPTime increase) {
100100
this->add(increase, *this);
@@ -109,7 +109,7 @@ class Vector {
109109

110110
[[nodiscard]] bool compare(const Vector &v) const;
111111

112-
Vector &incrementalMaximum(const Vector& vec) {
112+
Vector &incrementalMaximum(const Vector &vec) {
113113
this->maximum(vec, *this);
114114
return *this;
115115
}
@@ -149,7 +149,7 @@ class Matrix {
149149

150150
Matrix(Matrix &&) = default;
151151
Matrix &operator=(Matrix &&) = default;
152-
Matrix(const Matrix &)=default;
152+
Matrix(const Matrix &) = default;
153153

154154
Matrix &operator=(const Matrix &);
155155

@@ -175,14 +175,16 @@ class Matrix {
175175
[[nodiscard]] Matrix transpose() const;
176176

177177
[[nodiscard]] virtual Matrix getSubMatrix(const std::list<unsigned int> &rowIndices,
178-
const std::list<unsigned int> &colIndices) const;
178+
const std::list<unsigned int> &colIndices) const;
179179

180-
[[nodiscard]] virtual std::shared_ptr<Matrix> getSubMatrixPtr(const std::list<unsigned int> &rowIndices,
181-
const std::list<unsigned int> &colIndices) const;
180+
[[nodiscard]] virtual std::shared_ptr<Matrix>
181+
getSubMatrixPtr(const std::list<unsigned int> &rowIndices,
182+
const std::list<unsigned int> &colIndices) const;
182183

183184
[[nodiscard]] Matrix getSubMatrix(const std::list<unsigned int> &indices) const;
184185

185-
[[nodiscard]] virtual std::shared_ptr<Matrix> getSubMatrixPtr(const std::list<unsigned int> &indices) const;
186+
[[nodiscard]] virtual std::shared_ptr<Matrix>
187+
getSubMatrixPtr(const std::list<unsigned int> &indices) const;
186188

187189
[[nodiscard]] Matrix getSubMatrixNonSquare(const std::list<unsigned int> &indices) const;
188190

@@ -198,13 +200,13 @@ class Matrix {
198200
// Algebraic operations.
199201
[[nodiscard]] Matrix add(MPTime increase) const;
200202

201-
void add(MPTime increase, Matrix& result) const;
203+
void add(MPTime increase, Matrix &result) const;
202204

203205
[[nodiscard]] Matrix mp_sub(const Matrix &m) const;
204206

205207
[[nodiscard]] Matrix mp_maximum(const Matrix &m) const;
206208

207-
void maximum(const Matrix& matB, Matrix& result) const;
209+
void maximum(const Matrix &matB, Matrix &result) const;
208210

209211
[[nodiscard]] Vector mp_multiply(const Vector &v) const;
210212

@@ -231,9 +233,7 @@ class Matrix {
231233
return *this;
232234
}
233235

234-
void incrementalMaximum(const Matrix& matrix) {
235-
this->maximum(matrix, *this);
236-
}
236+
void incrementalMaximum(const Matrix &matrix) { this->maximum(matrix, *this); }
237237

238238
bool operator==(const Matrix &other);
239239

@@ -249,7 +249,7 @@ class Matrix {
249249
[[nodiscard]] Matrix starClosureMatrix(MPTime posCycleThreshold = MP_EPSILON) const;
250250

251251
[[nodiscard]] Matrix allPairLongestPathMatrix(MPTime posCycleThreshold,
252-
bool implyZeroSelfEdges) const;
252+
bool implyZeroSelfEdges) const;
253253
bool
254254
allPairLongestPathMatrix(MPTime posCycleThreshold, bool implyZeroSelfEdges, Matrix &res) const;
255255

@@ -259,7 +259,6 @@ class Matrix {
259259
// [[nodiscard]] virtual Matrix *makeMatrix(unsigned int nr_rows, unsigned int nr_cols) const;
260260

261261
private:
262-
263262
void init(MatrixFill fill);
264263
void init();
265264

@@ -270,7 +269,6 @@ class Matrix {
270269
unsigned int szCols;
271270
};
272271

273-
274272
/****************************************************
275273
* VectorList: usually represents a set of eigenvectors
276274
* More efficient than vector<MaxPlus::Vector>

include/maxplus/algebra/mptype.h

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ using MPDelay = MPTime;
8787
// MP_MAX()
8888
//==============================
8989

90-
inline MPTime MP_MAX(MPTime a, MPTime b) { return (static_cast<CDouble>(a)) > (static_cast<CDouble>(b)) ? (a) : (b); }
90+
inline MPTime MP_MAX(MPTime a, MPTime b) {
91+
return (static_cast<CDouble>(a)) > (static_cast<CDouble>(b)) ? (a) : (b);
92+
}
9193

9294
inline MPTime MP_MAX(CDouble a, MPTime b) { return MP_MAX(MPTime(a), b); }
9395

@@ -99,7 +101,9 @@ inline CDouble MP_MAX(CDouble a, CDouble b) { return CDouble(MP_MAX(MPTime(a), M
99101
// MP_MIN()
100102
//==============================
101103

102-
inline MPTime MP_MIN(MPTime a, MPTime b) { return (static_cast<CDouble>(a)) < (static_cast<CDouble>(b)) ? (a) : (b); }
104+
inline MPTime MP_MIN(MPTime a, MPTime b) {
105+
return (static_cast<CDouble>(a)) < (static_cast<CDouble>(b)) ? (a) : (b);
106+
}
103107

104108
inline MPTime MP_MIN(CDouble a, MPTime b) { return MP_MIN(MPTime(a), b); }
105109

@@ -119,17 +123,14 @@ inline bool MP_ISMINUSINFINITY(CDouble a) { return a <= MPTIME_MIN_INF_VALPTHR;
119123
inline bool MP_ISMINUSINFINITY(MPTime a) { return a <= MP_MINUSINFINITY_THR; }
120124

121125
inline MPTime MP_PLUS(CDouble a, CDouble b) {
122-
return (MP_ISMINUSINFINITY(a) || MP_ISMINUSINFINITY(b)) ? MP_MINUSINFINITY
123-
: MPTime(static_cast<CDouble>(a) + static_cast<CDouble>(b));
126+
return (MP_ISMINUSINFINITY(a) || MP_ISMINUSINFINITY(b))
127+
? MP_MINUSINFINITY
128+
: MPTime(static_cast<CDouble>(a) + static_cast<CDouble>(b));
124129
}
125130

126-
inline MPTime MP_PLUS(MPTime a, CDouble b) {
127-
return MP_PLUS(static_cast<CDouble>(a), b);
128-
}
131+
inline MPTime MP_PLUS(MPTime a, CDouble b) { return MP_PLUS(static_cast<CDouble>(a), b); }
129132

130-
inline MPTime MP_PLUS(CDouble a, MPTime b) {
131-
return MP_PLUS(a, static_cast<CDouble>(b));
132-
}
133+
inline MPTime MP_PLUS(CDouble a, MPTime b) { return MP_PLUS(a, static_cast<CDouble>(b)); }
133134

134135
inline MPTime MP_PLUS(MPTime a, MPTime b) {
135136
return MP_PLUS(static_cast<CDouble>(a), static_cast<CDouble>(b));
@@ -185,37 +186,21 @@ inline MPTime &MPTime::operator-=(MPTime a) {
185186
return *this;
186187
}
187188

188-
inline bool MPTime::operator==(MPTime a) const {
189-
return this->myVal == a.myVal;
190-
}
189+
inline bool MPTime::operator==(MPTime a) const { return this->myVal == a.myVal; }
191190

192-
inline bool MPTime::operator!=(MPTime a) const {
193-
return this->myVal != a.myVal;
194-
}
191+
inline bool MPTime::operator!=(MPTime a) const { return this->myVal != a.myVal; }
195192

196-
inline bool MPTime::operator<(MPTime a) const {
197-
return this->myVal < a.myVal;
198-
}
193+
inline bool MPTime::operator<(MPTime a) const { return this->myVal < a.myVal; }
199194

200-
inline bool MPTime::operator>(MPTime a) const {
201-
return this->myVal > a.myVal;
202-
}
195+
inline bool MPTime::operator>(MPTime a) const { return this->myVal > a.myVal; }
203196

204-
inline bool MPTime::operator<=(MPTime a) const {
205-
return this->myVal <= a.myVal;
206-
}
197+
inline bool MPTime::operator<=(MPTime a) const { return this->myVal <= a.myVal; }
207198

208-
inline bool MPTime::operator>=(MPTime a) const {
209-
return this->myVal >= a.myVal;
210-
}
199+
inline bool MPTime::operator>=(MPTime a) const { return this->myVal >= a.myVal; }
211200

212-
inline bool MPTime::isMinusInfinity() const {
213-
return MP_ISMINUSINFINITY(this->myVal);
214-
}
201+
inline bool MPTime::isMinusInfinity() const { return MP_ISMINUSINFINITY(this->myVal); }
215202

216-
inline MPTime MPTime::fabs() const {
217-
return MPTime(std::fabs(this->myVal));
218-
}
203+
inline MPTime MPTime::fabs() const { return MPTime(std::fabs(this->myVal)); }
219204

220205
//==============================
221206
// toString
@@ -225,7 +210,7 @@ inline CString timeToString(MPTime val) {
225210
// We intentionally dont use isMinusInfinity() here,
226211
// so that we can expose the unwanted "impure" infinities here.
227212
//
228-
if (static_cast<CDouble>(val)==MPTIME_MIN_INF_VAL) {
213+
if (static_cast<CDouble>(val) == MPTIME_MIN_INF_VAL) {
229214
return CString("-mp_inf");
230215
}
231216
return CString(static_cast<CDouble>(val));

include/maxplus/base/analysis/mcm/mcm.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ namespace Graphs {
5757
/// </summary>
5858
/// <param name="g">graph to analyse</param>
5959
/// <returns>The maximum cycle mean of the graph.</returns>
60-
CDouble maximumCycleMeanKarp(MCMgraph& g);
60+
CDouble maximumCycleMeanKarp(MCMgraph &g);
6161

6262
/// <summary>
6363
/// The function computes the maximum cycle mean of an MCMgraph using Karp's
6464
/// algorithm.
6565
/// </summary>
6666
/// <param name="g">graph to analyse</param>
67-
/// <param name="criticalNodeg">optional, will point to an arbitrary node on the cycle with the maximum cycle mean.</param>
68-
/// <returns>The maximum cycle mean of the graph and optionally a critical node.</returns>
67+
/// <param name="criticalNodeg">optional, will point to an arbitrary node on the cycle with the
68+
/// maximum cycle mean.</param> <returns>The maximum cycle mean of the graph and optionally a
69+
/// critical node.</returns>
6970
CDouble maximumCycleMeanKarpDouble(MCMgraph &g, const MCMnode **criticalNode = nullptr);
7071

7172
/// <summary>
@@ -84,18 +85,21 @@ CDouble maximumCycleMeanKarpGeneral(MCMgraph &g);
8485
/// Does not require that all nodes of the graph have an outgoing edge.
8586
/// </summary>
8687
/// <param name="g">graph to analyse</param>
87-
/// <param name="criticalNodeg">optional, will point to an arbitrary node on the cycle with the maximum cycle mean.</param>
88-
/// <returns>The maximum cycle mean of the graph and optionally a critical node.</returns>
88+
/// <param name="criticalNodeg">optional, will point to an arbitrary node on the cycle with the
89+
/// maximum cycle mean.</param> <returns>The maximum cycle mean of the graph and optionally a
90+
/// critical node.</returns>
8991
CDouble maximumCycleMeanKarpDoubleGeneral(MCMgraph &g, const MCMnode **criticalNode = nullptr);
9092

91-
9293
/**
9394
* mcmGetAdjacentActors ()
9495
* The function returns a list with actors directly reachable from
9596
* actor a.
9697
*/
97-
v_uint
98-
mcmGetAdjacentActors(uint a, const v_uint &nodeId, const v_uint &actorId, const std::vector<v_uint> &graph, uint nrNodes);
98+
v_uint mcmGetAdjacentActors(uint a,
99+
const v_uint &nodeId,
100+
const v_uint &actorId,
101+
const std::vector<v_uint> &graph,
102+
uint nrNodes);
99103

100104
} // namespace Graphs
101105
#endif

include/maxplus/base/analysis/mcm/mcmdg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace Graphs {
6060
* The function computes the maximum cycle mean of an MCM graph using
6161
* Dasdan-Gupta's algorithm.
6262
* Note: this algorithm assumes that edge weights are integer valued !
63-
*
63+
*
6464
* @todo
6565
* check if algorithm can be generalized to float edge weights
6666
*/

0 commit comments

Comments
 (0)