41 integer,
public :: npermutations
43 integer,
allocatable,
public :: allpermutations(:,:)
44 integer,
allocatable,
public :: permsign(:)
50 integer,
intent(in) :: nn
51 type(permutations_t),
intent(inout) :: this
53 integer :: i1, order, oldperm, iperm, newpos
59 safe_allocate(this%allpermutations(1:max(1,nn),1:this%npermutations))
60 safe_allocate(this%permsign(1:this%npermutations))
62 this%allpermutations(:, :) = -999
64 this%allpermutations(i1, 1) = i1
71 do newpos = order-1, 1, -1
73 this%allpermutations(1:newpos-1, iperm) = this%allpermutations(1:newpos-1, oldperm)
74 this%allpermutations(newpos, iperm) = order
75 this%allpermutations(newpos+1:order, iperm) = this%allpermutations(newpos:order-1, oldperm)
76 this%allpermutations(order+1:nn, iperm) = this%allpermutations(order+1:nn, oldperm)
78 this%permsign(iperm) = this%permsign(oldperm) * (-1)**(order-newpos)
87 type(permutations_t),
intent(inout) :: this
93 do iperm = 1, this%npermutations
94 write (
message(1),
'(a,I7,a,I7,a,10I7)')
'permutation ', iperm, &
95 ' sign ', this%permsign(iperm),
'= ', this%allpermutations(:,iperm)
103 type(permutations_t),
intent(inout) :: perm_in, perm_out
107 perm_out%nn = perm_in%nn
108 perm_out%npermutations = perm_in%npermutations
109 perm_out%npairs = perm_in%npairs
111 safe_allocate_source_a(perm_out%allpermutations,perm_in%allpermutations)
112 safe_allocate_source_a(perm_out%permsign,perm_in%permsign)
118 type(permutations_t),
intent(inout) :: this
122 safe_deallocate_a(this%allpermutations)
123 safe_deallocate_a(this%permsign)
This module is intended to contain "only mathematical" functions and procedures.
recursive integer function, public factorial(n)
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public permutations_copy(perm_in, perm_out)
subroutine, public permutations_init(nn, this)
subroutine, public permutations_end(this)
subroutine, public permutations_write(this)