Three-dimensional reconstruction interview 13X: Some algorithm questions-today's headline ai-lab__ algorithm

Source: Internet
Author: User
Tags square root

was led by the nose, to the place and Mo Ming chess Wonderful to eat a brick. Today's headline Ai-lab, in fact, I always found that the best is still point cloud image processing, and just point cloud processing.


First, C + + topics

The difference between New and malloc:

Look at this: the difference between New and malloc

Although the type of the malloc () function is (void *), any type of pointer can be converted to (void *), but it is preferable to force type conversions in the front, as this can evade some of the compiler's checks.

1 malloc and free are the standard library functions of the c++/c language, New/delete is the operator of C + +. Both can be used to request dynamic memory and free memory. 2 for non-internal data types of objects, optical maloc/free can not meet the requirements of dynamic objects. Objects are created with the constructor automatically executed, and the destructor is automatically executed before the object dies. Because Malloc/free is a library function and not an operator, it is not possible to impose the task of executing constructors and destructors on Malloc/free without the compiler controlling permissions. The C + + language therefore requires a new operator to complete dynamic memory allocation and initialization, as well as an operator delete that cleans and frees up memory work. Note that New/delete is not a library function. We do not attempt to use Malloc/free to complete the memory management of dynamic objects, we should use New/delete. Because "objects" of intrinsic data types do not have a process of structuring and destructors, Malloc/free and new/delete are equivalent to them. 3 since the function of New/delete completely covers the Malloc/free, why C + + does not eliminate the malloc/free. This is because C + + programs often call C functions, and C programs can only use Malloc/free to manage dynamic memory. If you release "dynamic object created by new" with free, the object may cause a program error because it cannot perform a destructor. If you use Delete to release "malloc requested dynamic memory", the result can also cause a program error, but the program's readability is poor. So new/delete have to be paired, and so is malloc/free.


new characteristics of c++11

the difference between unique_ptr and shared_ptr: The concept of ownership. p.671 page. For a particular image, only one smart pointer can have it, so that only the constructor that owns the object's smart pointer deletes the object. Then, let the assignment operation transfer ownership. This is the strategy for auto_ptr and Unique_ptr, when the unique strategy is more stringent.

Using reference counting, is the policy adopted by shared_ptr to call delete only if the last pointer expires. Unique distinguishes between secure and unsafe usage because of the use of C++11 attributes to move constructors and right-value reference functions.

