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
Show 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,6 +386,8 @@ namespace dlib
...
@@ -386,6 +386,8 @@ namespace dlib
// the rows matrix must contain integer elements
// the rows matrix must contain integer elements
COMPILE_TIME_ASSERT
(
std
::
numeric_limits
<
typename
EXP2
::
type
>::
is_integer
);
COMPILE_TIME_ASSERT
(
std
::
numeric_limits
<
typename
EXP2
::
type
>::
is_integer
);
#ifdef ENABLE_ASSERTS
if
(
rows
.
size
()
!=
0
)
{
DLIB_ASSERT
(
0
<=
min
(
rows
)
&&
max
(
rows
)
<
m
.
nr
()
&&
(
rows
.
nr
()
==
1
||
rows
.
nc
()
==
1
),
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)"
"
\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
You have given invalid arguments to this function"
...
@@ -396,6 +398,8 @@ namespace dlib
...
@@ -396,6 +398,8 @@ namespace dlib
<<
"
\n\t
rows.nr(): "
<<
rows
.
nr
()
<<
"
\n\t
rows.nr(): "
<<
rows
.
nr
()
<<
"
\n\t
rows.nc(): "
<<
rows
.
nc
()
<<
"
\n\t
rows.nc(): "
<<
rows
.
nc
()
);
);
}
#endif // ENABLE_ASSERTS
typedef
op_rowm_range
<
EXP1
,
EXP2
>
op
;
typedef
op_rowm_range
<
EXP1
,
EXP2
>
op
;
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
rows
.
ref
()));
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
rows
.
ref
()));
...
@@ -541,6 +545,8 @@ namespace dlib
...
@@ -541,6 +545,8 @@ namespace dlib
// the rows matrix must contain integer elements
// the rows matrix must contain integer elements
COMPILE_TIME_ASSERT
(
std
::
numeric_limits
<
typename
EXP2
::
type
>::
is_integer
);
COMPILE_TIME_ASSERT
(
std
::
numeric_limits
<
typename
EXP2
::
type
>::
is_integer
);
#ifdef ENABLE_ASSERTS
if
(
cols
.
size
()
!=
0
)
{
DLIB_ASSERT
(
0
<=
min
(
cols
)
&&
max
(
cols
)
<
m
.
nc
()
&&
(
cols
.
nr
()
==
1
||
cols
.
nc
()
==
1
),
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)"
"
\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
You have given invalid arguments to this function"
...
@@ -551,6 +557,8 @@ namespace dlib
...
@@ -551,6 +557,8 @@ namespace dlib
<<
"
\n\t
cols.nr(): "
<<
cols
.
nr
()
<<
"
\n\t
cols.nr(): "
<<
cols
.
nr
()
<<
"
\n\t
cols.nc(): "
<<
cols
.
nc
()
<<
"
\n\t
cols.nc(): "
<<
cols
.
nc
()
);
);
}
#endif // ENABLE_ASSERTS
typedef
op_colm_range
<
EXP1
,
EXP2
>
op
;
typedef
op_colm_range
<
EXP1
,
EXP2
>
op
;
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
cols
.
ref
()));
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
cols
.
ref
()));
...
...
dlib/matrix/matrix_subexp_abstract.h
View file @
3401b969
...
@@ -239,8 +239,8 @@ namespace dlib
...
@@ -239,8 +239,8 @@ namespace dlib
requires
requires
- rows contains integral elements (e.g. int, long)
- rows contains integral elements (e.g. int, long)
- 0 <= min(rows) && max(rows) < m.nr()
- 0 <= min(rows) && max(rows) < m.nr()
- rows.nr() == 1 || rows.nc() == 1
- rows.nr() == 1 || rows.nc() == 1
|| rows.size() == 0
(i.e. rows must be a vector)
(i.e. rows must be a vector
, or just empty
)
ensures
ensures
- returns a matrix R such that:
- returns a matrix R such that:
- R::type == the same type that was in m
- R::type == the same type that was in m
...
@@ -326,8 +326,8 @@ namespace dlib
...
@@ -326,8 +326,8 @@ namespace dlib
requires
requires
- cols contains integral elements (e.g. int, long)
- cols contains integral elements (e.g. int, long)
- 0 <= min(cols) && max(cols) < m.nc()
- 0 <= min(cols) && max(cols) < m.nc()
- cols.nr() == 1 || cols.nc() == 1
- cols.nr() == 1 || cols.nc() == 1
|| cols.size() == 0
(i.e. cols must be a vector)
(i.e. cols must be a vector
, or just empty
)
ensures
ensures
- returns a matrix R such that:
- returns a matrix R such that:
- R::type == the same type that was in m
- R::type == the same type that was in m
...
...
dlib/test/matrix.cpp
View file @
3401b969
...
@@ -1060,6 +1060,8 @@ namespace
...
@@ -1060,6 +1060,8 @@ namespace
DLIB_TEST
(
subm
(
m
,
range
(
1
,
1
),
range
(
0
,
2
))
==
rowm
(
m
,
1
));
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
(
2
,
2
),
range
(
0
,
2
))
==
rowm
(
m
,
2
));
DLIB_TEST
(
subm
(
m
,
range
(
3
,
3
),
range
(
0
,
2
))
==
rowm
(
m
,
3
));
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
,
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
)));
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