Loading...
Searching...
No Matches
Matrix Class Reference
Collaboration diagram for Matrix:
[legend]

## Public Member Functions

| Matrix (Matrix &m)
| Matrix (Matrix &m, const char *name)
| Matrix (int n, int m)
| Matrix (const char *name)
| Matrix (const char *name, int n, int m)
void | Dimension (int m, int n)
void | Dimension (int m, int n, double value)
void | GrowTo (int m, int n)
void | GrowTo (int m, int n, double value)
void | SetLabel (const char *name)
void | SetColumnLabel (int n, const char *name)
const char * | GetColumnLabel (int n)
void | SetColWidth (int n, int w)
void | SetColPrecision (int n, int p)
void | CopyLabels (Matrix &m)
void | Negate ()
void | Identity ()
void | Zero ()
void | Set (double k)
void | Copy (const Matrix &m)
void | Transpose (const Matrix &m)
void | Add (const Matrix &m)
void | AddMultiple (double k, const Matrix &m)
void | Product (const Matrix &left, const Matrix &right)
void | Add (double k)
void | Multiply (double k)
void | Reduce (double tol=0.0)
Vector & | operator[] (int i)
const Vector & | operator[] (int i) const
void | DeleteRow (int r)
void | DeleteColumn (int c)
void | SwapRows (int r1, int r2)
void | SwapColumns (int c1, int c2)
void | MultiplyRow (int r1, double k)
void | AddRows (int r1, int r2)
void | AddRows (double k, int r1, int r2)
void | Sort ()
void | Print (FILE *f, int maxRows=-1, int maxCols=-1)
void | PrintUpper (FILE *f, int maxRows=-1, int maxCols=-1, bool print_diag=false)
void | PrintLower (FILE *f, int maxRows=-1, int maxCols=-1, bool print_diag=false)
void | SetupPrint (FILE *f, int r, int c, int &column_zero, int *precision, int *width)
void | Read (FILE *f)
Matrix & | operator= (const Matrix &rhs)
bool | operator== (const Matrix &rhs) const
bool | operator!= (const Matrix &rhs) const
Matrix & | operator*= (double rhs)
Matrix & | operator/= (double rhs)
void | StackBottom (const Matrix &m)
void | StackLeft (const Matrix &m)
void | Swap (Matrix &m)
double | Min () const
double | Max () const
double | Mean () const
double | SafeMin () const
double | SafeMax () const
double | SafeMean () const
int | SafeCount () const
Vector & | Last ()

## Public Attributes

String | label
ColumnExtras * | extras
int | rows
int | cols
int | size
int | extraSize
Vector ** | data

## Detailed Description

Definition at line 76 of file MathMatrix.h.

## Constructor & Destructor Documentation

## Matrix() [1/6]

Matrix::Matrix | ( |  | ) |

inline

Definition at line 84 of file MathMatrix.h.

{
Init();
}

## Matrix() [2/6]

Matrix::Matrix | ( | Matrix & | m | ) |

inline

Definition at line 88 of file MathMatrix.h.

{
Init();
Copy(m);
}

## Matrix() [3/6]

Matrix::Matrix | ( | Matrix & | m,
|  | const char * | name
| ) |  |

inline

Definition at line 93 of file MathMatrix.h.

{
Init();
Copy(m);
SetLabel(name);
}

## Matrix() [4/6]

Matrix::Matrix | ( | int | n,
|  | int | m
| ) |  |

inline

Definition at line 99 of file MathMatrix.h.

{
Init();
Dimension(n, m);
}

## Matrix() [5/6]

Matrix::Matrix | ( | const char * | name | ) |

inline

Definition at line 104 of file MathMatrix.h.

{
Init();
SetLabel(name);
}

## Matrix() [6/6]

Matrix::Matrix | ( | const char * | name,
|  | int | n,
|  | int | m
| ) |  |

inline

Definition at line 109 of file MathMatrix.h.

{
Init();
Dimension(n, m);
SetLabel(name);
}

## ~Matrix()

Matrix::~Matrix | ( |  | ) |

Definition at line 30 of file MathMatrix.cpp.

{
// printf("Deleting Matrix %s...\n", (const char *) label);
for (int i=0; i<size; i++)
delete data[i];
if (size)
delete [] data;
if (extraSize)
delete [] extras;
}

## Member Function Documentation

## Add() [1/2]

void Matrix::Add | ( | const Matrix & | m | ) |

Definition at line 195 of file MathMatrix.cpp.

