QCAD
Open Source 2D CAD
|
Simple matrix class. More...
#include <RMatrix.h>
Public Member Functions | |
void | clear () |
Deletes the elements of this matrix and resets the matrix size to 0/0. More... | |
double | get (int r, int c) const |
RMatrix | getAppended (const RMatrix &v) const |
Appends matrix v to the right side of this matrix and returns the new matrix. More... | |
int | getCols () const |
RMatrix | getInverse () const |
double | getRotationAngle () const |
int | getRows () const |
RMatrix | getTransposed () const |
double | getUniformScaleFactor () const |
void | init (int r, int c) |
Initializes the matrix for the given size and resets all elements to 0. More... | |
bool | isRotationAndUniformScale () const |
bool | isValid () const |
RMatrix | multiplyWith (const RMatrix &w) const |
RVector | multiplyWith (const RVector &w) const |
RMatrix | multiplyWith (double w) const |
RMatrix | operator* (const RMatrix &other) const |
Multiplies two matrices. More... | |
RMatrix | operator* (double s) const |
RMatrix | operator*= (double f) |
Multiplies all elements of this matrix with the given factor and returns this matrix. More... | |
RMatrix & | operator= (const RMatrix &other) |
Assignment operator. More... | |
bool | operator== (const RMatrix &other) const |
Comparison. More... | |
double * | operator[] (int i) |
void | reset () |
Resets all elements to 0. More... | |
RMatrix () | |
Copyright (c) 2011-2018 by Andrew Mustun. More... | |
RMatrix (const RMatrix &other) | |
Copy constructor. More... | |
RMatrix (int r, int c) | |
Creates a matrix with r rows and c columns. More... | |
bool | rref () |
Changes this matrix into its rref . More... | |
void | set (int r, int c, double v) |
Sets the element at the given row/column to the given value v . More... | |
void | set2x3 (double a11, double a12, double a13, double a21, double a22, double a23) |
Sets the dimension of this matrix to 2x3 and the elements to the given elements. More... | |
void | set3x1 (double a11, double a21, double a31) |
Sets the dimension of this matrix to 3x1 and the elements to the given elements. More... | |
void | set3x3 (double a11, double a12, double a13, double a21, double a22, double a23, double a31, double a32, double a33) |
Sets the dimension of this matrix to 3x3 and the elements to the given elements. More... | |
~RMatrix () | |
Deletes the matrix. More... | |
Static Public Member Functions | |
static RMatrix | create2x2 (double a11, double a12, double a21, double a22) |
static RMatrix | create2x3 (double a11, double a12, double a13, double a21, double a22, double a23) |
static RMatrix | create3x1 (double a11, double a21, double a31) |
static RMatrix | create3x3 (double a11, double a12, double a13, double a21, double a22, double a23, double a31, double a32, double a33) |
static RMatrix | createIdentity (int size) |
static RMatrix | createIdentity2x2 () |
static RMatrix | createIdentity3x3 () |
static RMatrix | createRotation (double angle) |
Protected Member Functions | |
void | addRow (int r, double factor, int r2) |
Adds to row r factor times row r2 . More... | |
int | getPivotCol (int r) |
int | getPivotRow (int startRow) |
void | multiplyRow (int r, double factor) |
Multiplies row r with factor . More... | |
bool | ref (int startRow) |
Changes this matrix into its ref . More... | |
void | swapRows (int r1, int r2) |
Swaps the given two rows. More... | |
Private Attributes | |
int | cols |
double ** | m |
int | rows |
Simple matrix class.
RMatrix::RMatrix | ( | ) |
Copyright (c) 2011-2018 by Andrew Mustun.
All rights reserved.
This file is part of the QCAD project.
QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with QCAD. Creates and empty matrix (zero columns and zero rows).
RMatrix::RMatrix | ( | int | r, |
int | c | ||
) |
Creates a matrix with r
rows and c
columns.
All elements are reset to 0.
r | number of rows |
c | number of columns |
RMatrix::~RMatrix | ( | ) |
Deletes the matrix.
|
protected |
Adds to row r
factor
times row r2
.
r | the row |
r2 | the row 2 |
factor | The factor to apply to r2 before it is added to row r . |
void RMatrix::clear | ( | ) |
Deletes the elements of this matrix and resets the matrix size to 0/0.
|
static |
|
static |
|
static |
|
static |
|
static |
size
rows and size
columns:
|
static |
|
static |
|
static |
double RMatrix::get | ( | int | r, |
int | c | ||
) | const |
r | the row |
c | the column |
Appends matrix v
to the right side of this matrix and returns the new matrix.
This matrix is not affected.
v | the matrix to append to this matrix |
|
inline |
RMatrix RMatrix::getInverse | ( | ) | const |
|
protected |
r | the row |
r
.
|
protected |
startRow | the start row |
startRow
. double RMatrix::getRotationAngle | ( | ) | const |
|
inline |
RMatrix RMatrix::getTransposed | ( | ) | const |
double RMatrix::getUniformScaleFactor | ( | ) | const |
void RMatrix::init | ( | int | r, |
int | c | ||
) |
Initializes the matrix for the given size and resets all elements to 0.
bool RMatrix::isRotationAndUniformScale | ( | ) | const |
bool RMatrix::isValid | ( | ) | const |
|
protected |
Multiplies row r
with factor
.
r | the row |
factor | the factor to apply to the row |
RMatrix RMatrix::multiplyWith | ( | double | w | ) | const |
Multiplies two matrices.
RMatrix RMatrix::operator* | ( | double | s | ) | const |
RMatrix RMatrix::operator*= | ( | double | f | ) |
Multiplies all elements of this matrix with the given factor and returns this matrix.
Assignment operator.
bool RMatrix::operator== | ( | const RMatrix & | other | ) | const |
Comparison.
All elements of the matrix as well as the matrix dimensions have to match for the two matrices to be equal.
double* RMatrix::operator[] | ( | int | i | ) |
|
protected |
Changes this matrix into its ref
.
void RMatrix::reset | ( | ) |
Resets all elements to 0.
bool RMatrix::rref | ( | ) |
Changes this matrix into its rref
.
void RMatrix::set | ( | int | r, |
int | c, | ||
double | v | ||
) |
Sets the element at the given row/column to the given value v
.
r | the row |
c | the column |
v | the new value at the given row / column position |
void RMatrix::set2x3 | ( | double | a11, |
double | a12, | ||
double | a13, | ||
double | a21, | ||
double | a22, | ||
double | a23 | ||
) |
Sets the dimension of this matrix to 2x3 and the elements to the given elements.
void RMatrix::set3x1 | ( | double | a11, |
double | a21, | ||
double | a31 | ||
) |
Sets the dimension of this matrix to 3x1 and the elements to the given elements.
void RMatrix::set3x3 | ( | double | a11, |
double | a12, | ||
double | a13, | ||
double | a21, | ||
double | a22, | ||
double | a23, | ||
double | a31, | ||
double | a32, | ||
double | a33 | ||
) |
Sets the dimension of this matrix to 3x3 and the elements to the given elements.
|
protected |
Swaps the given two rows.
r1 | the row 1 |
r2 | the row 2 |
|
private |
|
private |
|
private |