From 26667cc58eb12f2e4d70bf4cc944098310fda7bf Mon Sep 17 00:00:00 2001 From: Adeline CARNIS Date: Wed, 24 Aug 2016 11:06:44 +0200 Subject: [PATCH] * Bug #14461 fixed - grand(n, 'markov', P, x0) dit not return all outputs. Change-Id: I050611de066ae013828b70258c5f078216ea6634 --- scilab/CHANGES.md | 1 + .../modules/randlib/sci_gateway/cpp/sci_grand.cpp | 10 +++++-- .../randlib/tests/nonreg_tests/bug_14461.dia.ref | 25 +++++++++++++++++ .../randlib/tests/nonreg_tests/bug_14461.tst | 29 ++++++++++++++++++++ 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 scilab/modules/randlib/tests/nonreg_tests/bug_14461.dia.ref create mode 100644 scilab/modules/randlib/tests/nonreg_tests/bug_14461.tst diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index cd4c8cc..060f50c 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -341,6 +341,7 @@ Bug Fixes * [#14367](http://bugzilla.scilab.org/show_bug.cgi?id=14367): `edit_curv` failed opening due to a `[]+1` operation. * [#14395](http://bugzilla.scilab.org/show_bug.cgi?id=14395): `dir` displayed a []+".." warning when no subdirectory exists. * [#14448](http://bugzilla.scilab.org/show_bug.cgi?id=14448): removed havewindow() was still documented +* [#14461](http://bugzilla.scilab.org/show_bug.cgi?id=14461): Calling `grand(n, "markov", P, x0)` did not return all outputs. * [#14513](http://bugzilla.scilab.org/show_bug.cgi?id=14513): `isqual` comparing two built-in functions yielded an error. * [#14527](http://bugzilla.scilab.org/show_bug.cgi?id=14527): Calling pathconvert function without parameters crashed Scilab. * [#14557](http://bugzilla.scilab.org/show_bug.cgi?id=14557): `csim` failed when the system has no state. diff --git a/scilab/modules/randlib/sci_gateway/cpp/sci_grand.cpp b/scilab/modules/randlib/sci_gateway/cpp/sci_grand.cpp index aef63c8..bf3dfa7 100644 --- a/scilab/modules/randlib/sci_gateway/cpp/sci_grand.cpp +++ b/scilab/modules/randlib/sci_gateway/cpp/sci_grand.cpp @@ -433,12 +433,16 @@ types::Function::ReturnValue sci_grand(types::typed_list &in, int _iRetCount, ty } else { - types::Double* pDblIn = in[0]->getAs(); - if (meth == 14)//'mul' + if (meth == 14 || meth == 13)//'mul' or 'markov' { int* iDimsArraytempo = new int[2]; - iDimsArraytempo[0] = in[3]->getAs()->getSize() + 1; + iDimsArraytempo[0] = in[3]->getAs()->getSize(); + if (meth == 14) + { + iDimsArraytempo[0] = iDimsArraytempo[0] + 1; + } + iDimsArraytempo[1] = iNumIter; pDblOut = new types::Double(pDblIn->getDims(), iDimsArraytempo); } diff --git a/scilab/modules/randlib/tests/nonreg_tests/bug_14461.dia.ref b/scilab/modules/randlib/tests/nonreg_tests/bug_14461.dia.ref new file mode 100644 index 0000000..90f6aef --- /dev/null +++ b/scilab/modules/randlib/tests/nonreg_tests/bug_14461.dia.ref @@ -0,0 +1,25 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2016 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 14461 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=14461 +// +// <-- Short Description --> +// Calling grand(n, "markov", P, x0) did not return all outputs. +// ============================================================================= +n = 200; +P = [0.1 0.3 0.2 0.01 0.09 0.3 ; ... + 0.2 0.1 0.1 0.5 0.05 0.05; ... + 0 0 0.2 0.3 0.4 0.1 ; ... + 0.4 0 0.1 0.05 0.05 0.4 ; ... + 0.1 0.1 0.1 0.3 0.2 0.2 ; ... + 0.2 0.2 0.1 0.1 0.2 0.2]; +x0 = [1:3]; +a=grand(n, "markov", P, x0); +assert_checkequal(size(a), [3 200]); diff --git a/scilab/modules/randlib/tests/nonreg_tests/bug_14461.tst b/scilab/modules/randlib/tests/nonreg_tests/bug_14461.tst new file mode 100644 index 0000000..1dfce50 --- /dev/null +++ b/scilab/modules/randlib/tests/nonreg_tests/bug_14461.tst @@ -0,0 +1,29 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2016 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 14461 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=14461 +// +// <-- Short Description --> +// Calling grand(n, "markov", P, x0) did not return all outputs. +// ============================================================================= + +n = 200; +P = [0.1 0.3 0.2 0.01 0.09 0.3 ; ... +0.2 0.1 0.1 0.5 0.05 0.05; ... +0 0 0.2 0.3 0.4 0.1 ; ... +0.4 0 0.1 0.05 0.05 0.4 ; ... +0.1 0.1 0.1 0.3 0.2 0.2 ; ... +0.2 0.2 0.1 0.1 0.2 0.2]; +x0 = [1:3]; + +a=grand(n, "markov", P, x0); +assert_checkequal(size(a), [3 200]); -- 1.7.9.5