Changeset 9e269a0 in git for kernel/linearAlgebra.h
- Timestamp:
- Dec 22, 2010, 1:54:29 PM (13 years ago)
- Branches:
- (u'spielwiese', 'd0474371d8c5d8068ab70bfb42719c97936b18a6')
- Children:
- e2fd5d453ccf5a7982b273cf039c5c7f41f41080
- Parents:
- 2fd30cb3d4e41a93238b92df65a30fb88c8276de
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/linearAlgebra.h
r2fd30cb r9e269a0 39 39 * entries equal to 1,<br> 40 40 * - U is an (m x n) matrix in upper row echelon form.<br> 41 * From these conditions, it easily followsthat also A = P * L * U,41 * From these conditions, it follows immediately that also A = P * L * U, 42 42 * since P is self-inverse.<br> 43 * 43 44 * The method will modify all argument matrices except aMat, so that 44 45 * they will finally contain the matrices P, L, and U as specified … … 264 265 265 266 /** 267 * Solves the linear system A * x = b, where A is an (m x n)-matrix 268 * which is given by its LDU-decomposition. 269 * 270 * The method expects the LDU-decomposition of A, that is, 271 * pMat * A = lMat * dMat^(-1) * uMat, where the argument matrices have 272 * the appropriate proteries; see method 273 * 'lduDecomp(const matrix aMat, matrix &pMat, matrix &lMat, 274 * matrix &dMat, matrix &uMat, poly &l, poly &u, poly &lTimesU)'.<br> 275 * Instead of trying to invert A and return x = A^(-1)*b, this 276 * method 277 * 1) computes b' = l * pMat * b, 278 * 2) solves the simple system L * y = b', 279 * 3) computes y' = u * dMat * y, 280 * 4) solves the simple system U * y'' = y', 281 * 5) computes x = 1/(lTimesU) * y''. 282 * Note that steps 1), 2) and 3) will always work, as L is in any case 283 * invertible. Moreover, y and thus y' are uniquely determined. 284 * Step 4) will only work if and only if y' is in the column span of U. 285 * In that case, there may be infinitely many solutions. 286 * In contrast to luSolveViaLUDecomp, this algorithm guarantees that 287 * all divisions which have to be performed in steps 2) and 4) will 288 * work without remainder. This is due to properties of the given LDU- 289 * decomposition. Only the final step 5) performs a division of a vector 290 * by a member of the ground field. (Suppose the ground field is Q or 291 * some rational function field. Then, if A contains only integers or 292 * polynomials, respectively, then steps 1) - 4) will keep all data 293 * integer or polynomial, respectively. This may speed up computations 294 * considerably.) 295 * For the outcome, there are three cases:<br> 296 * 1) There is no solution. Then the method returns false, and &xVec 297 * as well as &H remain unchanged.<br> 298 * 2) There is a unique solution. Then the method returns true and 299 * H is the 1x1 matrix with zero entry.<br> 300 * 3) There are infinitely many solutions. Then the method returns 301 * true and some solution of the given original linear system. 302 * Furthermore, the columns of H span the solution space of the 303 * homogeneous linear system. The dimension of the solution 304 * space is then the number of columns of H. 305 * 306 * @return true if there is at least one solution, false otherwise 307 **/ 308 bool luSolveViaLDUDecomp( 309 const matrix pMat, /**< [in] permutation matrix of an LDU- 310 decomposition */ 311 const matrix lMat, /**< [in] lower left matrix of an LDU- 312 decomposition */ 313 const matrix dMat, /**< [in] diagonal matrix of an LDU- 314 decomposition */ 315 const matrix uMat, /**< [in] upper right matrix of an LDU- 316 decomposition */ 317 const poly l, /**< [in] pivot product l of an LDU decomp. */ 318 const poly u, /**< [in] pivot product u of an LDU decomp. */ 319 const poly lTimesU, /**< [in] product of l and u */ 320 const matrix bVec, /**< [in] right-hand side of the linear 321 system to be solved */ 322 matrix &xVec, /**< [out] solution of A*x = b */ 323 matrix &H /**< [out] matrix with columns spanning 324 homogeneous solution space */ 325 ); 326 327 /** 266 328 * Creates a new matrix which is the (nxn) unit matrix, and returns true 267 329 * in case of success. … … 489 551 ); 490 552 553 /** 554 * LU-decomposition of a given (m x n)-matrix with performing only those 555 * divisions that yield zero remainders. 556 * 557 * Given an (m x n) matrix A, the method computes its LDU-decomposition, 558 * that is, it computes matrices P, L, D, and U such that<br> 559 * - P * A = L * D^(-1) * U,<br> 560 * - P is an (m x m) permutation matrix, i.e., its row/columns form the 561 * standard basis of K^m,<br> 562 * - L is an (m x m) matrix in lower triangular form of full rank,<br> 563 * - D is an (m x m) diagonal matrix with full rank, and<br> 564 * - U is an (m x n) matrix in upper row echelon form.<br> 565 * From these conditions, it follows immediately that also 566 * A = P * L * D^(-1) * U, since P is self-inverse.<br> 567 * 568 * In contrast to luDecomp, this method only performs those divisions which 569 * yield zero remainders. Hence, when e.g. computing over a rational function 570 * field and starting with polynomial entries only (or over Q and starting 571 * with integer entries only), then any newly computed matrix entry will again 572 * be polynomial (or integer). 573 * 574 * The method will modify all argument matrices except aMat, so that 575 * they will finally contain the matrices P, L, D, and U as specified 576 * above. Moreover, in order to further speed up subsequent calls of 577 * luSolveViaLDUDecomp, the two denominators and their product will also be 578 * returned. 579 **/ 580 void lduDecomp( 581 const matrix aMat, /**< [in] the initial matrix A, */ 582 matrix &pMat, /**< [out] the row permutation matrix P */ 583 matrix &lMat, /**< [out] the lower triangular matrix L */ 584 matrix &dMat, /**< [out] the diagonal matrix D */ 585 matrix &uMat, /**< [out] the upper row echelon matrix U */ 586 poly &l, /**< [out] the product of pivots of L */ 587 poly &u, /**< [out] the product of pivots of U */ 588 poly &lTimesU /**< [out] the product of l and u */ 589 ); 590 491 591 #endif 492 592 /* LINEAR_ALGEBRA_H */
Note: See TracChangeset
for help on using the changeset viewer.