File: symmul

package info (click to toggle)
cod-tools 3.11.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 159,136 kB
  • sloc: perl: 58,707; sh: 41,323; ansic: 7,268; xml: 1,982; yacc: 1,117; makefile: 731; python: 166
file content (87 lines) | stat: -rwxr-xr-x 2,246 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#! /bin/sh
#!perl -w # --*- Perl -*--
eval 'exec perl -x $0 ${1+"$@"}'
    if 0;
#------------------------------------------------------------------------------
#$Author: antanas $
#$Date: 2022-07-31 09:41:50 +0300 (Sun, 31 Jul 2022) $
#$Revision: 9352 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.11.0/scripts/symmul $
#------------------------------------------------------------------------------
#*
#* Multiply all symmetry operators provided on the command line.
#*
#* USAGE:
#*    $0 --options -- -y,-x,z -x,y,z
#*    $0 --options -- -y,-x,z -x,y,z z,y,x
#**

use strict;
use warnings;

use COD::Spacegroups::Symop::Parse qw(
    symop_from_string
    string_from_symop
);
use COD::Spacegroups::Symop::Algebra qw(
    symop_mul
    symop_modulo_1
    snap_to_crystallographic
);
use COD::SOptions qw( getOptions );
use COD::SUsage qw( usage );
use COD::ToolsVersion qw( get_version_string );

my $print_matrix = 0; # Print output as matrix or as a string.

#* OPTIONS:
#*   -m, --matrix
#*                     Print output in matrix form.
#*   -s, --string
#*                     Print output in string form as general position
#*                     coordinates (default).
#*
#*   --help, --usage
#*                     Output a short usage message (this message) and exit.
#*
#*   --version
#*                     Output version information and exit.
#**
@ARGV = getOptions(
    "-m,--matrix" => sub { $print_matrix = 1 },
    "-s,--string" => sub { $print_matrix = 0 },

    '--help,--usage' => sub { usage; exit },
    '--version'      => sub { print get_version_string(), "\n"; exit }
);

my $result =
    [
     [ 1, 0, 0, 0 ],
     [ 0, 1, 0, 0 ],
     [ 0, 0, 1, 0 ],
     [ 0, 0, 0, 1 ],
    ];

for my $symop_string (@ARGV) {
    my $symop = symop_from_string( $symop_string );
    $result =
        snap_to_crystallographic(
            symop_modulo_1(
                symop_mul( $result, $symop )
            )
        );
}

if( $print_matrix ) {
    for my $row (@$result) {
        my $separator = "";
        for (@$row) {
            print $separator, $_;
            $separator = "\t";
        }
        print "\n";
    }
} else {
    print string_from_symop( $result ), "\n";
}