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
3401b969
Commit
3401b969
authored
Mar 18, 2019
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
It's actually fine to call rowm() or colm() with an empty index set.
parent
ec63baa7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
4 deletions
+14
-4
matrix_subexp.h
dlib/matrix/matrix_subexp.h
+8
-0
matrix_subexp_abstract.h
dlib/matrix/matrix_subexp_abstract.h
+4
-4
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
// the rows matrix must contain integer elements
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
),
"
\t
const matrix_exp rowm(const matrix_exp& m, const matrix_exp& rows)"
<<
"
\n\t
You have given invalid arguments to this function"
...
...
@@ -396,6 +398,8 @@ namespace dlib
<<
"
\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,6 +545,8 @@ namespace dlib
// the rows matrix must contain integer elements
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
),
"
\t
const matrix_exp colm(const matrix_exp& m, const matrix_exp& cols)"
<<
"
\n\t
You have given invalid arguments to this function"
...
...
@@ -551,6 +557,8 @@ namespace dlib
<<
"
\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