main
Brett 2024-11-04 20:08:43 -05:00
parent a734102cbf
commit bfbf015b3d
3 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25) 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_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)

View File

@ -38,7 +38,7 @@ namespace assign3
neuron_t& update(const std::vector<Scalar>& new_data, const topology_function_t* basis_func, Scalar eta, Scalar r); neuron_t& update(const std::vector<Scalar>& 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<Scalar>& get_data() const [[nodiscard]] inline const std::vector<Scalar>& get_data() const
{ return data; } { return data; }

View File

@ -51,10 +51,10 @@ namespace assign3
return std::sqrt(dist); 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 dist = n1.dist(n2.data);
auto dy = n1.y_pos - n2.y_pos; auto dist_sq = dist * dist;
return std::sqrt(dx * dx + dy * dy); return std::exp(-time_ratio * dist_sq);
} }
} }