I came across a brief reference to a mask recently
The main function comprised 2 arrays i) a double type x [ 8] 22.2,33.3 etc and 2) a bool type y[8] true, false,false etc
Both were copied into 2 separate vectors with copy((v,x,8) and copy(b,y,8)
v was declared as vec v; and b was declared as bits b;
- typedef vector <double> vec;
-
typedef vector<bool> bits;
-
//There was a function:
-
vec projection(vec& v,bits& b)
-
(
-
int v_size = v.size();
-
assert(b.size()>= v_size);
-
vec w;
-
for(int i=0;i<v_size;i++)
-
if(b[i])w.push_back(v[i]);
-
return w;
-
}
When v was printed all 8 vector elements appeared eg 22.2 33.3 44.4 etc
When w was printed only the double elements which aligned with the bool true elements were printed.
The purpose of the above function was said to be ..."to use the bit vector b as a mask to remove selected elements of the vector v. The resulting vector w is called the projection of v onto the subspace determined by b"
Ref:Fundamentals of Computing with C++ John R Hubbard Ph.D pp235