12namespace CurveFitting {
51 static size_t makeSize(
int firstIndex,
int lastIndex);
56 if (lastIndex < firstIndex) {
57 throw std::invalid_argument(
"Vector defined with invalid index range.");
59 return static_cast<size_t>(lastIndex - firstIndex + 1);
66template <
class VectorClass>
77template <
class VectorClass>
79 : VectorClass(makeSize(iFirst, iLast)), m_base(iFirst) {}
87 this->resize(makeSize(iFirst, iLast));
95 this->resize(makeSize(1, newSize));
99template <
class VectorClass>
101 return this->VectorClass::operator[](
static_cast<size_t>(i - m_base));
105template <
class VectorClass>
107 return this->VectorClass::operator[](
static_cast<size_t>(i - m_base));
111template <
class VectorClass>
113 return this->VectorClass::operator[](
static_cast<size_t>(i - m_base));
117template <
class VectorClass>
119 return this->VectorClass::operator[](
static_cast<size_t>(i - m_base));
126 return VectorClass(std::move(*
this));
FortranVector is a wrapper template for EigenVactor and EigenComplexVector to simplify porting fortra...
VectorClass moveToBaseVector()
Move the data of this vector to a newly created vector of the bas class.
ElementConstType operator[](int i) const
The "index" operator.
FortranVector(const int n)
Constructor.
int m_base
Base for the index.
decltype(std::declval< VectorClass >()[0]) ElementRefType
FortranVector()
Constructor.
static size_t makeSize(int firstIndex, int lastIndex)
Calculate the size (1D) of a matrix First.
ElementRefType operator()(int i)
Get the reference to the data element.
void allocate(int newSize)
Resize the vector with base 1.
ElementRefType operator[](int i)
Get the reference to the data element.
void allocate(int firstIndex, int lastIndex)
Resize the vector.
FortranVector(const int iFrom, const int iTo)
Constructor.
int len() const
Get the length of the vector as an int.
decltype(std::declval< const VectorClass >()[0]) ElementConstType
Typedef the types returned by the base class's operators [].
ElementConstType operator()(int i) const
The "index" operator.
Helper class which provides the Collimation Length for SANS instruments.