perl-Math-GrahamFunction / modules / Math-GrahamFunction / lib / Math / GrahamFunction / SqFacts / Dipole.pm

 ``` 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128``` ```package Math::GrahamFunction::SqFacts::Dipole; use strict; use warnings; =head1 NAME Math::GrahamFunction::SqFacts::Dipole - a dipole of two vectors - a result and a composition. =head1 WARNING! This is a module for Math::GrahamFunction's internal use only. =cut use base qw(Math::GrahamFunction::SqFacts); use List::Util (); __PACKAGE__->mk_accessors(qw(result compose)); sub _initialize { my \$self = shift; my \$args = shift; \$self->result(\$args->{result}); \$self->compose(\$args->{compose}); return 0; } =head1 METHODS =head2 my \$copy = \$dipole->clone() Clones the dipole returning a new dipole with the clone of the result and the composition. =cut sub clone { my \$self = shift; return __PACKAGE__->new( { 'result' => \$self->result()->clone(), 'compose' => \$self->compose()->clone(), }); } =head2 \$changing_dipole->mult_by(\$constant_dipole) Multiplies the result by the result and the composition by the composition. =cut sub mult_by { my \$n_ref = shift; my \$m_ref = shift; \$n_ref->result()->mult_by(\$m_ref->result()); \$n_ref->compose()->mult_by(\$m_ref->compose()); return 0; } =head2 \$bool = \$dipole->is_square() Returns whether the result is square. =cut sub is_square { my \$self = shift; return \$self->result()->is_square(); } =head2 \$bool = \$dipole->exists(\$factor) Returns whether the factor exists in the result. =cut sub exists { my (\$self, \$factor) = @_; return \$self->result()->exists(\$factor); } =head2 \$first_factor = \$dipole->first() Returns the C factor of the result vector. =cut sub first { my \$self = shift; return \$self->result()->first(); } =head2 \$factors = \$dipole->factors() Equivalent to C<\$dipole->result()->factors()>. =cut sub factors { my \$self = shift; return \$self->result->factors(); } sub _get_ret { my \$self = shift; return [ @{\$self->compose->factors()} ]; } 1; ```