31static const QString
infinity =
"\u221E" ;
33static const QString
infinity = QString(
"\xE2\x88\x9E") ;
56 for (
int i=0;i<
m_cols; i++) {
70 for (
int i=0;i<
m_cols; i++) {
98 for (
int i=0;i<
m_cols; i++) {
118 Matrix (
int rowDim=0,
int colDim=0) ;
126 void resize (
const int m,
const int n) ;
128 qreal
item(
int r,
int c ) ;
130 void setItem(
const int r,
const int c,
const qreal elem );
148 int &imin,
int &jmin,
149 int &imax,
int &jmax);
187 const bool &leftMultiply=
false);
189 Matrix &
pow (
int n,
bool symmetry=
false) ;
207 const qreal eps,
const int &maxIter);
222 bool solve(qreal b[]);
224 bool ludcmp (
Matrix &a,
const int &n,
int indx[], qreal &d ) ;
226 void lubksb (
Matrix &a,
const int &n,
int indx[], qreal b[]);
230 const QString varLocation,
231 const bool &diagonal,
232 const bool &considerWeights);
236 const QString varLocation=
"Rows",
237 const bool &diagonal=
false,
238 const bool &considerWeights=
true);
242 const QString &varLocation=
"Rows",
243 const bool &diagonal=
false);
248 const bool markDiag=
false,
249 const bool &plain=
false,
250 const bool &printInfinity=
true);
void setSize(int cols)
Definition matrix.h:103
void setColumn(int index, qreal elem)
Definition matrix.h:85
qreal * cell
Definition matrix.h:108
qreal & operator[](const int k)
Definition matrix.h:82
MatrixRow(int cols=0)
Definition matrix.h:53
qreal column(int c) const
Definition matrix.h:77
~MatrixRow()
Definition matrix.h:61
void clearColumn(int index)
Definition matrix.h:89
int m_cols
Definition matrix.h:109
void resize(int cols)
Definition matrix.h:94
MatrixRow & operator=(MatrixRow &a)
Definition matrix.h:63
void operator*=(Matrix &b)
Multiplies (right) this m x n matrix with given n x p matrix b and returns the product in the calling...
Definition matrix.cpp:533
friend QTextStream & operator<<(QTextStream &os, Matrix &m)
Prints matrix m to given textstream.
Definition matrix.cpp:2375
Matrix & expBySquaring2(Matrix &Y, Matrix &X, int n, bool symmetry=false)
Recursive algorithm implementing "Exponentiation by squaring". Also known as Fast Modulo Multiplicati...
Definition matrix.cpp:675
void sum(Matrix &a, Matrix &b)
Matrix addition Takes two (nxn) matrices and returns their sum as a reference to this Same algorithm ...
Definition matrix.cpp:428
bool printHTMLTable(QTextStream &os, const bool markDiag=false, const bool &plain=false, const bool &printInfinity=true)
Prints this matrix as HTML table This has the problem that the real actorNumber != elementLabel i....
Definition matrix.cpp:2498
void NeighboursNearestFarthest(qreal &min, qreal &max, int &imin, int &jmin, int &imax, int &jmax)
Like Matrix::findMinMaxValues only it skips r==c.
Definition matrix.cpp:144
void multiplyRow(int row, qreal value)
Multiply every element of row by value.
Definition matrix.cpp:376
Matrix & operator*(Matrix &b)
Matrix multiplication, operator * Multiplies (right) this matrix with given matrix b....
Definition matrix.cpp:498
void powerIteration(qreal x[], qreal &xsum, qreal &xmax, int &xmaxi, qreal &xmin, int &xmini, const qreal eps, const int &maxIter)
Implementation of the Power method which computes the leading eigenvector x of this matrix,...
Definition matrix.cpp:808
Matrix & inverse(Matrix &a)
Computes and returns the inverse of given matrix a Allows b.inverse(a)
Definition matrix.cpp:1256
void fillMatrix(qreal value)
Fills a matrix with a given value.
Definition matrix.cpp:307
int cols()
Definition matrix.h:139
Matrix & cocitationMatrix()
Returns the Cocitation Matrix of this matrix (C = A * A^T) Allows T = A.cocitationMatrix()
Definition matrix.cpp:936
void resize(const int m, const int n)
Resizes this matrix to m x n Called before every operation on new matrices. Every MatrixRow object ho...
Definition matrix.cpp:94
Matrix & laplacianMatrix()
Returns the Laplacian of this matrix. The Laplacian is a NxN matrix L = D - A where D is the degree m...
Definition matrix.cpp:981
void lubksb(Matrix &a, const int &n, int indx[], qreal b[])
Solves the set of n linear equations A·X = b, where A nxn matrix decomposed as L·U (L lower triangula...
Definition matrix.cpp:1221
void identityMatrix(int dim)
Makes this square matrix the identity square matrix I.
Definition matrix.cpp:170
int m_rows
Definition matrix.h:257
int m_cols
Definition matrix.h:258
MatrixRow * row
Definition matrix.h:256
void setItem(const int r, const int c, const qreal elem)
Sets the (r,c) matrix element calling the setColumn method.
Definition matrix.cpp:228
bool illDefined()
Checks if matrix is ill-defined (contains at least an inf element)
Definition matrix.cpp:2667
qreal distanceEuclidean(qreal x[], int n)
Helper function, computes the Euclideian length (also known as L2 distance) of a vector: if x = (x1 x...
Definition matrix.cpp:778
bool ludcmp(Matrix &a, const int &n, int indx[], qreal &d)
Given matrix a, it replaces a by the LU decomposition of a rowwise permutation of itself....
Definition matrix.cpp:1095
Matrix & distancesMatrix(const int &metric, const QString varLocation, const bool &diagonal, const bool &considerWeights)
Computes the dissimilarities matrix of the variables (rows, columns, both) of this matrix using the u...
Definition matrix.cpp:1355
qreal distanceManhattan(qreal x[], qreal y[], int n)
Helper function, takes to vectors and returns their Manhattan distance (also known as l1 norm,...
Definition matrix.cpp:758
Matrix & productSym(Matrix &a, Matrix &b)
Takes two ( N x N ) matrices (symmetric) and outputs an upper triangular matrix.
Definition matrix.cpp:612
int size()
Definition matrix.h:143
Matrix & pow(int n, bool symmetry=false)
Returns the n-nth power of this matrix.
Definition matrix.cpp:642
Matrix & similarityMatrix(Matrix &AM, const int &measure, const QString varLocation="Rows", const bool &diagonal=false, const bool &considerWeights=true)
Computes the pair-wise matching score of the rows, columns or both of the given matrix AM,...
Definition matrix.cpp:1738
void product(Matrix &A, Matrix &B, bool symmetry=false)
Matrix Multiplication. Given two matrices A (mxn) and B (nxp) computes their product and stores it to...
Definition matrix.cpp:571
Matrix & operator-(Matrix &b)
Matrix subtraction, operator - Subtract this matrix - B of the same dim and returns the result S Allo...
Definition matrix.cpp:478
~Matrix()
Matrix::~Matrix Destructor.
Definition matrix.cpp:69
bool solve(qreal b[])
Computes and returns the solution of the set of n linear equations A·x = b Allows A....
Definition matrix.cpp:1308
Matrix & subtractFromI()
Subtracts this matrix from I and returns.
Definition matrix.cpp:320
MatrixRow & operator[](const int &r)
Definition matrix.h:135
Matrix & inverseByGaussJordanElimination(Matrix &a)
Inverts given matrix A by Gauss Jordan elimination Input: matrix A Output: matrix A becomes unit matr...
Definition matrix.cpp:1003
Matrix & degreeMatrix()
Returns the Degree Matrix of this matrix. The Degree Matrix is diagonal matrix which contains informa...
Definition matrix.cpp:956
Matrix & pearsonCorrelationCoefficients(Matrix &AM, const QString &varLocation="Rows", const bool &diagonal=false)
Computes the Pearson Correlation Coefficient of the rows or the columns of the given matrix AM.
Definition matrix.cpp:2091
void findMinMaxValues(qreal &min, qreal &max, bool &hasRealNumbers)
finds Min-Max values in current Matrix
Definition matrix.cpp:116
void clearItem(int r, int c)
Clears the (r,c) matrix element.
Definition matrix.cpp:239
void operator+=(Matrix &b)
Matrix::operator += Matrix add another matrix: += Adds to this matrix another matrix B of the same di...
Definition matrix.cpp:446
void clear()
Clears data.
Definition matrix.cpp:78
void swapRows(int rowA, int rowB)
Swaps row A with row B of this matrix.
Definition matrix.cpp:339
void zeroMatrix(const int m, const int n)
Makes this matrix the zero matrix of size mxn.
Definition matrix.cpp:191
qreal item(int r, int c)
Returns the (r,c) matrix element.
Definition matrix.cpp:216
void deleteRowColumn(int i)
Deletes row and column and shifts rows and cols accordingly.
Definition matrix.cpp:253
Matrix & transpose()
Returns the Transpose of this matrix Allows T = A.transpose()
Definition matrix.cpp:912
bool printMatrixConsole(bool debug=true)
Prints this matrix to stderr or stdout.
Definition matrix.cpp:2636
int rows()
Definition matrix.h:141
Matrix & operator+(Matrix &b)
Matrix addition, operator + Adds this matrix and B of the same dim and returns the sum S Allows S = A...
Definition matrix.cpp:461
qreal operator()(const int r, const int c)
Definition matrix.h:133
Matrix & operator=(Matrix &a)
Matrix equality/assignment , operator = Allows copying a matrix onto another using b=a where b,...
Definition matrix.cpp:398
void multiplyScalar(const qreal &f)
Scalar Multiplication. Multiplies this by qreal f and returns the product matrix of the same dim Allo...
Definition matrix.cpp:361
void productByVector(qreal in[], qreal out[], const bool &leftMultiply=false)
Calculates the matrix-by-vector product Ax of this matrix Default product: Ax if leftMultiply=true th...
Definition matrix.cpp:724
static const int METRIC_EUCLIDEAN_DISTANCE
Definition matrix.h:42
static const int METRIC_HAMMING_DISTANCE
Definition matrix.h:40
static const int METRIC_NONE
Definition matrix.h:37
static const int METRIC_CHEBYSHEV_MAXIMUM
Definition matrix.h:45
static const QString infinity
Definition matrix.h:33
static const int METRIC_MANHATTAN_DISTANCE
Definition matrix.h:43
static const int METRIC_COSINE_SIMILARITY
Definition matrix.h:41
static const int METRIC_PEARSON_COEFFICIENT
Definition matrix.h:44
static const int METRIC_JACCARD_INDEX
Definition matrix.h:39
static const int METRIC_SIMPLE_MATCHING
Definition matrix.h:38