version 1.14, 2005/06/09 02:35:55
|
version 1.16, 2006/03/13 20:28:53
|
Line 482 sub tostring {
|
Line 482 sub tostring {
|
# print STDERR Data::Dumper->Dump([@_]); |
# print STDERR Data::Dumper->Dump([@_]); |
my($self) = shift; |
my($self) = shift; |
my($type, @args) = @$self; |
my($type, @args) = @$self; |
|
|
local $_; |
local $_; |
$_ = $type; |
$_ = $type; |
/binop1/ && do { |
/binop1/ && do { |
Line 518 sub tostring {
|
Line 519 sub tostring {
|
}; |
}; |
/special|varname|numberE?/ && return $args[0]; |
/special|varname|numberE?/ && return $args[0]; |
/closep/ && do { |
/closep/ && do { |
my(%close) = %AlgParser::close; |
|
|
|
|
|
|
|
return ($args[0] . $args[1]->tostring() . $close{$args[0]}); |
return ($args[0] . $args[1]->tostring() . $close{$args[0]}); |
}; |
}; |
Line 529 sub tostring {
|
Line 527 sub tostring {
|
sub tolatex { |
sub tolatex { |
my($self) = shift; |
my($self) = shift; |
my($type, @args) = @$self; |
my($type, @args) = @$self; |
|
|
local $_; |
local $_; |
$_ = $type; |
$_ = $type; |
/binop1/ && do { |
/binop1/ && do { |
Line 551 sub tolatex {
|
Line 550 sub tolatex {
|
if ($args[0] eq '/'){ |
if ($args[0] eq '/'){ |
return('\frac{'.$lop.'}{'.$rop.'}'); |
return('\frac{'.$lop.'}{'.$rop.'}'); |
} |
} |
elsif ($args[0] eq '*'){ |
my $op = $args[0]; |
return($lop. '\cdot ' .$rop); |
if ($args[0] eq '*'){ |
|
$op = '\cdot '; |
} |
} |
else{ |
$lop = '\left('.$lop.'\right)' if ($args[1]->[0] =~ /binop1|numberE/); |
$lop = '\left('.$lop.'\right)' if ($args[1]->[0] =~ /binop1|numberE/); |
$rop = '\left('.$rop.'\right)' if ($args[2]->[0] =~ /binop[12]|numberE|unop1/); |
$rop = '\left('.$rop.'\right)' if ($args[2]->[0] =~ /binop[12]|numberE|unop1/); |
if ($args[0] =~ /implicit/) { |
if ($args[0] =~ /implicit/) { |
$op = ($lop =~ m/[.0-9]$/ && $rop =~ m/^[-+.0-9]/) ? '\cdot ' : ' '; |
$args[0] = ($lop =~ m/[.0-9]$/ && $rop =~ m/^[-+.0-9]/) ? '\cdot ' : ' '; |
|
} |
|
return ($lop.$args[0].$rop); |
|
} |
} |
|
return ($lop.$op.$rop); |
|
|
}; |
}; |
/binop3/ && do { |
/binop3/ && do { |
my ($p1, $p2, $p3, $p4)=('','','',''); |
my ($p1, $p2, $p3, $p4)=('','','',''); |
Line 626 sub tolatex {
|
Line 625 sub tolatex {
|
/closep/ && do { |
/closep/ && do { |
my($backslash) = ''; |
my($backslash) = ''; |
if ($args[0] eq '{') {$backslash = '\\';} |
if ($args[0] eq '{') {$backslash = '\\';} |
#This is for editors to match: } |
#This is for editors to match: } |
return ('\left' . $backslash . $args[0] . $args[1]->tolatex() . |
return ('\left' . $backslash . $args[0] . $args[1]->tolatex() . |
'\right' . $backslash . $close{$args[0]}); |
'\right' . $backslash . $close{$args[0]}); |
}; |
}; |