12#ifndef TLAPACK_MATRIXMARKET_HH
13#define TLAPACK_MATRIXMARKET_HH
29 const uint64_t a = 6364136223846793005ULL;
30 const uint64_t c = 1442695040888963407ULL;
48 static constexpr uint32_t max() noexcept {
return UINT32_MAX; }
71 state = state * a + c;
85 enable_if_t<is_real<T>,
bool> =
true>
97 enable_if_t<is_complex<T>,
bool> =
true>
98T rand_helper(Generator& gen, Distribution& d)
100 using real_t = real_type<T>;
103 return complex_type<real_t>(r1, r2);
116template <
class T,
class Generator>
124 std::uniform_real_distribution<real_t>,
125 std::uniform_real_distribution<float>>::type;
146 template <TLAPACK_MATRIX matrix_t>
151 const idx_t m = nrows(
A);
152 const idx_t n = ncols(
A);
154 for (idx_t j = 0; j < n; ++j)
155 for (idx_t i = 0; i < m; ++i)
164 template <TLAPACK_MATRIX matrix_t>
170 const idx_t m = nrows(
A);
171 const idx_t n = ncols(
A);
173 for (idx_t j = 0; j < n; ++j)
174 for (idx_t i = 0; i < m; ++i)
186 template <TLAPACK_UPLO uplo_t, TLAPACK_MATRIX matrix_t>
192 const idx_t m = nrows(
A);
193 const idx_t n = ncols(
A);
195 if (
uplo == Uplo::Upper) {
196 for (idx_t j = 0; j < n; ++j)
197 for (idx_t i = 0; i < m; ++i)
201 A(i, j) = T(
float(0xCAFEBABE));
204 for (idx_t j = 0; j < n; ++j)
205 for (idx_t i = 0; i < m; ++i)
209 A(i, j) = T(
float(0xCAFEBABE));
224 std::normal_distribution<double>>::type>
230 const idx_t m = nrows(
A);
231 const idx_t n = ncols(
A);
234 for (idx_t j = 0; j < n; ++j)
235 for (idx_t i = 0; i < m; ++i)
254 std::normal_distribution<double>>::type>
260 const idx_t m = nrows(
A);
261 const idx_t n = ncols(
A);
264 if (
uplo == Uplo::Upper) {
265 for (idx_t j = 0; j < n; ++j)
266 for (idx_t i = 0; i < m; ++i)
270 A(i, j) = T(
float(0xCAFEBABE));
273 for (idx_t j = 0; j < n; ++j)
274 for (idx_t i = 0; i < m; ++i)
278 A(i, j) = T(
float(0xCAFEBABE));
289 template <TLAPACK_MATRIX matrix_t>
295 const idx_t m = nrows(
A);
296 const idx_t n = ncols(
A);
298 for (idx_t j = 0; j < n; ++j)
299 for (idx_t i = 0; i < m; ++i)
303 A(i, j) = T(
float(0xFA57C0DE));
317 template <TLAPACK_MATRIX matrix_t>
323 const idx_t m = nrows(
A);
324 const idx_t n = ncols(
A);
326 for (idx_t j = 0; j < n; ++j)
327 for (idx_t i = 0; i < m; ++i)
328 A(i, j) = T(1) / T(i + j + 1);
337 template <TLAPACK_MATRIX matrix_t>
342 const idx_t m = nrows(
A);
343 const idx_t n = ncols(
A);
345 for (idx_t j = 0; j < n; ++j)
346 for (idx_t i = 0; i < m; ++i)
360 template <TLAPACK_UPLO uplo_t, TLAPACK_MATRIX matrix_t>
368 const idx_t m = nrows(
A);
369 const idx_t n = ncols(
A);
371 if (
uplo == Uplo::Upper) {
372 for (idx_t j = 0; j < n; ++j)
373 for (idx_t i = 0; i < m; ++i)
377 A(i, j) = T(
float(0xCAFEBABE));
380 for (idx_t j = 0; j < n; ++j)
381 for (idx_t i = 0; i < m; ++i)
385 A(i, j) = T(
float(0xCAFEBABE));
T rand_helper(Generator &gen, Distribution &d)
Helper function to generate random numbers.
Definition MatrixMarket.hpp:86
Permuted Congruential Generator.
Definition MatrixMarket.hpp:27
void seed(uint64_t s) noexcept
Sets the current state of PCG32. Same as PCG32(s).
Definition MatrixMarket.hpp:39
uint32_t operator()() noexcept
Generates a pseudo-random number using PCG's output function (XSH-RR).
Definition MatrixMarket.hpp:51
PCG32(uint64_t s=1302) noexcept
Constructor.
Definition MatrixMarket.hpp:36
#define TLAPACK_UPLO
Macro for tlapack::concepts::Uplo compatible with C++17.
Definition concepts.hpp:942
#define TLAPACK_MATRIX
Macro for tlapack::concepts::Matrix compatible with C++17.
Definition concepts.hpp:896
void rot(vectorX_t &x, vectorY_t &y, const c_type &c, const s_type &s)
Apply plane rotation:
Definition rot.hpp:44
typename traits::real_type_traits< Types..., int >::type real_type
The common real type of the list of types.
Definition scalar_type_traits.hpp:113
MatrixMarket class.
Definition MatrixMarket.hpp:137
void single_value(matrix_t &A, const type_t< matrix_t > &val) const
Generate a matrix with a single value in all entries.
Definition MatrixMarket.hpp:338
void colmajor_read(matrix_t &A, std::istream &is) const
Read a dense matrix from an input stream (file, stdin, etc).
Definition MatrixMarket.hpp:147
void random(uplo_t uplo, matrix_t &A)
Generate an upper- or lower-triangular random matrix.
Definition MatrixMarket.hpp:187
void random(matrix_t &A)
Generate a random dense matrix.
Definition MatrixMarket.hpp:165
void randn(uplo_t uplo, matrix_t &A)
Generate an upper- or lower-triangular random matrix.
Definition MatrixMarket.hpp:255
void hessenberg(matrix_t &A)
Generate a random upper Hessenberg matrix.
Definition MatrixMarket.hpp:290
void hilbert(matrix_t &A) const
Generate a Hilbert matrix.
Definition MatrixMarket.hpp:318
void randn(matrix_t &A)
Generate a random dense matrix based on a normal distribution.
Definition MatrixMarket.hpp:225
void single_value(uplo_t uplo, matrix_t &A, const type_t< matrix_t > &val) const
Generate an upper- or lower-triangular matrix with a single value in all entries.
Definition MatrixMarket.hpp:361