"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "b8bfef2ab94c423875158076aec481d8a65b7bfa"
Commit 818086a4 authored by Davis King's avatar Davis King
Browse files

Added more constructors to the matrix expression objects so that various potential

errors are avoided entirely.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402734
parent 64b859d0
...@@ -182,10 +182,13 @@ namespace dlib ...@@ -182,10 +182,13 @@ namespace dlib
const EXP& exp const EXP& exp
) : ref_(exp) {} ) : ref_(exp) {}
matrix_exp(const matrix_exp& item) : ref_(item.ref_) {}
private: private:
// you can't copy a matrix_exp at all. Things that inherit from it must
// define their own copy constructors that call the above protected
// constructor so that the reference below is maintained correctly.
matrix_exp(const matrix_exp& item);
matrix_exp& operator= (const matrix_exp&); matrix_exp& operator= (const matrix_exp&);
const exp_type& ref_; const exp_type& ref_;
...@@ -310,6 +313,14 @@ namespace dlib ...@@ -310,6 +313,14 @@ namespace dlib
typedef typename conditional_matrix_temp<const LHS,lhs_is_costly == false>::type LHS_ref_type; typedef typename conditional_matrix_temp<const LHS,lhs_is_costly == false>::type LHS_ref_type;
typedef typename conditional_matrix_temp<const RHS,rhs_is_costly == false>::type RHS_ref_type; typedef typename conditional_matrix_temp<const RHS,rhs_is_costly == false>::type RHS_ref_type;
matrix_multiply_exp (
const matrix_multiply_exp& item
) : matrix_exp<matrix_multiply_exp>(*this), lhs(item.lhs), rhs(item.rhs) {}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1, typename T2>
matrix_multiply_exp (T1,T2);
inline matrix_multiply_exp ( inline matrix_multiply_exp (
const LHS& lhs_, const LHS& lhs_,
...@@ -409,11 +420,14 @@ namespace dlib ...@@ -409,11 +420,14 @@ namespace dlib
const static long NC = matrix_traits<matrix_add_exp>::NC; const static long NC = matrix_traits<matrix_add_exp>::NC;
const static long cost = matrix_traits<matrix_add_exp>::cost; const static long cost = matrix_traits<matrix_add_exp>::cost;
/*
matrix_add_exp ( matrix_add_exp (
const matrix_add_exp& item const matrix_add_exp& item
) : matrix_exp<matrix_add_exp>(*this), lhs(item.lhs), rhs(item.rhs) {} ) : matrix_exp<matrix_add_exp>(*this), lhs(item.lhs), rhs(item.rhs) {}
*/
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1, typename T2>
matrix_add_exp (T1,T2);
matrix_add_exp ( matrix_add_exp (
const LHS& lhs_, const LHS& lhs_,
...@@ -514,6 +528,14 @@ namespace dlib ...@@ -514,6 +528,14 @@ namespace dlib
const static long NC = matrix_traits<matrix_subtract_exp>::NC; const static long NC = matrix_traits<matrix_subtract_exp>::NC;
const static long cost = matrix_traits<matrix_subtract_exp>::cost; const static long cost = matrix_traits<matrix_subtract_exp>::cost;
matrix_subtract_exp (
const matrix_subtract_exp& item
) : matrix_exp<matrix_subtract_exp>(*this), lhs(item.lhs), rhs(item.rhs) {}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1, typename T2>
matrix_subtract_exp (T1,T2);
matrix_subtract_exp ( matrix_subtract_exp (
const LHS& lhs_, const LHS& lhs_,
...@@ -617,6 +639,15 @@ namespace dlib ...@@ -617,6 +639,15 @@ namespace dlib
const static long NC = matrix_traits<matrix_div_scal_exp>::NC; const static long NC = matrix_traits<matrix_div_scal_exp>::NC;
const static long cost = matrix_traits<matrix_div_scal_exp>::cost; const static long cost = matrix_traits<matrix_div_scal_exp>::cost;
matrix_div_scal_exp (
const matrix_div_scal_exp& item
) : matrix_exp<matrix_div_scal_exp>(*this), m(item.m), s(item.s) {}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1>
matrix_div_scal_exp (T1, const S&);
matrix_div_scal_exp ( matrix_div_scal_exp (
const M& m_, const M& m_,
const S& s_ const S& s_
...@@ -701,6 +732,15 @@ namespace dlib ...@@ -701,6 +732,15 @@ namespace dlib
const static long NC = matrix_traits<matrix_mul_scal_exp>::NC; const static long NC = matrix_traits<matrix_mul_scal_exp>::NC;
const static long cost = matrix_traits<matrix_mul_scal_exp>::cost; const static long cost = matrix_traits<matrix_mul_scal_exp>::cost;
matrix_mul_scal_exp (
const matrix_mul_scal_exp& item
) : matrix_exp<matrix_mul_scal_exp>(*this), m(item.m), s(item.s) {}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1>
matrix_mul_scal_exp (T1, const S&);
matrix_mul_scal_exp ( matrix_mul_scal_exp (
const M& m_, const M& m_,
const S& s_ const S& s_
......
...@@ -58,6 +58,18 @@ namespace dlib ...@@ -58,6 +58,18 @@ namespace dlib
const static long NC = matrix_traits<matrix_unary_exp>::NC; const static long NC = matrix_traits<matrix_unary_exp>::NC;
const static long cost = matrix_traits<matrix_unary_exp>::cost; const static long cost = matrix_traits<matrix_unary_exp>::cost;
matrix_unary_exp (
const matrix_unary_exp& item
) :
matrix_exp<matrix_unary_exp>(*this),
m(item.m)
{}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1>
matrix_unary_exp (T1);
matrix_unary_exp ( matrix_unary_exp (
const M& m_ const M& m_
) : ) :
...@@ -130,6 +142,19 @@ namespace dlib ...@@ -130,6 +142,19 @@ namespace dlib
const static long NC = matrix_traits<matrix_scalar_binary_exp>::NC; const static long NC = matrix_traits<matrix_scalar_binary_exp>::NC;
const static long cost = matrix_traits<matrix_scalar_binary_exp>::cost; const static long cost = matrix_traits<matrix_scalar_binary_exp>::cost;
matrix_scalar_binary_exp (
const matrix_scalar_binary_exp& item
) :
matrix_exp<matrix_scalar_binary_exp>(*this),
m(item.m),
s(item.s)
{}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1>
matrix_scalar_binary_exp (T1,const S&);
matrix_scalar_binary_exp ( matrix_scalar_binary_exp (
const M& m_, const M& m_,
const S& s_ const S& s_
...@@ -207,6 +232,21 @@ namespace dlib ...@@ -207,6 +232,21 @@ namespace dlib
const static long NC = matrix_traits<matrix_scalar_ternary_exp>::NC; const static long NC = matrix_traits<matrix_scalar_ternary_exp>::NC;
const static long cost = matrix_traits<matrix_scalar_ternary_exp>::cost; const static long cost = matrix_traits<matrix_scalar_ternary_exp>::cost;
matrix_scalar_ternary_exp (
const matrix_scalar_ternary_exp& item
) :
matrix_exp<matrix_scalar_ternary_exp>(*this),
m(item.m),
s1(item.s1),
s2(item.s2)
{
}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1>
matrix_scalar_ternary_exp (T1, const S&, const S&);
matrix_scalar_ternary_exp ( matrix_scalar_ternary_exp (
const M& m_, const M& m_,
const S& s1_, const S& s1_,
...@@ -287,6 +327,19 @@ namespace dlib ...@@ -287,6 +327,19 @@ namespace dlib
const static long NC = matrix_traits<matrix_binary_exp>::NC; const static long NC = matrix_traits<matrix_binary_exp>::NC;
const static long cost = matrix_traits<matrix_binary_exp>::cost; const static long cost = matrix_traits<matrix_binary_exp>::cost;
matrix_binary_exp (
const matrix_binary_exp& item
) :
matrix_exp<matrix_binary_exp>(*this),
m1(item.m1),
m2(item.m2)
{}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1, typename T2>
matrix_binary_exp (T1,T2);
matrix_binary_exp ( matrix_binary_exp (
const M1& m1_, const M1& m1_,
const M2& m2_ const M2& m2_
...@@ -363,6 +416,20 @@ namespace dlib ...@@ -363,6 +416,20 @@ namespace dlib
const static long NC = matrix_traits<matrix_ternary_exp>::NC; const static long NC = matrix_traits<matrix_ternary_exp>::NC;
const static long cost = matrix_traits<matrix_ternary_exp>::cost; const static long cost = matrix_traits<matrix_ternary_exp>::cost;
matrix_ternary_exp (
const matrix_ternary_exp& item
) :
matrix_exp<matrix_ternary_exp>(*this),
m1(item.m1),
m2(item.m2),
m3(item.m3)
{}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1, typename T2, typename T3>
matrix_ternary_exp ( T1, T2, T3 );
matrix_ternary_exp ( matrix_ternary_exp (
const M1& m1_, const M1& m1_,
const M2& m2_, const M2& m2_,
...@@ -443,6 +510,21 @@ namespace dlib ...@@ -443,6 +510,21 @@ namespace dlib
const static long NC = matrix_traits<matrix_fourary_exp>::NC; const static long NC = matrix_traits<matrix_fourary_exp>::NC;
const static long cost = matrix_traits<matrix_fourary_exp>::cost; const static long cost = matrix_traits<matrix_fourary_exp>::cost;
matrix_fourary_exp (
const matrix_fourary_exp& item
) :
matrix_exp<matrix_fourary_exp>(*this),
m1(item.m1),
m2(item.m2),
m3(item.m3),
m4(item.m4)
{}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1, typename T2, typename T3, typename T4>
matrix_fourary_exp (T1,T2,T3,T4);
matrix_fourary_exp ( matrix_fourary_exp (
const M1& m1_, const M1& m1_,
const M2& m2_, const M2& m2_,
...@@ -520,6 +602,14 @@ namespace dlib ...@@ -520,6 +602,14 @@ namespace dlib
const static long NC = matrix_traits<dynamic_matrix_scalar_unary_exp>::NC; const static long NC = matrix_traits<dynamic_matrix_scalar_unary_exp>::NC;
const static long cost = matrix_traits<dynamic_matrix_scalar_unary_exp>::cost; const static long cost = matrix_traits<dynamic_matrix_scalar_unary_exp>::cost;
dynamic_matrix_scalar_unary_exp (
const dynamic_matrix_scalar_unary_exp& item
) :
matrix_exp<dynamic_matrix_scalar_unary_exp>(*this),
nr_(item.nr_),
nc_(item.nc_),
s(item.s)
{}
dynamic_matrix_scalar_unary_exp ( dynamic_matrix_scalar_unary_exp (
long nr__, long nr__,
...@@ -597,6 +687,13 @@ namespace dlib ...@@ -597,6 +687,13 @@ namespace dlib
const static long NC = matrix_traits<matrix_scalar_unary_exp>::NC; const static long NC = matrix_traits<matrix_scalar_unary_exp>::NC;
const static long cost = matrix_traits<matrix_scalar_unary_exp>::cost; const static long cost = matrix_traits<matrix_scalar_unary_exp>::cost;
matrix_scalar_unary_exp (
const matrix_scalar_unary_exp& item
) :
matrix_exp<matrix_scalar_unary_exp>(*this),
s(item.s)
{}
matrix_scalar_unary_exp ( matrix_scalar_unary_exp (
const S& s_ const S& s_
) : ) :
...@@ -662,6 +759,12 @@ namespace dlib ...@@ -662,6 +759,12 @@ namespace dlib
const static long NC = matrix_traits<matrix_zeroary_exp>::NC; const static long NC = matrix_traits<matrix_zeroary_exp>::NC;
const static long cost = matrix_traits<matrix_zeroary_exp>::cost; const static long cost = matrix_traits<matrix_zeroary_exp>::cost;
matrix_zeroary_exp (
const matrix_zeroary_exp& item
) :
matrix_exp<matrix_zeroary_exp>(*this)
{}
matrix_zeroary_exp ( matrix_zeroary_exp (
) : ) :
matrix_exp<matrix_zeroary_exp>(*this) matrix_exp<matrix_zeroary_exp>(*this)
...@@ -730,6 +833,21 @@ namespace dlib ...@@ -730,6 +833,21 @@ namespace dlib
const static long NC = matrix_traits<matrix_sub_range_exp>::NC; const static long NC = matrix_traits<matrix_sub_range_exp>::NC;
const static long cost = matrix_traits<matrix_sub_range_exp>::cost; const static long cost = matrix_traits<matrix_sub_range_exp>::cost;
matrix_sub_range_exp (
const matrix_sub_range_exp& item
) :
matrix_exp<matrix_sub_range_exp>(*this),
m(item.m),
rows(item.rows),
cols(item.cols)
{
}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1, typename T2, typename T3>
matrix_sub_range_exp (T1,T2,T3);
matrix_sub_range_exp ( matrix_sub_range_exp (
const M& m_, const M& m_,
const EXPr& rows_, const EXPr& rows_,
...@@ -805,6 +923,19 @@ namespace dlib ...@@ -805,6 +923,19 @@ namespace dlib
const static long NC = matrix_traits<matrix_std_vector_exp>::NC; const static long NC = matrix_traits<matrix_std_vector_exp>::NC;
const static long cost = matrix_traits<matrix_std_vector_exp>::cost; const static long cost = matrix_traits<matrix_std_vector_exp>::cost;
matrix_std_vector_exp (
const matrix_std_vector_exp& item
) :
matrix_exp<matrix_std_vector_exp>(*this),
m(item.m)
{
}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1>
matrix_std_vector_exp (T1);
matrix_std_vector_exp ( matrix_std_vector_exp (
const M& m_ const M& m_
) : ) :
...@@ -873,6 +1004,19 @@ namespace dlib ...@@ -873,6 +1004,19 @@ namespace dlib
const static long NC = matrix_traits<matrix_array_exp>::NC; const static long NC = matrix_traits<matrix_array_exp>::NC;
const static long cost = matrix_traits<matrix_array_exp>::cost; const static long cost = matrix_traits<matrix_array_exp>::cost;
matrix_array_exp (
const matrix_array_exp& item
) :
matrix_exp<matrix_array_exp>(*this),
m(item.m)
{
}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1>
matrix_array_exp (T1);
matrix_array_exp ( matrix_array_exp (
const M& m_ const M& m_
) : ) :
...@@ -941,6 +1085,19 @@ namespace dlib ...@@ -941,6 +1085,19 @@ namespace dlib
const static long NC = matrix_traits<matrix_array2d_exp>::NC; const static long NC = matrix_traits<matrix_array2d_exp>::NC;
const static long cost = matrix_traits<matrix_array2d_exp>::cost; const static long cost = matrix_traits<matrix_array2d_exp>::cost;
matrix_array2d_exp (
const matrix_array2d_exp& item
) :
matrix_exp<matrix_array2d_exp>(*this),
m(item.m)
{
}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1>
matrix_array2d_exp (T1);
matrix_array2d_exp ( matrix_array2d_exp (
const M& m_ const M& m_
) : ) :
...@@ -1008,6 +1165,23 @@ namespace dlib ...@@ -1008,6 +1165,23 @@ namespace dlib
const static long NC = matrix_traits<matrix_sub_exp>::NC; const static long NC = matrix_traits<matrix_sub_exp>::NC;
const static long cost = matrix_traits<matrix_sub_exp>::cost; const static long cost = matrix_traits<matrix_sub_exp>::cost;
matrix_sub_exp (
const matrix_sub_exp& item
) :
matrix_exp<matrix_sub_exp>(*this),
m(item.m),
r_(item.r_),
c_(item.c_),
nr_(item.nr_),
nc_(item.nc_)
{
}
// This constructor exists simply for the purpose of causing a compile time error if
// someone tries to create an instance of this object with the wrong kind of objects.
template <typename T1>
matrix_sub_exp (T1, long, long, long, long);
matrix_sub_exp ( matrix_sub_exp (
const M& m_, const M& m_,
const long& r__, const long& r__,
...@@ -1077,6 +1251,15 @@ namespace dlib ...@@ -1077,6 +1251,15 @@ namespace dlib
const static long NC = matrix_traits<matrix_range_exp>::NC; const static long NC = matrix_traits<matrix_range_exp>::NC;
const static long cost = matrix_traits<matrix_range_exp>::cost; const static long cost = matrix_traits<matrix_range_exp>::cost;
matrix_range_exp (
const matrix_range_exp& item
) :
matrix_exp<matrix_range_exp>(*this),
nr_(item.nr_),
start(item.start),
inc(item.inc)
{}
matrix_range_exp ( matrix_range_exp (
long start_, long start_,
long end_ long end_
...@@ -1162,6 +1345,12 @@ namespace dlib ...@@ -1162,6 +1345,12 @@ namespace dlib
const static long inc = (start <= end)?inc_:-inc_; const static long inc = (start <= end)?inc_:-inc_;
matrix_range_static_exp (
const matrix_range_static_exp& item
) :
matrix_exp<matrix_range_static_exp>(*this)
{}
matrix_range_static_exp ( matrix_range_static_exp (
) : ) :
matrix_exp<matrix_range_static_exp>(*this) matrix_exp<matrix_range_static_exp>(*this)
......
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