{
if ((rows != m.rows) && (cols != m.cols))
error("Matrix.Add - Attempted to add incompatible matrices\n"
"Matrices - %s [%d, %d] + %s [%d, %d]\n",
(const char *) label, rows, cols,
(const char *) m.label, m.rows, m.cols);
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
(*(data[i]))[j] += m[i][j];
}

## Add() [2/2]

void Matrix::Add | ( | double | k | ) |

Definition at line 181 of file MathMatrix.cpp.

{
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
(*(data[i]))[j] += k;
}

## AddMultiple()

void Matrix::AddMultiple | ( | double | k,
|  | const Matrix & | m
| ) |  |

Definition at line 208 of file MathMatrix.cpp.

{
if ((rows != m.rows) && (cols != m.cols))
error("Matrix.AddMultiple - Attempted to add incompatible matrices\n"
"Matrices - %s [%d, %d] + k * %s [%d, %d]\n",
(const char *) label, rows, cols,
(const char *) m.label, m.rows, m.cols);
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
(*(data[i]))[j] += k * m[i][j];
}

## AddRows() [1/2]

void Matrix::AddRows | ( | double | k,
|  | int | r1,
|  | int | r2
| ) |  |

Definition at line 239 of file MathMatrix.cpp.

{
Vector v(*(data[r1]));
v.Multiply(k);
data[r2]->Add(v);
}
Vector
Definition MathVector.h:29

## AddRows() [2/2]

void Matrix::AddRows | ( | int | r1,
|  | int | r2
| ) |  |

Definition at line 252 of file MathMatrix.cpp.

{
data[r2]->Add(*(data[r1]));
}

## Copy()

void Matrix::Copy | ( | const Matrix & | m | ) |

Definition at line 162 of file MathMatrix.cpp.

{
Dimension(m.rows, m.cols);
if (m.data != NULL)
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
(*this)[i][j] = m[i][j];
}

## CopyLabels()

void Matrix::CopyLabels | ( | Matrix & | m | ) |

Definition at line 407 of file MathMatrix.cpp.

{
for (int i = 0; i < rows; i++)
if (i < M.rows)
data[i]->SetLabel(M[i].label);
for (int i = 0; i < cols; i++)
if (i < M.cols)
SetColumnLabel(i, M.GetColumnLabel(i));
}

## DeleteColumn()

void Matrix::DeleteColumn | ( | int | c | ) |

Definition at line 314 of file MathMatrix.cpp.

{
for (int i = 0; i < rows; i++)
data[i] -> DeleteDimension(c);
for (int i = c + 1; i < cols; i++)
extras[i-1] = extras[i];
cols--;
}

## DeleteRow()

void Matrix::DeleteRow | ( | int | r | ) |

Definition at line 303 of file MathMatrix.cpp.

{
Vector * temp = data[r];
for (int i = r + 1; i < rows; i++)
data[i-1] = data[i];
data[rows - 1] = temp;
rows--;
}

## Dimension() [1/2]

void Matrix::Dimension | ( | int | m,
|  | int | n
| ) |  |

Definition at line 59 of file MathMatrix.cpp.

{
if (n == cols && m == rows)
return;
if (n > extraSize)
{
int newSize = (n + alloc) / alloc * alloc;
ColumnExtras * newExtras = new ColumnExtras [newSize];
if (extras != NULL)
for (int i = 0; i < extraSize; i++)
newExtras[i] = extras[i];
if (extraSize)
delete [] extras;
extraSize = newSize;
extras = newExtras;
}
if (m > size)
{
int newSize = (m + alloc) / alloc * alloc;
Vector ** newData = new Vector * [newSize];
if (data != NULL)
for (int i = 0; i < size; i++)
newData[i] = data[i];
for (int i = size; i < newSize; i++)
newData[i] = new Vector(n);
if (size)
delete [] data;
size = newSize;
data = newData;
}
if (cols != n)
for (int i = 0; i < rows; i++)
data[i]->Dimension(n);
if (rows != m)
for (int i = rows; i < m; i++)
data[i]->Dimension(n);
rows = m;
cols = n;
}
ColumnExtras
Definition MathMatrix.h:27

## Dimension() [2/2]

void Matrix::Dimension | ( | int | m,
|  | int | n,
|  | double | value
| ) |  |

Definition at line 111 of file MathMatrix.cpp.

{
int originalRows = rows;
int originalColumns = cols;
Dimension(m, n);
if (rows > originalRows)
for (int i = originalRows; i < rows; i++)
data[i]->Set(value);
if (cols > originalColumns)
for (int i = 0; i < originalRows; i++)
for (int j = originalColumns; j < cols; j++)
data[i]->data[j] = value;
}

