Mantid
Loading...
Searching...
No Matches
PolyBase.h
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#pragma once
8
9#include "MantidGeometry/DllConfig.h"
10
11namespace Mantid {
12
13namespace mathLevel {
14
31class MANTID_GEOMETRY_DLL PolyBase {
32private:
33 int iDegree;
34 std::vector<double> afCoeff;
35 double Eaccuracy;
36
37 int solveQuadratic(std::complex<double> &, std::complex<double> &) const;
38 int solveCubic(std::complex<double> &, std::complex<double> &, std::complex<double> &) const;
39
40public:
41 explicit PolyBase(int const);
42 PolyBase(int const, double const);
43
44 // member access
45 void setDegree(int const);
46 int getDegree() const;
47 operator const std::vector<double> &() const;
48 operator std::vector<double> &();
49 double operator[](int const) const;
50 double &operator[](int const);
51
52 // evaluation
53 double operator()(double const) const;
54
55 // arithmetic updates
59
60 // arithmetic operations
61 PolyBase operator+(const PolyBase &) const;
62 PolyBase operator-(const PolyBase &) const;
63 PolyBase operator*(const PolyBase &) const;
64 // PolyBase operator/(const PolyBase&) const;
65
66 // input is degree 0 poly
67 PolyBase operator+(double const) const; // input is degree 0 poly
68 PolyBase operator-(double const) const;
69 PolyBase operator*(double const) const;
70 PolyBase operator/(double const) const;
71
72 PolyBase operator-() const;
73
74 // input is degree 0 poly
75 PolyBase &operator+=(double const);
76 PolyBase &operator-=(double const);
77 PolyBase &operator*=(double const);
78 PolyBase &operator/=(double const);
79
80 // derivation
81 PolyBase getDerivative() const;
82 PolyBase &derivative();
83
84 // inversion ( invpoly[i] = poly[degree-i] for 0 <= i <= degree )
85 PolyBase GetInversion() const;
86
87 void compress(double const);
88
89 void divide(const PolyBase &, PolyBase &, PolyBase &, double const = -1.0) const;
90
91 std::vector<double> realRoots(double const = -1.0);
92 std::vector<std::complex<double>> calcRoots(double const = -1.0);
93
94 void write(std::ostream &) const;
95};
96
97PolyBase operator*(double const, const PolyBase &);
98std::ostream &operator<<(std::ostream &, const PolyBase &);
99
100} // namespace mathLevel
101
102} // NAMESPACE Mantid
Holds a polynominal as a primary type.
Definition: PolyBase.h:31
std::vector< double > afCoeff
Coefficients.
Definition: PolyBase.h:34
double Eaccuracy
Polynomic accuracy.
Definition: PolyBase.h:35
int iDegree
Degree of polynomial [0 == constant].
Definition: PolyBase.h:33
MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Divide two workspaces.
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.
MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Subtracts two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Divide two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Adds two workspaces.
std::ostream & operator<<(std::ostream &, const PolyBase &)
External Friend :: outputs point to a stream.
Definition: PolyBase.cpp:20
PolyBase operator*(double const, const PolyBase &)
Helper class which provides the Collimation Length for SANS instruments.
MANTID_GEOMETRY_DLL int solveCubic(InputIter, std::complex< double > &, std::complex< double > &, std::complex< double > &)
Solve a Cubic equation.
MANTID_GEOMETRY_DLL int solveQuadratic(InputIter, std::pair< std::complex< double >, std::complex< double > > &)
Solve a Quadratic equation.
Definition: mathSupport.cpp:23