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
c7f27517
Commit
c7f27517
authored
Aug 22, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added is_row_major(). Also made sum() run over the matrix in column major
order if that's the memory layout of the argument.
parent
ff6bd2dd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
+36
-2
matrix_utilities.h
dlib/matrix/matrix_utilities.h
+25
-2
matrix_utilities_abstract.h
dlib/matrix/matrix_utilities_abstract.h
+11
-0
No files found.
dlib/matrix/matrix_utilities.h
View file @
c7f27517
...
...
@@ -1415,6 +1415,16 @@ namespace dlib
return
typename
matrix_exp
<
EXP
>::
matrix_type
(
m
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
EXP
>
constexpr
bool
is_row_major
(
const
matrix_exp
<
EXP
>&
)
{
return
is_same_type
<
typename
EXP
::
layout_type
,
row_major_layout
>::
value
;
}
// ----------------------------------------------------------------------------------------
template
<
...
...
@@ -1427,11 +1437,24 @@ namespace dlib
typedef
typename
matrix_exp
<
EXP
>::
type
type
;
type
val
=
0
;
for
(
long
r
=
0
;
r
<
m
.
nr
();
++
r
)
if
(
is_row_major
(
m
))
{
for
(
long
r
=
0
;
r
<
m
.
nr
();
++
r
)
{
for
(
long
c
=
0
;
c
<
m
.
nc
();
++
c
)
{
val
+=
m
(
r
,
c
);
}
}
}
else
{
for
(
long
c
=
0
;
c
<
m
.
nc
();
++
c
)
{
val
+=
m
(
r
,
c
);
for
(
long
r
=
0
;
r
<
m
.
nr
();
++
r
)
{
val
+=
m
(
r
,
c
);
}
}
}
return
val
;
...
...
dlib/matrix/matrix_utilities_abstract.h
View file @
c7f27517
...
...
@@ -16,6 +16,17 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// Simple matrix utilities
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
EXP
>
constexpr
bool
is_row_major
(
const
matrix_exp
<
EXP
>&
);
/*!
ensures
- returns true if and only if the given matrix expression uses the row_major_layout.
!*/
// ----------------------------------------------------------------------------------------
const
matrix_exp
diag
(
...
...
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