Commit 75b581b8 authored by Davis King's avatar Davis King

Added a bunch of overloads of the kernel_matrix() function for all the various

combinations of vectors of samples and individual samples.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403320
parent 12413f27
This diff is collapsed.
......@@ -11,14 +11,19 @@
namespace dlib
{
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// Symmetric Kernel Matrices
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template <
typename kernel_type
typename kernel_type,
typename alloc
>
const matrix_exp kernel_matrix (
const kernel_type& kernel,
const std::vector<typename kernel_type::sample_type>& m
const std::vector<typename kernel_type::sample_type,alloc>& m
);
/*!
requires
......@@ -54,9 +59,162 @@ namespace dlib
- R(r,c) == kernel(m(r), m(c))
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// Column or Row Kernel Matrices
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
template <
typename kernel_type,
typename alloc
>
const matrix_exp kernel_matrix (
const kernel_type& kern,
const std::vector<typename kernel_type::sample_type,alloc>& m,
const typename kernel_type::sample_type& samp
);
/*!
requires
- kernel == a kernel function object as defined by the file dlib/svm/kernel_abstract.h
ensures
- returns a matrix R such that:
- R::type == kernel_type::scalar_type
- is_col_vector(R) == true
- R.size() == m.size()
- for all valid i:
- R(i) == kernel(m[i], samp)
!*/
// ----------------------------------------------------------------------------------------
template <
typename kernel_type
>
const matrix_exp kernel_matrix (
const kernel_type& kern,
const matrix_exp& m,
const typename kernel_type::sample_type& samp
);
/*!
requires
- kernel == a kernel function object as defined by the file dlib/svm/kernel_abstract.h
- is_vector(m) == true
- the elements of m must be the type of element the given kernel operates on.
(e.g. kernel(m(0), m(1)) should be a legal expression)
ensures
- returns a matrix R such that:
- R::type == kernel_type::scalar_type
- is_col_vector(R) == true
- R.size() == m.size()
- for all valid i:
- R(i) == kernel(m(i), samp)
!*/
// ----------------------------------------------------------------------------------------
template <
typename kernel_type,
typename alloc
>
const matrix_exp kernel_matrix (
const kernel_type& kern,
const typename kernel_type::sample_type& samp,
const std::vector<typename kernel_type::sample_type,alloc>& m
);
/*!
requires
- kernel == a kernel function object as defined by the file dlib/svm/kernel_abstract.h
ensures
- returns a matrix R such that:
- R::type == kernel_type::scalar_type
- is_row_vector(R) == true
- R.size() == m.size()
- for all valid i:
- R(i) == kernel(samp,m[i])
!*/
// ----------------------------------------------------------------------------------------
template <
typename kernel_type
>
const matrix_exp kernel_matrix (
const kernel_type& kern,
const typename kernel_type::sample_type& samp,
const matrix_exp& m
);
/*!
requires
- kernel == a kernel function object as defined by the file dlib/svm/kernel_abstract.h
- is_vector(m) == true
- the elements of m must be the type of element the given kernel operates on.
(e.g. kernel(m(0), m(1)) should be a legal expression)
ensures
- returns a matrix R such that:
- R::type == kernel_type::scalar_type
- is_row_vector(R) == true
- R.size() == m.size()
- for all valid i:
- R(i) == kernel(samp, m(i))
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// Rectangular Kernel Matrices
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template <
typename kernel_type,
typename alloc
>
const matrix_exp kernel_matrix (
const kernel_type& kern,
const std::vector<typename kernel_type::sample_type,alloc>& lhs,
const std::vector<typename kernel_type::sample_type,alloc>& rhs
);
/*!
requires
- kernel == a kernel function object as defined by the file dlib/svm/kernel_abstract.h
ensures
- returns a matrix R such that:
- R::type == kernel_type::scalar_type
- R.nr() == lhs.size()
- R.nc() == rhs.size()
- for all valid r and c:
- R(r,c) == kernel(lhs[r], rhs[c])
!*/
// ----------------------------------------------------------------------------------------
template <
typename kernel_type
>
const kernel_matrix_exp3<kernel_type,EXP1,EXP2> kernel_matrix (
const kernel_type& kern,
const matrix_exp& lhs,
const matrix_exp& rhs
);
/*!
requires
- kernel == a kernel function object as defined by the file dlib/svm/kernel_abstract.h
- is_vector(lhs) == true
- is_vector(rhs) == true
- the elements of lhs and rhs must be the type of element the given kernel operates on.
(e.g. kernel(lhs(0), rhs(0)) should be a legal expression)
ensures
- returns a matrix R such that:
- R::type == kernel_type::scalar_type
- R.nr() == lhs.size()
- R.nc() == rhs.size()
- for all valid r and c:
- R(r,c) == kernel(lhs(r), rhs(c))
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_SVm_KERNEL_MATRIX_ABSTRACT_
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