Skip to content
Snippets Groups Projects
Commit 8c00741d authored by Benjamin Cumming's avatar Benjamin Cumming
Browse files

coding style fixes

parent c8098d65
No related branches found
Tags 2.3.10
No related merge requests found
...@@ -14,77 +14,58 @@ struct point { ...@@ -14,77 +14,58 @@ struct point {
value_type y; value_type y;
value_type z; value_type z;
constexpr point(T a, T b, T c) constexpr point(T a, T b, T c) :
: x{a}, y{b}, z{c} x{a}, y{b}, z{c}
{} {}
// initialize to NaN by default // initialize to NaN by default
constexpr point() constexpr point() :
: x(std::numeric_limits<T>::quiet_NaN()), x(std::numeric_limits<T>::quiet_NaN()),
y(std::numeric_limits<T>::quiet_NaN()), y(std::numeric_limits<T>::quiet_NaN()),
z(std::numeric_limits<T>::quiet_NaN()) z(std::numeric_limits<T>::quiet_NaN())
{} {}
constexpr bool is_set() const constexpr bool is_set() const {
{
return (x==x && y==y && z==z); return (x==x && y==y && z==z);
} }
}; };
template <typename T> template <typename T>
constexpr point<T> constexpr point<T>
operator+ ( operator+( point<T> const& lhs, point<T> const& rhs) {
point<T> const& lhs,
point<T> const& rhs
) {
return point<T>(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); return point<T>(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z);
} }
template <typename T> template <typename T>
constexpr point<T> constexpr point<T>
operator- ( operator-(point<T> const& lhs, point<T> const& rhs) {
point<T> const& lhs,
point<T> const& rhs
) {
return point<T>(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); return point<T>(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z);
} }
template <typename T> template <typename T>
constexpr point<T> constexpr point<T>
operator* ( operator*(T alpha, point<T> const& p) {
T alpha,
point<T> const& p
) {
return point<T>(alpha*p.x, alpha*p.y, alpha*p.z); return point<T>(alpha*p.x, alpha*p.y, alpha*p.z);
} }
template <typename T> template <typename T>
T T norm(point<T> const& p) {
norm(point<T> const& p) return std::sqrt(p.x*p.x + p.y*p.y + p.z*p.z);
{
return sqrt(p.x*p.x + p.y*p.y + p.z*p.z);
} }
template <typename T> template <typename T>
constexpr T constexpr T
dot( dot(point<T> const& lhs, point<T> const& rhs) {
point<T> const& lhs,
point<T> const& rhs
) {
return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z; return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z;
} }
template<typename T> template<typename T>
bool operator==(const point<T> &rhs, const point<T> &lhs) bool operator==(const point<T> &rhs, const point<T> &lhs) {
{ return (rhs.x==lhs.x) && (rhs.y==lhs.y) && (rhs.z==lhs.z);
return (rhs.x == lhs.x) &&
(rhs.y == lhs.y) &&
(rhs.z == lhs.z);
} }
template<typename T> template<typename T>
bool operator!=(const point<T> &rhs, const point<T> &lhs) bool operator!=(const point<T> &rhs, const point<T> &lhs) {
{
return !(rhs == lhs); return !(rhs == lhs);
} }
...@@ -92,7 +73,6 @@ bool operator!=(const point<T> &rhs, const point<T> &lhs) ...@@ -92,7 +73,6 @@ bool operator!=(const point<T> &rhs, const point<T> &lhs)
} // namespace nest } // namespace nest
template <typename T> template <typename T>
std::ostream& operator << (std::ostream& o, nest::mc::point<T> const& p) std::ostream& operator << (std::ostream& o, nest::mc::point<T> const& p) {
{
return o << "[" << p.x << ", " << p.y << ", " << p.z << "]"; return o << "[" << p.x << ", " << p.y << ", " << p.z << "]";
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment