Commit 7b53a1cb authored by Davis King's avatar Davis King

Updated the assign_matrix stuff so that it works again.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402741
parent 4f6f436e
...@@ -992,9 +992,6 @@ namespace dlib ...@@ -992,9 +992,6 @@ namespace dlib
const matrix_exp<EXP>& m const matrix_exp<EXP>& m
): matrix_exp<matrix>(*this) ): matrix_exp<matrix>(*this)
{ {
using namespace std;
// TODO
//cout << "copy" << endl;
// You get an error on this line if the matrix m contains a type that isn't // You get an error on this line if the matrix m contains a type that isn't
// the same as the type contained in the target matrix. // the same as the type contained in the target matrix.
COMPILE_TIME_ASSERT((is_same_type<typename EXP::type,type>::value == true) || COMPILE_TIME_ASSERT((is_same_type<typename EXP::type,type>::value == true) ||
...@@ -1023,9 +1020,6 @@ namespace dlib ...@@ -1023,9 +1020,6 @@ namespace dlib
const matrix& m const matrix& m
): matrix_exp<matrix>(*this) ): matrix_exp<matrix>(*this)
{ {
using namespace std;
// TODO
//cout << "copy" << endl;
data.set_size(m.nr(),m.nc()); data.set_size(m.nr(),m.nc());
matrix_assign(*this, m); matrix_assign(*this, m);
} }
......
...@@ -25,18 +25,33 @@ namespace dlib ...@@ -25,18 +25,33 @@ namespace dlib
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
struct op_null
{
template <typename EXP>
struct op : has_nondestructive_aliasing, preserves_dimensions<EXP>
{
const static long cost = EXP::cost;
typedef typename EXP::type type;
template <typename M>
static type apply ( const M& m, long r, long c)
{
return m(r,c);
}
};
};
template < template <
typename EXP typename EXP
> >
const matrix_exp<EXP> make_exp ( const matrix_unary_exp<EXP,op_null> null_exp (
const EXP& exp const matrix_exp<EXP>& m
) )
/*! /*!
The only point of this function is to make it easy to cause the overloads The only point of this function is to make it easy to cause the overloads
of matrix_assign to not trigger for a matrix expression. of matrix_assign to not trigger for a matrix expression.
!*/ !*/
{ {
return matrix_exp<EXP>(exp); return matrix_unary_exp<EXP,op_null>(m.ref());
} }
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
...@@ -50,18 +65,15 @@ namespace dlib ...@@ -50,18 +65,15 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// TODO
#if 0
template < template <
typename matrix_dest_type, typename matrix_dest_type,
typename EXP1, typename EXP1,
typename EXP2, typename EXP2
unsigned long count
> >
inline typename disable_if_c<ma::matrix_is_vector<EXP1>::value || ma::matrix_is_vector<EXP2>::value>::type matrix_assign_big ( typename disable_if_c<ma::matrix_is_vector<EXP1>::value || ma::matrix_is_vector<EXP2>::value>::type
matrix_assign_big (
matrix_dest_type& dest, matrix_dest_type& dest,
const matrix_exp<matrix_multiply_exp<EXP1,EXP2,count> >& src const matrix_multiply_exp<EXP1,EXP2>& src
) )
/*! /*!
This overload catches assignments like: This overload catches assignments like:
...@@ -70,8 +82,8 @@ namespace dlib ...@@ -70,8 +82,8 @@ namespace dlib
!*/ !*/
{ {
using namespace ma; using namespace ma;
const matrix_exp<EXP1> lhs(src.ref().lhs); const matrix_exp<EXP1>& lhs = src.lhs;
const matrix_exp<EXP2> rhs(src.ref().rhs); const matrix_exp<EXP2>& rhs = src.rhs;
const long bs = 100; const long bs = 100;
// if the matrices are small enough then just use the simple multiply algorithm // if the matrices are small enough then just use the simple multiply algorithm
...@@ -109,7 +121,7 @@ namespace dlib ...@@ -109,7 +121,7 @@ namespace dlib
if (c != 0) if (c != 0)
set_subm(dest, res_block) = subm(dest,res_block) + subm(lhs,lhs_block)*subm(rhs, rhs_block); set_subm(dest, res_block) = subm(dest,res_block) + subm(lhs,lhs_block)*subm(rhs, rhs_block);
else else
set_subm(dest, res_block) = make_exp(subm(lhs,lhs_block)*subm(rhs, rhs_block)); set_subm(dest, res_block) = null_exp(subm(lhs,lhs_block)*subm(rhs, rhs_block));
} }
} }
} }
...@@ -120,8 +132,6 @@ namespace dlib ...@@ -120,8 +132,6 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
#endif
} }
#endif // DLIB_MATRIx_ASSIGn_ #endif // DLIB_MATRIx_ASSIGn_
......
...@@ -94,7 +94,10 @@ namespace dlib ...@@ -94,7 +94,10 @@ namespace dlib
- the part of dest outside the above sub matrix remains unchanged - the part of dest outside the above sub matrix remains unchanged
!*/ !*/
{ {
matrix_assign_big(dest,src); // Call src.ref() here so that the derived type of the matrix_exp shows
// up so we can overload matrix_assign_big() based on various matrix expression
// types.
matrix_assign_big(dest,src.ref());
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -115,7 +118,7 @@ namespace dlib ...@@ -115,7 +118,7 @@ namespace dlib
- the part of dest outside the above sub matrix remains unchanged - the part of dest outside the above sub matrix remains unchanged
!*/ !*/
{ {
matrix_assign_small(dest,src); matrix_assign_small(dest,src.ref());
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
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