39 integer,
public :: npermutations
41 integer,
allocatable,
public :: allpermutations(:,:)
42 integer,
allocatable,
public :: permsign(:)
48 integer,
intent(in) :: nn
49 type(permutations_t),
intent(inout) :: this
51 integer :: i1, order, oldperm, iperm, newpos
57 safe_allocate(this%allpermutations(1:max(1,nn),1:this%npermutations))
58 safe_allocate(this%permsign(1:this%npermutations))
60 this%allpermutations(:, :) = -999
62 this%allpermutations(i1, 1) = i1
69 do newpos = order-1, 1, -1
71 this%allpermutations(1:newpos-1, iperm) = this%allpermutations(1:newpos-1, oldperm)
72 this%allpermutations(newpos, iperm) = order
73 this%allpermutations(newpos+1:order, iperm) = this%allpermutations(newpos:order-1, oldperm)
74 this%allpermutations(order+1:nn, iperm) = this%allpermutations(order+1:nn, oldperm)
76 this%permsign(iperm) = this%permsign(oldperm) * (-1)**(order-newpos)
85 type(permutations_t),
intent(inout) :: this
89 safe_deallocate_a(this%allpermutations)
90 safe_deallocate_a(this%permsign)
This module is intended to contain "only mathematical" functions and procedures.
recursive integer function, public factorial(n)
subroutine, public permutations_init(nn, this)
subroutine, public permutations_end(this)