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
c5ff6a74
Commit
c5ff6a74
authored
Mar 17, 2014
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved speed of reshape_to_column_vector()
parent
48e02587
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
matrix_utilities.h
dlib/matrix/matrix_utilities.h
+45
-0
matrix3.cpp
dlib/test/matrix3.cpp
+2
-0
No files found.
dlib/matrix/matrix_utilities.h
View file @
c5ff6a74
...
...
@@ -3901,6 +3901,51 @@ namespace dlib
return
matrix_op
<
op
>
(
op
(
m
.
ref
()));
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
,
long
NR_
,
long
NC_
,
typename
MM
>
struct
op_mat_to_vect2
{
typedef
matrix
<
T
,
NR_
,
NC_
,
MM
,
row_major_layout
>
M
;
op_mat_to_vect2
(
const
M
&
m_
)
:
m
(
m_
)
{}
const
M
&
m
;
const
static
long
cost
=
M
::
cost
+
2
;
const
static
long
NR
=
M
::
NC
*
M
::
NR
;
const
static
long
NC
=
1
;
typedef
typename
M
::
type
type
;
typedef
typename
M
::
const_ret_type
const_ret_type
;
typedef
typename
M
::
mem_manager_type
mem_manager_type
;
typedef
typename
M
::
layout_type
layout_type
;
const_ret_type
apply
(
long
r
,
long
)
const
{
return
(
&
m
(
0
,
0
))[
r
];
}
long
nr
()
const
{
return
m
.
size
();
}
long
nc
()
const
{
return
1
;
}
template
<
typename
U
>
bool
aliases
(
const
matrix_exp
<
U
>&
item
)
const
{
return
m
.
aliases
(
item
);
}
template
<
typename
U
>
bool
destructively_aliases
(
const
matrix_exp
<
U
>&
item
)
const
{
return
m
.
aliases
(
item
);
}
};
template
<
typename
T
,
long
NR
,
long
NC
,
typename
MM
>
const
matrix_op
<
op_mat_to_vect2
<
T
,
NR
,
NC
,
MM
>
>
reshape_to_column_vector
(
const
matrix
<
T
,
NR
,
NC
,
MM
,
row_major_layout
>&
m
)
{
typedef
op_mat_to_vect2
<
T
,
NR
,
NC
,
MM
>
op
;
return
matrix_op
<
op
>
(
op
(
m
.
ref
()));
}
// ----------------------------------------------------------------------------------------
template
<
typename
M1
,
typename
M2
>
...
...
dlib/test/matrix3.cpp
View file @
c5ff6a74
...
...
@@ -610,6 +610,7 @@ namespace
m2
=
1
,
2
,
3
,
4
,
5
,
6
;
DLIB_TEST
(
reshape_to_column_vector
(
m
)
==
m2
);
DLIB_TEST
(
reshape_to_column_vector
(
m
+
m
)
==
m2
+
m2
);
}
{
...
...
@@ -622,6 +623,7 @@ namespace
m2
=
1
,
2
,
3
,
4
,
5
,
6
;
DLIB_TEST
(
reshape_to_column_vector
(
m
)
==
m2
);
DLIB_TEST
(
reshape_to_column_vector
(
m
+
m
)
==
m2
+
m2
);
}
}
...
...
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