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
c7f27517
Commit
c7f27517
authored
Aug 22, 2016
by
Davis King
Browse files
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
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
+36
-2
dlib/matrix/matrix_utilities.h
dlib/matrix/matrix_utilities.h
+25
-2
dlib/matrix/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,6 +1437,8 @@ namespace dlib
typedef
typename
matrix_exp
<
EXP
>::
type
type
;
type
val
=
0
;
if
(
is_row_major
(
m
))
{
for
(
long
r
=
0
;
r
<
m
.
nr
();
++
r
)
{
for
(
long
c
=
0
;
c
<
m
.
nc
();
++
c
)
...
...
@@ -1434,6 +1446,17 @@ namespace dlib
val
+=
m
(
r
,
c
);
}
}
}
else
{
for
(
long
c
=
0
;
c
<
m
.
nc
();
++
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