My Project
|
#include "kernel/mod2.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "coeffs/mpr_complex.h"
#include "polys/monomials/p_polys.h"
#include "polys/simpleideals.h"
#include "polys/matpol.h"
#include "kernel/structs.h"
#include "kernel/ideals.h"
#include "kernel/linear_algebra/linearAlgebra.h"
Go to the source code of this file.
Functions | |
int | pivotScore (number n, const ring r) |
The returned score is based on the implementation of 'nSize' for numbers (, see numbers.h): nSize(n) provides a measure for the complexity of n. More... | |
bool | pivot (const matrix aMat, const int r1, const int r2, const int c1, const int c2, int *bestR, int *bestC, const ring R) |
This code computes a score for each non-zero matrix entry in aMat[r1..r2, c1..c2]. More... | |
bool | unitMatrix (const int n, matrix &unitMat, const ring R) |
Creates a new matrix which is the (nxn) unit matrix, and returns true in case of success. More... | |
void | luDecomp (const matrix aMat, matrix &pMat, matrix &lMat, matrix &uMat, const ring R) |
LU-decomposition of a given (m x n)-matrix. More... | |
bool | luInverse (const matrix aMat, matrix &iMat, const ring R) |
This code first computes the LU-decomposition of aMat, and then calls the method for inverting a matrix which is given by its LU-decomposition. More... | |
int | rankFromRowEchelonForm (const matrix aMat) |
int | luRank (const matrix aMat, const bool isRowEchelon, const ring R) |
Computes the rank of a given (m x n)-matrix. More... | |
bool | upperRightTriangleInverse (const matrix uMat, matrix &iMat, bool diagonalIsOne, const ring R) |
Computes the inverse of a given (n x n)-matrix in upper right triangular form. More... | |
bool | lowerLeftTriangleInverse (const matrix lMat, matrix &iMat, bool diagonalIsOne) |
Computes the inverse of a given (n x n)-matrix in lower left triangular form. More... | |
bool | luInverseFromLUDecomp (const matrix pMat, const matrix lMat, const matrix uMat, matrix &iMat, const ring R) |
This code computes the inverse by inverting lMat and uMat, and then performing two matrix multiplications. More... | |
bool | luSolveViaLUDecomp (const matrix pMat, const matrix lMat, const matrix uMat, const matrix bVec, matrix &xVec, matrix &H) |
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LU-decomposition. More... | |
void | printNumber (const number z) |
void | printMatrix (const matrix m) |
number | complexNumber (const double r, const double i) |
Creates a new complex number from real and imaginary parts given by doubles. More... | |
number | tenToTheMinus (const int exponent) |
Returns one over the exponent-th power of ten. More... | |
void | printSolutions (const int a, const int b, const int c) |
bool | realSqrt (const number n, const number tolerance, number &root) |
Computes the square root of a non-negative real number and returns it as a new number. More... | |
int | quadraticSolve (const poly p, number &s1, number &s2, const number tolerance) |
Returns all solutions of a quadratic polynomial relation with real coefficients. More... | |
number | euclideanNormSquared (const matrix aMat) |
number | absValue (poly p) |
bool | subMatrix (const matrix aMat, const int rowIndex1, const int rowIndex2, const int colIndex1, const int colIndex2, matrix &subMat) |
Creates a new matrix which is a submatrix of the first argument, and returns true in case of success. More... | |
bool | charPoly (const matrix aMat, poly &charPoly) |
Computes the characteristic polynomial from a quadratic (2x2) matrix and returns true in case of success. More... | |
void | swapRows (int row1, int row2, matrix &aMat) |
Swaps two rows of a given matrix and thereby modifies it. More... | |
void | swapColumns (int column1, int column2, matrix &aMat) |
Swaps two columns of a given matrix and thereby modifies it. More... | |
void | matrixBlock (const matrix aMat, const matrix bMat, matrix &block) |
Creates a new matrix which contains the first argument in the top left corner, and the second in the bottom right. More... | |
number | hessenbergStep (const matrix vVec, matrix &uVec, matrix &pMat, const number tolerance) |
Computes information related to one householder transformation step for constructing the Hessenberg form of a given non-derogative matrix. More... | |
void | hessenberg (const matrix aMat, matrix &pMat, matrix &hessenbergMat, const number tolerance, const ring R) |
Computes the Hessenberg form of a given square matrix. More... | |
void | mpTrafo (matrix &H, int it, const number tolerance, const ring R) |
Performs one transformation step on the given matrix H as part of the gouverning QR double shift algorithm. More... | |
bool | qrDS (const int, matrix *queue, int &queueL, number *eigenValues, int &eigenValuesL, const number tol1, const number tol2, const ring R) |
int | similar (const number *nn, const int nnLength, const number n, const number tolerance) |
Tries to find the number n in the array nn[0..nnLength-1]. More... | |
void | henselFactors (const int xIndex, const int yIndex, const poly h, const poly f0, const poly g0, const int d, poly &f, poly &g) |
Computes a factorization of a polynomial h(x, y) in K[[x]][y] up to a certain degree in x, whenever a factorization of h(0, y) is given. More... | |
void | lduDecomp (const matrix aMat, matrix &pMat, matrix &lMat, matrix &dMat, matrix &uMat, poly &l, poly &u, poly &lTimesU) |
LU-decomposition of a given (m x n)-matrix with performing only those divisions that yield zero remainders. More... | |
bool | luSolveViaLDUDecomp (const matrix pMat, const matrix lMat, const matrix dMat, const matrix uMat, const poly l, const poly u, const poly lTimesU, const matrix bVec, matrix &xVec, matrix &H) |
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LDU-decomposition. More... | |
number absValue | ( | poly | p | ) |
Definition at line 725 of file linearAlgebra.cc.
Computes the characteristic polynomial from a quadratic (2x2) matrix and returns true in case of success.
The method will be successful whenever the input matrix is a (2x2) matrix. In this case, the resulting polynomial will be a univariate polynomial in the first ring variable of degree 2 and it will reside in the second argument. The method assumes that the matrix entries are all numbers, i.e., elements from the ground field/ring.
[in] | aMat | the input matrix |
[out] | charPoly | the characteristic polynomial |
Definition at line 748 of file linearAlgebra.cc.
Creates a new complex number from real and imaginary parts given by doubles.
Definition at line 541 of file linearAlgebra.cc.
Definition at line 705 of file linearAlgebra.cc.
void henselFactors | ( | const int | xIndex, |
const int | yIndex, | ||
const poly | h, | ||
const poly | f0, | ||
const poly | g0, | ||
const int | d, | ||
poly & | f, | ||
poly & | g | ||
) |
Computes a factorization of a polynomial h(x, y) in K[[x]][y] up to a certain degree in x, whenever a factorization of h(0, y) is given.
The algorithm is based on Hensel's lemma: Let h(x, y) denote a monic polynomial in y of degree m + n with coefficients in K[[x]]. Suppose there are two monic factors f_0(y) (of degree n) and g_0(y) of degree (m) such that h(0, y) = f_0(y) * g_0(y) and <f_0, g_0> = K[y]. Fix an integer d >= 0. Then there are monic polynomials in y with coefficients in K[[x]], namely f(x, y) of degree n and g(x, y) of degree m such that h(x, y) = f(x, y) * g(x, y) modulo <x^(d+1)> (*).
This implementation expects h, f0, g0, and d as described and computes the factors f and g. Effectively, h will be given as an element of K[x, y] since all terms of h with x-degree larger than d can be ignored due to (*). The method expects the ground ring to contain at least two variables; then x is the first ring variable, specified by the input index xIndex, and y the second one, specified by yIndex.
This code was placed here since the algorithm works by successively solving d linear equation systems. It is hence an application of other methods defined in this h-file and its corresponding cc-file.
[in] | xIndex | index of x in {1, ..., nvars(basering)} |
[in] | yIndex | index of y in {1, ..., nvars(basering)} |
[in] | h | the polynomial h(x, y) as above |
[in] | f0 | the first univariate factor of h(0, y) |
[in] | g0 | the second univariate factor of h(0, y) |
[in] | d | the degree bound, d >= 0 |
[out] | f | the first factor of h(x, y) |
[out] | g | the second factor of h(x, y) |
Definition at line 1219 of file linearAlgebra.cc.
void hessenberg | ( | const matrix | aMat, |
matrix & | pMat, | ||
matrix & | hessenbergMat, | ||
const number | tolerance, | ||
const ring | r | ||
) |
Computes the Hessenberg form of a given square matrix.
The method assumes that all matrix entries are numbers coming from some subfield of the reals.. Afterwards, the following conditions will hold: 1) hessenbergMat = pMat * aMat * pMat^{-1}, 2) hessenbergMat is in Hessenberg form. During the algorithm, pMat will be constructed as the product of self- inverse matrices. The algorithm relies on computing square roots of floating point numbers. These will be combuted by Heron's iteration formula, with iteration stopping when two successive approximations of the square root differ by no more than the given tolerance, which is assumed to be a positive real number.
[in] | aMat | the square input matrix |
[out] | pMat | the transformation matrix |
[out] | hessenbergMat | the Hessenberg form of aMat |
[in] | tolerance | accuracy |
Definition at line 909 of file linearAlgebra.cc.
Computes information related to one householder transformation step for constructing the Hessenberg form of a given non-derogative matrix.
The method assumes that all matrix entries are numbers coming from some subfield of the reals. And that v has a non-zero first entry v_1 and a second non-zero entry somewhere else. Given such a vector v, it computes a number r (which will be the return value of the method), a vector u and a matrix P such that: 1) P * v = r * e_1, 2) P = E - u * u^T, 3) P = P^{-1}. Note that enforcing norm(u) = sqrt(2), which is done in the algorithm, guarantees property 3). This can be checked by expanding P^2 using property 2).
[in] | vVec | the input vector v |
[out] | uVec | the output vector u |
[out] | pMat | the output matrix P |
[in] | tolerance | accuracy for square roots |
Definition at line 837 of file linearAlgebra.cc.
void lduDecomp | ( | const matrix | aMat, |
matrix & | pMat, | ||
matrix & | lMat, | ||
matrix & | dMat, | ||
matrix & | uMat, | ||
poly & | l, | ||
poly & | u, | ||
poly & | lTimesU | ||
) |
LU-decomposition of a given (m x n)-matrix with performing only those divisions that yield zero remainders.
Given an (m x n) matrix A, the method computes its LDU-decomposition, that is, it computes matrices P, L, D, and U such that
In contrast to luDecomp, this method only performs those divisions which yield zero remainders. Hence, when e.g. computing over a rational function field and starting with polynomial entries only (or over Q and starting with integer entries only), then any newly computed matrix entry will again be polynomial (or integer).
The method will modify all argument matrices except aMat, so that they will finally contain the matrices P, L, D, and U as specified above. Moreover, in order to further speed up subsequent calls of luSolveViaLDUDecomp, the two denominators and their product will also be returned.
[in] | aMat | the initial matrix A, |
[out] | pMat | the row permutation matrix P |
[out] | lMat | the lower triangular matrix L |
[out] | dMat | the diagonal matrix D |
[out] | uMat | the upper row echelon matrix U |
[out] | l | the product of pivots of L |
[out] | u | the product of pivots of U |
[out] | lTimesU | the product of l and u |
Definition at line 1343 of file linearAlgebra.cc.
Computes the inverse of a given (n x n)-matrix in lower left triangular form.
This method expects an (n x n)-matrix, that is, it must have as many rows as columns. Moreover, lMat[i,j] = 0, at least for all j > i, that ism lMat is in lower left triangular form.
If the argument diagonalIsOne is true, then we know additionally, that lMat[i, i] = 1, for all i. In this case lMat is invertible. Contrariwise, if diagonalIsOne is false, we do not know anything about the diagonal entries. (Note that they may still all be 1.)
In general, there are two cases:
1) The matrix is not invertible. Then the method returns false, and &iMat remains unchanged.
2) The matrix is invertible. Then the method returns true, and the content of iMat is the inverse of lMat.
[in] | lMat | (n x n)-matrix in lower left triangular form |
[out] | iMat | inverse of lMat if invertible |
[in] | diagonalIsOne | if true, then all diagonal entries of lMat are 1 |
Definition at line 300 of file linearAlgebra.cc.
void luDecomp | ( | const matrix | aMat, |
matrix & | pMat, | ||
matrix & | lMat, | ||
matrix & | uMat, | ||
const ring | r = currRing |
||
) |
LU-decomposition of a given (m x n)-matrix.
Given an (m x n) matrix A, the method computes its LU-decomposition, that is, it computes matrices P, L, and U such that
The method will modify all argument matrices except aMat, so that they will finally contain the matrices P, L, and U as specified above.
[in] | aMat | the initial matrix A, |
[out] | pMat | the row permutation matrix P |
[out] | lMat | the lower triangular matrix L |
[out] | uMat | the upper row echelon matrix U |
[in] | R | current ring |
Definition at line 103 of file linearAlgebra.cc.
This code first computes the LU-decomposition of aMat, and then calls the method for inverting a matrix which is given by its LU-decomposition.
Computes the inverse of a given (n x n)-matrix.
[in] | aMat | matrix to be inverted |
[out] | iMat | inverse of aMat if invertible |
[in] | R | current ring |
Definition at line 200 of file linearAlgebra.cc.
bool luInverseFromLUDecomp | ( | const matrix | pMat, |
const matrix | lMat, | ||
const matrix | uMat, | ||
matrix & | iMat, | ||
const ring | R | ||
) |
This code computes the inverse by inverting lMat and uMat, and then performing two matrix multiplications.
Computes the inverse of an (n x n)-matrix which is given by its LU- decomposition.
[in] | pMat | permutation matrix of an LU- decomposition |
[in] | lMat | lower left matrix of an LU- decomposition |
[in] | uMat | upper right matrix of an LU- decomposition |
[out] | iMat | inverse of A if invertible |
Definition at line 352 of file linearAlgebra.cc.
Computes the rank of a given (m x n)-matrix.
The matrix may already be given in row echelon form, e.g., when the user has before called luDecomp and passes the upper triangular matrix U to luRank. In this case, the second argument can be set to true in order to pass this piece of information to the method. Otherwise, luDecomp will be called first to compute the matrix U. The rank is then read off the matrix U.
[in] | aMat | input matrix |
[in] | isRowEchelon | if true then aMat is assumed to be already in row echelon form |
Definition at line 230 of file linearAlgebra.cc.
bool luSolveViaLDUDecomp | ( | const matrix | pMat, |
const matrix | lMat, | ||
const matrix | dMat, | ||
const matrix | uMat, | ||
const poly | l, | ||
const poly | u, | ||
const poly | lTimesU, | ||
const matrix | bVec, | ||
matrix & | xVec, | ||
matrix & | H | ||
) |
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LDU-decomposition.
The method expects the LDU-decomposition of A, that is, pMat * A = lMat * dMat^(-1) * uMat, where the argument matrices have the appropriate properties; see method 'lduDecomp(const matrix aMat, matrix &pMat, matrix &lMat,
matrix &dMat, matrix &uMat, poly &l, poly &u, poly &lTimesU)'.
Instead of trying to invert A and return x = A^(-1)*b, this method 1) computes b' = l * pMat * b, 2) solves the simple system L * y = b', 3) computes y' = u * dMat * y, 4) solves the simple system U * y'' = y', 5) computes x = 1/(lTimesU) * y''. Note that steps 1), 2) and 3) will always work, as L is in any case invertible. Moreover, y and thus y' are uniquely determined. Step 4) will only work if and only if y' is in the column span of U. In that case, there may be infinitely many solutions. In contrast to luSolveViaLUDecomp, this algorithm guarantees that all divisions which have to be performed in steps 2) and 4) will work without remainder. This is due to properties of the given LDU- decomposition. Only the final step 5) performs a division of a vector by a member of the ground field. (Suppose the ground field is Q or some rational function field. Then, if A contains only integers or polynomials, respectively, then steps 1) - 4) will keep all data integer or polynomial, respectively. This may speed up computations considerably.) For the outcome, there are three cases:
1) There is no solution. Then the method returns false, and &xVec as well as &H remain unchanged.
2) There is a unique solution. Then the method returns true and H is the 1x1 matrix with zero entry.
3) There are infinitely many solutions. Then the method returns true and some solution of the given original linear system. Furthermore, the columns of H span the solution space of the homogeneous linear system. The dimension of the solution space is then the number of columns of H.
[in] | pMat | permutation matrix of an LDU- decomposition |
[in] | lMat | lower left matrix of an LDU- decomposition |
[in] | dMat | diagonal matrix of an LDU- decomposition |
[in] | uMat | upper right matrix of an LDU- decomposition |
[in] | l | pivot product l of an LDU decomp. |
[in] | u | pivot product u of an LDU decomp. |
[in] | lTimesU | product of l and u |
[in] | bVec | right-hand side of the linear system to be solved |
[out] | xVec | solution of A*x = b |
[out] | H | matrix with columns spanning homogeneous solution space |
Definition at line 1461 of file linearAlgebra.cc.
bool luSolveViaLUDecomp | ( | const matrix | pMat, |
const matrix | lMat, | ||
const matrix | uMat, | ||
const matrix | bVec, | ||
matrix & | xVec, | ||
matrix & | H | ||
) |
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LU-decomposition.
The method expects the LU-decomposition of A, that is, pMat * A = lMat * uMat, where the argument matrices have the appropriate properties; see method 'luDecomp(const matrix aMat, matrix &pMat, matrix &lMat,
matrix &uMat)'.
Instead of trying to invert A and return x = A^(-1)*b, this method 1) computes b' = pMat * b, 2) solves the simple system L * y = b', and then 3) solves the simple system U * x = y. Note that steps 1) and 2) will always work, as L is in any case invertible. Moreover, y is uniquely determined. Step 3) will only work if and only if y is in the column span of U. In that case, there may be infinitely many solutions. Thus, there are three cases:
1) There is no solution. Then the method returns false, and &xVec as well as &H remain unchanged.
2) There is a unique solution. Then the method returns true and H is the 1x1 matrix with zero entry.
3) There are infinitely many solutions. Then the method returns true and some solution of the given original linear system. Furthermore, the columns of H span the solution space of the homogeneous linear system. The dimension of the solution space is then the number of columns of H.
[in] | pMat | permutation matrix of an LU- decomposition |
[in] | lMat | lower left matrix of an LU- decomposition |
[in] | uMat | upper right matrix of an LU- decomposition |
[in] | bVec | right-hand side of the linear system to be solved |
[out] | xVec | solution of A*x = b |
[out] | H | matrix with columns spanning homogeneous solution space |
Definition at line 377 of file linearAlgebra.cc.
Creates a new matrix which contains the first argument in the top left corner, and the second in the bottom right.
All other entries of the resulting matrix which will be created in the third argument, are zero.
[in] | aMat | the top left input matrix |
[in] | bMat | the bottom right input matrix |
[out] | block | the new block matrix |
Definition at line 805 of file linearAlgebra.cc.
Performs one transformation step on the given matrix H as part of the gouverning QR double shift algorithm.
The method will change the given matrix H side-effect-wise. The resulting matrix H' will be in Hessenberg form. The iteration index is needed, since for the 11th and 21st iteration, the transformation step is different from the usual step, to avoid convergence problems of the gouverning QR double shift process (who is also the only caller of this method).
H | [in/out] the matrix to be transformed | |
[in] | it | iteration index |
[in] | tolerance | accuracy for square roots |
Definition at line 979 of file linearAlgebra.cc.
bool pivot | ( | const matrix | aMat, |
const int | r1, | ||
const int | r2, | ||
const int | c1, | ||
const int | c2, | ||
int * | bestR, | ||
int * | bestC, | ||
const ring | R | ||
) |
This code computes a score for each non-zero matrix entry in aMat[r1..r2, c1..c2].
Finds the best pivot element in some part of a given matrix.
If all entries are zero, false is returned, otherwise true. In the latter case, the minimum of all scores is sought, and the row and column indices of the corresponding matrix entry are stored in bestR and bestC.
[in] | aMat | any matrix with number entries |
[in] | r1 | lower row index |
[in] | r2 | upper row index |
[in] | c1 | lower column index |
[in] | c2 | upper column index |
[out] | bestR | address of row index of best pivot element |
[out] | bestC | address of column index of best pivot element |
[in] | R | current ring |
Definition at line 68 of file linearAlgebra.cc.
int pivotScore | ( | number | n, |
const ring | r | ||
) |
The returned score is based on the implementation of 'nSize' for numbers (, see numbers.h): nSize(n) provides a measure for the complexity of n.
Returns a pivot score for any non-zero matrix entry.
Thus, less complex pivot elements will be preferred, and get therefore a smaller pivot score. Consequently, we simply return the value of nSize. An exception to this rule are the ground fields R, long R, and long C: In these, the result of nSize relates to |n|. And since a larger modulus of the pivot element ensures a numerically more stable Gauss elimination, we would like to have a smaller score for larger values of |n|. Therefore, in R, long R, and long C, the negative of nSize will be returned.
[in] | n | a non-zero matrix entry |
[in] | r | current ring |
Definition at line 50 of file linearAlgebra.cc.
Definition at line 522 of file linearAlgebra.cc.
void printNumber | ( | const number | z | ) |
Definition at line 575 of file linearAlgebra.cc.
bool qrDS | ( | const int | n, |
matrix * | queue, | ||
int & | queueL, | ||
number * | eigenValues, | ||
int & | eigenValuesL, | ||
const number | tol1, | ||
const number | tol2, | ||
const ring | R | ||
) |
Definition at line 1090 of file linearAlgebra.cc.
Returns all solutions of a quadratic polynomial relation with real coefficients.
The method assumes that the polynomial is univariate in the first ring variable, and that the current ground field is the complex numbers. The polynomial has degree <= 2. Thus, there may be a) infinitely many zeros, when p == 0; then -1 is returned; b) no zero, when p == constant <> 0; then 0 is returned; c) one zero, when p is linear; then 1 is returned; d) one double zero; then 2 is returned; e) two distinct zeros; then 3 is returned; In the case e), s1 and s2 will contain the two distinct solutions. In cases c) and d) s1 will contain the single/double solution.
[in] | p | the polynomial |
[out] | s1 | first zero, if any |
[out] | s2 | second zero, if any |
[in] | tolerance | accuracy |
Definition at line 626 of file linearAlgebra.cc.
Computes the square root of a non-negative real number and returns it as a new number.
The method assumes that the current ground field is the complex numbers, and that the argument has imaginary part zero. If the real part is negative, then false is returned, otherwise true. The square root will be computed in the last argument by Heron's iteration formula with the first argument as the starting value. The iteration will stop as soon as two successive values (in the resulting sequence) differ by no more than the given tolerance, which is assumed to be a positive real number.
[in] | n | the input number |
[in] | tolerance | accuracy of iteration |
[out] | root | the root of n |
Definition at line 601 of file linearAlgebra.cc.
Tries to find the number n in the array nn[0..nnLength-1].
The method assumes that the ground field is the complex numbers. n and an entry of nn will be regarded equal when the absolute value of their difference is not larger than the given tolerance. In this case, the index of the respective entry of nn is returned, otherwise -1.
[in] | nn | array of numbers to look-up |
[in] | nnLength | length of nn |
[in] | n | number to loop-up in nn |
[in] | tolerance | tolerance for comparison |
Definition at line 1188 of file linearAlgebra.cc.
bool subMatrix | ( | const matrix | aMat, |
const int | rowIndex1, | ||
const int | rowIndex2, | ||
const int | colIndex1, | ||
const int | colIndex2, | ||
matrix & | subMat | ||
) |
Creates a new matrix which is a submatrix of the first argument, and returns true in case of success.
The method will be successful whenever rowIndex1 <= rowIndex2 and colIndex1 <= colIndex2. In this case and only then true will be returned and the last argument will afterwards contain a copy of the respective submatrix of the first argument. Note that this method may also be used to copy an entire matrix.
[in] | aMat | the input matrix |
[in] | rowIndex1 | lower row index |
[in] | rowIndex2 | higher row index |
[in] | colIndex1 | lower column index |
[in] | colIndex2 | higher column index |
[out] | subMat | the new submatrix |
Definition at line 733 of file linearAlgebra.cc.
void swapColumns | ( | int | column1, |
int | column2, | ||
matrix & | aMat | ||
) |
Swaps two columns of a given matrix and thereby modifies it.
The method expects two valid, distinct column indices, i.e. in [1..n], where n is the number of columns in aMat.
[in] | column1 | index of first column to swap |
[in] | column2 | index of second column to swap |
aMat | [in/out] matrix subject to swapping |
Definition at line 793 of file linearAlgebra.cc.
void swapRows | ( | int | row1, |
int | row2, | ||
matrix & | aMat | ||
) |
Swaps two rows of a given matrix and thereby modifies it.
The method expects two valid, distinct row indices, i.e. in [1..n], where n is the number of rows in aMat.
[in] | row1 | index of first row to swap |
[in] | row2 | index of second row to swap |
aMat | [in/out] matrix subject to swapping |
Definition at line 781 of file linearAlgebra.cc.
number tenToTheMinus | ( | const int | exponent | ) |
Returns one over the exponent-th power of ten.
The method assumes that the base ring is the complex numbers.
return one over the exponent-th power of 10
[in] | exponent | the exponent for 1/10 |
Definition at line 554 of file linearAlgebra.cc.
Creates a new matrix which is the (nxn) unit matrix, and returns true in case of success.
The method will be successful whenever n >= 1. In this case and only then true will be returned and the new (nxn) unit matrix will reside inside the second argument.
[in] | n | size of the matrix |
[out] | unitMat | the new (nxn) unit matrix |
[in] | R | current ring |
Definition at line 95 of file linearAlgebra.cc.
bool upperRightTriangleInverse | ( | const matrix | uMat, |
matrix & | iMat, | ||
bool | diagonalIsOne, | ||
const ring | r = currRing |
||
) |
Computes the inverse of a given (n x n)-matrix in upper right triangular form.
This method expects a quadratic matrix, that is, it must have as many rows as columns. Moreover, uMat[i, j] = 0, at least for all i > j, that is, u is in upper right triangular form.
If the argument diagonalIsOne is true, then we know additionally, that uMat[i, i] = 1, for all i. In this case uMat is invertible. Contrariwise, if diagonalIsOne is false, we do not know anything about the diagonal entries. (Note that they may still all be 1.)
In general, there are two cases:
1) The matrix is not invertible. Then the method returns false, and &iMat remains unchanged.
2) The matrix is invertible. Then the method returns true, and the content of iMat is the inverse of uMat.
[in] | uMat | (n x n)-matrix in upper right triangular form |
[out] | iMat | inverse of uMat if invertible |
[in] | diagonalIsOne | if true, then all diagonal entries of uMat are 1 |
[in] | R | current ring |
Definition at line 251 of file linearAlgebra.cc.