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
1a2a524a
Commit
1a2a524a
authored
Oct 01, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed LAPACK bindings so that really small matrices don't use LAPACK
for eigenvalue_decomposition or the triangular solver.
parent
2bbab691
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
33 deletions
+48
-33
matrix_eigenvalue.h
dlib/matrix/matrix_eigenvalue.h
+36
-27
matrix_trsm.h
dlib/matrix/matrix_trsm.h
+12
-6
No files found.
dlib/matrix/matrix_eigenvalue.h
View file @
1a2a524a
...
...
@@ -18,6 +18,8 @@
#include "lapack/syevr.h"
#endif
#define DLIB_LAPACK_EIGENVALUE_DECOMP_SIZE_THRESH 4
namespace
dlib
{
...
...
@@ -178,35 +180,41 @@ namespace dlib
V
=
A
;
#ifdef DLIB_USE_LAPACK
e
=
0
;
if
(
A
.
nr
()
>
DLIB_LAPACK_EIGENVALUE_DECOMP_SIZE_THRESH
)
{
e
=
0
;
// We could compute the result using syev()
//lapack::syev('V', 'L', V, d);
// We could compute the result using syev()
//lapack::syev('V', 'L', V, d);
// Instead, we use syevr because its faster and maybe more stable.
matrix_type
tempA
(
A
);
matrix
<
lapack
::
integer
,
0
,
0
,
mem_manager_type
,
layout_type
>
isupz
;
// Instead, we use syevr because its faster and maybe more stable.
matrix_type
tempA
(
A
);
matrix
<
lapack
::
integer
,
0
,
0
,
mem_manager_type
,
layout_type
>
isupz
;
lapack
::
integer
temp
;
lapack
::
syevr
(
'V'
,
'A'
,
'L'
,
tempA
,
0
,
0
,
0
,
0
,
-
1
,
temp
,
d
,
V
,
isupz
);
#else
lapack
::
integer
temp
;
lapack
::
syevr
(
'V'
,
'A'
,
'L'
,
tempA
,
0
,
0
,
0
,
0
,
-
1
,
temp
,
d
,
V
,
isupz
);
}
#endif
// Tridiagonalize.
tred2
();
// Diagonalize.
tql2
();
#endif
}
else
{
#ifdef DLIB_USE_LAPACK
matrix
<
type
,
0
,
0
,
mem_manager_type
,
column_major_layout
>
temp
,
vl
,
vr
;
temp
=
A
;
lapack
::
geev
(
'N'
,
'V'
,
temp
,
d
,
e
,
vl
,
vr
);
V
=
vr
;
#else
if
(
A
.
nr
()
>
DLIB_LAPACK_EIGENVALUE_DECOMP_SIZE_THRESH
)
{
matrix
<
type
,
0
,
0
,
mem_manager_type
,
column_major_layout
>
temp
,
vl
,
vr
;
temp
=
A
;
lapack
::
geev
(
'N'
,
'V'
,
temp
,
d
,
e
,
vl
,
vr
);
V
=
vr
;
return
;
}
#endif
H
=
A
;
ort
.
set_size
(
n
);
...
...
@@ -216,7 +224,6 @@ namespace dlib
// Reduce Hessenberg to real Schur form.
hqr2
();
#endif
}
}
...
...
@@ -252,25 +259,27 @@ namespace dlib
V
=
A
;
#ifdef DLIB_USE_LAPACK
e
=
0
;
// We could compute the result using syev()
//lapack::syev('V', 'L', V, d);
if
(
A
.
nr
()
>
DLIB_LAPACK_EIGENVALUE_DECOMP_SIZE_THRESH
)
{
e
=
0
;
// Instead, we use syevr because its faster and maybe more stable.
matrix_type
tempA
(
A
);
matrix
<
lapack
::
integer
,
0
,
0
,
mem_manager_type
,
layout_type
>
isupz
;
// We could compute the result using syev()
//lapack::syev('V', 'L', V, d);
lapack
::
integer
temp
;
lapack
::
syevr
(
'V'
,
'A'
,
'L'
,
tempA
,
0
,
0
,
0
,
0
,
-
1
,
temp
,
d
,
V
,
isupz
);
// Instead, we use syevr because its faster and maybe more stable.
matrix_type
tempA
(
A
);
matrix
<
lapack
::
integer
,
0
,
0
,
mem_manager_type
,
layout_type
>
isupz
;
#else
lapack
::
integer
temp
;
lapack
::
syevr
(
'V'
,
'A'
,
'L'
,
tempA
,
0
,
0
,
0
,
0
,
-
1
,
temp
,
d
,
V
,
isupz
);
return
;
}
#endif
// Tridiagonalize.
tred2
();
// Diagonalize.
tql2
();
#endif
}
...
...
dlib/matrix/matrix_trsm.h
View file @
1a2a524a
...
...
@@ -519,10 +519,13 @@ namespace dlib
float
*
B
,
const
int
ldb
)
{
#ifdef DLIB_USE_BLAS
cblas_strsm
(
Order
,
Side
,
Uplo
,
TransA
,
Diag
,
M
,
N
,
alpha
,
A
,
lda
,
B
,
ldb
);
#else
local_trsm
(
Order
,
Side
,
Uplo
,
TransA
,
Diag
,
M
,
N
,
alpha
,
A
,
lda
,
B
,
ldb
);
if
(
M
>
4
)
{
cblas_strsm
(
Order
,
Side
,
Uplo
,
TransA
,
Diag
,
M
,
N
,
alpha
,
A
,
lda
,
B
,
ldb
);
return
;
}
#endif
local_trsm
(
Order
,
Side
,
Uplo
,
TransA
,
Diag
,
M
,
N
,
alpha
,
A
,
lda
,
B
,
ldb
);
}
inline
void
cblas_trsm
(
const
enum
CBLAS_ORDER
Order
,
const
enum
CBLAS_SIDE
Side
,
...
...
@@ -532,10 +535,13 @@ namespace dlib
double
*
B
,
const
int
ldb
)
{
#ifdef DLIB_USE_BLAS
cblas_dtrsm
(
Order
,
Side
,
Uplo
,
TransA
,
Diag
,
M
,
N
,
alpha
,
A
,
lda
,
B
,
ldb
);
#else
local_trsm
(
Order
,
Side
,
Uplo
,
TransA
,
Diag
,
M
,
N
,
alpha
,
A
,
lda
,
B
,
ldb
);
if
(
M
>
4
)
{
cblas_dtrsm
(
Order
,
Side
,
Uplo
,
TransA
,
Diag
,
M
,
N
,
alpha
,
A
,
lda
,
B
,
ldb
);
return
;
}
#endif
local_trsm
(
Order
,
Side
,
Uplo
,
TransA
,
Diag
,
M
,
N
,
alpha
,
A
,
lda
,
B
,
ldb
);
}
inline
void
cblas_trsm
(
const
enum
CBLAS_ORDER
Order
,
const
enum
CBLAS_SIDE
Side
,
...
...
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