| … | |
… | |
| 568 | $self->setValues(@_); |
568 | $self->setValues(@_); |
| 569 | foreach my $x (keys %{$self->{values}}) { |
569 | foreach my $x (keys %{$self->{values}}) { |
| 570 | $self->Error(["The value of '%s' can't be a formula",$x]) |
570 | $self->Error(["The value of '%s' can't be a formula",$x]) |
| 571 | if Value::isFormula($self->{values}{$x}); |
571 | if Value::isFormula($self->{values}{$x}); |
| 572 | } |
572 | } |
| 573 | Value::makeValue($self->{tree}->eval); |
573 | my $value = Value::makeValue($self->{tree}->eval); |
|
|
574 | $self->unsetValues; |
|
|
575 | return $value; |
| 574 | } |
576 | } |
| 575 | |
577 | |
| 576 | ################################################## |
578 | ################################################## |
| 577 | # |
579 | # |
| 578 | # Removes redundent items (like x+-y, 0+x and 1*x, etc) |
580 | # Removes redundent items (like x+-y, 0+x and 1*x, etc) |
| … | |
… | |
| 597 | my $self = shift; |
599 | my $self = shift; |
| 598 | $self = $self->copy($self); |
600 | $self = $self->copy($self); |
| 599 | $self->setValues(@_); |
601 | $self->setValues(@_); |
| 600 | foreach my $x (keys %{$self->{values}}) {delete $self->{variables}{$x}} |
602 | foreach my $x (keys %{$self->{values}}) {delete $self->{variables}{$x}} |
| 601 | $self->{tree} = $self->{tree}->substitute; |
603 | $self->{tree} = $self->{tree}->substitute; |
|
|
604 | $self->unsetValues; |
| 602 | return $self; |
605 | return $self; |
| 603 | } |
606 | } |
| 604 | |
607 | |
| 605 | ################################################## |
608 | ################################################## |
| 606 | # |
609 | # |
| 607 | # Produces a printable string (substituting the given values). |
610 | # Produces a printable string (substituting the given values). |
| 608 | # |
611 | # |
| 609 | sub string { |
612 | sub string { |
| 610 | my $self = shift; |
613 | my $self = shift; |
| 611 | $self->setValues(@_); |
614 | $self->setValues(@_); |
| 612 | $self->{tree}->string; |
615 | my $string = $self->{tree}->string; |
|
|
616 | $self->unsetValues; |
|
|
617 | return $string; |
| 613 | } |
618 | } |
| 614 | |
619 | |
| 615 | ################################################## |
620 | ################################################## |
| 616 | # |
621 | # |
| 617 | # Produces a TeX string (substituting the given values). |
622 | # Produces a TeX string (substituting the given values). |
| 618 | # |
623 | # |
| 619 | sub TeX { |
624 | sub TeX { |
| 620 | my $self = shift; |
625 | my $self = shift; |
| 621 | $self->setValues(@_); |
626 | $self->setValues(@_); |
| 622 | $self->{tree}->TeX; |
627 | my $tex = $self->{tree}->TeX; |
|
|
628 | $self->unsetValues; |
|
|
629 | return $tex; |
| 623 | } |
630 | } |
| 624 | |
631 | |
| 625 | ################################################## |
632 | ################################################## |
| 626 | # |
633 | # |
| 627 | # Produces a perl eval string (substituting the given values). |
634 | # Produces a perl eval string (substituting the given values). |
| … | |
… | |
| 629 | sub perl { |
636 | sub perl { |
| 630 | my $self = shift; |
637 | my $self = shift; |
| 631 | $self->setValues(@_); |
638 | $self->setValues(@_); |
| 632 | my $perl = $self->{tree}->perl; |
639 | my $perl = $self->{tree}->perl; |
| 633 | $perl = 'new Value::Real('.$perl.')' if $self->isRealNumber; |
640 | $perl = 'new Value::Real('.$perl.')' if $self->isRealNumber; |
|
|
641 | $self->unsetValues; |
| 634 | return $perl; |
642 | return $perl; |
| 635 | } |
643 | } |
| 636 | |
644 | |
| 637 | ################################################## |
645 | ################################################## |
| 638 | # |
646 | # |
| … | |
… | |
| 680 | unless Parser::Item::typeMatch($type,$variables->{$x}{type}); |
688 | unless Parser::Item::typeMatch($type,$variables->{$x}{type}); |
| 681 | $self->{values}{$x} = $value; |
689 | $self->{values}{$x} = $value; |
| 682 | } |
690 | } |
| 683 | } |
691 | } |
| 684 | |
692 | |
|
|
693 | sub unsetValues { |
|
|
694 | my $self = shift; |
|
|
695 | delete $self->{values}; |
|
|
696 | } |
|
|
697 | |
| 685 | |
698 | |
| 686 | ################################################## |
699 | ################################################## |
| 687 | ################################################## |
700 | ################################################## |
| 688 | # |
701 | # |
| 689 | # Produce a vector in ijk form |
702 | # Produce a vector in ijk form |