[system] / trunk / pg / macros / PGpolynomialmacros.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/PGpolynomialmacros.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1114 Revision 1115
201## returns a sting containing the polynomial with variable v 201## returns a sting containing the polynomial with variable v
202## default variable is x 202## default variable is x
203## 203##
204 204
205sub PolyString{ 205sub PolyString{
206 my $temp = $_[0]; 206 my $temp = $_[0];
207 my @poly = @{$temp}; 207 my @poly = @{$temp};
208 $string = ""; 208 my $string = '';
209 foreach $i (0..$#poly) { 209 foreach my $i (0..$#poly) {
210 $j = $#poly-$i; 210 my $j = $#poly-$i;
211 if ($j == $#poly) {if ($poly[$i]!=1){ 211 if ($j == $#poly) {
212 if ($poly[$i] >0) {
213 if ($poly[$i]!=1){
212 $string = $string."$poly[$i] x^{$j}";} 214 $string = $string."$poly[$i] x^{$j}";
215 }
213 else {$string=$string."x^{$j}";} 216 else {$string=$string."x^{$j}";}
214 } 217 }
215 elsif ($j > 0 && $j!=1) {
216 if ($poly[$i] >0) {
217 if ($poly[$i]!=1){
218 $string = $string."+$poly[$i] x^{$j}";}
219 else {$string = $string."+x^{$j}";}}
220 elsif ($poly[$i] == 0) {} 218 elsif ($poly[$i] == 0) {}
221 elsif ($poly[$i] == -1) {$string=$string."-x^{$j}";} 219 elsif ($poly[$i] == -1) {$string=$string."-x^{$j}";}
220 else {$string = $string."$poly[$i] x^{$j}";}
221 }
222 elsif ($j > 0 && $j!=1) {
223 if ($poly[$i] >0) {
224 if ($poly[$i]!=1){
225 $string = $string."+$poly[$i] x^{$j}";
226 }
227 else {$string = $string."+x^{$j}";}}
228 elsif ($poly[$i] == 0) {}
229 elsif ($poly[$i] == -1) {$string=$string."-x^{$j}";}
222 else {$string = $string."$poly[$i] x^{$j}";} 230 else {$string = $string."$poly[$i] x^{$j}";}
223 } 231 }
224 elsif ($j == 1) { 232 elsif ($j == 1) {
225 if ($poly[$i] > 0){ 233 if ($poly[$i] > 0){
226 if ($poly[$i]!=1){ 234 if ($poly[$i]!=1){
227 $string = $string."+$poly[$i] x";} 235 $string = $string."+$poly[$i] x";
228 else {$string = $string."+x";}} 236 }
237 else {$string = $string."+x";}
238 }
229 elsif ($poly[$i] == 0) {} 239 elsif ($poly[$i] == 0) {}
230 elsif ($poly[$i] == -1){$string=$string."-x";} 240 elsif ($poly[$i] == -1){$string=$string."-x";}
231 else {$string=$string."$poly[$i] x";} 241 else {$string=$string."$poly[$i] x";}
232 } 242 }
233 else { 243 else {
234 if ($poly[$i] > 0){ 244 if ($poly[$i] > 0){
235 $string = $string."+$poly[$i] ";} 245 $string = $string."+$poly[$i] ";
246 }
236 elsif ($poly[$i] == 0) {} 247 elsif ($poly[$i] == 0) {}
237 else {$string=$string."$poly[$i] ";} 248 else {$string=$string."$poly[$i] ";}
238 } 249 }
239 } 250 }
240 return $string; 251 return $string;
241} 252}
253
242 254
243sub PolyFunc { 255sub PolyFunc {
244 my $temp = $_[0]; 256 my $temp = $_[0];
245 my @poly = @{$temp}; 257 my @poly = @{$temp};
246 $func = ""; 258 $func = "";

Legend:
Removed from v.1114  
changed lines
  Added in v.1115

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9