40 #ifndef __OPENFLUID_CORE_MATRIX_HPP__
41 #define __OPENFLUID_CORE_MATRIX_HPP__
67 bool allocate(
unsigned long ColsNbr,
unsigned long RowsNbr);
87 Matrix(
unsigned long ColsNbr,
unsigned long RowsNbr);
92 Matrix(
unsigned long ColsNbr,
unsigned long RowsNbr,
const T& InitValue);
133 return (m_ColsNbr * m_RowsNbr);
139 inline unsigned long size()
const
141 return (m_ColsNbr * m_RowsNbr);
150 return static_cast<T*
>(m_Data.get());
156 void setData(T* Data,
unsigned long ColsNbr,
unsigned long RowsNbr);
161 T
getElement(
unsigned long ColIndex,
unsigned long RowIndex)
const;
166 inline T
at(
unsigned long ColIndex,
unsigned long RowIndex)
const
168 return getElement(ColIndex,RowIndex);
174 inline T
get(
unsigned long ColIndex,
unsigned long RowIndex)
const
175 {
return getElement(ColIndex,RowIndex); };
181 void setElement(
unsigned long ColIndex,
unsigned long RowIndex,
const T& Val);
186 inline void set(
unsigned long ColIndex,
unsigned long RowIndex,
const T& Val)
188 setElement(ColIndex,RowIndex,Val);
210 m_ColsNbr(0),m_RowsNbr(0)
243 if (!allocate(ColsNbr,RowsNbr))
259 if (!allocate(ColsNbr,RowsNbr))
304 m_ColsNbr = Other.m_ColsNbr;
305 m_RowsNbr = Other.m_RowsNbr;
306 m_Data = std::move(Other.m_Data);
336 if (ColsNbr > 0 && RowsNbr > 0)
339 m_Data = std::move(std::make_unique<T[]>(ColsNbr*RowsNbr));
364 if (!allocate(ColsNbr,RowsNbr))
369 std::copy(Data, Data + (ColsNbr*RowsNbr), m_Data.get());
380 if (ColIndex >= m_ColsNbr || RowIndex >= m_RowsNbr)
385 return m_Data[ColIndex*m_RowsNbr+RowIndex];
396 if (ColIndex >= m_ColsNbr || RowIndex >= m_RowsNbr)
401 m_Data[ColIndex*m_RowsNbr+RowIndex] = Val;
412 std::fill(m_Data.get(), m_Data.get() + (m_ColsNbr*m_RowsNbr),Val);
Definition: FrameworkException.hpp:51
Definition: Matrix.hpp:58
void fill(const T &Val)
Definition: Matrix.hpp:410
unsigned long m_ColsNbr
Definition: Matrix.hpp:63
bool allocate(unsigned long ColsNbr, unsigned long RowsNbr)
Definition: Matrix.hpp:334
T * data() const
Definition: Matrix.hpp:148
void setData(T *Data, unsigned long ColsNbr, unsigned long RowsNbr)
Definition: Matrix.hpp:360
unsigned long getColsNbr() const
Definition: Matrix.hpp:113
std::unique_ptr< T[]> m_Data
Definition: Matrix.hpp:61
unsigned long m_RowsNbr
Definition: Matrix.hpp:65
Matrix(unsigned long ColsNbr, unsigned long RowsNbr, const T &InitValue)
Definition: Matrix.hpp:255
void set(unsigned long ColIndex, unsigned long RowIndex, const T &Val)
Definition: Matrix.hpp:186
T getElement(unsigned long ColIndex, unsigned long RowIndex) const
Definition: Matrix.hpp:378
Matrix< T > & operator=(Matrix &&Other)
Definition: Matrix.hpp:297
void clear()
Definition: Matrix.hpp:421
unsigned long size() const
Definition: Matrix.hpp:139
T at(unsigned long ColIndex, unsigned long RowIndex) const
Definition: Matrix.hpp:166
void init()
Definition: Matrix.hpp:321
Matrix()
Definition: Matrix.hpp:209
unsigned long getSize() const
Definition: Matrix.hpp:131
virtual ~Matrix()=default
void setElement(unsigned long ColIndex, unsigned long RowIndex, const T &Val)
Definition: Matrix.hpp:394
Matrix(const Matrix &Other)
Definition: Matrix.hpp:221
Matrix(unsigned long ColsNbr, unsigned long RowsNbr)
Definition: Matrix.hpp:239
Matrix< T > & operator=(const Matrix &Other)
Definition: Matrix.hpp:273
unsigned long getRowsNbr() const
Definition: Matrix.hpp:122
T get(unsigned long ColIndex, unsigned long RowIndex) const
Definition: Matrix.hpp:174
#define OPENFLUID_API
Definition: dllexport.hpp:86
Definition: ApplicationException.hpp:47