SPVM::Complex_2d(3)

๐Ÿ“ฆ version 0.990125, in alpine 3.24

๐Ÿ’– NAME ๐Ÿ’–

okay so bestie, this is the page for SPVM::Complex_2d โ€” the double Complex Type. Itโ€™s giving โ€œI do math and I look cute doing itโ€ energy. ๐Ÿงฎโœจ

๐ŸŒธ USAGE ๐ŸŒธ

  use Complex_2d;

  my $z : Complex_2d;

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

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

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

SPVM::Complex_2d is a multi-numeric type used to represent a double complex number. periodt. ๐Ÿ’…

For the full lore on multi-numeric types, go look at SPVM::Document::Language::Types. ๐Ÿ‘‘

๐ŸŽ€ FIELDS ๐ŸŽ€

re ๐Ÿ“

  has re : double;

The real-number part. literally the re girlie. ๐Ÿ’–

im ๐Ÿฆ‹

  has im : double;

The imaginary-number part. no cap, itโ€™s the im icon. โœจ

โœจ CLASS METHODS โœจ

๐ŸŒŸ new

static method new : Complex_2d ($re : double = 0, $im : double = 0);

Creates a new Complex_2d multi-numeric value from the real number $re and the imaginary number $im, and returns it. The defaults are 0 and 0, bestie. ๐Ÿซถ

๐ŸŒŸ new_array_from_pairs

static method new_array_from_pairs : Complex_2d[] ($pairs : double[]);

Creates a new Complex_2d array from $pairs โ€” the pairs of a real number and an imaginary number โ€” and returns that new array. ๐Ÿ’ซ

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_2d[] ($re_array : double[]);

Creates a new Complex_2d array from the real numbers in $re_array, and returns the new array. ๐Ÿ“

๐ŸŒŸ new_array_from_im_array

static method new_array_from_im_array : Complex_2d[] ($im_array : double[]);

Creates a new Complex_2d array from the imaginary numbers in $im_array, and returns the new array. ๐Ÿฆ‹

๐ŸŒŸ to_re_array

static method to_re_array : double[] ($array : Complex_2d[]);

Converts the Complex_2d array $array into an array of real numbers, and returns it. ๐Ÿ’–

๐ŸŒŸ to_im_array

static method to_im_array : double[] ($array : Complex_2d[]);

Converts the Complex_2d array $array into an array of imaginary numbers, and returns it. โœจ

๐ŸŒŸ to_pairs

static method to_pairs : double[] ($array : Complex_2d[]);

Converts the Complex_2d array $array into pairs of a real number and an imaginary number, and returns it. ๐ŸŽ€

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_2d);

Converts the Complex_2d multi-numeric value into a string, such as "1+2i". slay. ๐Ÿ’…

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_2f
  • SPVM::Document::Language::Types

Copyright (c) 2023 Yuki Kimoto

MIT License


with love and zero cap ๐Ÿ’…, this was the SPVM::Complex_2d(3) page from perl v5.42.2, dated 2026-02-03. bye bestie! ๐Ÿซถ

๐Ÿ“ฆ where this page comes from