Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
c96cef9c
Commit
c96cef9c
authored
Jan 24, 2018
by
Davis King
Browse files
Added overload of svd_fast() that doesn't compute u.
parent
6fd1e18a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
42 deletions
+103
-42
dlib/matrix/matrix_la.h
dlib/matrix/matrix_la.h
+88
-42
dlib/matrix/matrix_la_abstract.h
dlib/matrix/matrix_la_abstract.h
+15
-0
No files found.
dlib/matrix/matrix_la.h
View file @
c96cef9c
...
@@ -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
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/matrix/matrix_la_abstract.h
View file @
c96cef9c
...
@@ -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
<
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment