Mantid
Loading...
Searching...
No Matches
EigenComplexVector.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 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#pragma once
8
9#include "MantidCurveFitting/DllConfig.h"
10
11#include <Eigen/Core>
12#include <complex>
13#include <ostream>
14#include <vector>
15
16namespace Mantid {
17namespace CurveFitting {
18
19using ComplexType = std::complex<double>;
20class ComplexVector;
21
22typedef Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> dynamic_stride;
23typedef Eigen::Map<Eigen::VectorXcd, 0, dynamic_stride> complex_vec_map_type;
24
28class MANTID_CURVEFITTING_DLL ComplexVector {
29public:
33 explicit ComplexVector(const size_t n);
35 explicit ComplexVector(const Eigen::VectorXcd v);
41 ComplexVector &operator=(const ComplexVector &v);
43 ComplexVector &operator=(const Eigen::VectorXcd &v);
45 ComplexVector &operator=(ComplexVector &&v) noexcept;
46
48 Eigen::VectorXcd &eigen();
50 const Eigen::VectorXcd eigen() const;
51
53 void resize(const size_t n);
55 size_t size() const;
56
58 void set(const size_t i, const ComplexType &value);
60 ComplexType get(const size_t i) const;
61 // Set all elements to zero
62 void zero();
64 const ComplexType operator[](const size_t i) const { return eigen()(i); }
66 ComplexType &operator[](size_t i) { return eigen()(i); }
67
77 void sort(const std::vector<size_t> &indices);
79
80protected:
82 ComplexVector move();
83
84private:
86 ComplexVector(Eigen::VectorXcd &&gslVector);
88 Eigen::VectorXcd m_vector;
89};
90
92MANTID_CURVEFITTING_DLL std::ostream &operator<<(std::ostream &ostr, const ComplexVector &v);
93
94} // namespace CurveFitting
95} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
A complex-valued vector for linear algebra computations.
const ComplexType operator[](const size_t i) const
Get a "const reference" to an element.
Eigen::VectorXcd m_vector
The Eigen vector.
ComplexType & operator[](size_t i)
Get a "reference" to an element.
MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Adds two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Subtracts two workspaces.
MANTID_API_DLL std::ostream & operator<<(std::ostream &, const AlgorithmHistory &)
Prints a text representation.
MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
std::complex< double > ComplexType
Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > dynamic_stride
Eigen::Map< Eigen::VectorXcd, 0, dynamic_stride > complex_vec_map_type
Helper class which provides the Collimation Length for SANS instruments.