In that page, we detail functions that are not related to Lapack
Transpose | replaces a matrix by its transpose |
TransposeConj | replaces a matrix by its conjugate transpose |
SetRow | modifies a row of the matrix |
GetRow | extracts a row from the matrix |
SetCol | modifies a column of the matrix |
GetCol | extracts a column from the matrix |
MaxAbs | returns highest absolute value of A |
Norm1 | returns 1-norm of A |
NormInf | returns infinity-norm of A |
PermuteMatrix | permutes row and column numbers of a matrix |
ScaleMatrix | multiplies rows and columns of a matrix by coefficients |
ScaleLeftMatrix | multiplies rows of a matrix by coefficients |
void Transpose(Matrix&); void TransposeConj(Matrix&);
Transpose
overwrites a matrix by its transpose, while
TransposeConj
overwrites a matrix by its conjugate
transpose. These functions are only available for dense matrices.
Matrix<double> A(5, 5); A.Fill(); Transpose(A); Matrix<complex<double> > B(5, 5); // you fill B as you want, then overwrites it by conj(transpose(B)) TransposeConj(B);
void SetRow(const Vector&, int, Matrix&);
This function modifies a row in the provided matrix. This function is available only for dense matrices.
Matrix<double> A(5, 5); A.Fill(); // now you construct a row Vector<double> row(5); row.FillRand(); // and you put it in A int irow = 1; SetRow(row, irow, A);
void GetRow(const Matrix&, int, Vector&);
This function extracts a row from the provided matrix. This function is available only for dense matrices.
Matrix<double> A(5, 5); A.Fill(); // now you extract the first row Vector<double> row; GetRow(A, 0, row);
void SetCol(const Vector&, int, Matrix&);
This function modifies a column in the provided matrix. This function is available only for dense matrices.
Matrix<double> A(5, 5); A.Fill(); // now you construct a column Vector<double> col(5); col.FillRand(); // and you put it in A int icol = 1; SetCol(col, icol, A);
void GetCol(const Matrix&, int, Vector&);
This function extracts a column from the provided matrix. This function is available only for dense matrices.
Matrix<double> A(5, 5); A.Fill(); // now you extract the first column Vector<double> col; GetCol(A, 0, col);
T MaxAbs(const Matrix<T>&);
This function returns the highest absolute value of a matrix.
Matrix<complex<double> > A(5, 5); A.Fill(); double module_max = MaxAbs(A);
T Norm1(const Matrix<T>&);
This function returns the 1-norm of a matrix.
Matrix<complex<double> > A(5, 5); A.Fill(); double anorm_one = Norm1(A);
T NormInf(const Matrix<T>&);
This function returns the infinite norm of a matrix.
Matrix<complex<double> > A(5, 5); A.Fill(); double anorm_inf = NormInf(A);
void PermuteMatrix(Matrix&, const Vector<int>&, const Vector<int>&);
This function permutes a given matrix with the provided new row
numbers and column numbers. PermuteMatrix(A, row, col)
does the same operation as A(row, col) = A
in
Matlab. This function is only available for ArrayRowSparse,
ArrayRowSymSparse, ArrayRowComplexSparse and
ArrayRowSymComplexSparse.
// you fill A as you wish Matrix<double, Symmetric, ArrayRowSymSparse> A(5, 5); // then new row and column numbers IVect row(5); // for symmetric matrix, row and column permutation must be the same // if you want to keep symmetry PermuteMatrix(A, row, row); // for unsymmetric matrices, you can specify different permutations IVect col(5); Matrix<double, General, ArrayRowSparse> B(5, 5); PermuteMatrix(B, row, col);
void ScaleMatrix(Matrix&, const Vector&, const Vector&);
This function multiplies each row and column with a coefficient,
i.e. A
is replaced by L*A*R
where
L
and R
are diagonal matrices and you
provide the diagonal when you call ScaleMatrix
.
This function is only available for ArrayRowSparse,
ArrayRowSymSparse, ArrayRowComplexSparse and
ArrayRowSymComplexSparse.
// you fill A as you wish Matrix<double, Symmetric, ArrayRowSymSparse> A(5, 5); // then scaling vectors Vector<double> scale(5); // for symmetric matrix, row and column scaling must be the same // if you want to keep symmetry ScaleMatrix(A, scale, scale); // for unsymmetric matrices, you can specify different scalings IVect scale_right(5); Matrix<double, General, ArrayRowSparse> B(5, 5); PermuteMatrix(B, scale, scale_right);
void ScaleLeftMatrix(Matrix&, const Vector&);
This function multiplies each row with a coefficient,
i.e. A
is replaced by L*A
where
L
is diagonal and you
provide the diagonal when you call ScaleLeftMatrix
.
This function is only available for ArrayRowSparse,
and ArrayRowComplexSparse.
// you fill A as you wish Matrix<double, General, ArrayRowSparse> A(5, 5); // then scaling vector Vector<double> scale(5); ScaleLeftMatrix(A, scale);