## GetColumnLabel()

const char * Matrix::GetColumnLabel | ( | int | n | ) |

inline

Definition at line 133 of file MathMatrix.h.

{
return extras[n].label;
}

## GrowTo() [1/2]

void Matrix::GrowTo | ( | int | m,
|  | int | n
| ) |  |

inline

Definition at line 119 of file MathMatrix.h.

{
Dimension(m > rows ? m : rows, n > cols ? n : cols);
}

## GrowTo() [2/2]

void Matrix::GrowTo | ( | int | m,
|  | int | n,
|  | double | value
| ) |  |

inline

Definition at line 123 of file MathMatrix.h.

{
Dimension(m > rows ? m : rows, n > cols ? n : cols, value);
}

## Identity()

void Matrix::Identity | ( |  | ) |

Definition at line 135 of file MathMatrix.cpp.

{
if (rows != cols)
error("Matrix.Identity - Identity matrices must be square");
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
if (i == j)
(*(data[i]))[j] = 1.0;
else
(*(data[i]))[j] = 0.0;
}

## Last()

Vector & Matrix::Last | ( |  | ) |

inline

Definition at line 247 of file MathMatrix.h.

{
return *(data[rows - 1]);
}

## Max()

double Matrix::Max | ( |  | ) | const

Definition at line 555 of file MathMatrix.cpp.

{
if (rows == 0 || cols == 0)
return 0.0;
double maximum = data[0]->Max();
for (int i = 1; i < rows; i++)
maximum = max(data[i]->Max(), maximum);
return maximum;
}

## Mean()

double Matrix::Mean | ( |  | ) | const

Definition at line 568 of file MathMatrix.cpp.

{
if (rows == 0 || cols == 0)
return 0.0;
double sum = data[0]->Sum();
for (int i = 1; i < rows; i++)
sum += data[i]->Sum();
return sum / (rows * cols);
}

## Min()

double Matrix::Min | ( |  | ) | const

Definition at line 542 of file MathMatrix.cpp.

{
if (rows == 0 || cols == 0)
return 0.0;
double minimum = data[0]->Min();
for (int i = 1; i < rows; i++)
minimum = min(data[i]->Min(), minimum);
return minimum;
}

## Multiply()

void Matrix::Multiply | ( | double | k | ) |

Definition at line 188 of file MathMatrix.cpp.

{
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
(*(data[i]))[j] *= k;
}

## MultiplyRow()

void Matrix::MultiplyRow | ( | int | r1,
|  | double | k
| ) |  |

Definition at line 247 of file MathMatrix.cpp.

{
data[r1]->Multiply(k);
}

## Negate()

void Matrix::Negate | ( |  | ) |

Definition at line 155 of file MathMatrix.cpp.

{
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
(*(data[i]))[j] = -(*(data[i]))[j];
}

## operator!=()

bool Matrix::operator!= | ( | const Matrix & | rhs | ) | const

inline

Definition at line 210 of file MathMatrix.h.

{
return !(*this == rhs);
}

## operator*=()

Matrix & Matrix::operator*= | ( | double | rhs | ) |

inline

Definition at line 215 of file MathMatrix.h.

{
Multiply(rhs);
return *this;
}

## operator/=()

Matrix & Matrix::operator/= | ( | double | rhs | ) |

inline

Definition at line 220 of file MathMatrix.h.

{
Multiply(1.0/rhs);
return *this;
}

## operator=()

Matrix & Matrix::operator= | ( | const Matrix & | rhs | ) |

inline

Definition at line 203 of file MathMatrix.h.

{
Copy(rhs);
return *this;
}

## operator==()

bool Matrix::operator== | ( | const Matrix & | rhs | ) | const

Definition at line 481 of file MathMatrix.cpp.

{
if (rhs.rows != rows || rhs.cols != cols) return false;
for (int i = 0; i < rows; i++)
if ((*this)[i] != rhs[i])
return false;
return true;
}

## operator[]() [1/2]

Vector & Matrix::operator[] | ( | int | i | ) |

inline

Definition at line 165 of file MathMatrix.h.

{
assert(i < rows);
return *(data[i]);
}

## operator[]() [2/2]

const Vector & Matrix::operator[] | ( | int | i | ) | const

inline

Definition at line 171 of file MathMatrix.h.

{
assert(i < rows);
return *(data[i]);
}

