Matrix Factorization (LU matrix decomposition) and GSL implementation, lugsl
Matrix Factorization refers to the product of two or more matrices in A matrix A. It refers to the decomposition of complex data. There are multiple methods, such as LU decomposition, rank decomposition, QR decomposition, Singular Value Decomposition, spectral decomposition, etc. This section describes the concept of LU decomposition.
According to the reference books, the LU decomposition here is limited to a series of linear equations with the same coefficient matrix:
Ax = b1, Ax = b2, Ax = bp (1)
When A is reversible matrix, the A-1 can be calculated, then the A-1 b1, A-1 b2, and so on. However, how can we calculate and use social practices? In practice, the first equation in (1) is obtained by line transformation, and the LU decomposition of matrix A is obtained at the same time.
If A is set to A matrix of order m x n, Am x n can be reduced to A step ladder. In this case, A can be written as A = LU, L is the lower Triangle Matrix of m × m, the primary diagonal element is all 1, and U is an equivalent m × n trapezoid matrix of. As follows:
Such a decomposition is called LU decomposition, and matrix L is reversible. We call it the unit lower Triangle Matrix.
From the above, we can know that when A = LU, the equation Ax = B can be written as L (Ux) = B, and the Ux is written as y. We can solve the following equation to solve x:
Ly = B
Ux = y
First, the solution Ly = B and then the solution Ux = y to obtain x, as shown below, each equation is easier to solve, because the sum is a triangular matrix. Below is an example;
For example, evaluate the LU decomposition of the following matrix:
Because A has four rows, L is A 4 × 4 matrix. The formula of L is that the first column of A is the first column of A divided by its first line principal element. L is as follows:
Compare the first column of A and L. Convert the last three elements in the first column of A to zero, and then to the last three columns of L. The following shows that A is changed to A step-shaped U:
Add the rows from A to U to L:
Therefore, the obtained L and U meet LU = A. Using LU decomposition, we can calculate linear equations to simplify this calculation. Later, I referred to the latest information on the network and obtained that even if the matrix is irreversible, the LU may still exist. In fact, if a rank isKBefore the matrixKThe primary sub-type is not zero, so it can perform LU decomposition, but vice versa. Currently, the necessary and sufficient conditions for LU decomposition in a square matrix on any Italian domain have been discovered. These conditions can be expressed by the rank of certain submatrices.
/*************************************** **************************************** **************************************** **************************************** **************************************** **************************************** **************************************** **************************************** **************************/
GNU Scientific Library (GSL) is a Scientific numerical computing Library provided for C and C ++ programmers. The scientific computing database is exceptionally powerful and provides the following support:
Complex Numbers Roots of Polynomials Special Functions Vectors and Matrices Permutations Sorting BLAS Support Linear Algebra Eigensystems Fast Fourier Transforms Quadrature Random Numbers Quasi-Random Sequences Random distritions bustatistics
Using N-grams Monte Carlo Integration Simulated unbounded Equations Interpolation Numerical regression Series using Discrete Hankel Transforms Root-Finding Minimization Least-Squares Fitting Physical Constants IEEE Floating-Point Discrete Wavelet transbasis splines
Developers who often process complex mathematical computing are undoubtedly relieved.
~
The home page of the project is:
Http://www.gnu.org/software/gsl/gsl.html
Developers who often process complex mathematical computing are undoubtedly relieved.
~
The home page of the project is:
Http://www.gnu.org/software/gsl/gsl.html
Developers who often process complex mathematical computing are undoubtedly relieved.
~
The home page of the project is:
Http://www.gnu.org/software/gsl/gsl.html
Developers who often process complex mathematical computing are undoubtedly greatly relieved. Their home page is:
GSL---GNU (Scientific Library)
GSL implementation:
<span style="font-family:FangSong_GB2312;font-size:18px;"><span style="font-family:KaiTi_GB2312;font-size:14px;">#include <stdio.h>#include <gsl/gsl_linalg.h>#pragma comment(lib, "libgsl_d.lib")#pragma comment(lib, "libgslcblas_d.lib")intmain (void){ double a_data[] = { 0.18, 0.60, 0.57, 0.96, 0.41, 0.24, 0.99, 0.58, 0.14, 0.30, 0.97, 0.66, 0.51, 0.13, 0.19, 0.85 }; double b_data[] = { 1.0, 2.0, 3.0, 4.0 }; gsl_matrix_view m = gsl_matrix_view_array (a_data, 4, 4); gsl_vector_view b = gsl_vector_view_array (b_data, 4); gsl_vector *x = gsl_vector_alloc (4); int s; gsl_permutation * p = gsl_permutation_alloc (4); gsl_linalg_LU_decomp (&m.matrix, p, &s); gsl_linalg_LU_solve (&m.matrix, p, &b.vector, x); printf ("x = \n"); gsl_vector_fprintf (stdout, x, "%g"); gsl_permutation_free (p); return 0;}</span></span>