diff --git a/openbr/core/common.cpp b/openbr/core/common.cpp index 55cbd3e..46bb953 100644 --- a/openbr/core/common.cpp +++ b/openbr/core/common.cpp @@ -63,3 +63,15 @@ QList Common::RandSample(int n, const QSet &values, bool unique) } return samples; } + +QList linspace(float start, float stop, int n) { + float delta = (stop - start) / (n - 1); + float curValue = start; + QList spaced; + spaced.reserve(n); + spaced.append(start); + for (int i = 1; i < (n - 1); i++) { + spaced.append(curValue += delta); + } + spaced.append(stop); +} diff --git a/openbr/core/common.h b/openbr/core/common.h index bd0b603..15516d0 100644 --- a/openbr/core/common.h +++ b/openbr/core/common.h @@ -253,6 +253,11 @@ QList RandSample(int n, const QList &weights, bool unique = false) } /*! + * \brief See Matlab function linspace() for documentation. + */ +QList linspace(float start, float stop, int n); + +/*! * \brief See Matlab function unique() for documentation. */ template