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
ae9546cb
Commit
ae9546cb
authored
Aug 11, 2014
by
Davis King
Browse files
Made svd3 faster when working on small matrices.
parent
f9fac06e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
dlib/matrix/matrix_la.h
dlib/matrix/matrix_la.h
+13
-9
No files found.
dlib/matrix/matrix_la.h
View file @
ae9546cb
...
...
@@ -1541,16 +1541,21 @@ convergence:
COMPILE_TIME_ASSERT
(
wX
==
0
||
wX
==
1
);
#ifdef DLIB_USE_LAPACK
matrix
<
typename
matrix_exp
<
EXP
>::
type
,
uNR
,
uNC
,
MM1
,
L1
>
temp
(
m
);
lapack
::
gesvd
(
'S'
,
'A'
,
temp
,
w
,
u
,
v
);
v
=
trans
(
v
);
// if u isn't the size we want then pad it (and v) with zeros
if
(
u
.
nc
()
<
m
.
nc
())
// use LAPACK but only if it isn't a really small matrix we are taking the SVD of.
if
(
NR
*
NC
==
0
||
NR
*
NC
>
3
*
3
)
{
w
=
join_cols
(
w
,
zeros_matrix
<
T
>
(
m
.
nc
()
-
u
.
nc
(),
1
));
u
=
join_rows
(
u
,
zeros_matrix
<
T
>
(
u
.
nr
(),
m
.
nc
()
-
u
.
nc
()));
matrix
<
typename
matrix_exp
<
EXP
>::
type
,
uNR
,
uNC
,
MM1
,
L1
>
temp
(
m
);
lapack
::
gesvd
(
'S'
,
'A'
,
temp
,
w
,
u
,
v
);
v
=
trans
(
v
);
// if u isn't the size we want then pad it (and v) with zeros
if
(
u
.
nc
()
<
m
.
nc
())
{
w
=
join_cols
(
w
,
zeros_matrix
<
T
>
(
m
.
nc
()
-
u
.
nc
(),
1
));
u
=
join_rows
(
u
,
zeros_matrix
<
T
>
(
u
.
nr
(),
m
.
nc
()
-
u
.
nc
()));
}
return
;
}
#e
lse
#e
ndif
v
.
set_size
(
m
.
nc
(),
m
.
nc
());
u
=
m
;
...
...
@@ -1558,7 +1563,6 @@ convergence:
w
.
set_size
(
m
.
nc
(),
1
);
matrix
<
T
,
matrix_exp
<
EXP
>::
NC
,
1
,
MM1
>
rv1
(
m
.
nc
(),
1
);
nric
::
svdcmp
(
u
,
w
,
v
,
rv1
);
#endif
}
// ----------------------------------------------------------------------------------------
...
...
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