Commit bd863f3f authored by Davis King's avatar Davis King

Made it so you can pass a dlib::matrix to the array_to_matrix

and vector_to_matrix functions.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402374
parent a5036437
...@@ -1382,7 +1382,21 @@ namespace dlib ...@@ -1382,7 +1382,21 @@ namespace dlib
template < template <
typename array_type typename array_type
> >
const matrix_exp<matrix_array_exp<array_type> > array_to_matrix ( const typename enable_if<is_matrix<array_type>,array_type>::type&
array_to_matrix (
const array_type& array
)
{
return array;
}
// ----------------------------------------------------------------------------------------
template <
typename array_type
>
const typename disable_if<is_matrix<array_type>,matrix_exp<matrix_array_exp<array_type> > >::type
array_to_matrix (
const array_type& array const array_type& array
) )
{ {
...@@ -1395,7 +1409,8 @@ namespace dlib ...@@ -1395,7 +1409,8 @@ namespace dlib
template < template <
typename vector_type typename vector_type
> >
const matrix_exp<matrix_vector_exp<vector_type> > vector_to_matrix ( const typename disable_if<is_matrix<vector_type>,matrix_exp<matrix_vector_exp<vector_type> > >::type
vector_to_matrix (
const vector_type& vector const vector_type& vector
) )
{ {
...@@ -1403,6 +1418,18 @@ namespace dlib ...@@ -1403,6 +1418,18 @@ namespace dlib
return matrix_exp<exp>(exp(vector)); return matrix_exp<exp>(exp(vector));
} }
// ----------------------------------------------------------------------------------------
template <
typename vector_type
>
const typename enable_if<is_matrix<vector_type>,vector_type>::type& vector_to_matrix (
const vector_type& vector
)
{
return vector;
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template < template <
......
...@@ -152,13 +152,16 @@ namespace dlib ...@@ -152,13 +152,16 @@ namespace dlib
/*! /*!
requires requires
- vector_type is an implementation of array/array_kernel_abstract.h or - vector_type is an implementation of array/array_kernel_abstract.h or
std::vector or dlib::std_vector_c std::vector or dlib::std_vector_c or dlib::matrix
ensures ensures
- returns a matrix R such that: - if (vector_type is a dlib::matrix) then
- R.nr() == vector.size() - returns a reference to vector
- R.nc() == 1 - else
- for all valid r: - returns a matrix R such that:
R(r) == vector[r] - R.nr() == vector.size()
- R.nc() == 1
- for all valid r:
R(r) == vector[r]
!*/ !*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -172,12 +175,16 @@ namespace dlib ...@@ -172,12 +175,16 @@ namespace dlib
/*! /*!
requires requires
- array_type is an implementation of array2d/array2d_kernel_abstract.h - array_type is an implementation of array2d/array2d_kernel_abstract.h
or dlib::matrix
ensures ensures
- returns a matrix R such that: - if (array_type is a dlib::matrix) then
- R.nr() == array.nr() - returns a reference to array
- R.nc() == array.nc() - else
- for all valid r and c: - returns a matrix R such that:
R(r, c) == array[r][c] - R.nr() == array.nr()
- R.nc() == array.nc()
- for all valid r and c:
R(r, c) == array[r][c]
!*/ !*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
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