## Print()

void Matrix::Print | ( | FILE * | f,
|  | int | maxRows = `-1`,
|  | int | maxCols = `-1`
| ) |  |

Definition at line 370 of file MathMatrix.cpp.

{
if (r == -1 || r > rows) r = rows;
if (c == -1 || c > cols) c = cols;
char dimensions[30];
sprintf(dimensions, "[%d x %d]", r, c);
int columnZero = label.Length() > 15 ? label.Length() : 15;
fprintf(f, "\n%*s =\n%*s ", columnZero, (const char *) label,
columnZero, dimensions);
int * precision = new int [c + 1];
int * width = new int [c + 1];
for (int j = 0; j < c; j++)
{
precision[j] = extras[j].GetPrecision();
width[j] = extras[j].GetWidth();
fprintf(f, "%*s ", width[j], (const char *) extras[j].label);
}
for (int i = 0; i < r; i++)
{
fprintf(f, "\n%*s ", columnZero, (const char *) data[i]->label);
for (int j = 0; j < c; j++)
fprintf(f, "%*.*f ", width[j], precision[j], (*this)[i][j]);
}
fprintf(f, "\n");
delete [] precision;
delete [] width;
}

## PrintLower()

void Matrix::PrintLower | ( | FILE * | f,
|  | int | maxRows = `-1`,
|  | int | maxCols = `-1`,
|  | bool | print_diag = `false`
| ) |  |

Definition at line 683 of file MathMatrix.cpp.

{
if (r == -1 || r > rows) r = rows;
if (c == -1 || c > cols) c = cols;
String dimensions;
dimensions.printf("[%d x %d]", r, c);
int columnZero = label.Length() > 15 ? label.Length() : 15;
fprintf(f, "\n%*s =\n%*s ", columnZero, (const char *) label,
columnZero, (const char *) dimensions);
int * precision = new int [c + 1];
int * width = new int [c + 1];
for (int j = 0; j < c; j++)
{
precision[j] = extras[j].GetPrecision();
width[j] = extras[j].GetWidth();
fprintf(f, "%*s ", width[j], (const char *) extras[j].label);
}
int upper = print_diag ? 1 : 0;
for (int i = 0; i < r ; i++)
{
fprintf(f, "\n%*s ", columnZero, (const char *) data[i]->label);
for (int j = 0; j < upper; j++)
fprintf(f, "%*.*f ", width[j], precision[j],(*this)[i][j]);
for (int j = upper; j < c; j++)
fprintf(f, "%*.*s ", width[j], precision[j]," ");
upper++;
}
fprintf(f, "\n");
delete [] precision;
delete [] width;
}
String
Definition StringBasics.h:39

## PrintUpper()

void Matrix::PrintUpper | ( | FILE * | f,
|  | int | maxRows = `-1`,
|  | int | maxCols = `-1`,
|  | bool | print_diag = `false`
| ) |  |

Definition at line 657 of file MathMatrix.cpp.

{
int columnZero;
int * precision = NULL, * width = NULL; // Initialization avoids compiler warnings
SetupPrint(f, r, c, columnZero, precision, width);
int upper = print_diag ? 0 : 1;
for (int i = 0; i < r ; i++)
{
fprintf(f, "\n%*s ", columnZero, (const char *) data[i]->label);
for (int j = 0; j < upper; j++)
fprintf(f, "%*.*s ", width[j], precision[j], " ");
for (int j = upper; j < c; j++)
fprintf(f, "%*.*f ", width[j], precision[j], (*this)[i][j]);
upper++;
}
fprintf(f, "\n");
delete [] precision;
delete [] width;
}

## Product()

void Matrix::Product | ( | const Matrix & | left,
|  | const Matrix & | right
| ) |  |

Definition at line 222 of file MathMatrix.cpp.

{
if (l.cols != r.rows)
error("Matrix.Multiply - Attempted to multiply incompatible matrices\n"
"Matrices - %s [%d, %d] + %s [%d, %d]\n",
(const char *) l.label, l.rows, l.cols,
(const char *) r.label, r.rows, r.cols);
Dimension(l.rows, r.cols);
Zero();
for (int k = 0; k < l.cols; k++)
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
(*(data[i]))[j] += l[i][k] * r[k][j];
}

## Read()

void Matrix::Read | ( | FILE * | f | ) |

Definition at line 339 of file MathMatrix.cpp.

