Skip to content

Commit

Permalink
Fix random binary number generation
Browse files Browse the repository at this point in the history
  • Loading branch information
pghysels committed May 29, 2024
1 parent d718503 commit 120a72a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/HSS/HSSMatrix.compress_stable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace strumpack {
auto m = this->rows();
DenseM_t Br, Cr, Sr, Rr, Bc, Cc, Sc, Rc;
DenseM_t pvrc(1, n+m);
pvrc.randombinary(); // Generate the pvrc matrix
pvrc.random_signed_one(); // Generate the pvrc matrix
int min_mn = std::min(m, n);
d = std::min(d, min_mn);
dd = std::min(opts.dd(), opts.max_rank()-d);
Expand Down
4 changes: 2 additions & 2 deletions src/dense/DenseMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ namespace strumpack {
}

template<typename scalar_t> void
DenseMatrix<scalar_t>::randombinary() {
DenseMatrix<scalar_t>::random_signed_one() {
TIMER_TIME(TaskType::RANDOM_GENERATE, 1, t_gen);
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> distrib(0, 1);
for (std::size_t j=0; j<cols(); j++)
for (std::size_t i=0; i<rows(); i++)
operator()(i,j) = distrib(gen);
operator()(i,j) = distrib(gen)*2-1;
}

template<typename scalar_t> void DenseMatrix<scalar_t>::random() {
Expand Down
5 changes: 2 additions & 3 deletions src/dense/DenseMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,9 @@ namespace strumpack {
value_type>& rgen);

/**
* Fill the matrix with random 0, 1 entries, using the specified
* random number generator.
* Fill the matrix with random -1, 1 entries.
*/
void randombinary();
void random_signed_one();

/**
* Fill matrix with a constant value
Expand Down

0 comments on commit 120a72a

Please sign in to comment.