Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false # show all errors for each platform (vs. cancel jobs on error)
matrix:
os: [ubuntu-latest, windows-2019, macos-latest]
os: [ubuntu-latest, windows-2022, macos-latest]

steps:
- name: Get latest CMake
Expand All @@ -28,7 +28,7 @@ jobs:

- name: Configure
shell: bash
run: cmake -DCMAKE_BUILD_TYPE=Release -DCHOWDSP_WDF_TEST_WITH_XSIMD_VERSION=8.0.5 -Bbuild
run: cmake -DCMAKE_BUILD_TYPE=Release -DCHOWDSP_WDF_TEST_WITH_XSIMD_VERSION="13.2.0" -Bbuild

- name: Build
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false # show all errors for each platform (vs. cancel jobs on error)
matrix:
xsimd_version: ["", "8.0.5"]
xsimd_version: ["", "13.2.0"]

steps:
- name: Install Linux Deps
Expand Down Expand Up @@ -49,8 +49,8 @@ jobs:
- name: Collect Coverage Data
shell: bash
run: |
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' "${HOME}"'/.cache/*' '/Applications/Xcode*' '*tests*' --output-file coverage.info
lcov --ignore-errors mismatch --directory . --capture --output-file coverage.info
lcov --ignore-errors unused --remove coverage.info '/usr/*' "${HOME}"'/.cache/*' '/Applications/Xcode*' '*chowdsp_wdf/build/*' '*chowdsp_wdf/tests/*' --output-file coverage.info

- name: Report Coverage Data
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
strategy:
fail-fast: false # show all errors for each platform (vs. cancel jobs on error)
matrix:
os: [ubuntu-latest, windows-2019, macos-latest]
xsimd_version: ["", "9.0.1", "8.0.0", "8.1.0"]
os: [ubuntu-latest, windows-2022, macos-latest]
xsimd_version: ["", "12.1.1", "13.2.0"]
include:
- os: macos-latest
xsimd_version: "8.0.5"
xsimd_version: "13.2.0"
cmake_args: "-GXcode -D\"CMAKE_OSX_ARCHITECTURES=arm64;x86_64\" -DCHOWDSP_WDF_BUILD_BENCHMARKS=OFF"

steps:
Expand Down
20 changes: 10 additions & 10 deletions include/chowdsp_wdf/wdf/wdf_nonlinearities.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ namespace wdf
public:
Open() : WDF<T> ("Open")
{
this->R = (T) 1.0e15;
this->G = (T) 1.0 / this->R;
this->wdf.R = (T) 1.0e15;
this->wdf.G = (T) 1.0 / this->wdf.R;
}

inline void calcImpedance() override {}

/** Accepts an incident wave into a WDF open. */
inline void incident (T x) noexcept override
{
this->a = x;
this->wdf.a = x;
}

/** Propogates a reflected wave from a WDF open. */
inline T reflected() noexcept override
{
this->b = this->a;
return this->b;
this->wdf.b = this->wdf.a;
return this->wdf.b;
}
};

Expand All @@ -58,23 +58,23 @@ namespace wdf
public:
Short() : WDF<T> ("Short")
{
this->R = (T) 1.0e-15;
this->G = (T) 1.0 / this->R;
this->wdf.R = (T) 1.0e-15;
this->wdf.G = (T) 1.0 / this->wdf.R;
}

inline void calcImpedance() override {}

/** Accepts an incident wave into a WDF short. */
inline void incident (T x) noexcept override
{
this->a = x;
this->wdf.a = x;
}

/** Propogates a reflected wave from a WDF short. */
inline T reflected() noexcept override
{
this->b = -this->a;
return this->b;
this->wdf.b = -this->wdf.a;
return this->wdf.b;
}
};

Expand Down
24 changes: 24 additions & 0 deletions tests/BasicCircuitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,28 @@ TEST_CASE ("Basic Circuits Test")
doImpedanceChecks (
ResistiveCurrentSource<float> { 1000.0f }, 1000.0f, 2000.0f, [=] (auto& r, float value) { r.setResistanceValue (value); }, [=] (float value) { return value; });
}

SECTION ("Open Test")
{
ResistiveVoltageSource<float> Vin { 1.0e3f };
Open<float> open {};

Vin.setVoltage (10.0f);
open.incident (Vin.reflected());
Vin.incident (open.reflected());

REQUIRE (open.voltage() == 10.0f);
}

