Simple patch for fix random bool vector generation (#10493)

* Dirty patch for fix bool generation

* Bernoulli distribution for bool
This commit is contained in:
Maksim Derbasov 2022-02-21 14:24:27 +03:00 committed by GitHub
parent 5dbf2f7088
commit 11bf540018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,6 +35,12 @@ generateVector(size_t vec_len,
res[i] = static_cast<dataType>(dist(gen)); res[i] = static_cast<dataType>(dist(gen));
} }
return res; return res;
} else if (std::is_same<bool, dataType>()) {
std::bernoulli_distribution dist;
for (size_t i = 0; i < vec_len; i++) {
res[i] = static_cast<dataType>(dist(gen));
}
return res;
} else { } else {
// chose values between this range to avoid type overrun (e.g. in case of I8 precision) // chose values between this range to avoid type overrun (e.g. in case of I8 precision)
std::uniform_int_distribution<long> dist(static_cast<long>(startFrom), static_cast<long>(upTo)); std::uniform_int_distribution<long> dist(static_cast<long>(startFrom), static_cast<long>(upTo));