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
62e9cf47
Commit
62e9cf47
authored
Aug 01, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed spelling and tabbing
parent
e3f984a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
46 deletions
+46
-46
matrix_la.h
dlib/matrix/matrix_la.h
+46
-46
No files found.
dlib/matrix/matrix_la.h
View file @
62e9cf47
...
...
@@ -1203,68 +1203,68 @@ convergence:
if
(
A
.
nr
()
>
4
)
// Only test for banded matrix if matrix is big enough
{
// Detect if matrix is banded and, if so, matrix bandwidth
banded
=
true
;
for
(
long
r
=
0
;
r
<
A
.
nr
();
++
r
)
for
(
long
c
=
(
r
+
bandwidth
+
1
);
c
<
A
.
nc
();
++
c
)
if
(
A
(
r
,
c
)
!=
0
)
{
bandwidth
=
c
-
r
;
if
(
bandwidth
>
A
.
nr
()
/
2
)
// Detect if matrix is banded and, if so, matrix bandwidth
banded
=
true
;
for
(
long
r
=
0
;
r
<
A
.
nr
();
++
r
)
for
(
long
c
=
(
r
+
bandwidth
+
1
);
c
<
A
.
nc
();
++
c
)
if
(
A
(
r
,
c
)
!=
0
)
{
banded
=
false
;
goto
escape_banded_detection
;
bandwidth
=
c
-
r
;
if
(
bandwidth
>
A
.
nr
()
/
2
)
{
banded
=
false
;
goto
escape_banded_detection
;
}
}
}
}
escape_banded_detection
:
if
(
banded
)
{
// Store in compact form - use column major for LAPACK
matrix
<
T
,
0
,
0
,
default_memory_manager
,
column_major_layout
>
B
(
bandwidth
+
1
,
A
.
nc
());
set_all_elements
(
B
,
0
);
// Store in compact form - use column major for LAPACK
matrix
<
T
,
0
,
0
,
default_memory_manager
,
column_major_layout
>
B
(
bandwidth
+
1
,
A
.
nc
());
set_all_elements
(
B
,
0
);
for
(
long
r
=
0
;
r
<
A
.
nr
();
++
r
)
for
(
long
c
=
r
;
c
<
std
::
min
(
r
+
bandwidth
+
1
,
A
.
nc
());
++
c
)
B
(
c
-
r
,
r
)
=
A
(
r
,
c
);
for
(
long
r
=
0
;
r
<
A
.
nr
();
++
r
)
for
(
long
c
=
r
;
c
<
std
::
min
(
r
+
bandwidth
+
1
,
A
.
nc
());
++
c
)
B
(
c
-
r
,
r
)
=
A
(
r
,
c
);
#ifdef DLIB_USE_LAPACK
lapack
::
pbtrf
(
'L'
,
B
);
lapack
::
pbtrf
(
'L'
,
B
);
#else
// Pe
form compact Cholesky
for
(
long
k
=
0
;
k
<
A
.
nr
();
++
k
)
{
long
last
=
std
::
min
(
k
+
bandwidth
,
A
.
nr
()
-
1
)
-
k
;
for
(
long
j
=
1
;
j
<=
last
;
++
j
)
{
long
i
=
k
+
j
;
for
(
long
c
=
0
;
c
<=
(
last
-
j
);
++
c
)
B
(
c
,
i
)
-=
B
(
j
,
k
)
/
B
(
0
,
k
)
*
B
(
c
+
j
,
k
);
}
T
norm
=
std
::
sqrt
(
B
(
0
,
k
));
for
(
long
i
=
0
;
i
<=
bandwidth
;
++
i
)
B
(
i
,
k
)
/=
norm
;
}
for
(
long
c
=
A
.
nc
()
-
bandwidth
+
1
;
c
<
A
.
nc
();
++
c
)
B
(
bandwidth
,
c
)
=
0
;
// Per
form compact Cholesky
for
(
long
k
=
0
;
k
<
A
.
nr
();
++
k
)
{
long
last
=
std
::
min
(
k
+
bandwidth
,
A
.
nr
()
-
1
)
-
k
;
for
(
long
j
=
1
;
j
<=
last
;
++
j
)
{
long
i
=
k
+
j
;
for
(
long
c
=
0
;
c
<=
(
last
-
j
);
++
c
)
B
(
c
,
i
)
-=
B
(
j
,
k
)
/
B
(
0
,
k
)
*
B
(
c
+
j
,
k
);
}
T
norm
=
std
::
sqrt
(
B
(
0
,
k
));
for
(
long
i
=
0
;
i
<=
bandwidth
;
++
i
)
B
(
i
,
k
)
/=
norm
;
}
for
(
long
c
=
A
.
nc
()
-
bandwidth
+
1
;
c
<
A
.
nc
();
++
c
)
B
(
bandwidth
,
c
)
=
0
;
#endif
// Unpack lower triangular area
set_all_elements
(
L
,
0
);
for
(
long
c
=
0
;
c
<
A
.
nc
();
++
c
)
for
(
long
i
=
0
;
i
<=
bandwidth
;
++
i
)
{
long
ind
=
c
+
i
;
if
(
ind
<
A
.
nc
())
L
(
ind
,
c
)
=
B
(
i
,
c
);
}
return
L
;
// Unpack lower triangular area
set_all_elements
(
L
,
0
);
for
(
long
c
=
0
;
c
<
A
.
nc
();
++
c
)
for
(
long
i
=
0
;
i
<=
bandwidth
;
++
i
)
{
long
ind
=
c
+
i
;
if
(
ind
<
A
.
nc
())
L
(
ind
,
c
)
=
B
(
i
,
c
);
}
return
L
;
}
#ifdef DLIB_USE_LAPACK
...
...
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