Statistiques
| Branche: | Révision :

meplib / binaries / bin / printESPointsList.pl @ master

Historique | Voir | Annoter | Télécharger (5,19 ko)

1
#! /usr/bin/perl
2

    
3
# printESPointsList.pl - ST - 2005-07-18
4

    
5
# COMMAND LINE SYNTAX:
6
# printESPointsList.pl lower_bound upper_bound number_of_points
7

    
8
# NOTE(S):
9
# This script is by product from printGeneratorVector.pl as
10
# uses the same function to compute a list of points. 
11
#
12
##############################################################################
13
# PROGRAM DECLARATIONS
14
##############################################################################
15

    
16
BEGIN
17
{
18
  # Modify @INC here if necessary
19
  push(@INC,"../utils");
20
  push(@INC,"../utils/vandermonde");
21
	
22
};
23

    
24
# core modules
25
use strict; # must be first to force strict in all others
26
use Carp;
27
use Getopt::Long;
28
use Math::BigFloat;
29
use Math::BigRat;
30

    
31
# custom modules
32
# Uncomment if you want to use standard exit error codes.
33
# the stdExitErrors.pm file must be available around.
34
use stdExitErrors;
35
use Vandermonde qw(:BASIC);
36
#use Matrix qw(:BASIC);
37

    
38
##############################################################################
39
# PROGRAM CONSTANT DECLARATIONS
40
##############################################################################
41
my @test = (1,2,10);
42

    
43
##############################################################################
44
# PROGRAM VARIABLE DECLARATIONS
45
##############################################################################
46
my $stringVectorRef   = [];
47
my $generatorVectorRef;
48

    
49
##############################################################################
50
# TEST ENVIRONMENT AND CONFIGURATION VARIABLES
51
##############################################################################
52

    
53
##############################################################################
54
# INITIALIZE DEBUG FILE
55
##############################################################################
56

    
57
##############################################################################
58
# INITIALIZE LOG FILE
59
##############################################################################
60

    
61
##############################################################################
62
# GET COMMAND LINE ARGUMENTS
63
##############################################################################
64

    
65
##############################################################################
66
# PROGRAM MAIN
67
##############################################################################
68
&usage();
69
$generatorVectorRef = &pointsListFromBoundsAndNumPointsRat($stringVectorRef);
70
for (my $i = 0 ; defined($$generatorVectorRef[$i]) ; $i++)
71
{
72
  print STDOUT "$$generatorVectorRef[$i] ";
73
}
74
print STDOUT "\n";
75
# Uncomment this line and remove the next one if using stdExitErrors.
76
exit($EX_OK);
77

    
78
##############################################################################
79
# PROGRAM SUBS
80
##############################################################################
81
##############################################################################
82
# sub mySub
83
##############################################################################
84
# Performed task:
85
#
86
# input   :
87
# output  :
88
# globals :
89
#
90
sub mySub {
91
  my ($someParameter) = @_;
92
  if (! defined($someParameter))
93
  {
94
    my @call_info = caller(0);
95
    print "\n\n", $call_info[3], " missing parameter. Aborting program!\n\n";
96
    # Uncomment this line and remove the next one if using stdExitErrors.
97
    #exit($EX_SOFTWARE);
98
    exit(1);
99
  }
100
} # End mySub
101
##############################################################################
102
# sub $retv = _privateSubName($argv)
103
##############################################################################
104

    
105
sub _privateSubName
106
{
107
	my $argv = shift();
108
	my $retv = undef;
109
	return($retv);
110
};
111
#
112
##############################################################################
113
# sub usage
114
##############################################################################
115
# Performed task: checks the command line parameters
116
#
117
# input   : none
118
# output  : none
119
# globals : $ARGV,others...
120
#
121
sub usage {
122
  if (! defined($ARGV[2]))
123
  {
124
    my $scriptName = `basename $0`;
125
    chomp $scriptName;
126
    print STDERR "\n\nUsage : $scriptName lowerBound upperBound num_points\n\n";
127
    print STDERR "  - lowerBound: the lower bound for the Vandermonde matrix;\n";
128
    print STDERR "  - upperBound: the upper bound for the Vandermonde matrix;\n";
129
    print STDERR "  - num_points: the number of points.\n\n";
130
    # Uncomment this line and remove the next one if using stdExitErrors.
131
    exit($EX_USAGE);
132
  } # End if
133
# Some initializations
134
$ARGV[0] =~ s/"//g;
135
if (Math::BigRat->new($ARGV[0])->is_nan())
136
{
137
  print STDERR "\n\n";
138
  print STDERR "Lower bound \"$ARGV[0]\" can not be converted into a ";
139
  print STDERR "Math::BigRat. Aborting the program!";
140
  print STDERR "\n\n";
141
  exit($EX_DATAERR);
142
}
143
push(@$stringVectorRef, $ARGV[0]);
144
$ARGV[1] =~ s/"//g;
145
if (Math::BigRat->new($ARGV[1])->is_nan())
146
{
147
  print STDERR "\n\n";
148
  print STDERR "Upper bound \"$ARGV[1]\" can not be converted into a ";
149
  print STDERR "Math::BigRat. Aborting the program!";
150
  print STDERR "\n\n";
151
  exit($EX_DATAERR);
152
}
153
push(@$stringVectorRef, $ARGV[1]);
154
$ARGV[2] =~ s/"//g;
155
if (Math::BigInt->new($ARGV[3])->is_nan())
156
{
157
  print STDERR "\n\n";
158
  print STDERR "The number of files \"$ARGV[2]\" is not a valid integer. ";
159
  print STDERR "Aborting the program!";
160
  print STDERR "\n\n";
161
  exit($EX_DATAERR);
162
}
163
push(@$stringVectorRef, $ARGV[2]);
164
} # End usage
165

    
166

    
167
__END__
168