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
3d48994a
Commit
3d48994a
authored
Jul 09, 2014
by
Roman Donchenko
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2883 from berak:b_3756_24
parents
71d36548
7b160fa3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
2 deletions
+43
-2
matop.cpp
modules/core/src/matop.cpp
+28
-2
test_mat.cpp
modules/core/test/test_mat.cpp
+15
-0
No files found.
modules/core/src/matop.cpp
View file @
3d48994a
...
@@ -200,6 +200,7 @@ public:
...
@@ -200,6 +200,7 @@ public:
void
multiply
(
const
MatExpr
&
e
,
double
s
,
MatExpr
&
res
)
const
;
void
multiply
(
const
MatExpr
&
e
,
double
s
,
MatExpr
&
res
)
const
;
static
void
makeExpr
(
MatExpr
&
res
,
int
method
,
Size
sz
,
int
type
,
double
alpha
=
1
);
static
void
makeExpr
(
MatExpr
&
res
,
int
method
,
Size
sz
,
int
type
,
double
alpha
=
1
);
static
void
makeExpr
(
MatExpr
&
res
,
int
method
,
int
ndims
,
const
int
*
sizes
,
int
type
,
double
alpha
=
1
);
};
};
static
MatOp_Initializer
*
getGlobalMatOpInitializer
()
static
MatOp_Initializer
*
getGlobalMatOpInitializer
()
...
@@ -1555,8 +1556,13 @@ void MatOp_Initializer::assign(const MatExpr& e, Mat& m, int _type) const
...
@@ -1555,8 +1556,13 @@ void MatOp_Initializer::assign(const MatExpr& e, Mat& m, int _type) const
{
{
if
(
_type
==
-
1
)
if
(
_type
==
-
1
)
_type
=
e
.
a
.
type
();
_type
=
e
.
a
.
type
();
m
.
create
(
e
.
a
.
size
(),
_type
);
if
(
e
.
flags
==
'I'
)
if
(
e
.
a
.
dims
<=
2
)
m
.
create
(
e
.
a
.
size
(),
_type
);
else
m
.
create
(
e
.
a
.
dims
,
e
.
a
.
size
,
_type
);
if
(
e
.
flags
==
'I'
&&
e
.
a
.
dims
<=
2
)
setIdentity
(
m
,
Scalar
(
e
.
alpha
));
setIdentity
(
m
,
Scalar
(
e
.
alpha
));
else
if
(
e
.
flags
==
'0'
)
else
if
(
e
.
flags
==
'0'
)
m
=
Scalar
();
m
=
Scalar
();
...
@@ -1577,6 +1583,12 @@ inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, Size sz, int t
...
@@ -1577,6 +1583,12 @@ inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, Size sz, int t
res
=
MatExpr
(
getGlobalMatOpInitializer
(),
method
,
Mat
(
sz
,
type
,
(
void
*
)
0
),
Mat
(),
Mat
(),
alpha
,
0
);
res
=
MatExpr
(
getGlobalMatOpInitializer
(),
method
,
Mat
(
sz
,
type
,
(
void
*
)
0
),
Mat
(),
Mat
(),
alpha
,
0
);
}
}
inline
void
MatOp_Initializer
::
makeExpr
(
MatExpr
&
res
,
int
method
,
int
ndims
,
const
int
*
sizes
,
int
type
,
double
alpha
)
{
res
=
MatExpr
(
getGlobalMatOpInitializer
(),
method
,
Mat
(
ndims
,
sizes
,
type
,
(
void
*
)
0
),
Mat
(),
Mat
(),
alpha
,
0
);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////
...
@@ -1636,6 +1648,20 @@ MatExpr Mat::ones(Size size, int type)
...
@@ -1636,6 +1648,20 @@ MatExpr Mat::ones(Size size, int type)
return
e
;
return
e
;
}
}
MatExpr
Mat
::
zeros
(
int
ndims
,
const
int
*
sizes
,
int
type
)
{
MatExpr
e
;
MatOp_Initializer
::
makeExpr
(
e
,
'0'
,
ndims
,
sizes
,
type
);
return
e
;
}
MatExpr
Mat
::
ones
(
int
ndims
,
const
int
*
sizes
,
int
type
)
{
MatExpr
e
;
MatOp_Initializer
::
makeExpr
(
e
,
'1'
,
ndims
,
sizes
,
type
);
return
e
;
}
MatExpr
Mat
::
eye
(
int
rows
,
int
cols
,
int
type
)
MatExpr
Mat
::
eye
(
int
rows
,
int
cols
,
int
type
)
{
{
MatExpr
e
;
MatExpr
e
;
...
...
modules/core/test/test_mat.cpp
View file @
3d48994a
...
@@ -918,3 +918,18 @@ TEST(Core_Mat, copyNx1ToVector)
...
@@ -918,3 +918,18 @@ TEST(Core_Mat, copyNx1ToVector)
ASSERT_PRED_FORMAT2
(
cvtest
::
MatComparator
(
0
,
0
),
ref_dst16
,
cv
::
Mat_
<
ushort
>
(
dst16
));
ASSERT_PRED_FORMAT2
(
cvtest
::
MatComparator
(
0
,
0
),
ref_dst16
,
cv
::
Mat_
<
ushort
>
(
dst16
));
}
}
TEST
(
Core_Mat
,
multiDim
)
{
int
d
[]
=
{
3
,
3
,
3
};
Mat
m0
=
Mat
::
zeros
(
3
,
d
,
CV_8U
);
ASSERT_EQ
(
0
,
sum
(
m0
)[
0
]);
Mat
m
=
Mat
::
ones
(
3
,
d
,
CV_8U
);
ASSERT_EQ
(
27
,
sum
(
m
)[
0
]);
m
+=
2
;
ASSERT_EQ
(
81
,
sum
(
m
)[
0
]);
m
*=
3
;
ASSERT_EQ
(
243
,
sum
(
m
)[
0
]);
m
+=
m
;
ASSERT_EQ
(
486
,
sum
(
m
)[
0
]);
}
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