Skip to content

Commit eaadd5e

Browse files
author
Raghuveer Devulapalli
committed
MInor corrections
1 parent 905d6e4 commit eaadd5e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ computes the `key` value for each object which is the metric used to sort the
2020
objects. `Func` needs to have the following signature:
2121
2222
```cpp
23-
[] (T obj) -> type_t { type_t key; /* compute key for obj */ return key; }
23+
[] (T obj) -> key_t { key_t key; /* compute key for obj */ return key; }
2424
```
2525

26-
Note that the return type of the key `type_t` needs to be one of the following
26+
Note that the return type of the key `key_t` needs to be one of the following
2727
: `[float, uint32_t, int32_t, double, uint64_t, int64_t]`. `object_qsort` has a
2828
space complexity of `O(N)`. Specifically, it requires `arrsize *
29-
sizeof(type_t)` bytes to store a vector with all the keys and an additional
29+
sizeof(key_t)` bytes to store a vector with all the keys and an additional
3030
`arrsize * sizeof(uint32_t)` bytes to store the indexes of the object array.
3131
For performance reasons, we support `object_qsort` only when the array size is
3232
less than or equal to `UINT32_MAX`. An example usage of `object_qsort` is
@@ -148,14 +148,14 @@ of the custom class and we highly recommend benchmarking before using it. For
148148
the sake of illustration, we provide a few examples in
149149
[./benchmarks/bench-objsort.hpp](./benchmarks/bench-objsort.hpp) which measures
150150
performance of `object_qsort` relative to `std::sort` when sorting an array of
151-
points in the cartesian coordinates represented by the class: `struct Point
152-
{double x, y, z;}` and `struct Point {float x, y, x;}`. We sort these points
153-
based on several different metrics:
151+
3D points represented by the class: `struct Point {double x, y, z;}` and
152+
`struct Point {float x, y, x;}`. We sort these points based on several
153+
different metrics:
154154
155155
+ sort by coordinate `x`
156156
+ sort by manhanttan distance (relative to origin): `abs(x) + abx(y) + abs(z)`
157157
+ sort by Euclidean distance (relative to origin): `sqrt(x*x + y*y + z*z)`
158-
+ sort by Chebyshev distance (relative to origin): `max(x, y, z)`
158+
+ sort by Chebyshev distance (relative to origin): `max(abs(x), abs(y), abs(z))`
159159
160160
The performance data (shown in the plot below) can be collected by building the
161161
benchmarks suite and running `./builddir/benchexe --benchmark_filter==*obj*`.

benchmarks/bench-objsort.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct Point3D {
2929
return std::abs(x) + std::abs(y) + std::abs(z);
3030
}
3131
else if constexpr (name == "chebyshev") {
32-
return std::max(std::max(x, y), z);
32+
return std::max(std::max(std::abs(x), std::abs(y)), std::abs(z));
3333
}
3434
}
3535
};

0 commit comments

Comments
 (0)