Parent Directory
|
Revision Log
Revision 5130 - (view) (download) (as text)
| 1 : | sh002i | 2558 | ######################################################################### |
| 2 : | # | ||
| 3 : | # Implement functions having two real inputs | ||
| 4 : | # | ||
| 5 : | package Parser::Function::numeric2; | ||
| 6 : | dpvc | 4975 | use strict; |
| 7 : | our @ISA = qw(Parser::Function); | ||
| 8 : | sh002i | 2558 | |
| 9 : | # | ||
| 10 : | # Check for two real-valued arguments | ||
| 11 : | dpvc | 4975 | # |
| 12 : | sh002i | 2558 | sub _check { |
| 13 : | my $self = shift; | ||
| 14 : | return if ($self->checkArgCount(2)); | ||
| 15 : | dpvc | 5130 | if (($self->{params}->[0]->isNumber && $self->{params}->[1]->isNumber && |
| 16 : | !$self->{params}->[0]->isComplex && !$self->{params}->[1]->isComplex) || | ||
| 17 : | $self->context->flag("allowBadFunctionInputs")) { | ||
| 18 : | sh002i | 2558 | $self->{type} = $Value::Type{number}; |
| 19 : | } else { | ||
| 20 : | dpvc | 3370 | $self->Error("Function '%s' has the wrong type of inputs",$self->{name}); |
| 21 : | sh002i | 2558 | } |
| 22 : | } | ||
| 23 : | |||
| 24 : | # | ||
| 25 : | # Check that the inputs are OK | ||
| 26 : | # | ||
| 27 : | sub _call { | ||
| 28 : | my $self = shift; my $name = shift; | ||
| 29 : | dpvc | 3370 | Value::Error("Function '%s' has too many inputs",$name) if scalar(@_) > 2; |
| 30 : | Value::Error("Function '%s' has too few inputs",$name) if scalar(@_) < 2; | ||
| 31 : | Value::Error("Function '%s' has the wrong type of inputs",$name) | ||
| 32 : | sh002i | 2558 | unless Value::matchNumber($_[0]) && Value::matchNumber($_[1]); |
| 33 : | return $self->$name(@_); | ||
| 34 : | } | ||
| 35 : | |||
| 36 : | # | ||
| 37 : | # Call the appropriate routine | ||
| 38 : | # | ||
| 39 : | sub _eval { | ||
| 40 : | my $self = shift; my $name = $self->{name}; | ||
| 41 : | $self->$name(@_); | ||
| 42 : | } | ||
| 43 : | |||
| 44 : | # | ||
| 45 : | # Do the core atan2 call | ||
| 46 : | # | ||
| 47 : | sub atan2 {shift; CORE::atan2($_[0],$_[1])} | ||
| 48 : | |||
| 49 : | ######################################################################### | ||
| 50 : | |||
| 51 : | 1; |
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |