2020-08-30 10:48:06 -07:00

105 lines
3.8 KiB
C++

/**
This file is a part of our_dick
Copyright (C) 2020 rexy712
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef REXY_VEC_HPP
#define REXY_VEC_HPP
#include "mat.hpp"
namespace math{
//class representing vectors
//inherit from matrix base because it also shared matrix attributes
template<typename T, size_t R>
class vector : public matrix_base<T,R,1>
{
private:
using base = matrix_base<T,R,1>;
public:
using value_type = typename base::value_type;
using size_type = typename base::size_type;
using pointer = typename base::pointer;
using const_pointer = typename base::const_pointer;
using reference = typename base::reference;
using const_reference = typename base::const_reference;
public:
using base::base;
constexpr vector(const vector&) = default;
constexpr vector(vector&&) = default;
~vector() = default;
//Assignement
constexpr vector& operator=(const vector&) = default;
constexpr vector& operator=(vector&&) = default;
template<typename U>
constexpr vector& operator=(const vector<U,R>& m);
constexpr reference operator[](size_type i);
constexpr const_reference operator[](size_type i)const;
constexpr reference x();
constexpr const_reference x()const;
template<typename U = T>
constexpr reference y();
template<typename U = T>
constexpr const_reference y()const;
template<typename U = T>
constexpr reference z();
template<typename U = T>
constexpr const_reference z()const;
template<typename U = T>
constexpr reference w();
template<typename U = T>
constexpr const_reference w()const;
};
template<typename T, typename U, size_t C, size_t R>
constexpr auto operator*(const matrix<U,R,C>& left, const vector<T,C>& right);
template<typename T, typename U, size_t R>
constexpr auto operator*(const vector<T,R>& left, const vector<U,R>& right);
template<typename T, typename U, size_t R, std::enable_if_t<!is_matrix<U>::value,int> = 0>
constexpr auto operator*(const vector<T,R>& left, U&& right);
template<typename T, typename U, size_t R, std::enable_if_t<!is_matrix<U>::value,int> = 0>
constexpr auto operator*(U&& left, const vector<T,R>& right);
template<typename T, typename U, size_t R, std::enable_if_t<!is_matrix<U>::value,int> = 0>
constexpr auto operator/(const vector<T,R>& left, U&& right);
template<typename T, typename U, size_t R>
constexpr auto operator+(const vector<T,R>& left, const vector<U,R>& right);
template<typename T, typename U, size_t R>
constexpr auto operator-(const vector<T,R>& left, const vector<U,R>& right);
template<typename T, typename U, size_t R>
constexpr auto operator-(const vector<T,R>& left);
template<typename T, typename U, size_t R, std::enable_if_t<!is_matrix<U>::value,int> = 0>
constexpr decltype(auto) operator*=(vector<T,R>& left, U&& right);
template<typename T, typename U, size_t R, std::enable_if_t<!is_matrix<U>::value,int> = 0>
constexpr decltype(auto) operator/=(vector<T,R>& left, U&& right);
template<typename T, typename U, size_t R>
constexpr decltype(auto) operator+=(vector<T,R>& left, const vector<U,R>& right);
template<typename T, typename U, size_t R>
constexpr decltype(auto) operator-=(vector<T,R>& left, const vector<U,R>& right);
}
#include "vec.tpp"
#endif