From d9645dd4a21196b3765dc9f4cd9ce1085c169204 Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 20 Sep 2024 00:37:46 -0400 Subject: [PATCH] crosstalk --- CMakeLists.txt | 2 +- lib/blt | 2 +- src/main.cpp | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a33208..4cf2dc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-1 VERSION 0.0.4) +project(COSC-4P80-Assignment-1 VERSION 0.0.5) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/lib/blt b/lib/blt index 6646db8..39fd5a7 160000 --- a/lib/blt +++ b/lib/blt @@ -1 +1 @@ -Subproject commit 6646db82493af081db49f7e4dec362256b34c9ae +Subproject commit 39fd5a73d67d2e911746ffe1cb0ed6d297a4d86e diff --git a/src/main.cpp b/src/main.cpp index 59beac4..9ef7991 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,12 +18,13 @@ void test_math() BLT_ASSERT(w_matrix == expected && "MATH FAILURE"); } +constexpr blt::u32 num_values = 4; constexpr blt::u32 input_count = 5; constexpr blt::u32 output_count = 4; using input_t = blt::generalized_matrix; using output_t = blt::generalized_matrix; -using crosstalk_t = blt::generalized_matrix; +using crosstalk_t = blt::generalized_matrix; float crosstalk(const input_t& i, const input_t& j) { @@ -103,9 +104,20 @@ void part_a() void part_b() { blt::log_box_t box(BLT_INFO_STREAM, "Part B", 8); - for (blt::u32 i = 0; i < output_count; i++) + for (blt::u32 i = 0; i < num_values; i++) { - + blt::generalized_matrix accum; + for (blt::u32 k = 0; k < num_values; k++) + { + if (i == k) + continue; + accum += (outputs[k] * crosstalk(inputs[k].normalize(), inputs[i].normalize())); + } + crosstalk_values.assign_to_column_from_column_rows(accum, i); + } + for (blt::u32 i = 0; i < num_values; i++) + { + BLT_INFO_STREAM << crosstalk_values[i] << " Mag: " << crosstalk_values[i].magnitude() << "\n"; } }