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
9ab53f01
Commit
9ab53f01
authored
May 06, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the += and -= operators to the set_subm(), set_rowm(), and set_colm()
functions.
parent
b5b061f9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
130 additions
and
0 deletions
+130
-0
matrix_subexp.h
dlib/matrix/matrix_subexp.h
+0
-0
matrix_subexp_abstract.h
dlib/matrix/matrix_subexp_abstract.h
+28
-0
matrix4.cpp
dlib/test/matrix4.cpp
+102
-0
No files found.
dlib/matrix/matrix_subexp.h
View file @
9ab53f01
This diff is collapsed.
Click to expand it.
dlib/matrix/matrix_subexp_abstract.h
View file @
9ab53f01
...
...
@@ -324,6 +324,10 @@ namespace dlib
- set_subm(m,row,col,nr,nc) = scalar_value;
result in it being the case that:
- subm(m,row,col,nr,nc) == uniform_matrix<matrix::type>(nr,nc,scalar_value).
- In addition to the normal assignment statements using the = symbol, you may
also use the usual += and -= versions of the assignment operator. In these
cases, they have their usual effect.
!*/
// ----------------------------------------------------------------------------------------
...
...
@@ -346,6 +350,10 @@ namespace dlib
- set_subm(m,rect) = scalar_value;
result in it being the case that:
- subm(m,rect) == uniform_matrix<matrix::type>(nr,nc,scalar_value).
- In addition to the normal assignment statements using the = symbol, you may
also use the usual += and -= versions of the assignment operator. In these
cases, they have their usual effect.
!*/
// ----------------------------------------------------------------------------------------
...
...
@@ -373,6 +381,10 @@ namespace dlib
- set_subm(m,rows,cols) = scalar_value;
result in it being the case that:
- subm(m,rows,cols) == uniform_matrix<matrix::type>(nr,nc,scalar_value).
- In addition to the normal assignment statements using the = symbol, you may
also use the usual += and -= versions of the assignment operator. In these
cases, they have their usual effect.
!*/
// ----------------------------------------------------------------------------------------
...
...
@@ -394,6 +406,10 @@ namespace dlib
- set_rowm(m,row) = scalar_value;
result in it being the case that:
- rowm(m,row) == uniform_matrix<matrix::type>(1,nc,scalar_value).
- In addition to the normal assignment statements using the = symbol, you may
also use the usual += and -= versions of the assignment operator. In these
cases, they have their usual effect.
!*/
// ----------------------------------------------------------------------------------------
...
...
@@ -418,6 +434,10 @@ namespace dlib
- set_rowm(m,rows) = scalar_value;
result in it being the case that:
- rowm(m,rows) == uniform_matrix<matrix::type>(nr,nc,scalar_value).
- In addition to the normal assignment statements using the = symbol, you may
also use the usual += and -= versions of the assignment operator. In these
cases, they have their usual effect.
!*/
// ----------------------------------------------------------------------------------------
...
...
@@ -439,6 +459,10 @@ namespace dlib
- set_colm(m,col) = scalar_value;
result in it being the case that:
- colm(m,col) == uniform_matrix<matrix::type>(nr,1,scalar_value).
- In addition to the normal assignment statements using the = symbol, you may
also use the usual += and -= versions of the assignment operator. In these
cases, they have their usual effect.
!*/
// ----------------------------------------------------------------------------------------
...
...
@@ -463,6 +487,10 @@ namespace dlib
- set_colm(m,cols) = scalar_value;
result in it being the case that:
- colm(m,cols) == uniform_matrix<matrix::type>(nr,nc,scalar_value).
- In addition to the normal assignment statements using the = symbol, you may
also use the usual += and -= versions of the assignment operator. In these
cases, they have their usual effect.
!*/
// ----------------------------------------------------------------------------------------
...
...
dlib/test/matrix4.cpp
View file @
9ab53f01
...
...
@@ -810,6 +810,106 @@ namespace
DLIB_TEST
(
mean
(
a
)
==
complex
<
double
>
(
4
,
5
));
}
void
test_setsubs
()
{
{
matrix
<
double
>
m
(
3
,
3
);
m
=
0
;
set_colm
(
m
,
0
)
+=
1
;
set_rowm
(
m
,
0
)
+=
1
;
set_subm
(
m
,
1
,
1
,
2
,
2
)
+=
5
;
matrix
<
double
>
m2
(
3
,
3
);
m2
=
2
,
1
,
1
,
1
,
5
,
5
,
1
,
5
,
5
;
DLIB_TEST
(
m
==
m2
);
set_colm
(
m
,
0
)
-=
1
;
set_rowm
(
m
,
0
)
-=
1
;
set_subm
(
m
,
1
,
1
,
2
,
2
)
-=
5
;
m2
=
0
;
DLIB_TEST
(
m
==
m2
);
matrix
<
double
,
1
,
3
>
r
;
matrix
<
double
,
3
,
1
>
c
;
matrix
<
double
,
2
,
2
>
b
;
r
=
1
,
2
,
3
;
c
=
2
,
3
,
4
;
b
=
2
,
3
,
4
,
5
;
set_colm
(
m
,
1
)
+=
c
;
set_rowm
(
m
,
1
)
+=
r
;
set_subm
(
m
,
1
,
1
,
2
,
2
)
+=
b
;
m2
=
0
,
2
,
0
,
1
,
7
,
6
,
0
,
8
,
5
;
DLIB_TEST
(
m2
==
m
);
set_colm
(
m
,
1
)
-=
c
;
set_rowm
(
m
,
1
)
-=
r
;
set_subm
(
m
,
1
,
1
,
2
,
2
)
-=
b
;
m2
=
0
;
DLIB_TEST
(
m2
==
m
);
// check that the code path for destructive aliasing works right.
m
=
2
*
identity_matrix
<
double
>
(
3
);
set_colm
(
m
,
1
)
+=
m
*
c
;
m2
=
2
,
4
,
0
,
0
,
8
,
0
,
0
,
8
,
2
;
DLIB_TEST
(
m
==
m2
);
m
=
2
*
identity_matrix
<
double
>
(
3
);
set_colm
(
m
,
1
)
-=
m
*
c
;
m2
=
2
,
-
4
,
0
,
0
,
-
4
,
0
,
0
,
-
8
,
2
;
DLIB_TEST
(
m
==
m2
);
m
=
2
*
identity_matrix
<
double
>
(
3
);
set_rowm
(
m
,
1
)
+=
r
*
m
;
m2
=
2
,
0
,
0
,
2
,
6
,
6
,
0
,
0
,
2
;
DLIB_TEST
(
m
==
m2
);
m
=
2
*
identity_matrix
<
double
>
(
3
);
set_rowm
(
m
,
1
)
-=
r
*
m
;
m2
=
2
,
0
,
0
,
-
2
,
-
2
,
-
6
,
0
,
0
,
2
;
DLIB_TEST
(
m
==
m2
);
m
=
identity_matrix
<
double
>
(
3
);
const
rectangle
rect
(
0
,
0
,
1
,
1
);
set_subm
(
m
,
rect
)
+=
subm
(
m
,
rect
)
*
b
;
m2
=
3
,
3
,
0
,
4
,
6
,
0
,
0
,
0
,
1
;
DLIB_TEST
(
m
==
m2
);
m
=
identity_matrix
<
double
>
(
3
);
set_subm
(
m
,
rect
)
-=
subm
(
m
,
rect
)
*
b
;
m2
=
-
1
,
-
3
,
0
,
-
4
,
-
4
,
0
,
0
,
0
,
1
;
DLIB_TEST
(
m
==
m2
);
}
}
class
matrix_tester
:
public
tester
{
...
...
@@ -823,6 +923,8 @@ namespace
void
perform_test
(
)
{
test_setsubs
();
test_conv
<
0
,
0
,
0
,
0
>
();
test_conv
<
1
,
2
,
3
,
4
>
();
...
...
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