Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update format file and add format check #18

Merged
merged 7 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 103 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,10 +1,109 @@
---
BasedOnStyle: Mozilla
AccessModifierOffset: '-4'

---
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
IndentWidth: '4'
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
#BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true

# Taken from git's rules
PenaltyBreakAssignment: 10
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 10
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 60

PointerAlignment: Right
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatementsExceptControlMacros
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++20
TabWidth: 4
#UseTab: Always
...
9 changes: 9 additions & 0 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install clang format
run: |
sudo apt-get update
sudo apt-get install clang-format

- name: Check format
run: |
find ./ -type f \( -iname \*.h -o -iname \*.cpp \) | xargs clang-format --dry-run -Werror

- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
Expand Down
7 changes: 1 addition & 6 deletions include/sdsp/FilterType.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,5 @@

namespace sdsp
{
enum class FilterType {
None = 0,
LowPass = 1,
HighPass = 2,
BandPass = 3
};
enum class FilterType { None = 0, LowPass = 1, HighPass = 2, BandPass = 3 };
}
86 changes: 42 additions & 44 deletions include/sdsp/casc2orderIIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include <array>
#include <cmath>

namespace sdsp {
template<size_t M>
class casc2orderIIR
namespace sdsp
{
template <size_t M>
class casc2orderIIR {
private:
int pos{ 0 };

Expand All @@ -18,9 +18,12 @@ class casc2orderIIR
FilterType fType{ FilterType::None };

public:
casc2orderIIR() { static_assert(M % 2 == 0, "M must be even!"); }
casc2orderIIR()
{
static_assert(M % 2 == 0, "M must be even!");
}

template<typename Iter>
template <typename Iter>
void Process(Iter begin, Iter end)
{
constexpr int order{ 2 };
Expand Down Expand Up @@ -51,10 +54,8 @@ class casc2orderIIR
for (j = 0; j < M; j++) {
y.at(j + 1).at(p) = y.at(j).at(p) * b.at(j).at(0);

y.at(j + 1).at(p) += y.at(j).at(d1) * b.at(j).at(j1) -
y.at(j + 1).at(d1) * a.at(j).at(j1);
y.at(j + 1).at(p) += y.at(j).at(d2) * b.at(j).at(j2) -
y.at(j + 1).at(d2) * a.at(j).at(j2);
y.at(j + 1).at(p) += y.at(j).at(d1) * b.at(j).at(j1) - y.at(j + 1).at(d1) * a.at(j).at(j1);
y.at(j + 1).at(p) += y.at(j).at(d2) * b.at(j).at(j2) - y.at(j + 1).at(d2) * a.at(j).at(j2);
}

*begin = y.at(j).at(p);
Expand Down Expand Up @@ -191,9 +192,8 @@ class casc2orderIIR
}
};

template<size_t M>
class casc_2o_IIR
{
template <size_t M>
class casc_2o_IIR {
protected:
int pos{ 0 };

Expand All @@ -203,7 +203,7 @@ class casc_2o_IIR

std::array<std::array<double, 3>, M> aCoeff{ 0 };

template<typename T, typename Iter>
template <typename T, typename Iter>
void process_base(Iter begin, Iter end)
{
constexpr int order{ 2 };
Expand Down Expand Up @@ -241,29 +241,28 @@ class casc_2o_IIR
}
};

template<size_t M>
class casc_2o_IIR_lp : casc_2o_IIR<M>
{
template <size_t M>
class casc_2o_IIR_lp : casc_2o_IIR<M> {
public:
casc_2o_IIR_lp() { static_assert(M % 2 == 0, "M must be even!"); }
casc_2o_IIR_lp()
{
static_assert(M % 2 == 0, "M must be even!");
}

template<typename Iter>
template <typename Iter>
void process(Iter begin, Iter end)
{
this->template process_base<casc_2o_IIR_lp<M>>(begin, end);
}

static void process_spec(std::array<std::array<double, 3>, M + 1>& y,
const std::array<std::array<double, 3>, M>& a,
static void process_spec(std::array<std::array<double, 3>, M + 1> &y, const std::array<std::array<double, 3>, M> &a,
int p, int d1, int d2)
{
for (uint j = 0; j < M; j++) {
y.at(j + 1).at(p) = y.at(j).at(p);

y.at(j + 1).at(p) += y.at(j).at(d1) + y.at(j).at(d1) -
y.at(j + 1).at(d1) * a.at(j).at(1);
y.at(j + 1).at(p) +=
y.at(j).at(d2) - y.at(j + 1).at(d2) * a.at(j).at(2);
y.at(j + 1).at(p) += y.at(j).at(d1) + y.at(j).at(d1) - y.at(j + 1).at(d1) * a.at(j).at(1);
y.at(j + 1).at(p) += y.at(j).at(d2) - y.at(j + 1).at(d2) * a.at(j).at(2);
}
}

Expand Down Expand Up @@ -294,29 +293,28 @@ class casc_2o_IIR_lp : casc_2o_IIR<M>
}
};

template<size_t M>
class casc_2o_IIR_hp : casc_2o_IIR<M>
{
template <size_t M>
class casc_2o_IIR_hp : casc_2o_IIR<M> {
public:
casc_2o_IIR_hp() { static_assert(M % 2 == 0, "M must be even!"); }
casc_2o_IIR_hp()
{
static_assert(M % 2 == 0, "M must be even!");
}

template<typename Iter>
template <typename Iter>
void process(Iter begin, Iter end)
{
this->template process_base<casc_2o_IIR_hp<M>>(begin, end);
}

static void process_spec(std::array<std::array<double, 3>, M + 1>& y,
const std::array<std::array<double, 3>, M>& a,
static void process_spec(std::array<std::array<double, 3>, M + 1> &y, const std::array<std::array<double, 3>, M> &a,
int p, int d1, int d2)
{
for (uint j = 0; j < M; j++) {
y.at(j + 1).at(p) = y.at(j).at(p);

y.at(j + 1).at(p) += -y.at(j).at(d1) - y.at(j).at(d1) -
y.at(j + 1).at(d1) * a.at(j).at(1);
y.at(j + 1).at(p) +=
y.at(j).at(d2) - y.at(j + 1).at(d2) * a.at(j).at(2);
y.at(j + 1).at(p) += -y.at(j).at(d1) - y.at(j).at(d1) - y.at(j + 1).at(d1) * a.at(j).at(1);
y.at(j + 1).at(p) += y.at(j).at(d2) - y.at(j + 1).at(d2) * a.at(j).at(2);
}
}

Expand Down Expand Up @@ -347,28 +345,28 @@ class casc_2o_IIR_hp : casc_2o_IIR<M>
}
};

template<size_t M>
class casc_2o_IIR_bp : casc_2o_IIR<M>
{
template <size_t M>
class casc_2o_IIR_bp : casc_2o_IIR<M> {
public:
casc_2o_IIR_bp() { static_assert(M % 2 == 0, "M must be even!"); }
casc_2o_IIR_bp()
{
static_assert(M % 2 == 0, "M must be even!");
}

template<typename Iter>
template <typename Iter>
void process(Iter begin, Iter end)
{
this->template process_base<casc_2o_IIR_bp<M>>(begin, end);
}

static void process_spec(std::array<std::array<double, 3>, M + 1>& y,
const std::array<std::array<double, 3>, M>& a,
static void process_spec(std::array<std::array<double, 3>, M + 1> &y, const std::array<std::array<double, 3>, M> &a,
int p, int d1, int d2)
{
for (uint j = 0; j < M; j++) {
y.at(j + 1).at(p) = y.at(j).at(p);

y.at(j + 1).at(p) += -y.at(j + 1).at(d1) * a.at(j).at(1);
y.at(j + 1).at(p) +=
-y.at(j).at(d2) - y.at(j + 1).at(d2) * a.at(j).at(2);
y.at(j + 1).at(p) += -y.at(j).at(d2) - y.at(j + 1).at(d2) * a.at(j).at(2);
}
}

Expand Down
Loading
Loading