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
12
13// Eigen's code generate maybe-uninitialized warning under GCC
14GNU_DIAG_OFF("maybe-uninitialized")
15#include <Eigen/Core>
16GNU_DIAG_ON("maybe-uninitialized")
17
18#include <complex>
19#include <ostream>
20#include <vector>
21
22namespace Mantid {
23namespace CurveFitting {
24
25using ComplexType = std::complex<double>;
26class ComplexVector;
27
28typedef Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> dynamic_stride;
29typedef Eigen::Map<Eigen::VectorXcd, 0, dynamic_stride> complex_vec_map_type;
30
34class MANTID_CURVEFITTING_DLL ComplexVector {
35public:
39 explicit ComplexVector(const size_t n);
41 explicit ComplexVector(const Eigen::VectorXcd v);
47 ComplexVector &operator=(const ComplexVector &v);
49 ComplexVector &operator=(const Eigen::VectorXcd &v);
51 ComplexVector &operator=(ComplexVector &&v) noexcept;
52
54 Eigen::VectorXcd &eigen();
56 const Eigen::VectorXcd eigen() const;
57
59 void resize(const size_t n);
61 size_t size() const;
62
64 void set(const size_t i, const ComplexType &value);
66 ComplexType get(const size_t i) const;
67 // Set all elements to zero
68 void zero();
70 const ComplexType operator[](const size_t i) const { return eigen()(i); }
72 ComplexType &operator[](size_t i) { return eigen()(i); }
73
83 void sort(const std::vector<size_t> &indices);
85
86protected:
88 ComplexVector move();
89
90private:
92 ComplexVector(Eigen::VectorXcd &&gslVector);
94 Eigen::VectorXcd m_vector;
95};
96
98MANTID_CURVEFITTING_DLL std::ostream &operator<<(std::ostream &ostr, const ComplexVector &v);
99
100} // namespace CurveFitting
101} // namespace Mantid
double value
The value of the point.
Definition FitMW.cpp:51
#define GNU_DIAG_ON(x)
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
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.