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
6e4c77cd
Commit
6e4c77cd
authored
Feb 29, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated the min and max functions so that they work with complex
numbers in the same manner as MATLAB.
parent
7f5dbb71
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
matrix_utilities.h
dlib/matrix/matrix_utilities.h
+14
-6
matrix_utilities_abstract.h
dlib/matrix/matrix_utilities_abstract.h
+6
-2
No files found.
dlib/matrix/matrix_utilities.h
View file @
6e4c77cd
...
...
@@ -64,6 +64,14 @@ namespace dlib
// ----------------------------------------------------------------------------------------
namespace
impl
{
template
<
typename
T
>
const
T
&
magnitude
(
const
T
&
item
)
{
return
item
;
}
template
<
typename
T
>
T
magnitude
(
const
std
::
complex
<
T
>&
item
)
{
return
std
::
norm
(
item
);
}
}
template
<
typename
EXP
>
...
...
@@ -87,9 +95,9 @@ namespace dlib
for
(
long
c
=
0
;
c
<
m
.
nc
();
++
c
)
{
type
temp
=
m
(
r
,
c
);
if
(
temp
>
max_val
)
if
(
dlib
::
impl
::
magnitude
(
temp
)
>
dlib
::
impl
::
magnitude
(
max_val
)
)
max_val
=
temp
;
if
(
temp
<
min_val
)
if
(
dlib
::
impl
::
magnitude
(
temp
)
<
dlib
::
impl
::
magnitude
(
min_val
)
)
min_val
=
temp
;
}
}
...
...
@@ -118,7 +126,7 @@ namespace dlib
for
(
long
i
=
1
;
i
<
m
.
size
();
++
i
)
{
type
temp
=
m
(
i
);
if
(
temp
>
val
)
if
(
dlib
::
impl
::
magnitude
(
temp
)
>
dlib
::
impl
::
magnitude
(
val
)
)
{
val
=
temp
;
best_idx
=
i
;
...
...
@@ -150,7 +158,7 @@ namespace dlib
for
(
long
i
=
1
;
i
<
m
.
size
();
++
i
)
{
type
temp
=
m
(
i
);
if
(
temp
<
val
)
if
(
dlib
::
impl
::
magnitude
(
temp
)
<
dlib
::
impl
::
magnitude
(
val
)
)
{
val
=
temp
;
best_idx
=
i
;
...
...
@@ -181,7 +189,7 @@ namespace dlib
for
(
long
c
=
0
;
c
<
m
.
nc
();
++
c
)
{
type
temp
=
m
(
r
,
c
);
if
(
temp
>
val
)
if
(
dlib
::
impl
::
magnitude
(
temp
)
>
dlib
::
impl
::
magnitude
(
val
)
)
val
=
temp
;
}
}
...
...
@@ -210,7 +218,7 @@ namespace dlib
for
(
long
c
=
0
;
c
<
m
.
nc
();
++
c
)
{
type
temp
=
m
(
r
,
c
);
if
(
temp
<
val
)
if
(
dlib
::
impl
::
magnitude
(
temp
)
<
dlib
::
impl
::
magnitude
(
val
)
)
val
=
temp
;
}
}
...
...
dlib/matrix/matrix_utilities_abstract.h
View file @
6e4c77cd
...
...
@@ -1355,7 +1355,9 @@ namespace dlib
requires
- m.size() > 0
ensures
- returns the value of the smallest element of m
- returns the value of the smallest element of m. If m contains complex
elements then the element returned is the one with the smallest norm
according to std::norm().
!*/
// ----------------------------------------------------------------------------------------
...
...
@@ -1367,7 +1369,9 @@ namespace dlib
requires
- m.size() > 0
ensures
- returns the value of the biggest element of m
- returns the value of the biggest element of m. If m contains complex
elements then the element returned is the one with the largest norm
according to std::norm().
!*/
// ----------------------------------------------------------------------------------------
...
...
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