Commit 01fbad9e authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

moved linspace

parent ba873fea
#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) {
......
......@@ -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
......@@ -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()));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment