From 31722bffc82f2a645a7350158ee5b5a307daeba2 Mon Sep 17 00:00:00 2001 From: Andru Liu <90433630+WallabyLester@users.noreply.github.com> Date: Tue, 8 Oct 2024 20:53:20 -0700 Subject: [PATCH] Implemented destructor. --- CPP_Implementation/rbf_model.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CPP_Implementation/rbf_model.cpp b/CPP_Implementation/rbf_model.cpp index 50b4427..04d0549 100644 --- a/CPP_Implementation/rbf_model.cpp +++ b/CPP_Implementation/rbf_model.cpp @@ -29,3 +29,15 @@ RBFModel::RBFModel(int numCenters, int inputDim, double sigma, bool randomCenter weights[i] = 0.0; // Initialize weights to zero } } + +/** + * @brief Destructor to free allocated memory. + */ +RBFModel::~RBFModel() { + for (int i = 0; i < numCenters; ++i) { + delete[] centers[i]; // Free memory for each center inside centers + } + delete[] centers; // Free memory for centers + delete[] weights; // Free memory for weights +} +