Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
c5ff6a74
"git@developer.sourcefind.cn:OpenDAS/ollama.git" did not exist on "282bfaaa957fff8402eb7a4b1657f57c49939604"
Commit
c5ff6a74
authored
Mar 17, 2014
by
Davis King
Browse files
Improved speed of reshape_to_column_vector()
parent
48e02587
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
dlib/matrix/matrix_utilities.h
dlib/matrix/matrix_utilities.h
+45
-0
dlib/test/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