Statistiques
| Branche: | Révision :

meplib / binaries / bin / createVandermonde.pl @ master

Historique | Voir | Annoter | Télécharger (4,52 ko)

1
#! /usr/bin/perl
2

    
3
# createVandermonde.pl - ST - 2005-06-21
4

    
5
# COMMAND LINE SYNTAX:
6
# createVandermonde.pl lowerBound upperBound degree
7

    
8
# NOTE(S):
9
# 
10
# This program emulates the behaviour of the vander function of Matlab.
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
my $matrixRef;
49

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

    
54
##############################################################################
55
# INITIALIZE DEBUG FILE
56
##############################################################################
57

    
58
##############################################################################
59
# INITIALIZE LOG FILE
60
##############################################################################
61

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

    
66
##############################################################################
67
# PROGRAM MAIN
68
##############################################################################
69
&usage();
70
$generatorVectorRef = &generatorVectorFromBoundsAndDegreeRat($stringVectorRef);
71
$matrixRef = createVanderMatrixRat($generatorVectorRef);
72
print STDERR "\n";
73
printMatrix($matrixRef, *STDOUT);
74
print STDERR "\n";
75
print STDERR "\n";
76
# Uncomment this line and remove the next one if using stdExitErrors.
77
exit($EX_OK); # exit main program
78

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

    
106
sub _privateSubName
107
{
108
	my $argv = shift();
109
	my $retv = undef;
110
	return($retv);
111
};
112
#
113
##############################################################################
114
# sub usage
115
##############################################################################
116
# Performed task: checks the command line parameters
117
#
118
# input   : none
119
# output  : none
120
# globals : $ARGV,others...
121
#
122
sub usage {
123
  if (! defined($ARGV[2]))
124
  {
125
    my $scriptName = `basename $0`;
126
    chomp $scriptName;
127
    print STDERR "\n\nUsage : $scriptName lowerBound upperBound degree\n\n";
128
    print STDERR "  - lowerBound: the lower bound for the Vandermonde matrix;\n";
129
    print STDERR "  - upperBound: the upper bound for the Vandermonde matrix;\n";
130
    print STDERR "  - degree    : the degree for the Vandermonde matrix.\n\n";
131
    # Uncomment this line and remove the next one if using stdExitErrors.
132
    exit($EX_USAGE);
133
  } # End if
134
# Some initializations 
135
$ARGV[0] =~ s/"//g;
136
push(@$stringVectorRef, $ARGV[0]);
137
$ARGV[1] =~ s/"//g;
138
push(@$stringVectorRef, $ARGV[1]);
139
$ARGV[2] =~ s/"//g;
140
push(@$stringVectorRef, $ARGV[2]);
141
} # End usage
142

    
143

    
144
__END__
145