dot-apply_mask function

Apply mask to extract the elements of the matrix that are both true