Skip to content

Commit 09c9efc

Browse files
committed
Reformat file to compact style for more accurate line count
1 parent 892c174 commit 09c9efc

File tree

2 files changed

+118
-28
lines changed

2 files changed

+118
-28
lines changed

Scripts/wrap_doc_box_comment.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""
2+
Locates a Visual Studio style comment block that starts at the beginning of a C++ file
3+
and wrap it around
4+
`// clang format off` and
5+
`// clang format on`
6+
"""
7+
8+
import sys
9+
from pathlib import Path
10+
11+
def wrap_top_box_comment_block(filename: str) -> None:
12+
"""
13+
Wraps a Visual Studio style comment block around the specified file.
14+
15+
Args:
16+
filename (str): File to format.
17+
"""
18+
path = Path(filename)
19+
if not path.exists():
20+
print(f"File '{filename}' does not exist.")
21+
return
22+
23+
lines = path.read_text(encoding="utf-8").splitlines()
24+
output = []
25+
26+
i = 0
27+
# Skip any leading blank lines
28+
while i < len(lines) and lines[i].strip() == "":
29+
output.append(lines[i])
30+
i += 1
31+
32+
# Check if the next line starts with /* to begin a box-style comment
33+
if i < len(lines) and lines[i].strip().startswith("/*"):
34+
output.append("// clang-format off")
35+
while i < len(lines):
36+
output.append(lines[i])
37+
if lines[i].strip().endswith("*/"):
38+
i += 1
39+
break
40+
i += 1
41+
output.append("// clang-format on")
42+
43+
# Append the rest of the file
44+
output.extend(lines[i:])
45+
46+
# Save modified content
47+
path.write_text("\n".join(output) + "\n", encoding="utf-8")
48+
print(f"Wrapped top-level box comment in '{filename}'")
49+
50+
if __name__ == "__main__":
51+
if len(sys.argv) != 2:
52+
print("Usage: python wrap_top_box_comment.py <source_file.cpp>")
53+
else:
54+
wrap_top_box_comment_block(sys.argv[1])

Util/ndarray/matrix_base_ext.hpp

Lines changed: 64 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,92 @@
1+
// clang-format off
12
/*****************************************************************//**
23
* \file matrix_base_ext.hpp
34
* \brief
45
*
56
* \author Xuhua Huang
67
* \date January 02, 2023
78
*********************************************************************/
9+
// clang-format on
810

911
#include <Eigen/Core>
1012

11-
inline Scalar at(uint i, uint j) const { return this->operator()(i, j); }
12-
inline Scalar& at(uint i, uint j) { return this->operator()(i, j); }
13-
inline Scalar at(uint i) const { return this->operator[](i); }
14-
inline Scalar& at(uint i) { return this->operator[](i); }
13+
inline Scalar at(uint i, uint j) const {
14+
return this->operator()(i, j);
15+
}
16+
inline Scalar& at(uint i, uint j) {
17+
return this->operator()(i, j);
18+
}
19+
inline Scalar at(uint i) const {
20+
return this->operator[](i);
21+
}
22+
inline Scalar& at(uint i) {
23+
return this->operator[](i);
24+
}
1525

16-
inline RealScalar squaredLength() const { return squaredNorm(); }
17-
inline RealScalar length() const { return norm(); }
18-
inline RealScalar invLength(void) const { return fast_inv_sqrt(squaredNorm()); }
26+
inline RealScalar squaredLength() const {
27+
return squaredNorm();
28+
}
29+
inline RealScalar length() const {
30+
return norm();
31+
}
32+
inline RealScalar invLength(void) const {
33+
return fast_inv_sqrt(squaredNorm());
34+
}
1935

20-
template<typename OtherDerived>
21-
inline Scalar squaredDistanceTo(const MatrixBase<OtherDerived>& other) const
22-
{
36+
template <typename OtherDerived>
37+
inline Scalar squaredDistanceTo(const MatrixBase<OtherDerived>& other) const {
2338
return (derived() - other.derived()).squaredNorm();
2439
}
2540

26-
template<typename OtherDerived>
27-
inline RealScalar distanceTo(const MatrixBase<OtherDerived>& other) const
28-
{
41+
template <typename OtherDerived>
42+
inline RealScalar distanceTo(const MatrixBase<OtherDerived>& other) const {
2943
return internal::sqrt(derived().squaredDistanceTo(other));
3044
}
3145

32-
inline void scaleTo(RealScalar l) { RealScalar vl = norm(); if (vl > 1e-9) derived() *= (l / vl); }
46+
inline void scaleTo(RealScalar l) {
47+
RealScalar vl = norm();
48+
if (vl > 1e-9)
49+
derived() *= (l / vl);
50+
}
3351

34-
inline Transpose<Derived> transposed() { return this->transpose(); }
35-
inline const Transpose<Derived> transposed() const { return this->transpose(); }
52+
inline Transpose<Derived> transposed() {
53+
return this->transpose();
54+
}
55+
inline const Transpose<Derived> transposed() const {
56+
return this->transpose();
57+
}
3658

37-
inline uint minComponentId(void) const { int i; this->minCoeff(&i); return i; }
38-
inline uint maxComponentId(void) const { int i; this->maxCoeff(&i); return i; }
59+
inline uint minComponentId(void) const {
60+
int i;
61+
this->minCoeff(&i);
62+
return i;
63+
}
64+
inline uint maxComponentId(void) const {
65+
int i;
66+
this->maxCoeff(&i);
67+
return i;
68+
}
3969

40-
template<typename OtherDerived>
41-
void makeFloor(const MatrixBase<OtherDerived>& other) { derived() = derived().cwiseMin(other.derived()); }
70+
template <typename OtherDerived>
71+
void makeFloor(const MatrixBase<OtherDerived>& other) {
72+
derived() = derived().cwiseMin(other.derived());
73+
}
4274

43-
template<typename OtherDerived>
44-
void makeCeil(const MatrixBase<OtherDerived>& other) { derived() = derived().cwiseMax(other.derived()); }
75+
template <typename OtherDerived>
76+
void makeCeil(const MatrixBase<OtherDerived>& other) {
77+
derived() = derived().cwiseMax(other.derived());
78+
}
4579

4680
const CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const Derived, const ConstantReturnType>
47-
operator+(const Scalar& scalar) const
48-
{
49-
return CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const Derived, const ConstantReturnType>(derived(), Constant(rows(), cols(), scalar));
81+
operator+(const Scalar& scalar) const {
82+
return CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const Derived, const ConstantReturnType>(
83+
derived(), Constant(rows(), cols(), scalar)
84+
);
5085
}
5186

5287
friend const CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const ConstantReturnType, Derived>
53-
operator+(const Scalar& scalar, const MatrixBase<Derived>& mat)
54-
{
55-
return CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const ConstantReturnType, Derived>(Constant(rows(), cols(), scalar), mat.derived());
88+
operator+(const Scalar& scalar, const MatrixBase<Derived>& mat) {
89+
return CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const ConstantReturnType, Derived>(
90+
Constant(rows(), cols(), scalar), mat.derived()
91+
);
5692
}

0 commit comments

Comments
 (0)