This is the basic C++ program of C++ armadillo library which shows how to get the common value or intersection of both the vectors of some particular size. It can be carried out by the help of inbuilt function "intersect" in armadillo library.
C = intersect( A, B )
(form 1)
intersect( C, iA, iB, A, B )
(form 2)
For form 1:
return the unique elements common to both A and B, sorted in ascending order
For form 2:
store in C the unique elements common to both A and B, sorted in ascending order
store in iA and iB the indices of the unique elements, such that C = A.elem(iA) and C = B.elem(iB)
iA and iB must have the type uvec (ie. the indices are stored as unsigned integers of type uword)
C is a column vector if either A or B is a matrix or column vector; C is a row vector if both A and B are row vectors
For matrices and vectors with complex numbers, ordering is via absolute values
Comments