diff --git a/CMakeLists.txt b/CMakeLists.txt index 84802c0..5c94a9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(COSC-4P80-Assignment-3 VERSION 0.0.4) +project(COSC-4P80-Assignment-3 VERSION 0.0.5) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/include/assign3/neuron.h b/include/assign3/neuron.h index 6d48ecf..c14db39 100644 --- a/include/assign3/neuron.h +++ b/include/assign3/neuron.h @@ -38,7 +38,7 @@ namespace assign3 neuron_t& update(const std::vector& new_data, const topology_function_t* basis_func, Scalar eta, Scalar r); - static Scalar distance(const neuron_t& n1, const neuron_t& n2); + static Scalar distance(const neuron_t& n1, const neuron_t& n2, Scalar time_ratio); [[nodiscard]] inline const std::vector& get_data() const { return data; } diff --git a/src/neuron.cpp b/src/neuron.cpp index 3f0fb37..9de8933 100644 --- a/src/neuron.cpp +++ b/src/neuron.cpp @@ -51,10 +51,10 @@ namespace assign3 return std::sqrt(dist); } - Scalar neuron_t::distance(const neuron_t& n1, const neuron_t& n2) + Scalar neuron_t::distance(const neuron_t& n1, const neuron_t& n2, Scalar time_ratio) { - auto dx = n1.x_pos - n2.x_pos; - auto dy = n1.y_pos - n2.y_pos; - return std::sqrt(dx * dx + dy * dy); + auto dist = n1.dist(n2.data); + auto dist_sq = dist * dist; + return std::exp(-time_ratio * dist_sq); } } \ No newline at end of file