[Aimmath-commit] AIM/WEB-INF/maple Random.mpl,1.11,1.12
Brought to you by:
gustav_delius,
npstrick
|
From: <mo...@us...> - 2003-10-15 15:37:26
|
Update of /cvsroot/aimmath/AIM/WEB-INF/maple
In directory sc8-pr-cvs1:/tmp/cvs-serv16129
Modified Files:
Random.mpl
Log Message:
changed Rand(Frac()) so it accepts a denominator = 1
Index: Random.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/Random.mpl,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Random.mpl 13 Oct 2003 21:16:37 -0000 1.11
--- Random.mpl 15 Oct 2003 15:37:22 -0000 1.12
***************
*** 80,84 ****
<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)@.
<LI>if the argument is of the form @Frac(n,d)@ then an improper fraction whose integer part is @Rand(n)@ and whose denominator is @Rand(d)@ is returned, i.e. if @N:=Rand(n)@, @M:=Rand(d)@, and @a:=Rand(1..M-1)@ then @(N*M+a)/M@ is returned.
<LI>if the argument is @Null@, then @NULL@ is returned (i.e. @Rand(Null)@ returns @NULL@).
--- 80,86 ----
<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)@ An argument
! of the form @SeqPartition()@ works exactly the same as @Partition()@ except
! that it returns a sequence instead of a list.
<LI>if the argument is of the form @Frac(n,d)@ then an improper fraction whose integer part is @Rand(n)@ and whose denominator is @Rand(d)@ is returned, i.e. if @N:=Rand(n)@, @M:=Rand(d)@, and @a:=Rand(1..M-1)@ then @(N*M+a)/M@ is returned.
<LI>if the argument is @Null@, then @NULL@ is returned (i.e. @Rand(Null)@ returns @NULL@).
***************
*** 310,313 ****
--- 312,318 ----
ans:=[seq(mn-1,i=1..s)]+Rand(Partition(n-s*(mn-1),s,mx-mn+1));
fi;
+ # SeqPartition(...)
+ elif type(r,specfunc(anything,'SeqPartition')) then
+ ans:=op(Rand(Partition(op(r))))
# Frac(integerpart,den)
elif type(r,specfunc(anything,'Frac')) then
***************
*** 315,321 ****
error "Syntax: Frac(integerpart,den)";
fi;
! n:=Rand(op(1,r)); m:=Rand(op(2,r)); a:=Rand(1..m-1);
! ans:=(a+n*m)/m;
!
# Random Expressions from a family of operators
elif type(r,specfunc(anything,Expression)) then
--- 320,330 ----
error "Syntax: Frac(integerpart,den)";
fi;
! n:=Rand(op(1,r)); m:=Rand(op(2,r));
! if m=1 then
! ans:=n
! else
! a:=Rand(1..m-1);
! ans:=(a+n*m)/m;
! fi:
# Random Expressions from a family of operators
elif type(r,specfunc(anything,Expression)) then
|