{
int r, c;
char buffer[100];
int numItems = 0;
numItems = fscanf(f, " %s =", buffer);
if(numItems != 1) { }
buffer[strlen(buffer) - 1] = 0;
SetLabel(buffer);
numItems = fscanf(f, " [ %d x %d ]", &r, &c);
if(numItems != 2) { }
Dimension(r, c);
for (int c = 0; c < cols; c++)
{
numItems = fscanf(f, " %s", buffer);
if(numItems != 1) { }
SetColumnLabel(c, buffer);
}
for (int r = 0; r < rows; r++)
for (int c = 0; c < cols; c++)
{
numItems = fscanf(f, " %lf", &((*this)[r][c]));
if(numItems != 1) { }
}
}

## Reduce()

void Matrix::Reduce | ( | double | tol = `0.0` | ) |

Definition at line 257 of file MathMatrix.cpp.

{
double pivot;
int pivotr = 0; // Initializing pivotr is not necessary, but avoids warnings
int r = 0; // the row we are currently reducing
for (int j = 0; j < cols; j++)
{
if (r > rows)
return;
pivot = 0.0;
for (int i = r; i < rows; i++)
if (fabs((*this)[i][j]) > pivot)
{
pivot = fabs((*this)[i][j]);
pivotr = i;
}
if (pivot <= tol)
{
for (int i = r; i < rows; i++)
(*this)[i][j] = 0.0;
continue;
}
SwapRows(pivotr, r);
double scale = (*this)[r][j];
(*this)[r][j] = 1.0;
for (int k = j+1; k < cols; k++)
(*this)[r][k] /= scale;
for (int i = r + 1; r < rows; i++)
{
scale = (*this)[i][j];
(*this)[i][j] = 0.0;
for (int k = j+1; k < cols; k++)
(*this)[i][k] -= (*this)[r][k] * scale;
}
r++;
}
}

## SafeCount()

int Matrix::SafeCount | ( |  | ) | const

Definition at line 647 of file MathMatrix.cpp.

{
int total = 0;
for (int i = 0; i < rows; i++)
total += data[i]->SafeCount();
return total;
}

## SafeMax()

double Matrix::SafeMax | ( |  | ) | const

Definition at line 606 of file MathMatrix.cpp.

{
double hi = (rows > 0 && cols > 0) ? _NAN_ : 0.0;
int i, j;
for (i = 0; i < rows; i++)
{
for (j = 0; j < cols; j++)
if (data[i]->data[j] != _NAN_)
{
hi = data[i]->data[j];
break;
}
if (j != cols) break;
}
for (; i < rows; i++, j = 0)
for (; j < cols; j++)
if (data[i]->data[j] > hi && data[i]->data[j] != _NAN_)
hi = data[i]->data[j];
return hi;
}

## SafeMean()

double Matrix::SafeMean | ( |  | ) | const

Definition at line 631 of file MathMatrix.cpp.

{
double sum = 0.0;
int count = 0;
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
if ((*this)[i][j] != _NAN_)
{
sum += (*this)[i][j];
count ++;
}
return (count) ? sum / count : 0.0;
}

## SafeMin()

double Matrix::SafeMin | ( |  | ) | const

Definition at line 581 of file MathMatrix.cpp.

{
double lo = (rows > 0 && cols > 0) ? _NAN_ : 0.0;
int i, j;
for (i = 0; i < rows; i++)
{
for (j = 0; j < cols; j++)
if (data[i]->data[j] != _NAN_)
{
lo = data[i]->data[j];
break;
}
if (j != cols) break;
}
for (; i < rows; i++, j = 0)
for (; j < cols; j++)
if (data[i]->data[j] < lo && data[i]->data[j] != _NAN_)
lo = data[i]->data[j];
return lo;
}

## Set()

void Matrix::Set | ( | double | k | ) |

Definition at line 148 of file MathMatrix.cpp.

{
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
(*(data[i]))[j] = k;
}

## SetColPrecision()

void Matrix::SetColPrecision | ( | int | n,
|  | int | p
| ) |  |

inline

Definition at line 141 of file MathMatrix.h.

{
extras[n].SetPrecision(p);
}

## SetColumnLabel()

void Matrix::SetColumnLabel | ( | int | n,
|  | const char * | name
| ) |  |

inline

Definition at line 129 of file MathMatrix.h.

{
extras[n].SetLabel(name);
}

## SetColWidth()

void Matrix::SetColWidth | ( | int | n,
|  | int | w
| ) |  |

inline

Definition at line 137 of file MathMatrix.h.

{
extras[n].SetWidth(w);
}

