summaryrefslogtreecommitdiff
path: root/modules/randlib/macros
diff options
context:
space:
mode:
authorShashank2017-05-29 12:40:26 +0530
committerShashank2017-05-29 12:40:26 +0530
commit0345245e860375a32c9a437c4a9d9cae807134e9 (patch)
treead51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/randlib/macros
downloadscilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip
CMSCOPE changed
Diffstat (limited to 'modules/randlib/macros')
-rwxr-xr-xmodules/randlib/macros/%b_grand.binbin0 -> 556 bytes
-rwxr-xr-xmodules/randlib/macros/%b_grand.sci15
-rwxr-xr-xmodules/randlib/macros/%c_grand.binbin0 -> 552 bytes
-rwxr-xr-xmodules/randlib/macros/%c_grand.sci15
-rwxr-xr-xmodules/randlib/macros/%grand_perm.binbin0 -> 6340 bytes
-rwxr-xr-xmodules/randlib/macros/%grand_perm.sci58
-rwxr-xr-xmodules/randlib/macros/%hm_grand.binbin0 -> 572 bytes
-rwxr-xr-xmodules/randlib/macros/%hm_grand.sci15
-rwxr-xr-xmodules/randlib/macros/%i_grand.binbin0 -> 556 bytes
-rwxr-xr-xmodules/randlib/macros/%i_grand.sci15
-rwxr-xr-xmodules/randlib/macros/%p_grand.binbin0 -> 568 bytes
-rwxr-xr-xmodules/randlib/macros/%p_grand.sci15
-rwxr-xr-xmodules/randlib/macros/%s_grand.binbin0 -> 556 bytes
-rwxr-xr-xmodules/randlib/macros/%s_grand.sci15
-rwxr-xr-xmodules/randlib/macros/%sp_grand.binbin0 -> 552 bytes
-rwxr-xr-xmodules/randlib/macros/%sp_grand.sci15
-rwxr-xr-xmodules/randlib/macros/buildmacros.bat11
-rwxr-xr-xmodules/randlib/macros/buildmacros.sce14
-rwxr-xr-xmodules/randlib/macros/cleanmacros.bat13
-rwxr-xr-xmodules/randlib/macros/libbin0 -> 456 bytes
-rwxr-xr-xmodules/randlib/macros/names8
21 files changed, 209 insertions, 0 deletions
diff --git a/modules/randlib/macros/%b_grand.bin b/modules/randlib/macros/%b_grand.bin
new file mode 100755
index 000000000..cafd0d7d8
--- /dev/null
+++ b/modules/randlib/macros/%b_grand.bin
Binary files differ
diff --git a/modules/randlib/macros/%b_grand.sci b/modules/randlib/macros/%b_grand.sci
new file mode 100755
index 000000000..9bbece05a
--- /dev/null
+++ b/modules/randlib/macros/%b_grand.sci
@@ -0,0 +1,15 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function y = %b_grand(n, prm, vect)
+ // Overload to use grand on boolean input
+
+ y = %grand_perm(floor(n), vect);
+
+endfunction
diff --git a/modules/randlib/macros/%c_grand.bin b/modules/randlib/macros/%c_grand.bin
new file mode 100755
index 000000000..373b70406
--- /dev/null
+++ b/modules/randlib/macros/%c_grand.bin
Binary files differ
diff --git a/modules/randlib/macros/%c_grand.sci b/modules/randlib/macros/%c_grand.sci
new file mode 100755
index 000000000..0d287a28a
--- /dev/null
+++ b/modules/randlib/macros/%c_grand.sci
@@ -0,0 +1,15 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function y = %c_grand(n, prm, vect)
+ // Overload to use grand on string input
+
+ y = %grand_perm(floor(n), vect);
+
+endfunction
diff --git a/modules/randlib/macros/%grand_perm.bin b/modules/randlib/macros/%grand_perm.bin
new file mode 100755
index 000000000..5cea0ac87
--- /dev/null
+++ b/modules/randlib/macros/%grand_perm.bin
Binary files differ
diff --git a/modules/randlib/macros/%grand_perm.sci b/modules/randlib/macros/%grand_perm.sci
new file mode 100755
index 000000000..ca1b74c2e
--- /dev/null
+++ b/modules/randlib/macros/%grand_perm.sci
@@ -0,0 +1,58 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Samuel Gougeon <sgougeon@free.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function rep = %grand_perm(N, V)
+ // Returns N random permutations of V's components.
+ // V may be a scalar, a row or column vector, a matrix, or an hypermatrix.
+ // All data types are supported: Integers, reals, complexes, strings, polynomes..
+ // if V is a row, permutations are returned as N rows
+ // if V is a column, permutations are returned as N columns
+ // if V is a matrix or a true hypermatrix, permutations are returned
+ // through an additional dimension of size N.
+
+ // Author : Samuel Gougeon - 2010
+ // Version: 1.2
+ // Software: Scilab and related
+ //
+ // Tests:
+ // with a row of reals:
+ // m = grand(1, 6, "uin", 0, 10)
+ // grand_perm(3, m)
+ // // with a column of reals:
+ // grand_perm(4, m')
+ // // with a matrix of reals:
+ // M = grand(2, 5, "uin", 0, 10)
+ // grand_perm(3, M)
+ // // with strings:
+ // grand_perm(5, ["a" "b" "c" "d"])
+ // // with polynomes:
+ // p = (m'-%z)^2
+ // grand_perm(3, p)
+
+ s = size(V);
+ L = prod(s);
+
+ if L == 1 then
+ rep = V(ones(1, N));
+ else
+ //[tmp, k] = gsort(rand(L, N), "r", "i");
+ k = grand(N, "prm", (1:L).'); // Faster for large L
+ if length(s) < 3 then
+ if s(1) == 1 then
+ rep = matrix(V(k), [s(2) N]).';
+ elseif s(2) == 1 then
+ rep = matrix(V(k),[s(1) N]);
+ else
+ rep = matrix(V(k), [s N]);
+ end
+ else
+ rep = matrix(V(k), [s N]); end
+ end
+
+endfunction
diff --git a/modules/randlib/macros/%hm_grand.bin b/modules/randlib/macros/%hm_grand.bin
new file mode 100755
index 000000000..2b9de2e8c
--- /dev/null
+++ b/modules/randlib/macros/%hm_grand.bin
Binary files differ
diff --git a/modules/randlib/macros/%hm_grand.sci b/modules/randlib/macros/%hm_grand.sci
new file mode 100755
index 000000000..e31b80daa
--- /dev/null
+++ b/modules/randlib/macros/%hm_grand.sci
@@ -0,0 +1,15 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function y = %hm_grand(n, prm, vect)
+ // Overload to use grand on hypermatrix input
+
+ y = %grand_perm(floor(n), vect);
+
+endfunction
diff --git a/modules/randlib/macros/%i_grand.bin b/modules/randlib/macros/%i_grand.bin
new file mode 100755
index 000000000..0fb483305
--- /dev/null
+++ b/modules/randlib/macros/%i_grand.bin
Binary files differ
diff --git a/modules/randlib/macros/%i_grand.sci b/modules/randlib/macros/%i_grand.sci
new file mode 100755
index 000000000..4fd908fe1
--- /dev/null
+++ b/modules/randlib/macros/%i_grand.sci
@@ -0,0 +1,15 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function y = %i_grand(n, prm, vect)
+ // Overload to use grand on integer input
+
+ y = %grand_perm(floor(n), vect);
+
+endfunction
diff --git a/modules/randlib/macros/%p_grand.bin b/modules/randlib/macros/%p_grand.bin
new file mode 100755
index 000000000..30af97de9
--- /dev/null
+++ b/modules/randlib/macros/%p_grand.bin
Binary files differ
diff --git a/modules/randlib/macros/%p_grand.sci b/modules/randlib/macros/%p_grand.sci
new file mode 100755
index 000000000..1737e6229
--- /dev/null
+++ b/modules/randlib/macros/%p_grand.sci
@@ -0,0 +1,15 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function y = %p_grand(n, prm, vect)
+ // Overload to use grand on polynomial input
+
+ y = %grand_perm(floor(n), vect);
+
+endfunction
diff --git a/modules/randlib/macros/%s_grand.bin b/modules/randlib/macros/%s_grand.bin
new file mode 100755
index 000000000..e06fc2541
--- /dev/null
+++ b/modules/randlib/macros/%s_grand.bin
Binary files differ
diff --git a/modules/randlib/macros/%s_grand.sci b/modules/randlib/macros/%s_grand.sci
new file mode 100755
index 000000000..769cd686e
--- /dev/null
+++ b/modules/randlib/macros/%s_grand.sci
@@ -0,0 +1,15 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function y = %s_grand(n, prm, vect)
+ // Overload to use grand on complex input
+
+ y = %grand_perm(floor(n), vect);
+
+endfunction
diff --git a/modules/randlib/macros/%sp_grand.bin b/modules/randlib/macros/%sp_grand.bin
new file mode 100755
index 000000000..3308c8c4b
--- /dev/null
+++ b/modules/randlib/macros/%sp_grand.bin
Binary files differ
diff --git a/modules/randlib/macros/%sp_grand.sci b/modules/randlib/macros/%sp_grand.sci
new file mode 100755
index 000000000..8b6c052b0
--- /dev/null
+++ b/modules/randlib/macros/%sp_grand.sci
@@ -0,0 +1,15 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function y = %sp_grand(n, prm, vect)
+ // Overload to use grand on sparse input
+
+ y = %grand_perm(floor(n), vect);
+
+endfunction
diff --git a/modules/randlib/macros/buildmacros.bat b/modules/randlib/macros/buildmacros.bat
new file mode 100755
index 000000000..a73ca67f8
--- /dev/null
+++ b/modules/randlib/macros/buildmacros.bat
@@ -0,0 +1,11 @@
+
+rem Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+rem Copyright (C) 2008 - INRIA
+rem
+rem This file must be used under the terms of the CeCILL.
+rem This source file is licensed as described in the file COPYING, which
+rem you should have received as part of this distribution. The terms
+rem are also available at
+rem http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+@..\..\..\bin\scilex -nwni -ns -e exec('buildmacros.sce');quit;
diff --git a/modules/randlib/macros/buildmacros.sce b/modules/randlib/macros/buildmacros.sce
new file mode 100755
index 000000000..8f3539045
--- /dev/null
+++ b/modules/randlib/macros/buildmacros.sce
@@ -0,0 +1,14 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+if (isdef("genlib") == %f) then
+ exec(SCI+"/modules/functions/scripts/buildmacros/loadgenlib.sce");
+end
+
+genlib("randliblib","SCI/modules/randlib/macros",%f,%t);
diff --git a/modules/randlib/macros/cleanmacros.bat b/modules/randlib/macros/cleanmacros.bat
new file mode 100755
index 000000000..4ad1bbae2
--- /dev/null
+++ b/modules/randlib/macros/cleanmacros.bat
@@ -0,0 +1,13 @@
+
+rem Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+rem Copyright (C) 2008 - INRIA
+rem
+rem This file must be used under the terms of the CeCILL.
+rem This source file is licensed as described in the file COPYING, which
+rem you should have received as part of this distribution. The terms
+rem are also available at
+rem http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+@del *.bin 2>NUL
+@del lib 2>NUL
+@del names 2>NUL
diff --git a/modules/randlib/macros/lib b/modules/randlib/macros/lib
new file mode 100755
index 000000000..ebcc83847
--- /dev/null
+++ b/modules/randlib/macros/lib
Binary files differ
diff --git a/modules/randlib/macros/names b/modules/randlib/macros/names
new file mode 100755
index 000000000..82d2f02b5
--- /dev/null
+++ b/modules/randlib/macros/names
@@ -0,0 +1,8 @@
+%b_grand
+%c_grand
+%grand_perm
+%hm_grand
+%i_grand
+%p_grand
+%s_grand
+%sp_grand