mirror of https://github.com/davisking/dlib.git
Simplified the matrix_assign() function a bit.
--HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402711
This commit is contained in:
parent
13f0b4338a
commit
b556ebf587
|
@ -895,17 +895,13 @@ namespace dlib
|
|||
>
|
||||
void matrix_assign (
|
||||
matrix_dest_type& dest,
|
||||
const matrix_exp<src_exp>& src,
|
||||
const long row_offset = 0,
|
||||
const long col_offset = 0
|
||||
const matrix_exp<src_exp>& src
|
||||
)
|
||||
/*!
|
||||
requires
|
||||
- src.destructively_aliases(dest) == false
|
||||
- dest.nr() == src.nr()-row_offset
|
||||
- dest.nc() == src.nc()-col_offset
|
||||
ensures
|
||||
- #subm(dest, row_offset, col_offset, src.nr(), src.nc()) == src
|
||||
- #dest == src
|
||||
- the part of dest outside the above sub matrix remains unchanged
|
||||
!*/
|
||||
{
|
||||
|
@ -913,7 +909,7 @@ namespace dlib
|
|||
{
|
||||
for (long c = 0; c < src.nc(); ++c)
|
||||
{
|
||||
dest(r+row_offset,c+col_offset) = src(r,c);
|
||||
dest(r,c) = src(r,c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,9 +56,7 @@ namespace dlib
|
|||
inline typename disable_if_c<ma::matrix_is_vector<EXP1>::value || ma::matrix_is_vector<EXP2>::value ||
|
||||
ma::is_small_matrix<EXP1>::value || ma::is_small_matrix<EXP2>::value >::type matrix_assign (
|
||||
matrix_dest_type& dest,
|
||||
const matrix_exp<matrix_multiply_exp<EXP1,EXP2,count> >& src,
|
||||
const long row_offset = 0,
|
||||
const long col_offset = 0
|
||||
const matrix_exp<matrix_multiply_exp<EXP1,EXP2,count> >& src
|
||||
)
|
||||
/*!
|
||||
This overload catches assignments like:
|
||||
|
@ -78,7 +76,7 @@ namespace dlib
|
|||
{
|
||||
for (long c = 0; c < src.nc(); ++c)
|
||||
{
|
||||
dest(r+row_offset,c+col_offset) = src(r,c);
|
||||
dest(r,c) = src(r,c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +101,6 @@ namespace dlib
|
|||
|
||||
// make a target rect in res
|
||||
rectangle res_block(rhs_block.left(),lhs_block.top(), rhs_block.right(), lhs_block.bottom());
|
||||
res_block = translate_rect(res_block,col_offset, row_offset);
|
||||
if (c != 0)
|
||||
set_subm(dest, res_block) = subm(dest,res_block) + subm(lhs,lhs_block)*subm(rhs, rhs_block);
|
||||
else
|
||||
|
|
|
@ -2304,6 +2304,17 @@ convergence:
|
|||
const rectangle& rect_
|
||||
) : m(m_), rect(rect_) {}
|
||||
|
||||
T& operator() (
|
||||
long r,
|
||||
long c
|
||||
)
|
||||
{
|
||||
return m(r+rect.top(),c+rect.left());
|
||||
}
|
||||
|
||||
long nr() const { return rect.height(); }
|
||||
long nc() const { return rect.width(); }
|
||||
|
||||
template <typename EXP>
|
||||
assignable_sub_matrix& operator= (
|
||||
const matrix_exp<EXP>& exp
|
||||
|
@ -2320,7 +2331,7 @@ convergence:
|
|||
|
||||
if (exp.destructively_aliases(m) == false)
|
||||
{
|
||||
matrix_assign(m, exp, rect.top(), rect.left());
|
||||
matrix_assign(*this, exp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2411,6 +2422,18 @@ convergence:
|
|||
const EXPc& cols_
|
||||
) : m(m_), rows(rows_), cols(cols_) {}
|
||||
|
||||
T& operator() (
|
||||
long r,
|
||||
long c
|
||||
)
|
||||
{
|
||||
return m(rows(r),cols(c));
|
||||
}
|
||||
|
||||
long nr() const { return rows.size(); }
|
||||
long nc() const { return cols.size(); }
|
||||
|
||||
|
||||
template <typename EXP>
|
||||
assignable_sub_range_matrix& operator= (
|
||||
const matrix_exp<EXP>& exp
|
||||
|
@ -2427,13 +2450,7 @@ convergence:
|
|||
|
||||
if (exp.destructively_aliases(m) == false)
|
||||
{
|
||||
for (long r = 0; r < rows.size(); ++r)
|
||||
{
|
||||
for (long c = 0; c < cols.size(); ++c)
|
||||
{
|
||||
m(rows(r),cols(c)) = exp(r,c);
|
||||
}
|
||||
}
|
||||
matrix_assign(*this, exp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2504,6 +2521,17 @@ convergence:
|
|||
const long col_
|
||||
) : m(m_), col(col_) {}
|
||||
|
||||
T& operator() (
|
||||
long r,
|
||||
long c
|
||||
)
|
||||
{
|
||||
return m(r,col);
|
||||
}
|
||||
|
||||
long nr() const { return m.nr(); }
|
||||
long nc() const { return 1; }
|
||||
|
||||
template <typename EXP>
|
||||
assignable_col_matrix& operator= (
|
||||
const matrix_exp<EXP>& exp
|
||||
|
@ -2519,7 +2547,7 @@ convergence:
|
|||
|
||||
if (exp.destructively_aliases(m) == false)
|
||||
{
|
||||
matrix_assign(m, exp, 0, col);
|
||||
matrix_assign(*this, exp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2580,6 +2608,19 @@ convergence:
|
|||
const long row_
|
||||
) : m(m_), row(row_) {}
|
||||
|
||||
|
||||
T& operator() (
|
||||
long r,
|
||||
long c
|
||||
)
|
||||
{
|
||||
return m(row,c);
|
||||
}
|
||||
|
||||
long nr() const { return 1; }
|
||||
long nc() const { return m.nc(); }
|
||||
|
||||
|
||||
template <typename EXP>
|
||||
assignable_row_matrix& operator= (
|
||||
const matrix_exp<EXP>& exp
|
||||
|
@ -2595,7 +2636,7 @@ convergence:
|
|||
|
||||
if (exp.destructively_aliases(m) == false)
|
||||
{
|
||||
matrix_assign(m, exp, row, 0);
|
||||
matrix_assign(*this, exp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue