Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compressed_sensing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Strand
compressed_sensing
Commits
4eab096c
Commit
4eab096c
authored
6 years ago
by
Erik Strand
Browse files
Options
Downloads
Patches
Plain Diff
Sample points in C++
parent
53704c96
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+0
-1
0 additions, 1 deletion
CMakeLists.txt
main.cpp
+29
-4
29 additions, 4 deletions
main.cpp
plotter.py
+9
-0
9 additions, 0 deletions
plotter.py
vector.h
+0
-18
0 additions, 18 deletions
vector.h
with
38 additions
and
23 deletions
CMakeLists.txt
+
0
−
1
View file @
4eab096c
...
@@ -12,7 +12,6 @@ include(cmake/shared_settings.cmake)
...
@@ -12,7 +12,6 @@ include(cmake/shared_settings.cmake)
add_executable
(
compressed_sensing
add_executable
(
compressed_sensing
main.cpp
main.cpp
vector.h
)
)
target_link_libraries
(
compressed_sensing shared_settings Eigen3::Eigen
)
target_link_libraries
(
compressed_sensing shared_settings Eigen3::Eigen
)
target_compile_features
(
compressed_sensing PUBLIC cxx_std_17
)
target_compile_features
(
compressed_sensing PUBLIC cxx_std_17
)
This diff is collapsed.
Click to expand it.
main.cpp
+
29
−
4
View file @
4eab096c
#include
<Eigen/Core>
#include
<iostream>
#include
<iostream>
#include
"vector.h"
using
namespace
cs
;
using
Scalar
=
double
;
using
Vector
=
Eigen
::
Matrix
<
Scalar
,
Eigen
::
Dynamic
,
1
>
;
using
Matrix
=
Eigen
::
Matrix
<
Scalar
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
;
void
python_print
(
char
const
*
name
,
Vector
const
&
x
)
{
std
::
cout
<<
name
<<
" = np.array(["
;
std
::
cout
<<
x
[
0
];
for
(
uint32_t
i
=
1
;
i
<
x
.
size
();
++
i
)
{
std
::
cout
<<
", "
<<
x
[
i
];
}
std
::
cout
<<
"])
\n
"
;
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
int
main
()
{
int
main
()
{
Vector
<
double
>
x
=
Vector
<
double
>::
Random
(
5
);
//Vector x = Vector::Random(5);
std
::
cout
<<
x
<<
'\n'
;
//std::cout << x << '\n';
Scalar
pi
=
3.1415926535897932384626433832795
;
Scalar
f1
=
697
;
Scalar
f2
=
1209
;
Scalar
sample_period
=
0.01
;
uint32_t
n_samples
=
10
;
Vector
sample_times
=
(
sample_period
/
n_samples
)
*
Vector
::
LinSpaced
(
n_samples
,
0
,
n_samples
);
python_print
(
"sample_times"
,
sample_times
);
Vector
sample_rads
=
2
*
pi
*
sample_times
;
Vector
sample_values
=
sin
((
f1
*
sample_rads
).
array
())
+
sin
((
f2
*
sample_rads
).
array
());
python_print
(
"sample_values"
,
sample_values
);
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
plotter.py
0 → 100644
+
9
−
0
View file @
4eab096c
import
numpy
as
np
import
matplotlib.pyplot
as
plt
if
__name__
==
"
__main__
"
:
sample_times
=
np
.
array
([
0
,
0.00111111
,
0.00222222
,
0.00333333
,
0.00444444
,
0.00555556
,
0.00666667
,
0.00777778
,
0.00888889
,
0.01
])
sample_values
=
np
.
array
([
0
,
-
0.155307
,
-
1.22423
,
1.08309
,
1.2909
,
-
1.69749
,
-
0.428405
,
1.04634
,
-
0.0577232
,
0.348445
])
plt
.
plot
(
sample_times
,
sample_values
)
plt
.
savefig
(
"
fig_a.png
"
)
plt
.
close
()
This diff is collapsed.
Click to expand it.
vector.h
deleted
100644 → 0
+
0
−
18
View file @
53704c96
#ifndef FUNSIM_VECTOR_H
#define FUNSIM_VECTOR_H
#include
<Eigen/Core>
namespace
cs
{
//--------------------------------------------------------------------------------------------------
template
<
typename
T
>
using
Vector
=
Eigen
::
Matrix
<
T
,
Eigen
::
Dynamic
,
1
>
;
//--------------------------------------------------------------------------------------------------
template
<
typename
T
>
using
Matrix
=
Eigen
::
Matrix
<
T
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
;
}
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment