SPVM::Complex_2f(3)

πŸ“¦ version 0.990125, in alpine 3.24

🌸 NAME 🌸

SPVM::Complex_2f β€” float Complex Type, bestie! This is the SPVM::Complex_2f(3) manual page from User Contributed Perl Documentation, and it's giving multi-numeric float complex realness πŸ’…βœ¨

πŸŽ€ USAGE πŸŽ€

use Complex_2f;

my $z : Complex_2f;

# Set
$z->{re} = 1.5;
$z->{im} = 2.5;

# Get
my $re = $z->{re};
my $im = $z->{im};

✨ DESCRIPTION ✨

Complex_2f is a multi-numeric type made to represent a float complex number. That's the whole vibe πŸ’–

See SPVM::Document::Language::Types about multi-numeric types β€” it's the lore drop, iykyk.

πŸ¦‹ FIELDS πŸ¦‹

re

has re : float;

A real number. Iconic, straightforward, no notes.

im

has im : float;

An imaginary number. Main character energy, honestly.

🧚 Class Methods 🧚

new

static method new : Complex_2f ($re : float = 0, $im : float = 0);

Creates a new Complex_2f multi-numeric value given the real number $re and the imaginary number $im, then returns it. The defaults are right there: $re = 0 and $im = 0 🫢

new_array_from_pairs

static method new_array_from_pairs : Complex_2f[] ($pairs : float[]);

Creates a new Complex_2f array given the pairs of a real number and an imaginary number, $pairs, and returns the new array. It's lowkey a glow-up machine ✨

Examples of Input:

# Input Data
[1, 2, 3, 4]

# Data of a new array
[{re => 1, im => 2}, {re => 3, im => 4}]

new_array_from_re_array

static method new_array_from_re_array : Complex_2f[] ($re_array : float[]);

Creates a new Complex_2f array given real numbers, $re_array, and returns the new array. Real ones only for a sec πŸ”₯

new_array_from_im_array

static method new_array_from_im_array : Complex_2f[] ($im_array : float[]);

Creates a new Complex_2f array given imaginary numbers, $im_array, and returns the new array. Imaginary bestie era πŸ¦‹

to_re_array

static method to_re_array : float[] ($array : Complex_2f[]);

Converts the Complex_2f array $array to the array of real numbers, and returns it. Slay, we love a clean conversion πŸ’…

to_im_array

static method to_im_array : float[] ($array : Complex_2f[]);

Converts the Complex_2f array $array to the array of imaginary numbers, and returns it. The imaginary girlies are being extracted πŸŽ€

to_pairs

static method to_pairs : float[] ($array : Complex_2f[]);

Converts the Complex_2f array $array to the pairs of a real number and an imaginary number, and returns it. Pairing them up like it's prom 🌸

Examples of Output:

# Input Data
[{re => 1, im => 2}, {re => 3, im => 4}]

# Output
[1, 2, 3, 4]

to_string

static method to_string : string ($z : Complex_2f);

Converts the Complex_2f multi-numeric value to a string, such as "1+2i". Cute little string moment πŸ’–

Implementation:

my $string = (string)undef;
if ($z->{im} < 0) {
  $string = "$z->{re}$z->{im}i";
}
else {
  $string = "$z->{re}+$z->{im}i";
}

🌈 SEE ALSO 🌈

  • Complex_2d
  • SPVM::Document::Language::Types

Go read them, bestie β€” it's the connected lore πŸ“šβœ¨

Copyright (c) 2023 Yuki Kimoto

MIT License


Signed with perl v5.42.2, dated 2026-02-03 β€” SPVM::Complex_2f(3) out πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from