HyperMath

Set Operations

Set Operations

Previous topic Next topic Expand/collapse all hidden text  

Set Operations

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  
hmtoggle_plus1greyIntersect

Intersection of two vectors (C = A ∩ B). Duplicate items in each are ignored. It returns the intersect vector in ascending order of entries. In addition, it also returns the indices of the intersect vector elements in the respective original vectors. For example, the locations of elements of C in A and B, ignoring the duplicates.

C, I, J = Intersect(A,B)

A,B

The subject vectors.

C

The intersecting vector in ascending order. Its orientation is the same as the first input.

I

A vector of indices of the intersect elements in the first vector. Its orientation is the same as the first input.

J

A vector of indices of the intersect elements in the second vector. Its orientation is the same as the first input.

hmtoggle_plus1greySetDiff

Set difference of two vectors (C = A – B), that are items unique to A, ignoring duplicates. It also returns the indices of the unique items in A.

C, I = SetDiff(A,B)

A,B

The subject vectors.

C

The set difference vector in ascending order. Its orientation is the same as the first input.

I

A vector of indices of the entries unique to the first vector. Its orientation is the same as the first input.

hmtoggle_plus1greySetXor

Exclusive OR of two vectors (not in intersection). It also returns the indices of the entries in the resultant vector in the original vectors.

C, I, J = SetXor(A,B)

A,B

The subject vectors.

C

A vector of the exclusive OR elements in ascending order. Its orientation is the same as the first input.

I

A vector of indices of the exclusive, OR elements in the first vector. Its orientation is the same as the first input.

J

A vector of indices of the exclusive, OR elements in the second vector. Its orientation is the same as the first input.

hmtoggle_plus1greyUnion

Union of two vectors (C = A U B). Duplicate items in each are ignored. It returns the union vector in ascending order of entries.

C, I = Union(A,B)

A,B

The subject vectors.

C

The union vector in ascending order. Its orientation is the same as the first input.

I

A vector of indices of the common elements (if any) in the first vector.  Its orientation is the same as the first input.

hmtoggle_plus1greyUnique

Extracts the unique elements in a vector in ascending order. It also returns the indices of the unique entries in the vector.

C, I = Unique(A)

A,B

The subject vectors.

C

A vector of the unique entries in ascending order. Its orientation is the same as the first input.

I

A vector of the indices of the unique elements in the vector. Its orientation is the same as the first input.