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
3401b969
Commit
3401b969
authored
Mar 17, 2019
by
Davis King
Browse files
It's actually fine to call rowm() or colm() with an empty index set.
parent
ec63baa7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
22 deletions
+32
-22
dlib/matrix/matrix_subexp.h
dlib/matrix/matrix_subexp.h
+26
-18
dlib/matrix/matrix_subexp_abstract.h
dlib/matrix/matrix_subexp_abstract.h
+4
-4
dlib/test/matrix.cpp
dlib/test/matrix.cpp
+2
-0
No files found.
dlib/matrix/matrix_subexp.h
View file @
3401b969
...
...
@@ -386,16 +386,20 @@ namespace dlib
// the rows matrix must contain integer elements
COMPILE_TIME_ASSERT
(
std
::
numeric_limits
<
typename
EXP2
::
type
>::
is_integer
);
DLIB_ASSERT
(
0
<=
min
(
rows
)
&&
max
(
rows
)
<
m
.
nr
()
&&
(
rows
.
nr
()
==
1
||
rows
.
nc
()
==
1
),
"
\t
const matrix_exp rowm(const matrix_exp& m, const matrix_exp& rows)"
<<
"
\n\t
You have given invalid arguments to this function"
<<
"
\n\t
m.nr(): "
<<
m
.
nr
()
<<
"
\n\t
m.nc(): "
<<
m
.
nc
()
<<
"
\n\t
min(rows): "
<<
min
(
rows
)
<<
"
\n\t
max(rows): "
<<
max
(
rows
)
<<
"
\n\t
rows.nr(): "
<<
rows
.
nr
()
<<
"
\n\t
rows.nc(): "
<<
rows
.
nc
()
#ifdef ENABLE_ASSERTS
if
(
rows
.
size
()
!=
0
)
{
DLIB_ASSERT
(
0
<=
min
(
rows
)
&&
max
(
rows
)
<
m
.
nr
()
&&
(
rows
.
nr
()
==
1
||
rows
.
nc
()
==
1
),
"
\t
const matrix_exp rowm(const matrix_exp& m, const matrix_exp& rows)"
<<
"
\n\t
You have given invalid arguments to this function"
<<
"
\n\t
m.nr(): "
<<
m
.
nr
()
<<
"
\n\t
m.nc(): "
<<
m
.
nc
()
<<
"
\n\t
min(rows): "
<<
min
(
rows
)
<<
"
\n\t
max(rows): "
<<
max
(
rows
)
<<
"
\n\t
rows.nr(): "
<<
rows
.
nr
()
<<
"
\n\t
rows.nc(): "
<<
rows
.
nc
()
);
}
#endif // ENABLE_ASSERTS
typedef
op_rowm_range
<
EXP1
,
EXP2
>
op
;
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
rows
.
ref
()));
...
...
@@ -541,16 +545,20 @@ namespace dlib
// the rows matrix must contain integer elements
COMPILE_TIME_ASSERT
(
std
::
numeric_limits
<
typename
EXP2
::
type
>::
is_integer
);
DLIB_ASSERT
(
0
<=
min
(
cols
)
&&
max
(
cols
)
<
m
.
nc
()
&&
(
cols
.
nr
()
==
1
||
cols
.
nc
()
==
1
),
"
\t
const matrix_exp colm(const matrix_exp& m, const matrix_exp& cols)"
<<
"
\n\t
You have given invalid arguments to this function"
<<
"
\n\t
m.nr(): "
<<
m
.
nr
()
<<
"
\n\t
m.nc(): "
<<
m
.
nc
()
<<
"
\n\t
min(cols): "
<<
min
(
cols
)
<<
"
\n\t
max(cols): "
<<
max
(
cols
)
<<
"
\n\t
cols.nr(): "
<<
cols
.
nr
()
<<
"
\n\t
cols.nc(): "
<<
cols
.
nc
()
#ifdef ENABLE_ASSERTS
if
(
cols
.
size
()
!=
0
)
{
DLIB_ASSERT
(
0
<=
min
(
cols
)
&&
max
(
cols
)
<
m
.
nc
()
&&
(
cols
.
nr
()
==
1
||
cols
.
nc
()
==
1
),
"
\t
const matrix_exp colm(const matrix_exp& m, const matrix_exp& cols)"
<<
"
\n\t
You have given invalid arguments to this function"
<<
"
\n\t
m.nr(): "
<<
m
.
nr
()
<<
"
\n\t
m.nc(): "
<<
m
.
nc
()
<<
"
\n\t
min(cols): "
<<
min
(
cols
)
<<
"
\n\t
max(cols): "
<<
max
(
cols
)
<<
"
\n\t
cols.nr(): "
<<
cols
.
nr
()
<<
"
\n\t
cols.nc(): "
<<
cols
.
nc
()
);
}
#endif // ENABLE_ASSERTS
typedef
op_colm_range
<
EXP1
,
EXP2
>
op
;
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
cols
.
ref
()));
...
...
dlib/matrix/matrix_subexp_abstract.h
View file @
3401b969
...
...
@@ -239,8 +239,8 @@ namespace dlib
requires
- rows contains integral elements (e.g. int, long)
- 0 <= min(rows) && max(rows) < m.nr()
- rows.nr() == 1 || rows.nc() == 1
(i.e. rows must be a vector)
- rows.nr() == 1 || rows.nc() == 1
|| rows.size() == 0
(i.e. rows must be a vector
, or just empty
)
ensures
- returns a matrix R such that:
- R::type == the same type that was in m
...
...
@@ -326,8 +326,8 @@ namespace dlib
requires
- cols contains integral elements (e.g. int, long)
- 0 <= min(cols) && max(cols) < m.nc()
- cols.nr() == 1 || cols.nc() == 1
(i.e. cols must be a vector)
- cols.nr() == 1 || cols.nc() == 1
|| cols.size() == 0
(i.e. cols must be a vector
, or just empty
)
ensures
- returns a matrix R such that:
- R::type == the same type that was in m
...
...
dlib/test/matrix.cpp
View file @
3401b969
...
...
@@ -1060,6 +1060,8 @@ namespace
DLIB_TEST
(
subm
(
m
,
range
(
1
,
1
),
range
(
0
,
2
))
==
rowm
(
m
,
1
));
DLIB_TEST
(
subm
(
m
,
range
(
2
,
2
),
range
(
0
,
2
))
==
rowm
(
m
,
2
));
DLIB_TEST
(
subm
(
m
,
range
(
3
,
3
),
range
(
0
,
2
))
==
rowm
(
m
,
3
));
DLIB_TEST
(
rowm
(
m
,
matrix
<
long
>
()).
size
()
==
0
);
DLIB_TEST
(
colm
(
m
,
matrix
<
long
>
()).
size
()
==
0
);
DLIB_TEST
(
subm
(
m
,
0
,
0
,
2
,
2
)
==
subm
(
m
,
range
(
0
,
1
),
range
(
0
,
1
)));
DLIB_TEST
(
subm
(
m
,
1
,
1
,
2
,
2
)
==
subm
(
m
,
range
(
1
,
2
),
range
(
1
,
2
)));
...
...
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