9#include "MantidKernel/DllConfig.h"
25#define KERNEL_MATRIX_CLASS_DLL
27#define KERNEL_MATRIX_CLASS_DLL MANTID_KERNEL_DLL
61 void lubcmp(
int *,
int &);
62 void lubksb(
int const *,
double *);
63 void rotate(
double const,
double const,
int const,
int const,
int const,
int const);
66 Matrix(
const size_t nrow = 0,
const size_t ncol = 0,
bool const makeIdentity =
false);
69 Matrix(
const std::vector<T> &,
const std::vector<T> &);
72 Matrix(
const std::vector<T> &);
74 Matrix(
const std::vector<T> &,
const size_t nrow,
const size_t ncol);
84 const T *operator[](const
size_t row)
const {
return m_rawData[row]; }
87 T *
operator[](
const size_t row) {
return m_rawData[row]; }
96 std::vector<T>
operator*(
const std::vector<T> &)
const;
97 void multiplyPoint(
const std::vector<T> &in,
98 std::vector<T> &out)
const;
110 bool equals(
const Matrix<T> &A,
const double Tolerance = FLT_EPSILON)
const;
111 T
item(
size_t row,
size_t col)
const {
return m_rawData[row][col]; }
114 void write(std::ostream &,
int const = 0)
const;
115 std::string str()
const;
118 std::vector<T> getVector()
const;
120 operator std::vector<T>()
const {
121 std::vector<T>
tmp = this->getVector();
125 void setColumn(
const size_t nCol,
const std::vector<T> &newCol);
126 void setRow(
const size_t nRow,
const std::vector<T> &newRow);
128 void identityMatrix();
129 void setRandom(
size_t seed = 0,
double rMin = -1,
134 std::vector<T> Diagonal()
const;
135 Matrix<T> preMultiplyByDiagonal(
const std::vector<T> &)
const;
136 Matrix<T> postMultiplyByDiagonal(
const std::vector<T> &)
const;
138 void setMem(
const size_t,
const size_t);
141 std::pair<size_t, size_t>
size()
const {
return std::pair<size_t, size_t>(m_numRows, m_numColumns); }
147 size_t numCols()
const {
return m_numColumns; }
150 size_t Ssize()
const {
return (m_numRows > m_numColumns) ? m_numColumns : m_numRows; }
152 void swapRows(
const size_t,
const size_t);
153 void swapCols(
const size_t,
const size_t);
157 void invertTridiagonal();
158 void averSymmetric();
165 T determinant()
const;
171 bool isRotation()
const;
173 bool isOrthogonal()
const;
175 std::vector<T> toRotation();
189 throw std::invalid_argument(
"Gauss-Jordan inversion not valid for integer matrix");
201#undef KERNEL_MATRIX_CLASS_DLL
#define KERNEL_MATRIX_CLASS_DLL
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.
MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Adds 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.
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)
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)