Annotation of OpenXM_contrib/PHC/Ada/Root_Counts/Symmetry/permutations.adb, Revision 1.1
1.1 ! maekawa 1: package body Permutations is
! 2:
! 3: function Is_Permutation ( p : Permutation ) return boolean is
! 4: begin
! 5: for i in p'range loop
! 6: if ((p(i) = 0) or else (p(i) < -p'last) or else (p(i) > p'last))
! 7: then return false;
! 8: else for j in p'first..(i-1) loop
! 9: if ((p(i) = p(j)) or else (p(i) = -p(j)))
! 10: then return false;
! 11: end if;
! 12: end loop;
! 13: end if;
! 14: end loop;
! 15: return true;
! 16: end Is_Permutation;
! 17:
! 18: function Equal ( p1,p2 : Permutation ) return boolean is
! 19: begin
! 20: if (p1'first /= p2'first) or else (p1'last /= p2'last)
! 21: then return false;
! 22: else for i in p1'range loop
! 23: if p1(i) /= p2(i)
! 24: then return false;
! 25: end if;
! 26: end loop;
! 27: return true;
! 28: end if;
! 29: end Equal;
! 30:
! 31: function "*" ( p1,p2 : Permutation ) return Permutation is
! 32:
! 33: r : Permutation(p1'range);
! 34:
! 35: begin
! 36: for i in r'range loop
! 37: if p2(i) >= 0
! 38: then r(i) := p1(p2(i));
! 39: else r(i) := -p1(-p2(i));
! 40: end if;
! 41: end loop;
! 42: return r;
! 43: end "*";
! 44:
! 45: function inv ( p : Permutation ) return Permutation is
! 46:
! 47: r : Permutation(p'range);
! 48:
! 49: begin
! 50: for i in r'range loop
! 51: if p(i) >= 0
! 52: then r(p(i)) := i;
! 53: else r(-p(i)) := -i;
! 54: end if;
! 55: end loop;
! 56: return r;
! 57: end inv;
! 58:
! 59: end Permutations;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>