Similar to the prior commit, when the `std::unique_ptr` usage was added here in
176c8a163a951a2b801956ed4a00da05603e3a06, I was incorrectly too focused on
preserving the previous property of this being a heap-allocated array. This is
not necessary, and using a `std::vector` instead allows more flexibility. E.g.
depending on the `std::vector` implementation, it could choose to allocate this
array on the stack instead of the heap.
#include <getopt.h>
#include <iomanip>
#include <iostream>
-#include <memory>
#include <sstream>
#include <vector>
ia = A->ia; ja = A->ja;
nz = A->nz;
- std::unique_ptr<double[]> xx(new double[nz * 4]);
+ std::vector<double> xx(nz * 4);
nz = 0;
dim = 4;
for (i = 0; i < A->m; i++){
if (Verbose)
std::cerr << "n = " << A->m << " nz = " << nz << '\n';
- B = nearest_neighbor_graph(nz, MIN(opts->nneighbors, nz), xx.get(), eps);
+ B = nearest_neighbor_graph(nz, MIN(opts->nneighbors, nz), xx.data(), eps);
SparseMatrix_delete(A);
A = B;
free(x);
- x = xx.get();
+ x = xx.data();
dim = 2;