💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
3.1 KiB

  1. /*
  2. * Copyright (C) 2021 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_MATH_MATRIX_OPERATORS_HPP
  20. #define ANTKEEPER_MATH_MATRIX_OPERATORS_HPP
  21. #include "math/matrix-type.hpp"
  22. #include "math/matrix-functions.hpp"
  23. /// @copydoc math::add(const math::matrix<T, 2, 2>&, const math::matrix<T, 2, 2>&)
  24. template <class T, std::size_t N, std::size_t M>
  25. math::matrix<T, N, M> operator+(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y);
  26. /// @copydoc math::mul(const math::matrix<T, 2, 2>&, const math::matrix<T, 2, 2>&)
  27. template <class T, std::size_t N, std::size_t M>
  28. math::matrix<T, N, M> operator*(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y);
  29. /// @copydoc math::mul(const math::matrix<T, N, M>&, T)
  30. template <class T, std::size_t N, std::size_t M>
  31. math::matrix<T, N, M> operator*(const math::matrix<T, N, M>& m, T s);
  32. /// @copydoc math::mul(const math::matrix<T, N, M>&, T)
  33. template <class T, std::size_t N, std::size_t M>
  34. math::matrix<T, N, M> operator*(T s, const math::matrix<T, N, M>& m);
  35. /// @copydoc math::mul(const math::matrix<T, 2, 2>&, const math::vector<T, 2>&)
  36. template <class T, std::size_t N>
  37. math::vector<T, N> operator*(const math::matrix<T, N, N>& m, const math::vector<T, N>& v);
  38. /// @copydoc math::sub(const math::matrix<T, 2, 2>&, const math::matrix<T, 2, 2>&)
  39. template <class T, std::size_t N, std::size_t M>
  40. math::matrix<T, N, M> operator-(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y);
  41. template <class T, std::size_t N, std::size_t M>
  42. inline math::matrix<T, N, M> operator+(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y)
  43. {
  44. return add(x, y);
  45. }
  46. template <class T, std::size_t N, std::size_t M>
  47. inline math::matrix<T, N, M> operator*(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y)
  48. {
  49. return mul(x, y);
  50. }
  51. template <class T, std::size_t N, std::size_t M>
  52. inline math::matrix<T, N, M> operator*(const math::matrix<T, N, M>& m, T s)
  53. {
  54. return mul(m, s);
  55. }
  56. template <class T, std::size_t N, std::size_t M>
  57. inline math::matrix<T, N, M> operator*(T s, const math::matrix<T, N, M>& m)
  58. {
  59. return mul(m, s);
  60. }
  61. template <class T, std::size_t N>
  62. inline math::vector<T, N> operator*(const math::matrix<T, N, N>& m, const math::vector<T, N>& v)
  63. {
  64. return mul(m, v);
  65. }
  66. template <class T, std::size_t N, std::size_t M>
  67. inline math::matrix<T, N, M> operator-(const math::matrix<T, N, M>& x, const math::matrix<T, N, M>& y)
  68. {
  69. return sub(x, y);
  70. }
  71. #endif // ANTKEEPER_MATH_MATRIX_OPERATORS_HPP