Add division operators for Matx.

pull/13928/head
catree 6 years ago
parent 5fd47352cf
commit 576ab3df9a
  1. 42
      modules/core/include/opencv2/core/matx.hpp

@ -1275,6 +1275,48 @@ Matx<_Tp, m, n> operator * (double alpha, const Matx<_Tp, m, n>& a)
return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp());
} }
template<typename _Tp, int m, int n> static inline
Matx<_Tp, m, n>& operator /= (Matx<_Tp, m, n>& a, int alpha)
{
for( int i = 0; i < m*n; i++ )
a.val[i] = saturate_cast<_Tp>(a.val[i] / alpha);
return a;
}
template<typename _Tp, int m, int n> static inline
Matx<_Tp, m, n>& operator /= (Matx<_Tp, m, n>& a, float alpha)
{
for( int i = 0; i < m*n; i++ )
a.val[i] = saturate_cast<_Tp>(a.val[i] / alpha);
return a;
}
template<typename _Tp, int m, int n> static inline
Matx<_Tp, m, n>& operator /= (Matx<_Tp, m, n>& a, double alpha)
{
for( int i = 0; i < m*n; i++ )
a.val[i] = saturate_cast<_Tp>(a.val[i] / alpha);
return a;
}
template<typename _Tp, int m, int n> static inline
Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, int alpha)
{
return Matx<_Tp, m, n>(a, 1./alpha, Matx_ScaleOp());
}
template<typename _Tp, int m, int n> static inline
Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, float alpha)
{
return Matx<_Tp, m, n>(a, 1.f/alpha, Matx_ScaleOp());
}
template<typename _Tp, int m, int n> static inline
Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, double alpha)
{
return Matx<_Tp, m, n>(a, 1./alpha, Matx_ScaleOp());
}
template<typename _Tp, int m, int n> static inline template<typename _Tp, int m, int n> static inline
Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a) Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a)
{ {

Loading…
Cancel
Save