Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
966c2191
Unverified
Commit
966c2191
authored
Feb 21, 2020
by
Alexander Alekhin
Committed by
GitHub
Feb 21, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13928 from catree:add_matx_div_operations
parents
8f386775
c87b99e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
0 deletions
+80
-0
matx.hpp
modules/core/include/opencv2/core/matx.hpp
+28
-0
test_operations.cpp
modules/core/test/test_operations.cpp
+52
-0
No files found.
modules/core/include/opencv2/core/matx.hpp
View file @
966c2191
...
...
@@ -1279,6 +1279,34 @@ Matx<_Tp, m, n> operator * (double alpha, const Matx<_Tp, m, n>& a)
return
Matx
<
_Tp
,
m
,
n
>
(
a
,
alpha
,
Matx_ScaleOp
());
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
Matx
<
_Tp
,
m
,
n
>&
operator
/=
(
Matx
<
_Tp
,
m
,
n
>&
a
,
float
alpha
)
{
for
(
int
i
=
0
;
i
<
m
*
n
;
i
++
)
a
.
val
[
i
]
=
a
.
val
[
i
]
/
alpha
;
return
a
;
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
Matx
<
_Tp
,
m
,
n
>&
operator
/=
(
Matx
<
_Tp
,
m
,
n
>&
a
,
double
alpha
)
{
for
(
int
i
=
0
;
i
<
m
*
n
;
i
++
)
a
.
val
[
i
]
=
a
.
val
[
i
]
/
alpha
;
return
a
;
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
Matx
<
_Tp
,
m
,
n
>
operator
/
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
float
alpha
)
{
return
Matx
<
_Tp
,
m
,
n
>
(
a
,
1.
f
/
alpha
,
Matx_ScaleOp
());
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
Matx
<
_Tp
,
m
,
n
>
operator
/
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
double
alpha
)
{
return
Matx
<
_Tp
,
m
,
n
>
(
a
,
1.
/
alpha
,
Matx_ScaleOp
());
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
Matx
<
_Tp
,
m
,
n
>
operator
-
(
const
Matx
<
_Tp
,
m
,
n
>&
a
)
{
...
...
modules/core/test/test_operations.cpp
View file @
966c2191
...
...
@@ -69,6 +69,8 @@ protected:
bool
TestVec
();
bool
TestMatxMultiplication
();
bool
TestMatxElementwiseDivison
();
bool
TestDivisionByValue
();
bool
TestInplaceDivisionByValue
();
bool
TestMatMatxCastSum
();
bool
TestSubMatAccess
();
bool
TestExp
();
...
...
@@ -976,6 +978,50 @@ bool CV_OperationsTest::TestMatxElementwiseDivison()
return
true
;
}
bool
CV_OperationsTest
::
TestDivisionByValue
()
{
try
{
Matx22f
mat
(
2
,
4
,
6
,
8
);
float
alpha
=
2.
f
;
Matx22f
res
=
mat
/
alpha
;
if
(
res
(
0
,
0
)
!=
1.0
)
throw
test_excep
();
if
(
res
(
0
,
1
)
!=
2.0
)
throw
test_excep
();
if
(
res
(
1
,
0
)
!=
3.0
)
throw
test_excep
();
if
(
res
(
1
,
1
)
!=
4.0
)
throw
test_excep
();
}
catch
(
const
test_excep
&
)
{
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_OUTPUT
);
return
false
;
}
return
true
;
}
bool
CV_OperationsTest
::
TestInplaceDivisionByValue
()
{
try
{
Matx22f
mat
(
2
,
4
,
6
,
8
);
float
alpha
=
2.
f
;
mat
/=
alpha
;
if
(
mat
(
0
,
0
)
!=
1.0
)
throw
test_excep
();
if
(
mat
(
0
,
1
)
!=
2.0
)
throw
test_excep
();
if
(
mat
(
1
,
0
)
!=
3.0
)
throw
test_excep
();
if
(
mat
(
1
,
1
)
!=
4.0
)
throw
test_excep
();
}
catch
(
const
test_excep
&
)
{
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_OUTPUT
);
return
false
;
}
return
true
;
}
bool
CV_OperationsTest
::
TestVec
()
{
...
...
@@ -1204,6 +1250,12 @@ void CV_OperationsTest::run( int /* start_from */)
if
(
!
TestMatxElementwiseDivison
())
return
;
if
(
!
TestDivisionByValue
())
return
;
if
(
!
TestInplaceDivisionByValue
())
return
;
if
(
!
TestMatMatxCastSum
())
return
;
...
...
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