Skip to content

Commit 439ae0a

Browse files
Fix compilation error for open/short components (#26)
* Fix compilation error for open/short components * CI updates * More CI fixes * Trying to fix lcov error * More lcov errors
1 parent d67af36 commit 439ae0a

File tree

7 files changed

+118
-93
lines changed

7 files changed

+118
-93
lines changed

.github/workflows/bench.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false # show all errors for each platform (vs. cancel jobs on error)
1919
matrix:
20-
os: [ubuntu-latest, windows-2019, macos-latest]
20+
os: [ubuntu-latest, windows-2022, macos-latest]
2121

2222
steps:
2323
- name: Get latest CMake
@@ -28,7 +28,7 @@ jobs:
2828

2929
- name: Configure
3030
shell: bash
31-
run: cmake -DCMAKE_BUILD_TYPE=Release -DCHOWDSP_WDF_TEST_WITH_XSIMD_VERSION=8.0.5 -Bbuild
31+
run: cmake -DCMAKE_BUILD_TYPE=Release -DCHOWDSP_WDF_TEST_WITH_XSIMD_VERSION="13.2.0" -Bbuild
3232

3333
- name: Build
3434
shell: bash

.github/workflows/cov.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false # show all errors for each platform (vs. cancel jobs on error)
2020
matrix:
21-
xsimd_version: ["", "8.0.5"]
21+
xsimd_version: ["", "13.2.0"]
2222

2323
steps:
2424
- name: Install Linux Deps
@@ -49,8 +49,8 @@ jobs:
4949
- name: Collect Coverage Data
5050
shell: bash
5151
run: |
52-
lcov --directory . --capture --output-file coverage.info
53-
lcov --remove coverage.info '/usr/*' "${HOME}"'/.cache/*' '/Applications/Xcode*' '*tests*' --output-file coverage.info
52+
lcov --ignore-errors mismatch --directory . --capture --output-file coverage.info
53+
lcov --ignore-errors unused --remove coverage.info '/usr/*' "${HOME}"'/.cache/*' '/Applications/Xcode*' '*chowdsp_wdf/build/*' '*chowdsp_wdf/tests/*' --output-file coverage.info
5454
5555
- name: Report Coverage Data
5656
shell: bash

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717
strategy:
1818
fail-fast: false # show all errors for each platform (vs. cancel jobs on error)
1919
matrix:
20-
os: [ubuntu-latest, windows-2019, macos-latest]
21-
xsimd_version: ["", "9.0.1", "8.0.0", "8.1.0"]
20+
os: [ubuntu-latest, windows-2022, macos-latest]
21+
xsimd_version: ["", "12.1.1", "13.2.0"]
2222
include:
2323
- os: macos-latest
24-
xsimd_version: "8.0.5"
24+
xsimd_version: "13.2.0"
2525
cmake_args: "-GXcode -D\"CMAKE_OSX_ARCHITECTURES=arm64;x86_64\" -DCHOWDSP_WDF_BUILD_BENCHMARKS=OFF"
2626

2727
steps:

include/chowdsp_wdf/wdf/wdf_nonlinearities.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@ namespace wdf
3131
public:
3232
Open() : WDF<T> ("Open")
3333
{
34-
this->R = (T) 1.0e15;
35-
this->G = (T) 1.0 / this->R;
34+
this->wdf.R = (T) 1.0e15;
35+
this->wdf.G = (T) 1.0 / this->wdf.R;
3636
}
3737

3838
inline void calcImpedance() override {}
3939

4040
/** Accepts an incident wave into a WDF open. */
4141
inline void incident (T x) noexcept override
4242
{
43-
this->a = x;
43+
this->wdf.a = x;
4444
}
4545

4646
/** Propogates a reflected wave from a WDF open. */
4747
inline T reflected() noexcept override
4848
{
49-
this->b = this->a;
50-
return this->b;
49+
this->wdf.b = this->wdf.a;
50+
return this->wdf.b;
5151
}
5252
};
5353

