diff --git a/include/world_builder/point.h b/include/world_builder/point.h index 38db542cc..28e6a3a0a 100644 --- a/include/world_builder/point.h +++ b/include/world_builder/point.h @@ -92,7 +92,7 @@ namespace WorldBuilder inline double operator*(const Point &point_right) const { - const std::array array = point_right.get_array(); + const std::array& array = point_right.get_array(); double dot_product = 0; for (unsigned int i = 0; i < dim; ++i) dot_product += point[i] * array[i]; @@ -107,9 +107,9 @@ namespace WorldBuilder Point operator*(const double scalar) const { // initialize the array to zero. - std::array array = Point(coordinate_system).get_array(); + std::array array; for (unsigned int i = 0; i < dim; ++i) - array[i] += point[i] * scalar; + array[i] = point[i] * scalar; return Point(array,coordinate_system); } @@ -120,10 +120,10 @@ namespace WorldBuilder Point operator/(const double scalar) const { // initialize the array to zero. - std::array array = Point(coordinate_system).get_array(); + std::array array; const double one_over_scalar = 1/scalar; for (unsigned int i = 0; i < dim; ++i) - array[i] += point[i] * one_over_scalar; + array[i] = point[i] * one_over_scalar; return Point(array,coordinate_system); } diff --git a/source/point.cc b/source/point.cc index 4918ec7ab..a5f3c6b0a 100644 --- a/source/point.cc +++ b/source/point.cc @@ -177,7 +177,7 @@ namespace WorldBuilder operator/(const double scalar, const Point &point) { // initialize the array to zero. - std::array array = Point(point.coordinate_system).get_array(); + std::array array; for (unsigned int i = 0; i < dim; ++i) array[i] = scalar / point[i]; return Point(array,point.coordinate_system);