SECTION ("Short Test")
{
ResistiveVoltageSource<float> Vin { 1.0e3f };
Short<float> sh {};

Vin.setVoltage (10.0f);
sh.incident (Vin.reflected());
Vin.incident (sh.reflected());

REQUIRE (sh.voltage() == 0.0f);
}
}
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
add_executable(chowdsp_wdf_tests)
target_include_directories(chowdsp_wdf_tests PRIVATE .)
target_link_libraries(chowdsp_wdf_tests PRIVATE ${PROJECT_NAME} chowdsp_wdf)
target_compile_definitions(chowdsp_wdf_tests PRIVATE _USE_MATH_DEFINES=1)
target_sources(chowdsp_wdf_tests
PRIVATE
BasicCircuitTest.cpp
Expand Down
150 changes: 75 additions & 75 deletions tests/CombinedComponentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,81 +6,81 @@ using namespace chowdsp::wdft;

TEST_CASE ("Combined Component Test")
{
// SECTION ("Resistor/Capacitor Series")
// {
// static constexpr auto r_val = 2000.0f;
// static constexpr auto c_val = 2.0e-6f;
//
// ResistorT<float> r1 { r_val };
// CapacitorT<float> c1 { c_val };
// WDFSeriesT<float, decltype (r1), decltype (c1)> s1 { r1, c1 };
//
// ResistorCapacitorSeriesT<float> rc1 { r_val, c_val };
//
// float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
// for (auto& a : inputs)
// {
// s1.incident (a);
// const auto ref = s1.reflected();
//
// rc1.incident (a);
// const auto actual = rc1.reflected();
//
// REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
// }
// }
//
// SECTION ("Resistor/Capacitor Parallel")
// {
// static constexpr auto r_val = 2000.0f;
// static constexpr auto c_val = 2.0e-6f;
//
// ResistorT<float> r1 { r_val };
// CapacitorT<float> c1 { c_val };
// WDFParallelT<float, decltype (r1), decltype (c1)> p1 { r1, c1 };
//
// ResistorCapacitorParallelT<float> rc1 { r_val, c_val };
//
// float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
// for (auto& a : inputs)
// {
// p1.incident (a);
// const auto ref = p1.reflected();
//
// rc1.incident (a);
// const auto actual = rc1.reflected();
//
// REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
// }
// }
//
// SECTION ("Resistor/Capacitor/Voltage Source Series")
// {
// static constexpr auto r_val = 2000.0f;
// static constexpr auto c_val = 2.0e-6f;
// static constexpr auto source_v = 1.5f;
//
// ResistiveVoltageSourceT<float> rv1 { r_val };
// rv1.setVoltage (source_v);
// CapacitorT<float> c1 { c_val };
// WDFSeriesT<float, decltype (rv1), decltype (c1)> s1 { rv1, c1 };
//
// ResistiveCapacitiveVoltageSourceT<float> rc1 { r_val, c_val };
// rc1.setVoltage (source_v);
// rc1.reset();
//
// float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
// for (auto& a : inputs)
// {
// s1.incident (a);
// const auto ref = s1.reflected();
//
// rc1.incident (a);
// const auto actual = rc1.reflected();
//
// REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
// }
// }
SECTION ("Resistor/Capacitor Series")
{
static constexpr auto r_val = 2000.0f;
static constexpr auto c_val = 2.0e-6f;

ResistorT<float> r1 { r_val };
CapacitorT<float> c1 { c_val };
WDFSeriesT<float, decltype (r1), decltype (c1)> s1 { r1, c1 };

ResistorCapacitorSeriesT<float> rc1 { r_val, c_val };

float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
for (auto& a : inputs)
{
s1.incident (a);
const auto ref = s1.reflected();

rc1.incident (a);
const auto actual = rc1.reflected();

REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
}
}

SECTION ("Resistor/Capacitor Parallel")
{
static constexpr auto r_val = 2000.0f;
static constexpr auto c_val = 2.0e-6f;

ResistorT<float> r1 { r_val };
CapacitorT<float> c1 { c_val };
WDFParallelT<float, decltype (r1), decltype (c1)> p1 { r1, c1 };

ResistorCapacitorParallelT<float> rc1 { r_val, c_val };

float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
for (auto& a : inputs)
{
p1.incident (a);
const auto ref = p1.reflected();

rc1.incident (a);
const auto actual = rc1.reflected();

REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
}
}

SECTION ("Resistor/Capacitor/Voltage Source Series")
{
static constexpr auto r_val = 2000.0f;
static constexpr auto c_val = 2.0e-6f;
static constexpr auto source_v = 1.5f;

ResistiveVoltageSourceT<float> rv1 { r_val };
rv1.setVoltage (source_v);
CapacitorT<float> c1 { c_val };
WDFSeriesT<float, decltype (rv1), decltype (c1)> s1 { rv1, c1 };

ResistiveCapacitiveVoltageSourceT<float> rc1 { r_val, c_val };
rc1.setVoltage (source_v);
rc1.reset();

float inputs[] = { 0.0f, 1.0f, -1.0f, 2.0f, -3.0f };
for (auto& a : inputs)
{
s1.incident (a);
const auto ref = s1.reflected();

rc1.incident (a);
const auto actual = rc1.reflected();

REQUIRE (ref == Approx { actual }.margin (1.0e-4f));
}
}

SECTION ("Capacitive Voltage Source")
{
Expand Down