<commit_before>## $Id$

=head1 TITLE

Complex - Perl 6 complex numbers

=head1 DESCRIPTION

=head2 Methods

=over 4

=item onload

Implementation is a bit different from other basic objects (Int...) because
'Complex' is also the name of the builtin Parrot PMC.

=cut

.namespace [ 'Perl6Complex' ]

.sub 'onload' :anon :init :load
    .local pmc p6meta, complexproto
    p6meta = get_hll_global ['Perl6Object'], '$!P6META'
    complexproto = p6meta.'new_class'('Perl6Complex', 'parent'=>'Complex Any', 'name'=>'Complex')
    complexproto.'!IMMUTABLE'()
    p6meta.'register'('Complex', 'parent'=>complexproto, 'protoobject'=>complexproto)

    $P0 = get_hll_namespace ['Perl6Complex']
    '!EXPORT'('log,polar', 'from'=>$P0)
.end


=item perl()

Returns a Perl representation of the Complex.

=cut

.sub 'perl' :method
    $S0 = self
    .return ($S0)
.end

=back

=head2 Subs

=over 4

=item exp

=cut

.namespace []
.sub 'exp' :multi('Complex')
    .param pmc x
    $P0 = x.'exp'()
    .return ($P0)
.end


=item log

=cut

.namespace ['Perl6Complex']
.sub 'log' :method :multi('Complex')
    $P0 = self.'ln'()
    .return ($P0)
.end

=item polar

=cut

.namespace ['Perl6Complex']
.sub 'polar' :method :multi('Complex')
    .local num real, imag, magnitude, angle
    real = self[0]
    imag = self[1]
    $N0 = real * real
    $N1 = imag * imag
    $N2 = $N0 + $N1
    magnitude = sqrt $N2
    angle = atan imag, real
    .tailcall 'list'(magnitude, angle)
.end

=item sqrt

=cut

.namespace []
.sub 'sqrt' :multi('Complex')
    .param pmc x
    $P0 = x.'sqrt'()
    .return ($P0)
.end

.namespace [ 'Any' ]

=item Complex

Casts a value to a complex number.
<commit_msg>Add some basic docs to Complex.pir<commit_after>## $Id$

=head1 TITLE

Complex - Perl 6 complex numbers

=head1 DESCRIPTION

=head2 Methods

=over 4

=item onload

Implementation is a bit different from other basic objects (Int...) because
'Complex' is also the name of the builtin Parrot PMC.

=cut

.namespace [ 'Perl6Complex' ]

.sub 'onload' :anon :init :load
    .local pmc p6meta, complexproto
    p6meta = get_hll_global ['Perl6Object'], '$!P6META'
    complexproto = p6meta.'new_class'('Perl6Complex', 'parent'=>'Complex Any', 'name'=>'Complex')
    complexproto.'!IMMUTABLE'()
    p6meta.'register'('Complex', 'parent'=>complexproto, 'protoobject'=>complexproto)

    $P0 = get_hll_namespace ['Perl6Complex']
    '!EXPORT'('log,polar', 'from'=>$P0)
.end


=item perl()

Returns a Perl representation of the Complex.

=cut

.sub 'perl' :method
    $S0 = self
    .return ($S0)
.end

=back

=head2 Subs

=over 4

=item exp

Returns the exponential of a Complex.

=cut

.namespace []
.sub 'exp' :multi('Complex')
    .param pmc x
    $P0 = x.'exp'()
    .return ($P0)
.end


=item log

Returns the logarithm of a Complex.

=cut

.namespace ['Perl6Complex']
.sub 'log' :method :multi('Complex')
    $P0 = self.'ln'()
    .return ($P0)
.end

=item polar

Returns the polar representation of a Complex.

=cut

.namespace ['Perl6Complex']
.sub 'polar' :method :multi('Complex')
    .local num real, imag, magnitude, angle
    real = self[0]
    imag = self[1]
    $N0 = real * real
    $N1 = imag * imag
    $N2 = $N0 + $N1
    magnitude = sqrt $N2
    angle = atan imag, real
    .tailcall 'list'(magnitude, angle)
.end

=item sqrt

Returns the square root of a Complex.

=cut

.namespace []
.sub 'sqrt' :multi('Complex')
    .param pmc x
    $P0 = x.'sqrt'()
    .return ($P0)
.end

.namespace [ 'Any' ]

=item Complex

Casts a value to a complex number.

{'fraction_non_alphanumeric': 0.15138653084323714, 'fraction_numerical': 0.02037351443123939, 'mean_word_length': 3.3162393162393164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '777472', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1315, 'n_words': 403}