[Aimmath-commit] AIM/WEB-INF/maple Random.mpl,1.10,1.11
Brought to you by:
gustav_delius,
npstrick
|
From: <mo...@us...> - 2003-10-13 21:16:43
|
Update of /cvsroot/aimmath/AIM/WEB-INF/maple
In directory sc8-pr-cvs1:/tmp/cvs-serv7760
Modified Files:
Random.mpl
Log Message:
added SeqVec and ListVec options
Index: Random.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/Random.mpl,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Random.mpl 20 Sep 2003 21:46:08 -0000 1.10
--- Random.mpl 13 Oct 2003 21:16:37 -0000 1.11
***************
*** 78,82 ****
or product of n terms computed from @Rand(A)@ is returned. For @SUM@, @Prod@, @Set@, @SET@, @List@, and @Seq@ the @n@ elements will be distinct. For @DupSeq@ and @DupList@ there can be repetitions among the @n@ elements.
<LI>if the argument is of the form @Set(A,B,f)@, @AIMSET(A,B,f)@, @List(A,B,f)@, @Seq(A,B,f)@, @SUM(A,B,f)@, or @Prod(A,B,f)@ then a natural number @n=Rand(B)@ is computed and a set, list, sequence, sum, or product of @n@ terms computed from @Rand(A)@ is returned containing distinct terms, where @f@ is a boolean function of two variables used to compare two terms to see if they are considered to be equal (thus allowing one to supply the definition of \"distinct\").
! <LI>if the argument is of the form @Vec(x[1],...,x[k])@ then the Maple vector @vector([Rand(x[1]),...,Rand(x[k])])@ is returned.
<LI>if the argument is of the form @Permute([x[1],...,x[k]])@ then a random permutation of the list @[Rand(x[1]),...,Rand(x[k])]@ is returned. Similarly if the argument is of the form @Permute(x[1],...,x[k])@ then a random permutation of the sequence @Rand(x[1]),...,Rand(x[k])@ is returned.
<LI>if the argument is of the form @Partition(x)@ where @Rand(x)@ returns a positive integer @n@, then a list of positive integers whose sum is @n@ is returned (with elements in random order). If the argument is of the form @Partition(x,k)@ then a partition of @n@ is returned having exactly @Rand(k)@ terms. Similarly if the argument is of the form @Partition(n,k,M)@ then a partition of @n@ is returned having exactly @Rand(k)@ terms and no term greater than @Rand(M)@. Finally if the argument is of the form @Partition(n,k,M,m)@ then a partition of @n@ is returned having exactly @Rand(k)@ terms and no term greater than @Rand(M)@ and no term less than @Rand(m)@.
--- 78,82 ----
or product of n terms computed from @Rand(A)@ is returned. For @SUM@, @Prod@, @Set@, @SET@, @List@, and @Seq@ the @n@ elements will be distinct. For @DupSeq@ and @DupList@ there can be repetitions among the @n@ elements.
<LI>if the argument is of the form @Set(A,B,f)@, @AIMSET(A,B,f)@, @List(A,B,f)@, @Seq(A,B,f)@, @SUM(A,B,f)@, or @Prod(A,B,f)@ then a natural number @n=Rand(B)@ is computed and a set, list, sequence, sum, or product of @n@ terms computed from @Rand(A)@ is returned containing distinct terms, where @f@ is a boolean function of two variables used to compare two terms to see if they are considered to be equal (thus allowing one to supply the definition of \"distinct\").
! <LI>if the argument is of the form @Vec(x[1],...,x[k])@ then the Maple vector @vector([Rand(x[1]),...,Rand(x[k])])@ is returned. Similiarly @ListVec(x[1],...,x[k])@ returns @[Rand(x[1]),...,Rand(x[k])]@ and @SeqVec(x[1],...,x[k])@ returns @Rand(x[1]),...,Rand(x[k])@
<LI>if the argument is of the form @Permute([x[1],...,x[k]])@ then a random permutation of the list @[Rand(x[1]),...,Rand(x[k])]@ is returned. Similarly if the argument is of the form @Permute(x[1],...,x[k])@ then a random permutation of the sequence @Rand(x[1]),...,Rand(x[k])@ is returned.
<LI>if the argument is of the form @Partition(x)@ where @Rand(x)@ returns a positive integer @n@, then a list of positive integers whose sum is @n@ is returned (with elements in random order). If the argument is of the form @Partition(x,k)@ then a partition of @n@ is returned having exactly @Rand(k)@ terms. Similarly if the argument is of the form @Partition(n,k,M)@ then a partition of @n@ is returned having exactly @Rand(k)@ terms and no term greater than @Rand(M)@. Finally if the argument is of the form @Partition(n,k,M,m)@ then a partition of @n@ is returned having exactly @Rand(k)@ terms and no term greater than @Rand(M)@ and no term less than @Rand(m)@.
***************
*** 261,264 ****
--- 261,270 ----
elif type(r,specfunc(anything,Vec)) then
ans:=vector([seq(Rand(op(i,r)),i=1..nops(r))]);
+ # SeqVec(...)
+ elif type(r,specfunc(anything,SeqVec)) then
+ ans:=seq(Rand(op(i,r)),i=1..nops(r));
+ # ListVec(...)
+ elif type(r,specfunc(anything,ListVec)) then
+ ans:=[seq(Rand(op(i,r)),i=1..nops(r))];
# Permute(...)
elif type(r,specfunc(anything,Permute)) then
|