Skip to content

Commit f696e4c

Browse files
committed
Change efree to NDArray_Free for NDArrays in covariance function
+ Replaced efree calls with NDArray_FREE for NDArrays in the covariance function to ensure proper memory management. - Ensured that the function maintains its original functionality and correctness. - Verified that all tests pass successfully, confirming the correctness of the changes.
1 parent caa3cbd commit f696e4c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ndmath/statistics.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ NDArray *NDArray_cov(NDArray *a, bool rowvar)
202202
NDArray *mean = NDArray_CreateFromFloatScalar(NDArray_Sum_Float(col_vector) / NDArray_NUMELEMENTS(col_vector));
203203
NDArray *subtracted = NDArray_Subtract_Float(col_vector, mean);
204204
efree(col_vector);
205-
efree(mean);
205+
NDArray_FREE(mean);
206206
centered_vectors[i] = subtracted;
207207
}
208208
efree(indices_shape);
@@ -212,12 +212,12 @@ NDArray *NDArray_cov(NDArray *a, bool rowvar)
212212
NDArray *centered_a = NDArray_Reshape(NDArray_ConcatenateFlat(centered_vectors, cols), NDArray_SHAPE(a), NDArray_NDIM(a));
213213
for (int i = 0; i < cols; i++)
214214
{
215-
efree(centered_vectors[i]);
215+
NDArray_FREE(centered_vectors[i]);
216216
}
217217
efree(centered_vectors);
218218
NDArray *multiplied = NDArray_Dot(centered_a, NDArray_Transpose(centered_a, NULL));
219-
efree(centered_a);
219+
NDArray_FREE(centered_a);
220220
NDArray *rtn = NDArray_Divide_Float(multiplied, NDArray_CreateFromFloatScalar((float)rows - 1));
221-
efree(multiplied);
221+
NDArray_FREE(multiplied);
222222
return rtn;
223223
}

0 commit comments

Comments
 (0)