Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
e93639f1
Commit
e93639f1
authored
Dec 29, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
These changes don't actually change what the code does, but they
avoid some silly warnings from gcc 4.4 and 4.5.
parent
a8337a66
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
93 deletions
+93
-93
matrix_data_layout.h
dlib/matrix/matrix_data_layout.h
+10
-10
matrix_eigenvalue.h
dlib/matrix/matrix_eigenvalue.h
+83
-83
No files found.
dlib/matrix/matrix_data_layout.h
View file @
e93639f1
...
@@ -133,20 +133,20 @@ namespace dlib
...
@@ -133,20 +133,20 @@ namespace dlib
T
&
operator
()
(
T
&
operator
()
(
long
r
,
long
r
,
long
c
long
c
)
{
return
data
[
r
][
c
]
;
}
)
{
return
*
(
data
+
r
*
num_cols
+
c
)
;
}
const
T
&
operator
()
(
const
T
&
operator
()
(
long
r
,
long
r
,
long
c
long
c
)
const
{
return
data
[
r
][
c
]
;
}
)
const
{
return
*
(
data
+
r
*
num_cols
+
c
)
;
}
T
&
operator
()
(
T
&
operator
()
(
long
i
long
i
)
{
return
*
(
*
data
+
i
)
;
}
)
{
return
data
[
i
]
;
}
const
T
&
operator
()
(
const
T
&
operator
()
(
long
i
long
i
)
const
{
return
*
(
*
data
+
i
)
;
}
)
const
{
return
data
[
i
]
;
}
void
swap
(
void
swap
(
layout
&
item
layout
&
item
...
@@ -175,7 +175,7 @@ namespace dlib
...
@@ -175,7 +175,7 @@ namespace dlib
}
}
private
:
private
:
T
data
[
num_rows
][
num_cols
];
T
data
[
num_rows
*
num_cols
];
};
};
// ------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------
...
@@ -546,20 +546,20 @@ namespace dlib
...
@@ -546,20 +546,20 @@ namespace dlib
T
&
operator
()
(
T
&
operator
()
(
long
r
,
long
r
,
long
c
long
c
)
{
return
data
[
c
][
r
]
;
}
)
{
return
*
(
data
+
c
*
num_rows
+
r
)
;
}
const
T
&
operator
()
(
const
T
&
operator
()
(
long
r
,
long
r
,
long
c
long
c
)
const
{
return
data
[
c
][
r
]
;
}
)
const
{
return
*
(
data
+
c
*
num_rows
+
r
)
;
}
T
&
operator
()
(
T
&
operator
()
(
long
i
long
i
)
{
return
*
(
*
data
+
i
)
;
}
)
{
return
data
[
i
]
;
}
const
T
&
operator
()
(
const
T
&
operator
()
(
long
i
long
i
)
const
{
return
*
(
*
data
+
i
)
;
}
)
const
{
return
data
[
i
]
;
}
void
swap
(
void
swap
(
layout
&
item
layout
&
item
...
@@ -588,7 +588,7 @@ namespace dlib
...
@@ -588,7 +588,7 @@ namespace dlib
}
}
private
:
private
:
T
data
[
num_cols
][
num_rows
];
T
data
[
num_cols
*
num_rows
];
};
};
// ------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------
...
...
dlib/matrix/matrix_eigenvalue.h
View file @
e93639f1
...
@@ -87,7 +87,7 @@ namespace dlib
...
@@ -87,7 +87,7 @@ namespace dlib
private
:
private
:
/** Row and column dimension (square matrix). */
/** Row and column dimension (square matrix). */
int
n
;
long
n
;
bool
issymmetric
;
bool
issymmetric
;
...
@@ -167,9 +167,9 @@ namespace dlib
...
@@ -167,9 +167,9 @@ namespace dlib
issymmetric
=
true
;
issymmetric
=
true
;
for
(
int
j
=
0
;
(
j
<
n
)
&&
issymmetric
;
j
++
)
for
(
long
j
=
0
;
(
j
<
n
)
&&
issymmetric
;
j
++
)
{
{
for
(
int
i
=
0
;
(
i
<
n
)
&&
issymmetric
;
i
++
)
for
(
long
i
=
0
;
(
i
<
n
)
&&
issymmetric
;
i
++
)
{
{
issymmetric
=
(
A
(
i
,
j
)
==
A
(
j
,
i
));
issymmetric
=
(
A
(
i
,
j
)
==
A
(
j
,
i
));
}
}
...
@@ -352,7 +352,7 @@ namespace dlib
...
@@ -352,7 +352,7 @@ namespace dlib
{
{
complex_matrix_type
CV
(
n
,
n
);
complex_matrix_type
CV
(
n
,
n
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
for
(
long
i
=
0
;
i
<
n
;
i
++
)
{
{
if
(
e
(
i
)
>
0
)
if
(
e
(
i
)
>
0
)
{
{
...
@@ -380,9 +380,9 @@ namespace dlib
...
@@ -380,9 +380,9 @@ namespace dlib
{
{
matrix_type
D
(
n
,
n
);
matrix_type
D
(
n
,
n
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
for
(
long
i
=
0
;
i
<
n
;
i
++
)
{
{
for
(
int
j
=
0
;
j
<
n
;
j
++
)
for
(
long
j
=
0
;
j
<
n
;
j
++
)
{
{
D
(
i
,
j
)
=
0
.
0
;
D
(
i
,
j
)
=
0
.
0
;
}
}
...
@@ -419,28 +419,28 @@ namespace dlib
...
@@ -419,28 +419,28 @@ namespace dlib
// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
// Fortran subroutine in EISPACK.
// Fortran subroutine in EISPACK.
for
(
int
j
=
0
;
j
<
n
;
j
++
)
for
(
long
j
=
0
;
j
<
n
;
j
++
)
{
{
d
(
j
)
=
V
(
n
-
1
,
j
);
d
(
j
)
=
V
(
n
-
1
,
j
);
}
}
// Householder reduction to tridiagonal form.
// Householder reduction to tridiagonal form.
for
(
int
i
=
n
-
1
;
i
>
0
;
i
--
)
for
(
long
i
=
n
-
1
;
i
>
0
;
i
--
)
{
{
// Scale to avoid under/overflow.
// Scale to avoid under/overflow.
type
scale
=
0
.
0
;
type
scale
=
0
.
0
;
type
h
=
0
.
0
;
type
h
=
0
.
0
;
for
(
int
k
=
0
;
k
<
i
;
k
++
)
for
(
long
k
=
0
;
k
<
i
;
k
++
)
{
{
scale
=
scale
+
abs
(
d
(
k
));
scale
=
scale
+
abs
(
d
(
k
));
}
}
if
(
scale
==
0
.
0
)
if
(
scale
==
0
.
0
)
{
{
e
(
i
)
=
d
(
i
-
1
);
e
(
i
)
=
d
(
i
-
1
);
for
(
int
j
=
0
;
j
<
i
;
j
++
)
for
(
long
j
=
0
;
j
<
i
;
j
++
)
{
{
d
(
j
)
=
V
(
i
-
1
,
j
);
d
(
j
)
=
V
(
i
-
1
,
j
);
V
(
i
,
j
)
=
0
.
0
;
V
(
i
,
j
)
=
0
.
0
;
...
@@ -452,7 +452,7 @@ namespace dlib
...
@@ -452,7 +452,7 @@ namespace dlib
// Generate Householder vector.
// Generate Householder vector.
for
(
int
k
=
0
;
k
<
i
;
k
++
)
for
(
long
k
=
0
;
k
<
i
;
k
++
)
{
{
d
(
k
)
/=
scale
;
d
(
k
)
/=
scale
;
h
+=
d
(
k
)
*
d
(
k
);
h
+=
d
(
k
)
*
d
(
k
);
...
@@ -466,19 +466,19 @@ namespace dlib
...
@@ -466,19 +466,19 @@ namespace dlib
e
(
i
)
=
scale
*
g
;
e
(
i
)
=
scale
*
g
;
h
=
h
-
f
*
g
;
h
=
h
-
f
*
g
;
d
(
i
-
1
)
=
f
-
g
;
d
(
i
-
1
)
=
f
-
g
;
for
(
int
j
=
0
;
j
<
i
;
j
++
)
for
(
long
j
=
0
;
j
<
i
;
j
++
)
{
{
e
(
j
)
=
0
.
0
;
e
(
j
)
=
0
.
0
;
}
}
// Apply similarity transformation to remaining columns.
// Apply similarity transformation to remaining columns.
for
(
int
j
=
0
;
j
<
i
;
j
++
)
for
(
long
j
=
0
;
j
<
i
;
j
++
)
{
{
f
=
d
(
j
);
f
=
d
(
j
);
V
(
j
,
i
)
=
f
;
V
(
j
,
i
)
=
f
;
g
=
e
(
j
)
+
V
(
j
,
j
)
*
f
;
g
=
e
(
j
)
+
V
(
j
,
j
)
*
f
;
for
(
int
k
=
j
+
1
;
k
<=
i
-
1
;
k
++
)
for
(
long
k
=
j
+
1
;
k
<=
i
-
1
;
k
++
)
{
{
g
+=
V
(
k
,
j
)
*
d
(
k
);
g
+=
V
(
k
,
j
)
*
d
(
k
);
e
(
k
)
+=
V
(
k
,
j
)
*
f
;
e
(
k
)
+=
V
(
k
,
j
)
*
f
;
...
@@ -486,21 +486,21 @@ namespace dlib
...
@@ -486,21 +486,21 @@ namespace dlib
e
(
j
)
=
g
;
e
(
j
)
=
g
;
}
}
f
=
0
.
0
;
f
=
0
.
0
;
for
(
int
j
=
0
;
j
<
i
;
j
++
)
for
(
long
j
=
0
;
j
<
i
;
j
++
)
{
{
e
(
j
)
/=
h
;
e
(
j
)
/=
h
;
f
+=
e
(
j
)
*
d
(
j
);
f
+=
e
(
j
)
*
d
(
j
);
}
}
type
hh
=
f
/
(
h
+
h
);
type
hh
=
f
/
(
h
+
h
);
for
(
int
j
=
0
;
j
<
i
;
j
++
)
for
(
long
j
=
0
;
j
<
i
;
j
++
)
{
{
e
(
j
)
-=
hh
*
d
(
j
);
e
(
j
)
-=
hh
*
d
(
j
);
}
}
for
(
int
j
=
0
;
j
<
i
;
j
++
)
for
(
long
j
=
0
;
j
<
i
;
j
++
)
{
{
f
=
d
(
j
);
f
=
d
(
j
);
g
=
e
(
j
);
g
=
e
(
j
);
for
(
int
k
=
j
;
k
<=
i
-
1
;
k
++
)
for
(
long
k
=
j
;
k
<=
i
-
1
;
k
++
)
{
{
V
(
k
,
j
)
-=
(
f
*
e
(
k
)
+
g
*
d
(
k
));
V
(
k
,
j
)
-=
(
f
*
e
(
k
)
+
g
*
d
(
k
));
}
}
...
@@ -513,36 +513,36 @@ namespace dlib
...
@@ -513,36 +513,36 @@ namespace dlib
// Accumulate transformations.
// Accumulate transformations.
for
(
int
i
=
0
;
i
<
n
-
1
;
i
++
)
for
(
long
i
=
0
;
i
<
n
-
1
;
i
++
)
{
{
V
(
n
-
1
,
i
)
=
V
(
i
,
i
);
V
(
n
-
1
,
i
)
=
V
(
i
,
i
);
V
(
i
,
i
)
=
1
.
0
;
V
(
i
,
i
)
=
1
.
0
;
type
h
=
d
(
i
+
1
);
type
h
=
d
(
i
+
1
);
if
(
h
!=
0
.
0
)
if
(
h
!=
0
.
0
)
{
{
for
(
int
k
=
0
;
k
<=
i
;
k
++
)
for
(
long
k
=
0
;
k
<=
i
;
k
++
)
{
{
d
(
k
)
=
V
(
k
,
i
+
1
)
/
h
;
d
(
k
)
=
V
(
k
,
i
+
1
)
/
h
;
}
}
for
(
int
j
=
0
;
j
<=
i
;
j
++
)
for
(
long
j
=
0
;
j
<=
i
;
j
++
)
{
{
type
g
=
0
.
0
;
type
g
=
0
.
0
;
for
(
int
k
=
0
;
k
<=
i
;
k
++
)
for
(
long
k
=
0
;
k
<=
i
;
k
++
)
{
{
g
+=
V
(
k
,
i
+
1
)
*
V
(
k
,
j
);
g
+=
V
(
k
,
i
+
1
)
*
V
(
k
,
j
);
}
}
for
(
int
k
=
0
;
k
<=
i
;
k
++
)
for
(
long
k
=
0
;
k
<=
i
;
k
++
)
{
{
V
(
k
,
j
)
-=
g
*
d
(
k
);
V
(
k
,
j
)
-=
g
*
d
(
k
);
}
}
}
}
}
}
for
(
int
k
=
0
;
k
<=
i
;
k
++
)
for
(
long
k
=
0
;
k
<=
i
;
k
++
)
{
{
V
(
k
,
i
+
1
)
=
0
.
0
;
V
(
k
,
i
+
1
)
=
0
.
0
;
}
}
}
}
for
(
int
j
=
0
;
j
<
n
;
j
++
)
for
(
long
j
=
0
;
j
<
n
;
j
++
)
{
{
d
(
j
)
=
V
(
n
-
1
,
j
);
d
(
j
)
=
V
(
n
-
1
,
j
);
V
(
n
-
1
,
j
)
=
0
.
0
;
V
(
n
-
1
,
j
)
=
0
.
0
;
...
@@ -567,7 +567,7 @@ namespace dlib
...
@@ -567,7 +567,7 @@ namespace dlib
// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
// Fortran subroutine in EISPACK.
// Fortran subroutine in EISPACK.
for
(
int
i
=
1
;
i
<
n
;
i
++
)
for
(
long
i
=
1
;
i
<
n
;
i
++
)
{
{
e
(
i
-
1
)
=
e
(
i
);
e
(
i
-
1
)
=
e
(
i
);
}
}
...
@@ -576,13 +576,13 @@ namespace dlib
...
@@ -576,13 +576,13 @@ namespace dlib
type
f
=
0
.
0
;
type
f
=
0
.
0
;
type
tst1
=
0
.
0
;
type
tst1
=
0
.
0
;
const
type
eps
=
std
::
numeric_limits
<
type
>::
epsilon
();
const
type
eps
=
std
::
numeric_limits
<
type
>::
epsilon
();
for
(
int
l
=
0
;
l
<
n
;
l
++
)
for
(
long
l
=
0
;
l
<
n
;
l
++
)
{
{
// Find small subdiagonal element
// Find small subdiagonal element
tst1
=
max
(
tst1
,
abs
(
d
(
l
))
+
abs
(
e
(
l
)));
tst1
=
max
(
tst1
,
abs
(
d
(
l
))
+
abs
(
e
(
l
)));
int
m
=
l
;
long
m
=
l
;
// Original while-loop from Java code
// Original while-loop from Java code
while
(
m
<
n
)
while
(
m
<
n
)
...
@@ -600,7 +600,7 @@ namespace dlib
...
@@ -600,7 +600,7 @@ namespace dlib
if
(
m
>
l
)
if
(
m
>
l
)
{
{
int
iter
=
0
;
long
iter
=
0
;
do
do
{
{
iter
=
iter
+
1
;
// (Could check iteration count here.)
iter
=
iter
+
1
;
// (Could check iteration count here.)
...
@@ -618,7 +618,7 @@ namespace dlib
...
@@ -618,7 +618,7 @@ namespace dlib
d
(
l
+
1
)
=
e
(
l
)
*
(
p
+
r
);
d
(
l
+
1
)
=
e
(
l
)
*
(
p
+
r
);
type
dl1
=
d
(
l
+
1
);
type
dl1
=
d
(
l
+
1
);
type
h
=
g
-
d
(
l
);
type
h
=
g
-
d
(
l
);
for
(
int
i
=
l
+
2
;
i
<
n
;
i
++
)
for
(
long
i
=
l
+
2
;
i
<
n
;
i
++
)
{
{
d
(
i
)
-=
h
;
d
(
i
)
-=
h
;
}
}
...
@@ -633,7 +633,7 @@ namespace dlib
...
@@ -633,7 +633,7 @@ namespace dlib
type
el1
=
e
(
l
+
1
);
type
el1
=
e
(
l
+
1
);
type
s
=
0
.
0
;
type
s
=
0
.
0
;
type
s2
=
0
.
0
;
type
s2
=
0
.
0
;
for
(
int
i
=
m
-
1
;
i
>=
l
;
i
--
)
for
(
long
i
=
m
-
1
;
i
>=
l
;
i
--
)
{
{
c3
=
c2
;
c3
=
c2
;
c2
=
c
;
c2
=
c
;
...
@@ -649,7 +649,7 @@ namespace dlib
...
@@ -649,7 +649,7 @@ namespace dlib
// Accumulate transformation.
// Accumulate transformation.
for
(
int
k
=
0
;
k
<
n
;
k
++
)
for
(
long
k
=
0
;
k
<
n
;
k
++
)
{
{
h
=
V
(
k
,
i
+
1
);
h
=
V
(
k
,
i
+
1
);
V
(
k
,
i
+
1
)
=
s
*
V
(
k
,
i
)
+
c
*
h
;
V
(
k
,
i
+
1
)
=
s
*
V
(
k
,
i
)
+
c
*
h
;
...
@@ -694,16 +694,16 @@ namespace dlib
...
@@ -694,16 +694,16 @@ namespace dlib
// Vol.ii-Linear Algebra, and the corresponding
// Vol.ii-Linear Algebra, and the corresponding
// Fortran subroutines in EISPACK.
// Fortran subroutines in EISPACK.
int
low
=
0
;
long
low
=
0
;
int
high
=
n
-
1
;
long
high
=
n
-
1
;
for
(
int
m
=
low
+
1
;
m
<=
high
-
1
;
m
++
)
for
(
long
m
=
low
+
1
;
m
<=
high
-
1
;
m
++
)
{
{
// Scale column.
// Scale column.
type
scale
=
0
.
0
;
type
scale
=
0
.
0
;
for
(
int
i
=
m
;
i
<=
high
;
i
++
)
for
(
long
i
=
m
;
i
<=
high
;
i
++
)
{
{
scale
=
scale
+
abs
(
H
(
i
,
m
-
1
));
scale
=
scale
+
abs
(
H
(
i
,
m
-
1
));
}
}
...
@@ -713,7 +713,7 @@ namespace dlib
...
@@ -713,7 +713,7 @@ namespace dlib
// Compute Householder transformation.
// Compute Householder transformation.
type
h
=
0
.
0
;
type
h
=
0
.
0
;
for
(
int
i
=
high
;
i
>=
m
;
i
--
)
for
(
long
i
=
high
;
i
>=
m
;
i
--
)
{
{
ort
(
i
)
=
H
(
i
,
m
-
1
)
/
scale
;
ort
(
i
)
=
H
(
i
,
m
-
1
)
/
scale
;
h
+=
ort
(
i
)
*
ort
(
i
);
h
+=
ort
(
i
)
*
ort
(
i
);
...
@@ -729,29 +729,29 @@ namespace dlib
...
@@ -729,29 +729,29 @@ namespace dlib
// Apply Householder similarity transformation
// Apply Householder similarity transformation
// H = (I-u*u'/h)*H*(I-u*u')/h)
// H = (I-u*u'/h)*H*(I-u*u')/h)
for
(
int
j
=
m
;
j
<
n
;
j
++
)
for
(
long
j
=
m
;
j
<
n
;
j
++
)
{
{
type
f
=
0
.
0
;
type
f
=
0
.
0
;
for
(
int
i
=
high
;
i
>=
m
;
i
--
)
for
(
long
i
=
high
;
i
>=
m
;
i
--
)
{
{
f
+=
ort
(
i
)
*
H
(
i
,
j
);
f
+=
ort
(
i
)
*
H
(
i
,
j
);
}
}
f
=
f
/
h
;
f
=
f
/
h
;
for
(
int
i
=
m
;
i
<=
high
;
i
++
)
for
(
long
i
=
m
;
i
<=
high
;
i
++
)
{
{
H
(
i
,
j
)
-=
f
*
ort
(
i
);
H
(
i
,
j
)
-=
f
*
ort
(
i
);
}
}
}
}
for
(
int
i
=
0
;
i
<=
high
;
i
++
)
for
(
long
i
=
0
;
i
<=
high
;
i
++
)
{
{
type
f
=
0
.
0
;
type
f
=
0
.
0
;
for
(
int
j
=
high
;
j
>=
m
;
j
--
)
for
(
long
j
=
high
;
j
>=
m
;
j
--
)
{
{
f
+=
ort
(
j
)
*
H
(
i
,
j
);
f
+=
ort
(
j
)
*
H
(
i
,
j
);
}
}
f
=
f
/
h
;
f
=
f
/
h
;
for
(
int
j
=
m
;
j
<=
high
;
j
++
)
for
(
long
j
=
m
;
j
<=
high
;
j
++
)
{
{
H
(
i
,
j
)
-=
f
*
ort
(
j
);
H
(
i
,
j
)
-=
f
*
ort
(
j
);
}
}
...
@@ -763,32 +763,32 @@ namespace dlib
...
@@ -763,32 +763,32 @@ namespace dlib
// Accumulate transformations (Algol's ortran).
// Accumulate transformations (Algol's ortran).
for
(
int
i
=
0
;
i
<
n
;
i
++
)
for
(
long
i
=
0
;
i
<
n
;
i
++
)
{
{
for
(
int
j
=
0
;
j
<
n
;
j
++
)
for
(
long
j
=
0
;
j
<
n
;
j
++
)
{
{
V
(
i
,
j
)
=
(
i
==
j
?
1
.
0
:
0
.
0
);
V
(
i
,
j
)
=
(
i
==
j
?
1
.
0
:
0
.
0
);
}
}
}
}
for
(
int
m
=
high
-
1
;
m
>=
low
+
1
;
m
--
)
for
(
long
m
=
high
-
1
;
m
>=
low
+
1
;
m
--
)
{
{
if
(
H
(
m
,
m
-
1
)
!=
0
.
0
)
if
(
H
(
m
,
m
-
1
)
!=
0
.
0
)
{
{
for
(
int
i
=
m
+
1
;
i
<=
high
;
i
++
)
for
(
long
i
=
m
+
1
;
i
<=
high
;
i
++
)
{
{
ort
(
i
)
=
H
(
i
,
m
-
1
);
ort
(
i
)
=
H
(
i
,
m
-
1
);
}
}
for
(
int
j
=
m
;
j
<=
high
;
j
++
)
for
(
long
j
=
m
;
j
<=
high
;
j
++
)
{
{
type
g
=
0
.
0
;
type
g
=
0
.
0
;
for
(
int
i
=
m
;
i
<=
high
;
i
++
)
for
(
long
i
=
m
;
i
<=
high
;
i
++
)
{
{
g
+=
ort
(
i
)
*
V
(
i
,
j
);
g
+=
ort
(
i
)
*
V
(
i
,
j
);
}
}
// Double division avoids possible underflow
// Double division avoids possible underflow
g
=
(
g
/
ort
(
m
))
/
H
(
m
,
m
-
1
);
g
=
(
g
/
ort
(
m
))
/
H
(
m
,
m
-
1
);
for
(
int
i
=
m
;
i
<=
high
;
i
++
)
for
(
long
i
=
m
;
i
<=
high
;
i
++
)
{
{
V
(
i
,
j
)
+=
g
*
ort
(
i
);
V
(
i
,
j
)
+=
g
*
ort
(
i
);
}
}
...
@@ -840,10 +840,10 @@ namespace dlib
...
@@ -840,10 +840,10 @@ namespace dlib
// Initialize
// Initialize
int
nn
=
this
->
n
;
long
nn
=
this
->
n
;
int
n
=
nn
-
1
;
long
n
=
nn
-
1
;
int
low
=
0
;
long
low
=
0
;
int
high
=
nn
-
1
;
long
high
=
nn
-
1
;
const
type
eps
=
std
::
numeric_limits
<
type
>::
epsilon
();
const
type
eps
=
std
::
numeric_limits
<
type
>::
epsilon
();
type
exshift
=
0
.
0
;
type
exshift
=
0
.
0
;
type
p
=
0
,
q
=
0
,
r
=
0
,
s
=
0
,
z
=
0
,
t
,
w
,
x
,
y
;
type
p
=
0
,
q
=
0
,
r
=
0
,
s
=
0
,
z
=
0
,
t
,
w
,
x
,
y
;
...
@@ -851,14 +851,14 @@ namespace dlib
...
@@ -851,14 +851,14 @@ namespace dlib
// Store roots isolated by balanc and compute matrix norm
// Store roots isolated by balanc and compute matrix norm
type
norm
=
0
.
0
;
type
norm
=
0
.
0
;
for
(
int
i
=
0
;
i
<
nn
;
i
++
)
for
(
long
i
=
0
;
i
<
nn
;
i
++
)
{
{
if
((
i
<
low
)
||
(
i
>
high
))
if
((
i
<
low
)
||
(
i
>
high
))
{
{
d
(
i
)
=
H
(
i
,
i
);
d
(
i
)
=
H
(
i
,
i
);
e
(
i
)
=
0
.
0
;
e
(
i
)
=
0
.
0
;
}
}
for
(
int
j
=
max
(
i
-
1
,
0
);
j
<
nn
;
j
++
)
for
(
long
j
=
max
(
i
-
1
,
0L
);
j
<
nn
;
j
++
)
{
{
norm
=
norm
+
abs
(
H
(
i
,
j
));
norm
=
norm
+
abs
(
H
(
i
,
j
));
}
}
...
@@ -866,13 +866,13 @@ namespace dlib
...
@@ -866,13 +866,13 @@ namespace dlib
// Outer loop over eigenvalue index
// Outer loop over eigenvalue index
int
iter
=
0
;
long
iter
=
0
;
while
(
n
>=
low
)
while
(
n
>=
low
)
{
{
// Look for single small sub-diagonal element
// Look for single small sub-diagonal element
int
l
=
n
;
long
l
=
n
;
while
(
l
>
low
)
while
(
l
>
low
)
{
{
s
=
abs
(
H
(
l
-
1
,
l
-
1
))
+
abs
(
H
(
l
,
l
));
s
=
abs
(
H
(
l
-
1
,
l
-
1
))
+
abs
(
H
(
l
,
l
));
...
@@ -941,7 +941,7 @@ namespace dlib
...
@@ -941,7 +941,7 @@ namespace dlib
// Row modification
// Row modification
for
(
int
j
=
n
-
1
;
j
<
nn
;
j
++
)
for
(
long
j
=
n
-
1
;
j
<
nn
;
j
++
)
{
{
z
=
H
(
n
-
1
,
j
);
z
=
H
(
n
-
1
,
j
);
H
(
n
-
1
,
j
)
=
q
*
z
+
p
*
H
(
n
,
j
);
H
(
n
-
1
,
j
)
=
q
*
z
+
p
*
H
(
n
,
j
);
...
@@ -950,7 +950,7 @@ namespace dlib
...
@@ -950,7 +950,7 @@ namespace dlib
// Column modification
// Column modification
for
(
int
i
=
0
;
i
<=
n
;
i
++
)
for
(
long
i
=
0
;
i
<=
n
;
i
++
)
{
{
z
=
H
(
i
,
n
-
1
);
z
=
H
(
i
,
n
-
1
);
H
(
i
,
n
-
1
)
=
q
*
z
+
p
*
H
(
i
,
n
);
H
(
i
,
n
-
1
)
=
q
*
z
+
p
*
H
(
i
,
n
);
...
@@ -959,7 +959,7 @@ namespace dlib
...
@@ -959,7 +959,7 @@ namespace dlib
// Accumulate transformations
// Accumulate transformations
for
(
int
i
=
low
;
i
<=
high
;
i
++
)
for
(
long
i
=
low
;
i
<=
high
;
i
++
)
{
{
z
=
V
(
i
,
n
-
1
);
z
=
V
(
i
,
n
-
1
);
V
(
i
,
n
-
1
)
=
q
*
z
+
p
*
V
(
i
,
n
);
V
(
i
,
n
-
1
)
=
q
*
z
+
p
*
V
(
i
,
n
);
...
@@ -1001,7 +1001,7 @@ namespace dlib
...
@@ -1001,7 +1001,7 @@ namespace dlib
if
(
iter
==
10
)
if
(
iter
==
10
)
{
{
exshift
+=
x
;
exshift
+=
x
;
for
(
int
i
=
low
;
i
<=
n
;
i
++
)
for
(
long
i
=
low
;
i
<=
n
;
i
++
)
{
{
H
(
i
,
i
)
-=
x
;
H
(
i
,
i
)
-=
x
;
}
}
...
@@ -1024,7 +1024,7 @@ namespace dlib
...
@@ -1024,7 +1024,7 @@ namespace dlib
s
=
-
s
;
s
=
-
s
;
}
}
s
=
x
-
w
/
((
y
-
x
)
/
2
.
0
+
s
);
s
=
x
-
w
/
((
y
-
x
)
/
2
.
0
+
s
);
for
(
int
i
=
low
;
i
<=
n
;
i
++
)
for
(
long
i
=
low
;
i
<=
n
;
i
++
)
{
{
H
(
i
,
i
)
-=
s
;
H
(
i
,
i
)
-=
s
;
}
}
...
@@ -1037,7 +1037,7 @@ namespace dlib
...
@@ -1037,7 +1037,7 @@ namespace dlib
// Look for two consecutive small sub-diagonal elements
// Look for two consecutive small sub-diagonal elements
int
m
=
n
-
2
;
long
m
=
n
-
2
;
while
(
m
>=
l
)
while
(
m
>=
l
)
{
{
z
=
H
(
m
,
m
);
z
=
H
(
m
,
m
);
...
@@ -1063,7 +1063,7 @@ namespace dlib
...
@@ -1063,7 +1063,7 @@ namespace dlib
m
--
;
m
--
;
}
}
for
(
int
i
=
m
+
2
;
i
<=
n
;
i
++
)
for
(
long
i
=
m
+
2
;
i
<=
n
;
i
++
)
{
{
H
(
i
,
i
-
2
)
=
0
.
0
;
H
(
i
,
i
-
2
)
=
0
.
0
;
if
(
i
>
m
+
2
)
if
(
i
>
m
+
2
)
...
@@ -1074,9 +1074,9 @@ namespace dlib
...
@@ -1074,9 +1074,9 @@ namespace dlib
// Double QR step involving rows l:n and columns m:n
// Double QR step involving rows l:n and columns m:n
for
(
int
k
=
m
;
k
<=
n
-
1
;
k
++
)
for
(
long
k
=
m
;
k
<=
n
-
1
;
k
++
)
{
{
int
notlast
=
(
k
!=
n
-
1
);
long
notlast
=
(
k
!=
n
-
1
);
if
(
k
!=
m
)
if
(
k
!=
m
)
{
{
p
=
H
(
k
,
k
-
1
);
p
=
H
(
k
,
k
-
1
);
...
@@ -1118,7 +1118,7 @@ namespace dlib
...
@@ -1118,7 +1118,7 @@ namespace dlib
// Row modification
// Row modification
for
(
int
j
=
k
;
j
<
nn
;
j
++
)
for
(
long
j
=
k
;
j
<
nn
;
j
++
)
{
{
p
=
H
(
k
,
j
)
+
q
*
H
(
k
+
1
,
j
);
p
=
H
(
k
,
j
)
+
q
*
H
(
k
+
1
,
j
);
if
(
notlast
)
if
(
notlast
)
...
@@ -1132,7 +1132,7 @@ namespace dlib
...
@@ -1132,7 +1132,7 @@ namespace dlib
// Column modification
// Column modification
for
(
int
i
=
0
;
i
<=
min
(
n
,
k
+
3
);
i
++
)
for
(
long
i
=
0
;
i
<=
min
(
n
,
k
+
3
);
i
++
)
{
{
p
=
x
*
H
(
i
,
k
)
+
y
*
H
(
i
,
k
+
1
);
p
=
x
*
H
(
i
,
k
)
+
y
*
H
(
i
,
k
+
1
);
if
(
notlast
)
if
(
notlast
)
...
@@ -1146,7 +1146,7 @@ namespace dlib
...
@@ -1146,7 +1146,7 @@ namespace dlib
// Accumulate transformations
// Accumulate transformations
for
(
int
i
=
low
;
i
<=
high
;
i
++
)
for
(
long
i
=
low
;
i
<=
high
;
i
++
)
{
{
p
=
x
*
V
(
i
,
k
)
+
y
*
V
(
i
,
k
+
1
);
p
=
x
*
V
(
i
,
k
)
+
y
*
V
(
i
,
k
+
1
);
if
(
notlast
)
if
(
notlast
)
...
@@ -1178,13 +1178,13 @@ namespace dlib
...
@@ -1178,13 +1178,13 @@ namespace dlib
if
(
q
==
0
)
if
(
q
==
0
)
{
{
int
l
=
n
;
long
l
=
n
;
H
(
n
,
n
)
=
1
.
0
;
H
(
n
,
n
)
=
1
.
0
;
for
(
int
i
=
n
-
1
;
i
>=
0
;
i
--
)
for
(
long
i
=
n
-
1
;
i
>=
0
;
i
--
)
{
{
w
=
H
(
i
,
i
)
-
p
;
w
=
H
(
i
,
i
)
-
p
;
r
=
0
.
0
;
r
=
0
.
0
;
for
(
int
j
=
l
;
j
<=
n
;
j
++
)
for
(
long
j
=
l
;
j
<=
n
;
j
++
)
{
{
r
=
r
+
H
(
i
,
j
)
*
H
(
j
,
n
);
r
=
r
+
H
(
i
,
j
)
*
H
(
j
,
n
);
}
}
...
@@ -1232,7 +1232,7 @@ namespace dlib
...
@@ -1232,7 +1232,7 @@ namespace dlib
t
=
abs
(
H
(
i
,
n
));
t
=
abs
(
H
(
i
,
n
));
if
((
eps
*
t
)
*
t
>
1
)
if
((
eps
*
t
)
*
t
>
1
)
{
{
for
(
int
j
=
i
;
j
<=
n
;
j
++
)
for
(
long
j
=
i
;
j
<=
n
;
j
++
)
{
{
H
(
j
,
n
)
=
H
(
j
,
n
)
/
t
;
H
(
j
,
n
)
=
H
(
j
,
n
)
/
t
;
}
}
...
@@ -1245,7 +1245,7 @@ namespace dlib
...
@@ -1245,7 +1245,7 @@ namespace dlib
}
}
else
if
(
q
<
0
)
else
if
(
q
<
0
)
{
{
int
l
=
n
-
1
;
long
l
=
n
-
1
;
// Last vector component imaginary so matrix is triangular
// Last vector component imaginary so matrix is triangular
...
@@ -1262,12 +1262,12 @@ namespace dlib
...
@@ -1262,12 +1262,12 @@ namespace dlib
}
}
H
(
n
,
n
-
1
)
=
0
.
0
;
H
(
n
,
n
-
1
)
=
0
.
0
;
H
(
n
,
n
)
=
1
.
0
;
H
(
n
,
n
)
=
1
.
0
;
for
(
int
i
=
n
-
2
;
i
>=
0
;
i
--
)
for
(
long
i
=
n
-
2
;
i
>=
0
;
i
--
)
{
{
type
ra
,
sa
,
vr
,
vi
;
type
ra
,
sa
,
vr
,
vi
;
ra
=
0
.
0
;
ra
=
0
.
0
;
sa
=
0
.
0
;
sa
=
0
.
0
;
for
(
int
j
=
l
;
j
<=
n
;
j
++
)
for
(
long
j
=
l
;
j
<=
n
;
j
++
)
{
{
ra
=
ra
+
H
(
i
,
j
)
*
H
(
j
,
n
-
1
);
ra
=
ra
+
H
(
i
,
j
)
*
H
(
j
,
n
-
1
);
sa
=
sa
+
H
(
i
,
j
)
*
H
(
j
,
n
);
sa
=
sa
+
H
(
i
,
j
)
*
H
(
j
,
n
);
...
@@ -1324,7 +1324,7 @@ namespace dlib
...
@@ -1324,7 +1324,7 @@ namespace dlib
t
=
max
(
abs
(
H
(
i
,
n
-
1
)),
abs
(
H
(
i
,
n
)));
t
=
max
(
abs
(
H
(
i
,
n
-
1
)),
abs
(
H
(
i
,
n
)));
if
((
eps
*
t
)
*
t
>
1
)
if
((
eps
*
t
)
*
t
>
1
)
{
{
for
(
int
j
=
i
;
j
<=
n
;
j
++
)
for
(
long
j
=
i
;
j
<=
n
;
j
++
)
{
{
H
(
j
,
n
-
1
)
=
H
(
j
,
n
-
1
)
/
t
;
H
(
j
,
n
-
1
)
=
H
(
j
,
n
-
1
)
/
t
;
H
(
j
,
n
)
=
H
(
j
,
n
)
/
t
;
H
(
j
,
n
)
=
H
(
j
,
n
)
/
t
;
...
@@ -1337,11 +1337,11 @@ namespace dlib
...
@@ -1337,11 +1337,11 @@ namespace dlib
// Vectors of isolated roots
// Vectors of isolated roots
for
(
int
i
=
0
;
i
<
nn
;
i
++
)
for
(
long
i
=
0
;
i
<
nn
;
i
++
)
{
{
if
(
i
<
low
||
i
>
high
)
if
(
i
<
low
||
i
>
high
)
{
{
for
(
int
j
=
i
;
j
<
nn
;
j
++
)
for
(
long
j
=
i
;
j
<
nn
;
j
++
)
{
{
V
(
i
,
j
)
=
H
(
i
,
j
);
V
(
i
,
j
)
=
H
(
i
,
j
);
}
}
...
@@ -1350,12 +1350,12 @@ namespace dlib
...
@@ -1350,12 +1350,12 @@ namespace dlib
// Back transformation to get eigenvectors of original matrix
// Back transformation to get eigenvectors of original matrix
for
(
int
j
=
nn
-
1
;
j
>=
low
;
j
--
)
for
(
long
j
=
nn
-
1
;
j
>=
low
;
j
--
)
{
{
for
(
int
i
=
low
;
i
<=
high
;
i
++
)
for
(
long
i
=
low
;
i
<=
high
;
i
++
)
{
{
z
=
0
.
0
;
z
=
0
.
0
;
for
(
int
k
=
low
;
k
<=
min
(
j
,
high
);
k
++
)
for
(
long
k
=
low
;
k
<=
min
(
j
,
high
);
k
++
)
{
{
z
=
z
+
V
(
i
,
k
)
*
H
(
k
,
j
);
z
=
z
+
V
(
i
,
k
)
*
H
(
k
,
j
);
}
}
...
...
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