Mantid
Loading...
Searching...
No Matches
EigenVector.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"
16#include "Eigen/Dense"
17GNU_DIAG_ON("maybe-uninitialized")
18
19#include "MantidCurveFitting/EigenVectorView.h"
20
21#include <ostream>
22#include <vector>
23
24namespace Mantid {
25namespace CurveFitting {
33class MANTID_CURVEFITTING_DLL EigenVector {
34public:
38 explicit EigenVector(const size_t n);
40 explicit EigenVector(std::vector<double> v);
42 explicit EigenVector(const Eigen::VectorXd *v);
44 EigenVector(std::initializer_list<double> ilist);
46 EigenVector(const EigenVector &v);
48 EigenVector(EigenVector &&v) noexcept;
50 EigenVector &operator=(const EigenVector &v);
52 EigenVector &operator=(const std::vector<double> &v);
54 EigenVector &operator=(const Eigen::VectorXd v);
55
57 inline vec_map_type &mutator() { return m_view.vector_mutator(); }
59 const vec_map_type inspector() const { return m_view.vector_inspector(); }
61 vec_map_type copy_view() const { return m_view.vector_copy(); }
62
64 void resize(const size_t n);
66 size_t size() const;
67
69 void set(const size_t i, const double value);
71 double get(const size_t i) const;
73 const double &operator[](const size_t i) const { return m_data[i]; }
75 double &operator[](const size_t i) { return m_data[i]; }
76 // Set all elements to zero
77 void zero();
79 void normalize();
81 double norm() const;
83 double norm2() const;
85 double dot(const EigenVector &v) const;
87 size_t indexOfMinElement() const;
89 size_t indexOfMaxElement() const;
91 std::pair<size_t, size_t> indicesOfMinMaxElements() const;
93 std::vector<size_t> sortIndices(bool ascending = true) const;
95 void sort(const std::vector<size_t> &indices);
97 const std::vector<double> &toStdVector() const;
99 std::vector<double> &StdVectorRef();
100
108 EigenVector &operator*=(const double d);
110 EigenVector &operator+=(const double d);
111
112private:
114 std::vector<double> m_data;
117};
118
120MANTID_CURVEFITTING_DLL std::ostream &operator<<(std::ostream &ostr, const EigenVector &v);
121
122} // namespace CurveFitting
123} // namespace Mantid
double value
The value of the point.
Definition FitMW.cpp:51
const std::vector< Type > & m_data
#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 wrapper around Eigen::Vector.
Definition EigenVector.h:33
std::vector< double > m_data
Default element storage.
vec_map_type & mutator()
Get the map of the eigen vector.
Definition EigenVector.h:57
double & operator[](const size_t i)
Get a reference to an element.
Definition EigenVector.h:75
EigenVector_View m_view
The map to the Eigen vector.
const double & operator[](const size_t i) const
Get a const reference to an element.
Definition EigenVector.h:73
vec_map_type copy_view() const
Get a copy of the eigen vector.
Definition EigenVector.h:61
const vec_map_type inspector() const
Get the const map of the eigen vector.
Definition EigenVector.h:59
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.
Eigen::Map< Eigen::VectorXd, 0, dynamic_stride > vec_map_type
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.
Definition V3D.h:352
Helper class which provides the Collimation Length for SANS instruments.