]> git.ipfire.org Git - thirdparty/gcc.git/commit
skip Cholesky decomposition in is>>n_mv_dist
authorAlexandre Oliva <aoliva@gcc.gnu.org>
Fri, 9 Aug 2019 09:20:58 +0000 (09:20 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Fri, 9 Aug 2019 09:20:58 +0000 (09:20 +0000)
commitc787deb0124b667802d8519bc285894bb6d771d7
treedcf471c17642d638b25a9502daa1265fac53201b
parent279dc7a3624ff68e9bb4f44293877250a8097c14
skip Cholesky decomposition in is>>n_mv_dist

normal_mv_distribution maintains the variance-covariance matrix param
in Cholesky-decomposed form.  Existing param_type constructors, when
taking a full or lower-triangle varcov matrix, perform Cholesky
decomposition to convert it to the internal representation.  This
internal representation is visible both in the varcov() result, and in
the streamed-out representation of a normal_mv_distribution object.

The problem is that when that representation is streamed back in, the
read-back decomposed varcov matrix is used as a lower-triangle
non-decomposed varcov matrix, and it undergoes Cholesky decomposition
again.  So, each cycle of stream-out/stream-in changes the varcov
matrix to its "square root", instead of restoring the original
params.

This patch includes Corentin's changes that introduce verification in
testsuite/ext/random/normal_mv_distribution/operators/serialize.cc and
other similar tests that the object read back in compares equal to the
written-out object: the modified tests pass only if (u == v).

This patch also fixes the error exposed by his change, introducing an
alternate private constructor for param_type, used only by operator>>.

for  libstdc++-v3/ChangeLog

* include/ext/random
(normal_mv_distribution::param_type::param_type): New private
ctor taking a decomposed varcov matrix, for use by...
(operator>>): ... this, befriended.
* include/ext/random.tcc (operator>>): Use it.
(normal_mv_distribution::param_type::_M_init_lower): Adjust
member function name in exception message.

for  libstdc++-v3/ChangeLog
from  Corentin Gay  <gay@adacore.com>

* testsuite/ext/random/beta_distribution/operators/serialize.cc,
testsuite/ext/random/hypergeometric_distribution/operators/serialize.cc,
testsuite/ext/random/normal_mv_distribution/operators/serialize.cc,
testsuite/ext/random/triangular_distribution/operators/serialize.cc,
testsuite/ext/random/von_mises_distribution/operators/serialize.cc:
Add call to `VERIFY`.

From-SVN: r274233
libstdc++-v3/ChangeLog
libstdc++-v3/include/ext/random
libstdc++-v3/include/ext/random.tcc
libstdc++-v3/testsuite/ext/random/beta_distribution/operators/serialize.cc
libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/operators/serialize.cc
libstdc++-v3/testsuite/ext/random/normal_mv_distribution/operators/serialize.cc
libstdc++-v3/testsuite/ext/random/triangular_distribution/operators/serialize.cc
libstdc++-v3/testsuite/ext/random/von_mises_distribution/operators/serialize.cc