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
const matrix_exp<EXP>& m
): 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
// the same as the type contained in the target matrix.
COMPILE_TIME_ASSERT((is_same_type<typename EXP::type,type>::value == true) ||
......@@ -1023,9 +1020,6 @@ namespace dlib
const matrix& m
): matrix_exp<matrix>(*this)
{
using namespace std;
// TODO
//cout << "copy" << endl;
data.set_size(m.nr(),m.nc());
matrix_assign(*this, m);
}
......
......@@ -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 <
typename EXP
>
const matrix_exp<EXP> make_exp (
const EXP& exp
const matrix_unary_exp<EXP,op_null> null_exp (
const matrix_exp<EXP>& m
)
/*!
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.
!*/
{
return matrix_exp<EXP>(exp);
return matrix_unary_exp<EXP,op_null>(m.ref());
}
// ------------------------------------------------------------------------------------
......@@ -50,18 +65,15 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// TODO
#if 0
template <
typename matrix_dest_type,
typename EXP1,
typename EXP2,
unsigned long count
typename EXP2
>
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,
const matrix_exp<matrix_multiply_exp<EXP1,EXP2,count> >& src
const matrix_multiply_exp<EXP1,EXP2>& src
)
/*!
This overload catches assignments like:
......@@ -70,8 +82,8 @@ namespace dlib
!*/
{
using namespace ma;
const matrix_exp<EXP1> lhs(src.ref().lhs);
const matrix_exp<EXP2> rhs(src.ref().rhs);
const matrix_exp<EXP1>& lhs = src.lhs;
const matrix_exp<EXP2>& rhs = src.rhs;
const long bs = 100;
// if the matrices are small enough then just use the simple multiply algorithm
......@@ -109,7 +121,7 @@ namespace dlib
if (c != 0)
set_subm(dest, res_block) = subm(dest,res_block) + subm(lhs,lhs_block)*subm(rhs, rhs_block);
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
// ----------------------------------------------------------------------------------------
#endif
}
#endif // DLIB_MATRIx_ASSIGn_
......
......@@ -94,7 +94,10 @@ namespace dlib
- 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
- 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