 
     cudaFree(d_points);
     cudaFree(d_result);
-    cudaFree(d_reduce);
 
     cudaFree(d_f);
     free(h_f);

#include "kernels.h"

typedef double (*func)(double n, double m);

__global__ void reduce(const Point3D * const d_points, const uint number, Point3D *d_result, func* f, Point3D *d_reduce) {

    const int idx = threadIdx.x;

    d_reduce[idx] = d_points[idx];  // use this copy (to shared memory) for padding with identity element
    d_reduce[idx] = d_points[idx];

    __syncthreads();

    for (unsigned int s = number / 2; s > 0; s >>= 1)
    {
        if (idx < s)
        {

}
__device__ func max_func = max_d;

double max_identity_element = - DBL_MAX;

Point3D reduce_max(PointCloud<Point3D> &cloud) {
    return reduce(cloud, max_func, max_identity_element);
}


__device__ double min_d(double n, double m) {
    return (m < n) ? m : n;
}
__device__ func min_func = min_d;

double min_identity_element = DBL_MAX;

Point3D reduce_min(PointCloud<Point3D> &cloud) {
    return reduce(cloud, min_func, min_identity_element);
}