Commit c96cef9c authored by Davis King's avatar Davis King

Added overload of svd_fast() that doesn't compute u.

parent 6fd1e18a
...@@ -724,6 +724,8 @@ convergence: ...@@ -724,6 +724,8 @@ convergence:
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
namespace simpl
{
template < template <
typename sparse_vector_type, typename sparse_vector_type,
typename T, typename T,
...@@ -734,12 +736,13 @@ convergence: ...@@ -734,12 +736,13 @@ convergence:
typename L typename L
> >
void svd_fast ( void svd_fast (
bool compute_u,
const std::vector<sparse_vector_type>& A, const std::vector<sparse_vector_type>& A,
matrix<T,Unr,Unc,MM,L>& u, matrix<T,Unr,Unc,MM,L>& u,
matrix<T,Wnr,Wnc,MM,L>& w, matrix<T,Wnr,Wnc,MM,L>& w,
matrix<T,Vnr,Vnc,MM,L>& v, matrix<T,Vnr,Vnc,MM,L>& v,
unsigned long l, unsigned long l,
unsigned long q = 1 unsigned long q
) )
{ {
const long n = max_index_plus_one(A); const long n = max_index_plus_one(A);
...@@ -784,8 +787,51 @@ convergence: ...@@ -784,8 +787,51 @@ convergence:
},1); },1);
svd3(B, v,w,u); svd3(B, v,w,u);
if (compute_u)
u = Q*u; u = Q*u;
} }
}
template <
typename sparse_vector_type,
typename T,
long Unr, long Unc,
long Wnr, long Wnc,
long Vnr, long Vnc,
typename MM,
typename L
>
void svd_fast (
const std::vector<sparse_vector_type>& A,
matrix<T,Unr,Unc,MM,L>& u,
matrix<T,Wnr,Wnc,MM,L>& w,
matrix<T,Vnr,Vnc,MM,L>& v,
unsigned long l,
unsigned long q = 1
)
{
simpl::svd_fast(true, A,u,w,v,l,q);
}
template <
typename sparse_vector_type,
typename T,
long Wnr, long Wnc,
long Vnr, long Vnc,
typename MM,
typename L
>
void svd_fast (
const std::vector<sparse_vector_type>& A,
matrix<T,Wnr,Wnc,MM,L>& w,
matrix<T,Vnr,Vnc,MM,L>& v,
unsigned long l,
unsigned long q = 1
)
{
matrix<T,0,0,MM,L> u;
simpl::svd_fast(false, A,u,w,v,l,q);
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -249,6 +249,21 @@ namespace dlib ...@@ -249,6 +249,21 @@ namespace dlib
value should be good for many problems. value should be good for many problems.
!*/ !*/
template <
typename sparse_vector_type,
typename T
>
void svd_fast (
const std::vector<sparse_vector_type>& A,
matrix<T>& w,
matrix<T>& v,
unsigned long l,
unsigned long q = 1
);
/*!
This function is identical to the above svd_fast() except it doesn't compute u.
!*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template < template <
......
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