kwave  18.07.70
Kwave::Matrix< T > Class Template Reference

#include <Matrix.h>

Collaboration diagram for Kwave::Matrix< T >:
Collaboration graph

Public Member Functions

 Matrix (unsigned int cols, unsigned int rows)
 
 Matrix (const Matrix &other)
 
virtual ~Matrix ()
 
T * operator[] (unsigned int col) const
 

Private Attributes

unsigned int m_rows
 
unsigned int m_cols
 
T * m_data
 

Detailed Description

template<class T>
class Kwave::Matrix< T >

Definition at line 33 of file Matrix.h.

Constructor & Destructor Documentation

◆ Matrix() [1/2]

template<class T>
Kwave::Matrix< T >::Matrix ( unsigned int  cols,
unsigned int  rows 
)
inline

constructor

Parameters
colsnumber of columns
rowsnumber of rows

Definition at line 42 of file Matrix.h.

43  :m_rows(rows), m_cols(cols), m_data(Q_NULLPTR)
44  {
45  m_data = new T[m_rows * m_cols];
46  Q_ASSERT(m_data);
47  }
T * m_data
Definition: Matrix.h:78
unsigned int m_cols
Definition: Matrix.h:75
unsigned int m_rows
Definition: Matrix.h:72

◆ Matrix() [2/2]

template<class T>
Kwave::Matrix< T >::Matrix ( const Matrix< T > &  other)
inline

copy constructor

Definition at line 50 of file Matrix.h.

51  :m_rows(other.m_rows), m_cols(other.m_cols), m_data(Q_NULLPTR)
52  {
53  m_data = new T[m_rows * m_cols];
54  Q_ASSERT(m_data);
55  memcpy(m_data, other.m_data, m_rows * m_cols * sizeof(T));
56  }
T * m_data
Definition: Matrix.h:78
unsigned int m_cols
Definition: Matrix.h:75
unsigned int m_rows
Definition: Matrix.h:72

◆ ~Matrix()

template<class T>
virtual Kwave::Matrix< T >::~Matrix ( )
inlinevirtual

destructor

Definition at line 59 of file Matrix.h.

60  {
61  if (m_data) delete[] m_data;
62  }
T * m_data
Definition: Matrix.h:78

Member Function Documentation

◆ operator[]()

template<class T>
T* Kwave::Matrix< T >::operator[] ( unsigned int  col) const
inline

Get the xth column. Enables expressions like myMatrix[x][y].

Definition at line 65 of file Matrix.h.

65  {
66  return m_data + (col * m_rows);
67  }
T * m_data
Definition: Matrix.h:78
unsigned int m_rows
Definition: Matrix.h:72

Member Data Documentation

◆ m_cols

template<class T>
unsigned int Kwave::Matrix< T >::m_cols
private

number of columns

Definition at line 75 of file Matrix.h.

Referenced by Kwave::Matrix< double >::Matrix().

◆ m_data

template<class T>
T* Kwave::Matrix< T >::m_data
private

◆ m_rows

template<class T>
unsigned int Kwave::Matrix< T >::m_rows
private

number of rows

Definition at line 72 of file Matrix.h.

Referenced by Kwave::Matrix< double >::Matrix(), and Kwave::Matrix< double >::operator[]().


The documentation for this class was generated from the following file: