Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mpp
MLUQ
Commits
01fbad9e
Commit
01fbad9e
authored
May 12, 2021
by
niklas.baumgarten
Browse files
moved linspace
parent
ba873fea
Changes
3
Show whitespace changes
Inline
Side-by-side
mlmc/src/basics/Utilities.cpp
View file @
01fbad9e
#include
<RVector.hpp>
#include
<CVector.hpp>
#include
"Utilities.hpp"
#include
<sstream>
std
::
vector
<
double
>
linspace
(
const
double
&
start
,
const
double
&
end
,
int
num
)
{
std
::
vector
<
double
>
linspaced
;
if
(
num
==
0
)
{
return
linspaced
;
}
if
(
num
==
1
)
{
linspaced
.
push_back
(
start
);
return
linspaced
;
}
double
delta
=
(
end
-
start
)
/
(
num
-
1
);
for
(
int
i
=
0
;
i
<
num
-
1
;
i
++
)
{
linspaced
.
push_back
(
start
+
delta
*
i
);
}
linspaced
.
push_back
(
end
);
return
linspaced
;
}
template
<
>
std
::
string
vec2str
<
int
>
(
std
::
vector
<
int
>
vec
)
{
...
...
mlmc/src/basics/Utilities.hpp
View file @
01fbad9e
...
...
@@ -13,7 +13,4 @@
template
<
typename
T
>
std
::
string
vec2str
(
std
::
vector
<
T
>
vec
);
std
::
vector
<
double
>
linspace
(
const
double
&
start
,
const
double
&
end
,
int
num
);
#endif //TOOLS_HPP
mlmc/src/generators/algorithms/SymmetricCovariance.cpp
View file @
01fbad9e
...
...
@@ -25,6 +25,21 @@ RMatrix BMOCE(RMatrix &toepRows, RMatrix &toepCols) {
return
circRows
;
}
std
::
vector
<
double
>
linspace
(
const
double
&
start
,
const
double
&
end
,
int
num
)
{
std
::
vector
<
double
>
linspaced
;
if
(
num
==
0
)
{
return
linspaced
;
}
if
(
num
==
1
)
{
linspaced
.
push_back
(
start
);
return
linspaced
;
}
double
delta
=
(
end
-
start
)
/
(
num
-
1
);
for
(
int
i
=
0
;
i
<
num
-
1
;
i
++
)
{
linspaced
.
push_back
(
start
+
delta
*
i
);
}
linspaced
.
push_back
(
end
);
return
linspaced
;
}
void
CovarianceFunction1D
::
ToeplitzMatrix
(
CovarianceFunction1D
::
T
&
toepRow
,
CovarianceFunction1D
::
T
&
toepCol
)
{
RVector
firstCoord
(
linspace
(
0
,
1
,
toepRow
.
size
()));
...
...
Write
Preview
Supports
Markdown
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