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
e7c770f0
Commit
e7c770f0
authored
Jan 14, 2013
by
Davis King
Browse files
Made cca() more numerically robust.
parent
38ed409e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
dlib/statistics/cca.h
dlib/statistics/cca.h
+10
-2
No files found.
dlib/statistics/cca.h
View file @
e7c770f0
...
@@ -65,8 +65,16 @@ namespace dlib
...
@@ -65,8 +65,16 @@ namespace dlib
svd_fast
(
L
,
Ul
,
Dl
,
Vl
,
num_correlations
+
extra_rank
,
q
);
svd_fast
(
L
,
Ul
,
Dl
,
Vl
,
num_correlations
+
extra_rank
,
q
);
svd_fast
(
R
,
Ur
,
Dr
,
Vr
,
num_correlations
+
extra_rank
,
q
);
svd_fast
(
R
,
Ur
,
Dr
,
Vr
,
num_correlations
+
extra_rank
,
q
);
// This matrix is really small so we can do a normal full SVD on it.
// Zero out singular values that are essentially zero so they don't cause numerical
svd3
(
trans
(
Ul
)
*
Ur
,
U
,
D
,
V
);
// difficulties in the code below.
const
double
eps
=
std
::
numeric_limits
<
T
>::
epsilon
()
*
std
::
max
(
max
(
Dr
),
max
(
Dl
))
*
100
;
Dl
=
round_zeros
(
Dl
,
eps
);
Dr
=
round_zeros
(
Dr
,
eps
);
// This matrix is really small so we can do a normal full SVD on it. Note that we
// also throw away the columns of Ul and Ur corresponding to zero singular values.
svd3
(
diagm
(
Dl
>
0
)
*
tmp
(
trans
(
Ul
)
*
Ur
)
*
diagm
(
Dr
>
0
),
U
,
D
,
V
);
// now throw away extra columns of the transformations. We do this in a way
// now throw away extra columns of the transformations. We do this in a way
// that keeps the directions that have the highest correlations.
// that keeps the directions that have the highest correlations.
matrix
<
T
,
0
,
1
>
temp
=
D
;
matrix
<
T
,
0
,
1
>
temp
=
D
;
...
...
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