Mantid
Loading...
Searching...
No Matches
Framework
API
src
LinearScale.cpp
Go to the documentation of this file.
1
// Mantid Repository : https://github.com/mantidproject/mantid
2
//
3
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4
// NScD Oak Ridge National Laboratory, European Spallation Source,
5
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6
// SPDX - License - Identifier: GPL - 3.0 +
7
//----------------------------------------------------------------------
8
// Includes
9
//----------------------------------------------------------------------
10
11
#include "
MantidAPI/LinearScale.h
"
12
#include "
MantidAPI/TransformScaleFactory.h
"
13
14
namespace
Mantid::API
{
15
16
DECLARE_TRANSFORMSCALE
(LinearScale)
17
18
/* Transform the grid to adopt a linear scale
19
* @param gd a grid object
20
*/
21
void
LinearScale
::transform(
std
::vector<
double
> &gd) {
22
size_t
n
= gd.size();
23
if
(
n
< 3)
24
return
;
// no need to process
25
double
startX = gd.front();
26
double
endX = gd.back();
27
double
spacing = (endX - startX) /
double
(
n
);
28
double
x
= startX + spacing;
29
for
(
auto
it = gd.begin() + 1; it != gd.end() - 1; it++) {
30
*it =
x
;
31
x
+= spacing;
32
}
33
}
34
35
}
// namespace Mantid::API
n
size_t n
Definition:
AugmentedLagrangianOptimizer.cpp:42
DECLARE_TRANSFORMSCALE
#define DECLARE_TRANSFORMSCALE(classname)
Definition:
ITransformScale.h:46
LinearScale.h
TransformScaleFactory.h
Mantid::API::LinearScale
Definition:
LinearScale.h:26
Mantid::API
Definition:
AbsorptionCorrection.h:20
Mantid::Geometry::x
I a m x
Definition:
SpaceGroupFactory.cpp:675
std
STL namespace.
Generated on Tue Jan 3 2023 11:57:23 for Mantid by
1.9.5