/*
* Copyright (C) 2020 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see .
*/
#ifndef ANTKEEPER_MATH_VECTOR_OPERATORS_HPP
#define ANTKEEPER_MATH_VECTOR_OPERATORS_HPP
#include "math/vector-type.hpp"
#include "math/vector-functions.hpp"
namespace math {
namespace vector_operators {
/// @addtogroup vector
/// @{
/// @copydoc add(const vector&, const vector&)
template
vector operator+(const vector& x, const vector& y);
/// @copydoc div(const vector&, const vector&)
template
vector operator/(const vector& x, const vector& y);
/// @copydoc div(const vector&, T)
template
vector operator/(const vector& v, T s);
/// @copydoc mul(const vector&, const vector&)
template
vector operator*(const vector& x, const vector& y);
/// @copydoc mul(const vector&, T)
template
vector operator*(const vector& v, T s);
/// @copydoc mul(const vector&, T)
template
vector operator*(T s, const vector& v);
/// @copydoc negate(const vector&)
template
vector operator-(const vector& x);
/// @copydoc sub(const vector&, const vector&)
template
vector operator-(const vector& x, const vector& y);
/**
* Adds two vectors and stores the result in the first vector.
*
* @param x First vector.
* @param y Second vector.
* @return Reference to the first vector.
*/
template
vector& operator+=(vector& x, const vector& y);
/**
* Subtracts two vectors and stores the result in the first vector.
*
* @param x First vector.
* @param y Second vector.
* @return Reference to the first vector.
*/
template
vector& operator-=(vector& x, const vector& y);
/**
* Multiplies two vectors and stores the result in the first vector.
*
* @param x First vector.
* @param y Second vector.
* @return Reference to the first vector.
*/
template
vector& operator*=(vector& x, const vector& y);
/**
* Multiplies a vector and a scalar and stores the result in the vector.
*
* @param v Vector.
* @param s Scalar.
* @return Reference to the vector.
*/
template
vector& operator*=(vector& v, T s);
/**
* Divides the first vector by the second vector the result in the first vector.
*
* @param x First vector.
* @param y Second vector.
* @return Reference to the first vector.
*/
template
vector& operator/=(vector& x, const vector& y);
/**
* Divides a vector by a scalar and stores the result in the vector.
*
* @param v Vector.
* @param s Scalar.
* @return Reference to the vector.
*/
template
vector& operator/=(vector& v, T s);
template
inline vector operator+(const vector& x, const vector& y)
{
return add(x, y);
}
template
inline vector operator-(const vector& x)
{
return negate(x);
}
template
inline vector operator-(const vector& x, const vector& y)
{
return sub(x, y);
}
template
inline vector operator*(const vector& x, const vector& y)
{
return mul(x, y);
}
template
inline vector operator*(const vector& v, T s)
{
return mul(v, s);
}
template
inline vector operator*(T s, const vector& v)
{
return mul(v, s);
}
template
inline vector operator/(const vector& x, const vector& y)
{
return div(x, y);
}
template
inline vector operator/(const vector& v, T s)
{
return div(v, s);
}
template
inline vector& operator+=(vector& x, const vector& y)
{
return (x = x + y);
}
template
inline vector& operator-=(vector& x, const vector& y)
{
return (x = x - y);
}
template
inline vector& operator*=(vector& x, const vector& y)
{
return (x = x * y);
}
template
inline vector& operator*=(vector& v, T s)
{
return (v = v * s);
}
template
inline vector& operator/=(vector& x, const vector& y)
{
return (x = x * y);
}
template
inline vector& operator/=(vector& v, T s)
{
return (v = v / s);
}
/// @}
} // namespace vector_operators
} // namespace math
// Bring vector operators into global namespace
using namespace math::vector_operators;
#endif // ANTKEEPER_MATH_VECTOR_OPERATORS_HPP