Note : When you use new to allocate memory, you cannot use auto and share to allocate memory using new[, and you cannot use them. You cannot use auto and share when allocating memory without using new, and you cannot use unique_ptr when you do not use new or new[.

Mobile semantics : Mobile semantics avoids moving the original data, but only modifies the record. How it works: Let the compiler know when to replicate and when not to replicate, which is where the right value reference works.

Right Value reference : Using the move constructor. c++.p808.


Two, multi-view geometry

Polar line Constraint


third, matrix analysis

The difference between Cholesky decomposition and QR decomposition: suggest or read a book, do a good job of the topic again.

Cholesky Decomposition Method , also called square root method , is one of the most common methods for solving symmetric positive definite linear equations . For the general matrix, in order to eliminate the limitation of LU decomposition and excessive accumulation of errors, the method of selecting the principal element is adopted, but for the symmetric positive definite matrix, it is unnecessary to select the principal element.

-lu decomposition, LDLT decomposition, Cholesky decomposition:

Cholesky decomposition is a kind of decomposition matrix method, which has an important application in linear algebra. Cholesky decomposes The matrix into a lower triangular matrix and the product of its conjugate transpose matrix (which is analogous to the square root of the real-world analogy). Compared with the general matrix decomposition solution equation, theCholesky decomposition efficiency is very high .

Cholesky conditions of decomposition:

Hermitianmatrix: The conjugate symmetry of elements in a matrix (the definition of a plural field is analogous to the symmetric matrix of real numbers). Hermitiank means that for any vector x and y, (x*) ay conjugate equals

Second, Positive-definite: Positive definite (matrix field, analogy to a definition of positive real numbers). Positive definite matrix A means that for any vector x, (x^t) Ax is always > 0 (the plural field is (x*) ax>0).

Cholesky the form of decomposition:

Can be recorded as a = L l*. Where l is the lower triangular matrix. L* is the conjugate transpose matrix of L.

It can be proved that if a satisfies the above two conditions, L is uniquely determined and the diagonal element of L is definitely positive. Conversely, that is, where L decomposes A, a satisfies the above two conditions.

If A is a semidefinite (semi-definite), it can also be decomposed, but this time L is not unique.

In particular, if a is a symmetric matrix of real numbers, then the elements of L are certainly also real numbers.

In addition, satisfying the above two conditions means that the eigenvalues of a matrix are positive real numbers because AX = Lamda * x, (x*) ax = Lamda * (x*) x > 0, lamda > 0.

-QR decomposition is the product of a matrix into an orthogonal matrix and an upper triangular matrix. The QR decomposition can be graphically represented by a picture:

In which, q is the orthogonal matrix, and the qtq=i,r is the upper triangular matrix. In practice, QR Decomposition is often used to solve linear least squares problems.

Cholesky decomposition can only be used for positive definite symmetric matrices, but in the actual equations, the positive definite symmetric matrix is not satisfied, and the problem of morbid matrix arises when near definite matrix. QR is a universal method.

Common matrix decomposition has triangular (LU) decomposition of reversible matrices, orthogonal triangular (QR) decomposition of arbitrary full rank matrices, Cholesky decomposition of symmetric positive definite matrices, and Schur decomposition of arbitrary matrices, Hessenberg decomposition, EVD decomposition, SVD decomposition, GMD decomposition, etc. (1) LU decomposition of the LU decomposition matrix of reversible matrices is represented as a product form of a commutative triangular matrix and a upper triangular matrix.
It has been proved in linear algebra that LU decomposition can always be done as long as the square A is nonsingular (i.e. reversible). When L is the lower triangular matrix and U is the upper triangular matrix, this triangular decomposition is called Dulit (Doolittle) decomposition. When L is the lower triangular matrix and U is the upper triangular matrix of the unit, this triangular decomposition is called crout (crout) decomposition.
Obviously, if present, the triangular decomposition of matrices is not unique. (PS: Square A can be uniquely decomposed into A=ldu (where the l,u, the upper triangular matrix, D is the diagonal matrix), the sufficient and necessary conditions for the first n-1 order of A is not 0. In particular: for n-order symmetric positive definite matrices, there exists a nonsingular lower triangular matrix L, which makes A=ll ' tenable. The LU function provided by MATLAB is used for LU decomposition of matrices, and its invocation format is: [L,u] =lu (X): Produces a upper triangular array U and a transformation form of the lower triangular array L (line Exchange) to satisfy the x=lu.
   Note that the matrix X here must be a phalanx. [L,u,p]=lu (X): produces an upper triangular array U and a lower triangular matrix L and a permutation matrix P to satisfy the px=lu. 
Of course the Matrix X must also be a phalanx. (2) The QR decomposition of the full rank matrix is the QR decomposition of Matrix X, which is to decompose X into a product form of an orthogonal matrix Q and a upper triangular matrix R. QR decomposition can only be done on a square.
   matlab function QR can be used to the matrix QR decomposition, its calling format: [Q,r] =QR (X): produces an orthogonal matrix Q and a upper triangular matrix R, so that it satisfies the X=QR. 
[Q,r,e]=qr (X): produces an orthogonal matrix Q, an upper triangular matrix R, and a permutation matrix E to satisfy the XE=QR. (3) Cholesky decomposition of symmetric positive definite matrices if the matrix X is a symmetric positive definite, then the Cholesky decomposition decomposes the matrix X into a product of the lower triangular matrix and the upper triangular matrix. When the triangular matrix is set to R, the lower triangular matrix is its transpose, that is, X=r ' r. The MATLAB function chol (x) is used for Cholesky decomposition of the Matrix X, and its invocation format is: R =chol (x): produces a upper triangular array R to make R ' R=x.
   If x is asymmetric positive, output an error message. [r,p]=Chol (X): This command format will not output error messages. When x is a symmetric positive definite, the result of P=0,r is the same as that of the above format; otherwise p is a positive integer.
If X is a full rank matrix, r is an upper triangular array with a order of q=p-1 and satisfies R ' R=x (1:Q,1:Q).
   (4) The Schur decomposition of any square matrix can be decomposed into X=uru ', where U is unitary matrix, r is the upper triangular Schur matrix, and the element on its main diagonal is the characteristic value of x.
   [U,r]=schur (X) (5) The Hessenberg decomposition of arbitrary square matrices can be decomposed into x=php ', where p is unitary matrix, and the elements under the first diagonal of H are 0, i.e. H is the Hessenberg matrix.
   [P,h]=hess (X) (6) The eigenvalue decomposition of arbitrary matrices evd any one n-order matrix X can be decomposed into XV=VD, where D is the eigenvalues of x, and V is the eigenvector matrix of X.
[V,d]=eig (X) [V,d]=eig (X,y) computes the generalized eigenvalue matrix D and the generalized eigenvector matrix V, which makes the XV=YVD.
   (7) The singular value decomposition of arbitrary matrix SVD any one m*n-dimensional matrix X can be decomposed into X=USV ', u,v are unitary matrices, S is m*n-dimensional diagonal matrix, and its diagonal element is the nonnegative singular value of x from large to small. [U,s,v]=svd (X) (8) The geometric mean decomposition of any matrix GMD the matrix X of m*n dimension of any matrix can be decomposed into X=QRP ', q,p are unitary matrices, R is the real positive line triangular matrix of k*k dimension, and its main diagonal element equals the geometric mean value of all k positive singular values of X, k=
Rank (X). (PS: A nxn real symmetric matrix M is positive definite if and only if for all non 0 real coefficients vector z, there are ztmz > 0.
   Where ZT represents the transpose of Z. For a complex number, the definition is: a nxn Hermitian matrix M is positive definite if and only if for each non-zero complex vector z, there are z*mz > 0. Where z* represents the conjugate transpose of Z. Since M is a Hermitian matrix, it is calculated that the z,z*mz of arbitrary complex vectors must be real numbers, which can be compared with 0. So this definition is self-consistent. All eigenvalue λi of positive definite matrix m are positive.
 )

Iv. Programming Topics

breadth-first traversal-use queues ;

Using an advanced first-out queue, you can achieve a binary tree's breadth-first traversal BFS.


Five, depth image

Surface element extraction, three-dimensional features,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.