@@ -58,23 +58,23 @@ namespace wdf
5858
public:
5959
Short() : WDF<T> ("Short")
6060
{
61-
this->R = (T) 1.0e-15;
62-
this->G = (T) 1.0 / this->R;
61+
this->wdf.R = (T) 1.0e-15;
62+
this->wdf.G = (T) 1.0 / this->wdf.R;
6363
}
6464

6565
inline void calcImpedance() override {}
6666

6767
/** Accepts an incident wave into a WDF short. */
6868
inline void incident (T x) noexcept override
6969
{
70-
this->a = x;
70+
this->wdf.a = x;
7171
}
7272

7373
/** Propogates a reflected wave from a WDF short. */
7474
inline T reflected() noexcept override
7575
{
76-
this->b = -this->a;
77-
return this->b;
76+
this->wdf.b = -this->wdf.a;
77+
return this->wdf.b;
7878
}
7979
};
8080

tests/BasicCircuitTest.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,28 @@ TEST_CASE ("Basic Circuits Test")
281281
doImpedanceChecks (
282282
ResistiveCurrentSource<float> { 1000.0f }, 1000.0f, 2000.0f, [=] (auto& r, float value) { r.setResistanceValue (value); }, [=] (float value) { return value; });
283283
}
284+
285+
SECTION ("Open Test")
286+
{
287+
ResistiveVoltageSource<float> Vin { 1.0e3f };
288+
Open<float> open {};
289+
290+
Vin.setVoltage (10.0f);
291+
open.incident (Vin.reflected());
292+
Vin.incident (open.reflected());
293+
294+
REQUIRE (open.voltage() == 10.0f);
295+
}
296+
297+
SECTION ("Short Test")
298+
{
299+
ResistiveVoltageSource<float> Vin { 1.0e3f };
300+
Short<float> sh {};
301+
302+
Vin.setVoltage (10.0f);
303+
sh.incident (Vin.reflected());
304+
Vin.incident (sh.reflected());
305+
306+
REQUIRE (sh.voltage() == 0.0f);
307+
}
284308
}

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_executable(chowdsp_wdf_tests)
22
target_include_directories(chowdsp_wdf_tests PRIVATE .)
33
target_link_libraries(chowdsp_wdf_tests PRIVATE ${PROJECT_NAME} chowdsp_wdf)
4+
target_compile_definitions(chowdsp_wdf_tests PRIVATE _USE_MATH_DEFINES=1)
45
target_sources(chowdsp_wdf_tests
56
PRIVATE
67
BasicCircuitTest.cpp

tests/CombinedComponentTest.cpp

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -6,81 +6,81 @@ using namespace chowdsp::wdft;
66

77
TEST_CASE ("Combined Component Test")
88
{
9-
// SECTION ("Resistor/Capacitor Series")
10-
// {
11-
// static constexpr auto r_val = 2000.0f;
12-
// static constexpr auto c_val = 2.0e-6f;
13-
//
14-
// ResistorT<float> r1 { r_val };
15-
// CapacitorT<float> c1 { c_val };
16-
// WDFSeriesT<float, decltype (r1), decltype (c1)> s1 { r1, c1 };
17-
//
18-
// ResistorCapacitorSeriesT<float> rc1 { r_val, c_val };
19-
//
20-
// float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
21-
// for (auto& a : inputs)
22-
// {
23-
// s1.incident (a);
24-
// const auto ref = s1.reflected();
25-
//
26-
// rc1.incident (a);
27-
// const auto actual = rc1.reflected();
28-
//
29-
// REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
30-
// }
31-
// }
32-
//
33-
// SECTION ("Resistor/Capacitor Parallel")
34-
// {
35-
// static constexpr auto r_val = 2000.0f;
36-
// static constexpr auto c_val = 2.0e-6f;
37-
//
38-
// ResistorT<float> r1 { r_val };
39-
// CapacitorT<float> c1 { c_val };
40-
// WDFParallelT<float, decltype (r1), decltype (c1)> p1 { r1, c1 };
41-
//
42-
// ResistorCapacitorParallelT<float> rc1 { r_val, c_val };
43-
//
44-
// float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
45-
// for (auto& a : inputs)
46-
// {
47-
// p1.incident (a);
48-
// const auto ref = p1.reflected();
49-
//
50-
// rc1.incident (a);
51-
// const auto actual = rc1.reflected();
52-
//
53-
// REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
54-
// }
55-
// }
56-
//
57-
// SECTION ("Resistor/Capacitor/Voltage Source Series")
58-
// {
59-
// static constexpr auto r_val = 2000.0f;
60-
// static constexpr auto c_val = 2.0e-6f;
61-
// static constexpr auto source_v = 1.5f;
62-
//
63-
// ResistiveVoltageSourceT<float> rv1 { r_val };
64-
// rv1.setVoltage (source_v);
65-
// CapacitorT<float> c1 { c_val };
66-
// WDFSeriesT<float, decltype (rv1), decltype (c1)> s1 { rv1, c1 };
67-
//
68-
// ResistiveCapacitiveVoltageSourceT<float> rc1 { r_val, c_val };
69-
// rc1.setVoltage (source_v);
70-
// rc1.reset();
71-
//
72-
// float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
73-
// for (auto& a : inputs)
74-
// {
75-
// s1.incident (a);
76-
// const auto ref = s1.reflected();
77-
//
78-
// rc1.incident (a);
79-
// const auto actual = rc1.reflected();
80-
//
81-
// REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
82-
// }
83-
// }
9+
SECTION ("Resistor/Capacitor Series")
10+
{
11+
static constexpr auto r_val = 2000.0f;
12+
static constexpr auto c_val = 2.0e-6f;
13+
14+
ResistorT<float> r1 { r_val };
15+
CapacitorT<float> c1 { c_val };
16+
WDFSeriesT<float, decltype (r1), decltype (c1)> s1 { r1, c1 };
17+
18+
ResistorCapacitorSeriesT<float> rc1 { r_val, c_val };
19+
20+
float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
21+
for (auto& a : inputs)
22+
{
23+
s1.incident (a);
24+
const auto ref = s1.reflected();
25+
26+
rc1.incident (a);
27+
const auto actual = rc1.reflected();
28+
29+
REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
30+
}
31+
}
32+
33+
SECTION ("Resistor/Capacitor Parallel")
34+
{
35+
static constexpr auto r_val = 2000.0f;
36+
static constexpr auto c_val = 2.0e-6f;
37+
38+
ResistorT<float> r1 { r_val };
39+
CapacitorT<float> c1 { c_val };
40+
WDFParallelT<float, decltype (r1), decltype (c1)> p1 { r1, c1 };
41+
42+
ResistorCapacitorParallelT<float> rc1 { r_val, c_val };
43+
44+
float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
45+
for (auto& a : inputs)
46+
{
47+
p1.incident (a);
48+
const auto ref = p1.reflected();
49+
50+
rc1.incident (a);
51+
const auto actual = rc1.reflected();
52+
53+
REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
54+
}
55+
}
56+
57+
SECTION ("Resistor/Capacitor/Voltage Source Series")
58+
{
59+
static constexpr auto r_val = 2000.0f;
60+
static constexpr auto c_val = 2.0e-6f;
61+
static constexpr auto source_v = 1.5f;
62+
63+
ResistiveVoltageSourceT<float> rv1 { r_val };
64+
rv1.setVoltage (source_v);
65+
CapacitorT<float> c1 { c_val };
66+
WDFSeriesT<float, decltype (rv1), decltype (c1)> s1 { rv1, c1 };
67+
68+
ResistiveCapacitiveVoltageSourceT<float> rc1 { r_val, c_val };
69+
rc1.setVoltage (source_v);
70+
rc1.reset();
71+
72+
float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
73+
for (auto& a : inputs)
74+
{
75+
s1.incident (a);
76+
const auto ref = s1.reflected();
77+
78+
rc1.incident (a);
79+
const auto actual = rc1.reflected();
80+
81+
REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
82+
}
83+
}
8484

8585
SECTION ("Capacitive Voltage Source")
8686
{

0 commit comments

Comments
 (0)