1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
package PDL::Complex::Overloads;
use strict;
use warnings;
use parent 'Math::Complex';
use overload fallback => 1;
sub cplx { bless &Math::Complex::cplx, __PACKAGE__ }
# needed for JSON serialisation
sub FREEZE {
my ($self, $serialiser) = @_;
return %$self;
}
sub THAW {
my ($self, $serialiser, @data) = @_;
return bless {@data}, $self;
}
=head1 NAME
PDL::Complex::Overloads - subclass of Math::Complex with overload fallbacks
=head1 SYNOPSIS
require PDL::Complex::Overloads;
my $same = PDL::Complex::Overloads::cplx(1, 2) eq '1+2i';
=head1 DESCRIPTION
This is a subclass whose only purpose is to provide L<Math::Complex>'s
overloads but with C<fallback> true, mainly to allow string-comparison
for backwards compatibility.
=head1 AUTHOR
Ed J
=head1 SEE ALSO
L<Math::Complex>
=cut
1;
|