Audacity  2.2.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Matrix Class Reference

Holds a matrix of doubles and supports arithmetic, subsetting, and matrix inversion. Used by InterpolateAudio. More...

#include <Matrix.h>

Public Member Functions

 Matrix (const Matrix &copyFrom)
 
 Matrix (unsigned rows, unsigned cols, double **data=NULL)
 
 ~Matrix ()
 
Matrixoperator= (const Matrix &other)
 
Vectoroperator[] (unsigned i)
 
Vectoroperator[] (unsigned i) const
 
unsigned Rows () const
 
unsigned Cols () const
 
void SwapRows (unsigned i, unsigned j)
 

Private Member Functions

void CopyFrom (const Matrix &other)
 

Private Attributes

unsigned mRows
 
unsigned mCols
 
ArrayOf< VectormRowVec
 

Detailed Description

Holds a matrix of doubles and supports arithmetic, subsetting, and matrix inversion. Used by InterpolateAudio.

Definition at line 57 of file Matrix.h.

Constructor & Destructor Documentation

Matrix::Matrix ( const Matrix copyFrom)

Definition at line 102 of file Matrix.cpp.

References CopyFrom().

103 {
104  CopyFrom(other);
105 }
void CopyFrom(const Matrix &other)
Definition: Matrix.cpp:107
Matrix::Matrix ( unsigned  rows,
unsigned  cols,
double **  data = NULL 
)

Definition at line 80 of file Matrix.cpp.

81  : mRows{ rows }
82  , mCols{ cols }
83  , mRowVec{ mRows }
84 {
85  for(unsigned i = 0; i < mRows; i++) {
86  mRowVec[i].Reinit( mCols );
87  for(unsigned j = 0; j < mCols; j++) {
88  if (data)
89  (*this)[i][j] = data[i][j];
90  else
91  (*this)[i][j] = 0.0;
92  }
93  }
94 }
unsigned mRows
Definition: Matrix.h:76
ArrayOf< Vector > mRowVec
Definition: Matrix.h:78
unsigned mCols
Definition: Matrix.h:77
Matrix::~Matrix ( )

Definition at line 118 of file Matrix.cpp.

119 {
120 }

Member Function Documentation

unsigned Matrix::Cols ( ) const
inline

Definition at line 69 of file Matrix.h.

References mCols.

Referenced by InterpolateAudio(), InvertMatrix(), MatrixConcatenateCols(), MatrixMultiply(), operator*(), operator+(), ScalarMultiply(), and TransposeMatrix().

69 { return mCols; }
unsigned mCols
Definition: Matrix.h:77
void Matrix::CopyFrom ( const Matrix other)
private

Definition at line 107 of file Matrix.cpp.

References mCols, mRows, mRowVec, and ArrayOf< X >::reinit().

Referenced by Matrix(), and operator=().

108 {
109  mRows = other.mRows;
110  mCols = other.mCols;
112  for (unsigned i = 0; i < mRows; i++) {
113  mRowVec[i].Reinit( mCols );
114  mRowVec[i] = other.mRowVec[i];
115  }
116 }
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:499
unsigned mRows
Definition: Matrix.h:76
ArrayOf< Vector > mRowVec
Definition: Matrix.h:78
unsigned mCols
Definition: Matrix.h:77
Matrix & Matrix::operator= ( const Matrix other)

Definition at line 96 of file Matrix.cpp.

References CopyFrom().

97 {
98  CopyFrom(other);
99  return *this;
100 }
void CopyFrom(const Matrix &other)
Definition: Matrix.cpp:107
Vector& Matrix::operator[] ( unsigned  i)
inline

Definition at line 66 of file Matrix.h.

References mRowVec.

66 { return mRowVec[i]; }
ArrayOf< Vector > mRowVec
Definition: Matrix.h:78
Vector& Matrix::operator[] ( unsigned  i) const
inline

Definition at line 67 of file Matrix.h.

References mRowVec.

67 { return mRowVec[i]; }
ArrayOf< Vector > mRowVec
Definition: Matrix.h:78
unsigned Matrix::Rows ( ) const
inline

Definition at line 68 of file Matrix.h.

References mRows.

Referenced by InterpolateAudio(), InvertMatrix(), MatrixConcatenateCols(), MatrixMultiply(), operator*(), operator+(), ScalarMultiply(), and TransposeMatrix().

68 { return mRows; }
unsigned mRows
Definition: Matrix.h:76
void Matrix::SwapRows ( unsigned  i,
unsigned  j 
)

Definition at line 122 of file Matrix.cpp.

References mRowVec.

Referenced by InvertMatrix().

123 {
124  mRowVec[i].Swap(mRowVec[j]);
125 }
ArrayOf< Vector > mRowVec
Definition: Matrix.h:78

Member Data Documentation

unsigned Matrix::mCols
private

Definition at line 77 of file Matrix.h.

Referenced by Cols(), and CopyFrom().

unsigned Matrix::mRows
private

Definition at line 76 of file Matrix.h.

Referenced by CopyFrom(), and Rows().

ArrayOf<Vector> Matrix::mRowVec
private

Definition at line 78 of file Matrix.h.

Referenced by CopyFrom(), operator[](), and SwapRows().


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