9#include "MantidKernel/DllConfig.h"
26#define KERNEL_MATRIX_CLASS_DLL
28#define KERNEL_MATRIX_CLASS_DLL MANTID_KERNEL_DLL
60 void lubcmp(
int *,
int &);
61 void lubksb(
int const *,
double *);
62 void rotate(
double const,
double const,
int const,
int const,
int const,
int const);
65 Matrix(
const size_t nrow = 0,
const size_t ncol = 0,
bool const makeIdentity =
false);
68 Matrix(
const std::vector<T> &,
const std::vector<T> &);
71 Matrix(
const std::vector<T> &);
73 Matrix(
const std::vector<T> &,
const size_t nrow,
const size_t ncol);
83 const T *operator[](const
size_t row)
const {
return m_rawData[row]; }
86 T *
operator[](
const size_t row) {
return m_rawData[row]; }
95 std::vector<T>
operator*(
const std::vector<T> &)
const;
96 void multiplyPoint(
const std::vector<T> &in,
97 std::vector<T> &out)
const;
109 bool equals(
const Matrix<T> &A,
const double Tolerance = FLT_EPSILON)
const;
110 T
item(
size_t row,
size_t col)
const {
return m_rawData[row][col]; }
113 void write(std::ostream &,
int const = 0)
const;
114 std::string str()
const;
117 std::vector<T> getVector()
const;
119 operator std::vector<T>()
const {
120 std::vector<T>
tmp = this->getVector();
124 void setColumn(
const size_t nCol,
const std::vector<T> &newCol);
125 void setRow(
const size_t nRow,
const std::vector<T> &newRow);
127 void identityMatrix();
128 void setRandom(
size_t seed = 0,
double rMin = -1,
133 std::vector<T> Diagonal()
const;
134 Matrix<T> preMultiplyByDiagonal(
const std::vector<T> &)
const;
135 Matrix<T> postMultiplyByDiagonal(
const std::vector<T> &)
const;
137 void setMem(
const size_t,
const size_t);
140 std::pair<size_t, size_t>
size()
const {
return std::pair<size_t, size_t>(m_numRows, m_numColumns); }
146 size_t numCols()
const {
return m_numColumns; }
149 size_t Ssize()
const {
return (m_numRows > m_numColumns) ? m_numColumns : m_numRows; }
151 void swapRows(
const size_t,
const size_t);
152 void swapCols(
const size_t,
const size_t);
156 void invertTridiagonal(
double tolerance = FLT_EPSILON);
157 void averSymmetric();
164 T determinant()
const;
170 bool isRotation()
const;
172 bool isOrthogonal()
const;
174 std::vector<T> toRotation();
188 throw std::invalid_argument(
"Gauss-Jordan inversion not valid for integer matrix");
200#undef KERNEL_MATRIX_CLASS_DLL
#define KERNEL_MATRIX_CLASS_DLL
MANTID_NEXUS_DLL bool operator!=(std::string const &s, Mantid::Nexus::NexusAddress const &p)
MANTID_NEXUS_DLL std::string operator+(std::string const &s, Mantid::Nexus::NexusAddress const &p)
MANTID_NEXUS_DLL bool operator==(std::string const &s, Mantid::Nexus::NexusAddress const &p)
std::unique_ptr< U[]> CMemoryArray
1D memory allocation to be wrapped with pointers to the rows
T * operator[](const size_t row)
Array accessor. Use, e.g. Matrix[row][col].
size_t Ssize() const
Return the smallest matrix size.
void GaussJordan(Matrix< T > &)
Create a Gauss-Jordan Inversion.
T item(size_t row, size_t col) const
CMemoryArray< T > m_rawDataAlloc
Pointer to allocated memory.
T value_type
Enable users to retrieve the element type.
friend void fillFromStream(std::istream &, Kernel::Matrix< TYPE > &, const char)
size_t numRows() const
Return the number of rows in the matrix.
size_t m_numRows
Number of rows (x coordinate)
size_t m_numColumns
Number of columns (y coordinate)
size_t numCols() const
Return the number of columns in the matrix.
std::unique_ptr< U *[]> MatrixMemoryPtrs
Pointers to rows in the raw data array to make it appear 2D.
friend void dumpToStream(std::ostream &, const Kernel::Matrix< TYPE > &, const char)
std::pair< size_t, size_t > size() const
Access matrix sizes.
MatrixMemoryPtrs< T > m_rawData
Representation of 2D data.
MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
bool MANTID_API_DLL equals(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs, double tolerance=0.0)
Performs a comparison operation on two workspaces, using the CompareWorkspaces algorithm.
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.
MANTID_KERNEL_DLL std::ostream & operator<<(std::ostream &, CPUTimer &)
Convenience function to provide for easier debug printing.
MANTID_KERNEL_DLL std::istream & operator>>(std::istream &, Interpolation &)
Reads in parameter value.
Mantid::Kernel::Matrix< float > FloatMatrix
void dumpToStream(std::ostream &, const Kernel::Matrix< T > &, const char)
Write a Matrix to a stream.
void fillFromStream(std::istream &, Kernel::Matrix< T > &, const char)
Fill a Matrix from a stream using the given separator.
Helper class which provides the Collimation Length for SANS instruments.
constexpr bool operator>=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator<(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)