File: vonNeumann.pl

package info (click to toggle)
dmrgpp 6.06-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 113,900 kB
  • sloc: cpp: 80,986; perl: 14,772; ansic: 2,923; makefile: 83; sh: 17
file content (53 lines) | stat: -rwxr-xr-x 926 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
#!/usr/bin/perl

use strict;
use utf8;
use warnings;

my ($file, $symmetrize) = @ARGV;
defined($file) or die "USAGE: $0 filename [symmetrize 0 or 1]\n";

my @entropy = load($file);

printEntropy(\@entropy);

sub printEntropy
{
	my ($entropy) = @_;
	my $n = scalar(@$entropy);
	print STDERR "$0: $n values in array\n";
	my $nOver2 = int($n/2);
	for (my $i = 0; $i < $n; ++$i) {
		my $value = $entropy->[$i];
		defined($value) or next;
		$value = $entropy->[$n - $i] if ($i >= $nOver2 and $symmetrize);
		print "$i $value\n";
	}
}

sub load
{
	my ($file) = @_;
	open(FILE, "<", $file) or die "$0: Cannot open $file : $!\n";
	my $split;
	my $flag = 0;
	my @entropy;
	while (<FILE>) {
		if (/sites=([^\+]+)\+/) {
			$split = $1;
			$flag = 1;
		}
		
		if (/EntropyVonNeumann= ([^;]+);/) {
			my $entropy = $1;
			#last if ($flag != 1);
			$flag = 0;
			$entropy[$split] = $entropy;
		}	
	}
	
	close(FILE);
	
	return @entropy;
}