Commit 1d7dc77d authored by MIJIEUX Thomas's avatar MIJIEUX Thomas

Replace uniform with normal distribution in RandomMatrixLoader

parent c8ccb16d
......@@ -52,7 +52,7 @@ cmake .. # -DCHAMELEON_DIR=$(spack location -i chameleon)
make
#+end_src
* Run Examples
** Impact of restart parameter
** Influence of restart(m) parameter
*** run test case
#+begin_src sh :session *TEST* :results silent
cd ${WORKDIR}/build/src/test_core/
......@@ -77,7 +77,7 @@ ggplot(df, aes(x=nb_mvp, y=maxRes, color=name)) +
geom_hline(aes(yintercept=1e-4, color="threshold")) +
scale_y_log10() + ggtitle("Memory usage influence (young1c IB IMGS-RUHE)")
#+end_src
** Impact of incremental QR factorization
** Influence of incremental QR factorization
*** run test case
#+begin_src sh :session *TEST* :results silent
cd ${WORKDIR}/build/src/test_core/
......@@ -143,7 +143,7 @@ ggplot(df, aes(x=nb_mvp)) +
scale_y_log10() + geom_hline(aes(yintercept=1e-6, color="threshold")) +
ggtitle("young1c (nrhs=6, m=90 k=5)") + ylab(TeX("$\\eta_b$ (min, max)"))
#+end_src
** Influence of restart parameter (nrhs=6, m=90)
** Influence of deflated restart (k) parameter (nrhs=6, m=90)
*** run test case
#+begin_src sh :session *TEST* :results silent
cd ${WORKDIR}/build/src/test_core/
......
......@@ -6,47 +6,46 @@
namespace fabulous {
template<class U,
class E = typename std::enable_if< // only real types
std::is_same<U, float>::value ||
std::is_same<U, double>::value
>::type,
class T
>
U rnd(std::uniform_real_distribution<T> &dis, std::mt19937 &gen)
{
return U{dis(gen)};
}
template<class U,
class E = typename std::enable_if< // only complex types
std::is_same<U, std::complex<typename U::value_type>>::value>::type,
class T,
class = void
>
static inline
U rnd(std::uniform_real_distribution<T> &dis, std::mt19937 &gen)
{
return U{dis(gen), dis(gen)};
}
class RandomMatrixLoader
{
private:
std::mt19937 _gen;
std::mt19937_64 _gen; // Mersenne twister 19937
private:
template<class S,
class E = typename std::enable_if< // only real types
std::is_same<S, float>::value ||
std::is_same<S, double>::value
>::type,
class DISTRIB >
S rnd(DISTRIB &dis)
{
return S{dis(_gen)};
}
template<class S,
class E = typename std::enable_if< // only complex types
std::is_same<S, std::complex<typename S::value_type>>::value>::type,
class DISTRIB,
class = void >
S rnd(DISTRIB &dis)
{
return S{dis(_gen), dis(_gen)};
}
public:
RandomMatrixLoader(): _gen(0) {}
template<class MatrixStorage>
void LoadMatrix(MatrixStorage &A, double maxValue=2.0)
template<class Matrix>
void LoadMatrix(Matrix &A)
{
using P = typename MatrixStorage::primary_type;
using V = typename MatrixStorage::value_type;
std::uniform_real_distribution<P> dis(0, P(maxValue));
using S = typename Matrix::value_type;
using P = typename Matrix::primary_type;
std::normal_distribution<P> dis{};
for (int j = 0; j < A.get_nb_col(); ++j)
for (int i = 0; i < A.get_nb_row(); ++i)
A.at(i,j) = V{rnd<V>(dis, _gen)};
A.at(i, j) = S{rnd<S>(dis)};
}
}; // end class RandomMatrixLoader
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment