群の積を中値演算子 .o. と定義。逆演算子は単項演算子にしてもいいが関数のままに。f2008の findloc 関数が使えると便利なんですが、無いので do..loop にて処理。
実行結果
: 1 2 3 4 5 6
- -
1: 1 2 3 4 5 6
2: 2 3 1 5 6 4
3: 3 1 2 6 4 5
4: 4 6 5 1 3 2
5: 5 4 6 2 1 3
6: 6 5 4 3 2 1inv 1 3 2 4 5 6
続行するには何かキーを押してください . . .
ソース・プログラム
module m_S3group implicit none integer, parameter :: si(3, 6) = [[1, 2, 3], [3, 1, 2], [2, 3, 1], [1, 3, 2], [3, 2, 1], [2, 1, 3]] interface operator(.o.) module procedure :: iprod end interface contains integer function iprod(k1, k2) integer, intent(in) :: k1, k2 do iprod = 1, size(si, 2) if ( all(si(:, iprod) == si( si(:, k2), k1 )) ) exit end do return end function iprod integer function inv(k1) integer, intent(in) :: k1 do inv = 1, size(si, 2) if ( all([1, 2, 3] == si( si(:, k1), inv)) ) exit end do return end function inv end module m_S3group program S3group use m_S3group implicit none integer :: i, j print '(a, 6i3)', ' :', (j, j = 1, 6) print '(a, 6a)', '--+', ('--', j = 1, 6) do i = 1, 6 print '(i2, a, 6i3)', i, ':', (i .o. j, j = 1, 6) end do ! print * print '(a, 6i3)', 'inv', (inv(i), i = 1, 6) stop end program S3group