## SetLabel()

void Matrix::SetLabel | ( | const char * | name | ) |

Definition at line 52 of file MathMatrix.cpp.

{
label = '[';
label += name;
label += ']';
}

## SetupPrint()

void Matrix::SetupPrint | ( | FILE * | f,
|  | int | r,
|  | int | c,
|  | int & | column_zero,
|  | int * | precision,
|  | int * | width
| ) |  |

Definition at line 726 of file MathMatrix.cpp.

{
if (r == -1 || r > rows) r = rows;
if (c == -1 || c > cols) c = cols;
String dimensions;
dimensions.printf("[%d x %d]", r, c);
column_zero = label.Length() > 15 ? label.Length() : 15;
fprintf(f, "\n%*s =\n%*s ", column_zero, (const char *) label,
column_zero, (const char *) dimensions);
precision = new int [c + 1];
width = new int [c + 1];
for (int j = 0; j < c; j++)
{
precision[j] = extras[j].GetPrecision();
width[j] = extras[j].GetWidth();
fprintf(f, "%*s ", width[j], (const char *) extras[j].label);
}
}

## Sort()

void Matrix::Sort | ( |  | ) |

Definition at line 476 of file MathMatrix.cpp.

{
QuickSort(data, rows, sizeof(Vector *), COMPAREFUNC CompareRows);
}

## StackBottom()

void Matrix::StackBottom | ( | const Matrix & | m | ) |

Definition at line 491 of file MathMatrix.cpp.

{
if (m.cols != cols)
error("Attempted to stack matrices with different number of columns");
int end = rows;
Dimension(rows + m.rows, cols);
for (int i = 0; i < m.rows; i++)
*(data[i + end]) = m[i];
}

## StackLeft()

void Matrix::StackLeft | ( | const Matrix & | m | ) |

Definition at line 504 of file MathMatrix.cpp.

{
if (m.rows != rows)
error("Attempted to stack matrics with different numbers of rows");
for (int i = 0; i < rows; i++)
data[i]->Stack(m[i]);
Dimension(rows, cols + m.cols);
}

## Swap()

void Matrix::Swap | ( | Matrix & | m | ) |

Definition at line 515 of file MathMatrix.cpp.

{
label.Swap(m.label);
ColumnExtras * tmpExtras = extras;
extras = m.extras;
m.extras = tmpExtras;
int swap;
swap = rows;
rows = m.rows;
m.rows = swap;
swap = cols;
cols = m.cols;
m.cols = swap;
swap = size;
size = m.size;
m.size = swap;
swap = extraSize;
extraSize = m.extraSize;
m.extraSize = swap;
Vector ** tmpData = data;
data = m.data;
m.data = tmpData;
}

## SwapColumns()

void Matrix::SwapColumns | ( | int | c1,
|  | int | c2
| ) |  |

Definition at line 325 of file MathMatrix.cpp.

{
double temp;
for (int i = 0; i < rows; i++)
{
temp = (*data[i])[c1];
(*data[i])[c1] = (*data[i])[c2];
(*data[i])[c2] = temp;
}
extras[c1].Swap(extras[c2]);
}

## SwapRows()

void Matrix::SwapRows | ( | int | r1,
|  | int | r2
| ) |  |

inline

Definition at line 180 of file MathMatrix.h.

{
Vector * temp = data[r1];
data[r1] = data[r2];
data[r2] = temp;
};

## Transpose()

void Matrix::Transpose | ( | const Matrix & | m | ) |

Definition at line 172 of file MathMatrix.cpp.

{
Dimension(m.cols, m.rows);
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
(*(data[i]))[j] = m[j][i];
}

## Zero()

void Matrix::Zero | ( |  | ) |

Definition at line 128 of file MathMatrix.cpp.

{
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
(*(data[i]))[j] = 0.0;
}

## Member Data Documentation

## cols

int Matrix::cols

Definition at line 81 of file MathMatrix.h.

## data

Vector** Matrix::data

Definition at line 82 of file MathMatrix.h.

## extras

ColumnExtras* Matrix::extras

Definition at line 80 of file MathMatrix.h.

## extraSize

int Matrix::extraSize

Definition at line 81 of file MathMatrix.h.

## label

String Matrix::label

Definition at line 79 of file MathMatrix.h.

## rows

int Matrix::rows

Definition at line 81 of file MathMatrix.h.

## size

int Matrix::size

Definition at line 81 of file MathMatrix.h.

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

- general/MathMatrix.h
- general/MathMatrix.cpp