Commit 3acb55b2 authored by Davis King's avatar Davis King

Added flip()

parent 3b412f23
......@@ -3967,6 +3967,44 @@ namespace dlib
return matrix_op<op>(op(m.ref()));
}
// ----------------------------------------------------------------------------------------
template <typename M>
struct op_flip
{
op_flip( const M& m_) : m(m_){}
const M& m;
const static long cost = M::cost;
const static long NR = M::NR;
const static long NC = M::NC;
typedef typename M::type type;
typedef typename M::const_ret_type const_ret_type;
typedef typename M::mem_manager_type mem_manager_type;
typedef typename M::layout_type layout_type;
const_ret_type apply (long r, long c) const { return m(m.nr()-r-1, m.nc()-c-1); }
long nr () const { return m.nr(); }
long nc () const { return m.nc(); }
template <typename U> bool aliases ( const matrix_exp<U>& item) const { return m.aliases(item); }
template <typename U> bool destructively_aliases ( const matrix_exp<U>& item) const { return m.aliases(item); }
};
template <
typename M
>
const matrix_op<op_flip<M> > flip (
const matrix_exp<M>& m
)
{
typedef op_flip<M> op;
return matrix_op<op>(op(m.ref()));
}
// ----------------------------------------------------------------------------------------
template <typename T, long NR, long NC, typename MM, typename L>
......
......@@ -400,6 +400,22 @@ namespace dlib
M(r,c) == m(m.nr()-r-1, c)
!*/
// ----------------------------------------------------------------------------------------
const matrix_exp flip (
const matrix_exp& m
);
/*!
ensures
- flips the matrix m from up to down and left to right and returns the
result. I.e. returns flipud(fliplr(m)).
- returns a matrix M such that:
- M::type == the same type that was in m
- M has the same dimensions as m
- for all valid r and c:
M(r,c) == m(m.nr()-r-1, m.nc()-c-1)
!*/
// ----------------------------------------------------------------------------------------
template <
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment