File: Overloads.pm

package info (click to toggle)
pdl 1%3A2.100-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,816 kB
  • sloc: perl: 22,587; ansic: 14,969; sh: 31; makefile: 30; sed: 6
file content (44 lines) | stat: -rw-r--r-- 819 bytes parent folder | download
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;