matx.hpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. // By downloading, copying, installing or using the software you agree to this license.
  6. // If you do not agree to this license, do not download, install,
  7. // copy or use the software.
  8. //
  9. //
  10. // License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
  14. // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
  15. // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
  16. // Third party copyrights are property of their respective owners.
  17. //
  18. // Redistribution and use in source and binary forms, with or without modification,
  19. // are permitted provided that the following conditions are met:
  20. //
  21. // * Redistribution's of source code must retain the above copyright notice,
  22. // this list of conditions and the following disclaimer.
  23. //
  24. // * Redistribution's in binary form must reproduce the above copyright notice,
  25. // this list of conditions and the following disclaimer in the documentation
  26. // and/or other materials provided with the distribution.
  27. //
  28. // * The name of the copyright holders may not be used to endorse or promote products
  29. // derived from this software without specific prior written permission.
  30. //
  31. // This software is provided by the copyright holders and contributors "as is" and
  32. // any express or implied warranties, including, but not limited to, the implied
  33. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  34. // In no event shall the Intel Corporation or contributors be liable for any direct,
  35. // indirect, incidental, special, exemplary, or consequential damages
  36. // (including, but not limited to, procurement of substitute goods or services;
  37. // loss of use, data, or profits; or business interruption) however caused
  38. // and on any theory of liability, whether in contract, strict liability,
  39. // or tort (including negligence or otherwise) arising in any way out of
  40. // the use of this software, even if advised of the possibility of such damage.
  41. //
  42. //M*/
  43. #ifndef OPENCV_CORE_MATX_HPP
  44. #define OPENCV_CORE_MATX_HPP
  45. #ifndef __cplusplus
  46. # error matx.hpp header must be compiled as C++
  47. #endif
  48. #include "opencv2/core/cvdef.h"
  49. #include "opencv2/core/base.hpp"
  50. #include "opencv2/core/traits.hpp"
  51. #include "opencv2/core/saturate.hpp"
  52. #include <initializer_list>
  53. namespace cv
  54. {
  55. //! @addtogroup core_basic
  56. //! @{
  57. //! @cond IGNORED
  58. // FIXIT Remove this (especially CV_EXPORTS modifier)
  59. struct CV_EXPORTS Matx_AddOp { Matx_AddOp() {} Matx_AddOp(const Matx_AddOp&) {} };
  60. struct CV_EXPORTS Matx_SubOp { Matx_SubOp() {} Matx_SubOp(const Matx_SubOp&) {} };
  61. struct CV_EXPORTS Matx_ScaleOp { Matx_ScaleOp() {} Matx_ScaleOp(const Matx_ScaleOp&) {} };
  62. struct CV_EXPORTS Matx_MulOp { Matx_MulOp() {} Matx_MulOp(const Matx_MulOp&) {} };
  63. struct CV_EXPORTS Matx_DivOp { Matx_DivOp() {} Matx_DivOp(const Matx_DivOp&) {} };
  64. struct CV_EXPORTS Matx_MatMulOp { Matx_MatMulOp() {} Matx_MatMulOp(const Matx_MatMulOp&) {} };
  65. struct CV_EXPORTS Matx_TOp { Matx_TOp() {} Matx_TOp(const Matx_TOp&) {} };
  66. //! @endcond
  67. ////////////////////////////// Small Matrix ///////////////////////////
  68. /** @brief Template class for small matrices whose type and size are known at compilation time
  69. If you need a more flexible type, use Mat . The elements of the matrix M are accessible using the
  70. M(i,j) notation. Most of the common matrix operations (see also @ref MatrixExpressions ) are
  71. available. To do an operation on Matx that is not implemented, you can easily convert the matrix to
  72. Mat and backwards:
  73. @code{.cpp}
  74. Matx33f m(1, 2, 3,
  75. 4, 5, 6,
  76. 7, 8, 9);
  77. cout << sum(Mat(m*m.t())) << endl;
  78. @endcode
  79. Except of the plain constructor which takes a list of elements, Matx can be initialized from a C-array:
  80. @code{.cpp}
  81. float values[] = { 1, 2, 3};
  82. Matx31f m(values);
  83. @endcode
  84. In case if C++11 features are available, std::initializer_list can be also used to initialize Matx:
  85. @code{.cpp}
  86. Matx31f m = { 1, 2, 3};
  87. @endcode
  88. */
  89. template<typename _Tp, int m, int n> class Matx
  90. {
  91. public:
  92. enum {
  93. rows = m,
  94. cols = n,
  95. channels = rows*cols,
  96. #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
  97. depth = traits::Type<_Tp>::value,
  98. type = CV_MAKETYPE(depth, channels),
  99. #endif
  100. shortdim = (m < n ? m : n)
  101. };
  102. typedef _Tp value_type;
  103. typedef Matx<_Tp, m, n> mat_type;
  104. typedef Matx<_Tp, shortdim, 1> diag_type;
  105. //! default constructor
  106. Matx();
  107. explicit Matx(_Tp v0); //!< 1x1 matrix
  108. Matx(_Tp v0, _Tp v1); //!< 1x2 or 2x1 matrix
  109. Matx(_Tp v0, _Tp v1, _Tp v2); //!< 1x3 or 3x1 matrix
  110. Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 1x4, 2x2 or 4x1 matrix
  111. Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 1x5 or 5x1 matrix
  112. Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 1x6, 2x3, 3x2 or 6x1 matrix
  113. Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 1x7 or 7x1 matrix
  114. Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 1x8, 2x4, 4x2 or 8x1 matrix
  115. Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 1x9, 3x3 or 9x1 matrix
  116. Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 1x10, 2x5 or 5x2 or 10x1 matrix
  117. Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3,
  118. _Tp v4, _Tp v5, _Tp v6, _Tp v7,
  119. _Tp v8, _Tp v9, _Tp v10, _Tp v11); //!< 1x12, 2x6, 3x4, 4x3, 6x2 or 12x1 matrix
  120. Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3,
  121. _Tp v4, _Tp v5, _Tp v6, _Tp v7,
  122. _Tp v8, _Tp v9, _Tp v10, _Tp v11,
  123. _Tp v12, _Tp v13); //!< 1x14, 2x7, 7x2 or 14x1 matrix
  124. Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3,
  125. _Tp v4, _Tp v5, _Tp v6, _Tp v7,
  126. _Tp v8, _Tp v9, _Tp v10, _Tp v11,
  127. _Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix
  128. explicit Matx(const _Tp* vals); //!< initialize from a plain array
  129. Matx(std::initializer_list<_Tp>); //!< initialize from an initializer list
  130. CV_NODISCARD_STD static Matx all(_Tp alpha);
  131. CV_NODISCARD_STD static Matx zeros();
  132. CV_NODISCARD_STD static Matx ones();
  133. CV_NODISCARD_STD static Matx eye();
  134. CV_NODISCARD_STD static Matx diag(const diag_type& d);
  135. /** @brief Generates uniformly distributed random numbers
  136. @param a Range boundary.
  137. @param b The other range boundary (boundaries don't have to be ordered, the lower boundary is inclusive,
  138. the upper one is exclusive).
  139. */
  140. CV_NODISCARD_STD static Matx randu(_Tp a, _Tp b);
  141. /** @brief Generates normally distributed random numbers
  142. @param a Mean value.
  143. @param b Standard deviation.
  144. */
  145. CV_NODISCARD_STD static Matx randn(_Tp a, _Tp b);
  146. //! dot product computed with the default precision
  147. _Tp dot(const Matx<_Tp, m, n>& v) const;
  148. //! dot product computed in double-precision arithmetics
  149. double ddot(const Matx<_Tp, m, n>& v) const;
  150. //! conversion to another data type
  151. template<typename T2> operator Matx<T2, m, n>() const;
  152. //! change the matrix shape
  153. template<int m1, int n1> Matx<_Tp, m1, n1> reshape() const;
  154. //! extract part of the matrix
  155. template<int m1, int n1> Matx<_Tp, m1, n1> get_minor(int base_row, int base_col) const;
  156. //! extract the matrix row
  157. Matx<_Tp, 1, n> row(int i) const;
  158. //! extract the matrix column
  159. Matx<_Tp, m, 1> col(int i) const;
  160. //! extract the matrix diagonal
  161. diag_type diag() const;
  162. //! transpose the matrix
  163. Matx<_Tp, n, m> t() const;
  164. //! invert the matrix
  165. Matx<_Tp, n, m> inv(int method=DECOMP_LU, bool *p_is_ok = NULL) const;
  166. //! solve linear system
  167. template<int l> Matx<_Tp, n, l> solve(const Matx<_Tp, m, l>& rhs, int flags=DECOMP_LU) const;
  168. Vec<_Tp, n> solve(const Vec<_Tp, m>& rhs, int method) const;
  169. //! multiply two matrices element-wise
  170. Matx<_Tp, m, n> mul(const Matx<_Tp, m, n>& a) const;
  171. //! divide two matrices element-wise
  172. Matx<_Tp, m, n> div(const Matx<_Tp, m, n>& a) const;
  173. //! element access
  174. const _Tp& operator ()(int row, int col) const;
  175. _Tp& operator ()(int row, int col);
  176. //! 1D element access
  177. const _Tp& operator ()(int i) const;
  178. _Tp& operator ()(int i);
  179. Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_AddOp);
  180. Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_SubOp);
  181. template<typename _T2> Matx(const Matx<_Tp, m, n>& a, _T2 alpha, Matx_ScaleOp);
  182. Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_MulOp);
  183. Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_DivOp);
  184. template<int l> Matx(const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b, Matx_MatMulOp);
  185. Matx(const Matx<_Tp, n, m>& a, Matx_TOp);
  186. _Tp val[m*n]; ///< matrix elements
  187. };
  188. typedef Matx<float, 1, 2> Matx12f;
  189. typedef Matx<double, 1, 2> Matx12d;
  190. typedef Matx<float, 1, 3> Matx13f;
  191. typedef Matx<double, 1, 3> Matx13d;
  192. typedef Matx<float, 1, 4> Matx14f;
  193. typedef Matx<double, 1, 4> Matx14d;
  194. typedef Matx<float, 1, 6> Matx16f;
  195. typedef Matx<double, 1, 6> Matx16d;
  196. typedef Matx<float, 2, 1> Matx21f;
  197. typedef Matx<double, 2, 1> Matx21d;
  198. typedef Matx<float, 3, 1> Matx31f;
  199. typedef Matx<double, 3, 1> Matx31d;
  200. typedef Matx<float, 4, 1> Matx41f;
  201. typedef Matx<double, 4, 1> Matx41d;
  202. typedef Matx<float, 6, 1> Matx61f;
  203. typedef Matx<double, 6, 1> Matx61d;
  204. typedef Matx<float, 2, 2> Matx22f;
  205. typedef Matx<double, 2, 2> Matx22d;
  206. typedef Matx<float, 2, 3> Matx23f;
  207. typedef Matx<double, 2, 3> Matx23d;
  208. typedef Matx<float, 3, 2> Matx32f;
  209. typedef Matx<double, 3, 2> Matx32d;
  210. typedef Matx<float, 3, 3> Matx33f;
  211. typedef Matx<double, 3, 3> Matx33d;
  212. typedef Matx<float, 3, 4> Matx34f;
  213. typedef Matx<double, 3, 4> Matx34d;
  214. typedef Matx<float, 4, 3> Matx43f;
  215. typedef Matx<double, 4, 3> Matx43d;
  216. typedef Matx<float, 4, 4> Matx44f;
  217. typedef Matx<double, 4, 4> Matx44d;
  218. typedef Matx<float, 6, 6> Matx66f;
  219. typedef Matx<double, 6, 6> Matx66d;
  220. template<typename _Tp, int m> static inline
  221. double determinant(const Matx<_Tp, m, m>& a);
  222. template<typename _Tp, int m, int n> static inline
  223. double trace(const Matx<_Tp, m, n>& a);
  224. template<typename _Tp, int m, int n> static inline
  225. double norm(const Matx<_Tp, m, n>& M);
  226. template<typename _Tp, int m, int n> static inline
  227. double norm(const Matx<_Tp, m, n>& M, int normType);
  228. template<typename _Tp1, typename _Tp2, int m, int n> static inline
  229. Matx<_Tp1, m, n>& operator += (Matx<_Tp1, m, n>& a, const Matx<_Tp2, m, n>& b);
  230. template<typename _Tp1, typename _Tp2, int m, int n> static inline
  231. Matx<_Tp1, m, n>& operator -= (Matx<_Tp1, m, n>& a, const Matx<_Tp2, m, n>& b);
  232. template<typename _Tp, int m, int n> static inline
  233. Matx<_Tp, m, n> operator + (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b);
  234. template<typename _Tp, int m, int n> static inline
  235. Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b);
  236. template<typename _Tp, int m, int n> static inline
  237. Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, int alpha);
  238. template<typename _Tp, int m, int n> static inline
  239. Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, float alpha);
  240. template<typename _Tp, int m, int n> static inline
  241. Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, double alpha);
  242. template<typename _Tp, int m, int n> static inline
  243. Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, int alpha);
  244. template<typename _Tp, int m, int n> static inline
  245. Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, float alpha);
  246. template<typename _Tp, int m, int n> static inline
  247. Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, double alpha);
  248. template<typename _Tp, int m, int n> static inline
  249. Matx<_Tp, m, n> operator * (int alpha, const Matx<_Tp, m, n>& a);
  250. template<typename _Tp, int m, int n> static inline
  251. Matx<_Tp, m, n> operator * (float alpha, const Matx<_Tp, m, n>& a);
  252. template<typename _Tp, int m, int n> static inline
  253. Matx<_Tp, m, n> operator * (double alpha, const Matx<_Tp, m, n>& a);
  254. template<typename _Tp, int m, int n> static inline
  255. Matx<_Tp, m, n>& operator /= (Matx<_Tp, m, n>& a, float alpha);
  256. template<typename _Tp, int m, int n> static inline
  257. Matx<_Tp, m, n>& operator /= (Matx<_Tp, m, n>& a, double alpha);
  258. template<typename _Tp, int m, int n> static inline
  259. Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, float alpha);
  260. template<typename _Tp, int m, int n> static inline
  261. Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, double alpha);
  262. template<typename _Tp, int m, int n> static inline
  263. Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a);
  264. template<typename _Tp, int m, int n, int l> static inline
  265. Matx<_Tp, m, n> operator * (const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b);
  266. template<typename _Tp, int m, int n> static inline
  267. Vec<_Tp, m> operator * (const Matx<_Tp, m, n>& a, const Vec<_Tp, n>& b);
  268. template<typename _Tp, int m, int n> static inline
  269. bool operator == (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b);
  270. template<typename _Tp, int m, int n> static inline
  271. bool operator != (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b);
  272. /////////////////////// Vec (used as element of multi-channel images /////////////////////
  273. /** @brief Template class for short numerical vectors, a partial case of Matx
  274. This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements) on which you
  275. can perform basic arithmetical operations, access individual elements using [] operator etc. The
  276. vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc., which
  277. elements are dynamically allocated in the heap.
  278. The template takes 2 parameters:
  279. @tparam _Tp element type
  280. @tparam cn the number of elements
  281. In addition to the universal notation like Vec<float, 3>, you can use shorter aliases
  282. for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec<float, 3>.
  283. It is possible to convert Vec\<T,2\> to/from Point_, Vec\<T,3\> to/from Point3_ , and Vec\<T,4\>
  284. to CvScalar or Scalar_. Use operator[] to access the elements of Vec.
  285. All the expected vector operations are also implemented:
  286. - v1 = v2 + v3
  287. - v1 = v2 - v3
  288. - v1 = v2 \* scale
  289. - v1 = scale \* v2
  290. - v1 = -v2
  291. - v1 += v2 and other augmenting operations
  292. - v1 == v2, v1 != v2
  293. - norm(v1) (euclidean norm)
  294. The Vec class is commonly used to describe pixel types of multi-channel arrays. See Mat for details.
  295. */
  296. template<typename _Tp, int cn> class Vec : public Matx<_Tp, cn, 1>
  297. {
  298. public:
  299. typedef _Tp value_type;
  300. enum {
  301. channels = cn,
  302. #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
  303. depth = Matx<_Tp, cn, 1>::depth,
  304. type = CV_MAKETYPE(depth, channels),
  305. #endif
  306. _dummy_enum_finalizer = 0
  307. };
  308. //! default constructor
  309. Vec();
  310. Vec(_Tp v0); //!< 1-element vector constructor
  311. Vec(_Tp v0, _Tp v1); //!< 2-element vector constructor
  312. Vec(_Tp v0, _Tp v1, _Tp v2); //!< 3-element vector constructor
  313. Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 4-element vector constructor
  314. Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 5-element vector constructor
  315. Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 6-element vector constructor
  316. Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 7-element vector constructor
  317. Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 8-element vector constructor
  318. Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 9-element vector constructor
  319. Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 10-element vector constructor
  320. Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13); //!< 14-element vector constructor
  321. explicit Vec(const _Tp* values);
  322. Vec(std::initializer_list<_Tp>);
  323. Vec(const Vec<_Tp, cn>& v);
  324. static Vec all(_Tp alpha);
  325. static Vec ones();
  326. static Vec randn(_Tp a, _Tp b);
  327. static Vec randu(_Tp a, _Tp b);
  328. static Vec zeros();
  329. static Vec diag(_Tp alpha) = delete;
  330. static Vec eye() = delete;
  331. //! per-element multiplication
  332. Vec mul(const Vec<_Tp, cn>& v) const;
  333. //! conjugation (makes sense for complex numbers and quaternions)
  334. Vec conj() const;
  335. /*!
  336. cross product of the two 3D vectors.
  337. For other dimensionalities the exception is raised
  338. */
  339. Vec cross(const Vec& v) const;
  340. //! conversion to another data type
  341. template<typename T2> operator Vec<T2, cn>() const;
  342. /*! element access */
  343. const _Tp& operator [](int i) const;
  344. _Tp& operator[](int i);
  345. const _Tp& operator ()(int i) const;
  346. _Tp& operator ()(int i);
  347. Vec<_Tp, cn>& operator=(const Vec<_Tp, cn>& rhs) = default;
  348. Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_AddOp);
  349. Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_SubOp);
  350. template<typename _T2> Vec(const Matx<_Tp, cn, 1>& a, _T2 alpha, Matx_ScaleOp);
  351. };
  352. /** @name Shorter aliases for the most popular specializations of Vec<T,n>
  353. @{
  354. */
  355. typedef Vec<uchar, 2> Vec2b;
  356. typedef Vec<uchar, 3> Vec3b;
  357. typedef Vec<uchar, 4> Vec4b;
  358. typedef Vec<short, 2> Vec2s;
  359. typedef Vec<short, 3> Vec3s;
  360. typedef Vec<short, 4> Vec4s;
  361. typedef Vec<ushort, 2> Vec2w;
  362. typedef Vec<ushort, 3> Vec3w;
  363. typedef Vec<ushort, 4> Vec4w;
  364. typedef Vec<int, 2> Vec2i;
  365. typedef Vec<int, 3> Vec3i;
  366. typedef Vec<int, 4> Vec4i;
  367. typedef Vec<int, 6> Vec6i;
  368. typedef Vec<int, 8> Vec8i;
  369. typedef Vec<float, 2> Vec2f;
  370. typedef Vec<float, 3> Vec3f;
  371. typedef Vec<float, 4> Vec4f;
  372. typedef Vec<float, 6> Vec6f;
  373. typedef Vec<double, 2> Vec2d;
  374. typedef Vec<double, 3> Vec3d;
  375. typedef Vec<double, 4> Vec4d;
  376. typedef Vec<double, 6> Vec6d;
  377. /** @} */
  378. template<typename _Tp, int cn> inline
  379. Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v);
  380. template<typename _Tp1, typename _Tp2, int cn> static inline
  381. Vec<_Tp1, cn>& operator += (Vec<_Tp1, cn>& a, const Vec<_Tp2, cn>& b);
  382. template<typename _Tp1, typename _Tp2, int cn> static inline
  383. Vec<_Tp1, cn>& operator -= (Vec<_Tp1, cn>& a, const Vec<_Tp2, cn>& b);
  384. template<typename _Tp, int cn> static inline
  385. Vec<_Tp, cn> operator + (const Vec<_Tp, cn>& a, const Vec<_Tp, cn>& b);
  386. template<typename _Tp, int cn> static inline
  387. Vec<_Tp, cn> operator - (const Vec<_Tp, cn>& a, const Vec<_Tp, cn>& b);
  388. template<typename _Tp, int cn> static inline
  389. Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, int alpha);
  390. template<typename _Tp, int cn> static inline
  391. Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, float alpha);
  392. template<typename _Tp, int cn> static inline
  393. Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, double alpha);
  394. template<typename _Tp, int cn> static inline
  395. Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, int alpha);
  396. template<typename _Tp, int cn> static inline
  397. Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, float alpha);
  398. template<typename _Tp, int cn> static inline
  399. Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, double alpha);
  400. template<typename _Tp, int cn> static inline
  401. Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, int alpha);
  402. template<typename _Tp, int cn> static inline
  403. Vec<_Tp, cn> operator * (int alpha, const Vec<_Tp, cn>& a);
  404. template<typename _Tp, int cn> static inline
  405. Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, float alpha);
  406. template<typename _Tp, int cn> static inline
  407. Vec<_Tp, cn> operator * (float alpha, const Vec<_Tp, cn>& a);
  408. template<typename _Tp, int cn> static inline
  409. Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, double alpha);
  410. template<typename _Tp, int cn> static inline
  411. Vec<_Tp, cn> operator * (double alpha, const Vec<_Tp, cn>& a);
  412. template<typename _Tp, int cn> static inline
  413. Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, int alpha);
  414. template<typename _Tp, int cn> static inline
  415. Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, float alpha);
  416. template<typename _Tp, int cn> static inline
  417. Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, double alpha);
  418. template<typename _Tp, int cn> static inline
  419. Vec<_Tp, cn> operator - (const Vec<_Tp, cn>& a);
  420. template<typename _Tp> inline
  421. Vec<_Tp, 4> operator * (const Vec<_Tp, 4>& v1, const Vec<_Tp, 4>& v2);
  422. template<typename _Tp> inline
  423. Vec<_Tp, 4>& operator *= (Vec<_Tp, 4>& v1, const Vec<_Tp, 4>& v2);
  424. //! @} core_basic
  425. } // cv
  426. #include "opencv2/core/matx.inl.hpp"
  427. #endif // OPENCV_CORE_MATX_HPP