Ruby: include/ruby/internal/intern/complex.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Functions
complex.h File Reference

Public APIs related to rb_cComplex. More...

`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/value.h"`
`#include "ruby/internal/arithmetic/long.h"`

Go to the source code of this file.

## Macros
#define | rb_complex_raw1(x) rb_complex_raw((x), INT2FIX(0))
#define | rb_complex_raw2(x, y) rb_complex_raw((x), (y))
#define | rb_complex_new1(x) rb_complex_new((x), INT2FIX(0))
#define | rb_complex_new2(x, y) rb_complex_new((x), (y))
#define | rb_complex_add rb_complex_plus
#define | rb_complex_sub rb_complex_minus
#define | rb_complex_nagate rb_complex_uminus
#define | rb_Complex1(x) rb_Complex((x), INT2FIX(0))
#define | rb_Complex2(x, y) rb_Complex((x), (y))

## Functions
VALUE | rb_complex_raw (VALUE, VALUE)
VALUE | rb_complex_new (VALUE, VALUE)
VALUE | rb_complex_new_polar (VALUE abs, VALUE arg)
VALUE | rb_complex_polar (VALUE abs, VALUE arg)
VALUE | rb_complex_real (VALUE z)
VALUE | rb_complex_imag (VALUE z)
VALUE | rb_complex_plus (VALUE x, VALUE y)
VALUE | rb_complex_minus (VALUE x, VALUE y)
VALUE | rb_complex_mul (VALUE x, VALUE y)
VALUE | rb_complex_div (VALUE x, VALUE y)
VALUE | rb_complex_uminus (VALUE z)
VALUE | rb_complex_conjugate (VALUE z)
VALUE | rb_complex_abs (VALUE z)
VALUE | rb_complex_arg (VALUE z)
VALUE | rb_complex_pow (VALUE base, VALUE exp)
VALUE | rb_dbl_complex_new (double real, double imag)
| Creates a Complex object. More...
VALUE | rb_Complex (VALUE, VALUE)

## Detailed Description

Public APIs related to rb_cComplex.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either `RBIMPL` or `rbimpl` are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__VA_ARGS__` is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file complex.h.

## Macro Definition Documentation

## ◆ rb_Complex1

#define rb_Complex1 | ( |  | x | ) | rb_Complex((x), INT2FIX(0))

Definition at line 55 of file complex.h.

## ◆ rb_Complex2

#define rb_Complex2 | ( |  | x,
|  |  | y
| ) |  | rb_Complex((x), (y))

Definition at line 56 of file complex.h.

## ◆ rb_complex_add

#define rb_complex_add rb_complex_plus

Definition at line 50 of file complex.h.

## ◆ rb_complex_nagate

#define rb_complex_nagate rb_complex_uminus

Definition at line 52 of file complex.h.

## ◆ rb_complex_new1

#define rb_complex_new1 | ( |  | x | ) | rb_complex_new((x), INT2FIX(0))

Definition at line 34 of file complex.h.

## ◆ rb_complex_new2

#define rb_complex_new2 | ( |  | x,
|  |  | y
| ) |  | rb_complex_new((x), (y))

Definition at line 35 of file complex.h.

## ◆ rb_complex_raw1

#define rb_complex_raw1 | ( |  | x | ) | rb_complex_raw((x), INT2FIX(0))

Definition at line 31 of file complex.h.

## ◆ rb_complex_raw2

#define rb_complex_raw2 | ( |  | x,
|  |  | y
| ) |  | rb_complex_raw((x), (y))

Definition at line 32 of file complex.h.

## ◆ rb_complex_sub

#define rb_complex_sub rb_complex_minus

Definition at line 51 of file complex.h.

## Function Documentation

## ◆ rb_Complex()

VALUE rb_Complex | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1560 of file complex.c.

References rb_cComplex.

## ◆ rb_complex_abs()

VALUE rb_complex_abs | ( | VALUE | z | ) |

Definition at line 1170 of file complex.c.

References f_abs, get_dat1, and rb_math_hypot().

Referenced by Init_Complex().

## ◆ rb_complex_arg()

VALUE rb_complex_arg | ( | VALUE | z | ) |

Definition at line 1217 of file complex.c.

References get_dat1, and rb_math_atan2().

Referenced by Init_Complex().

## ◆ rb_complex_conjugate()

VALUE rb_complex_conjugate | ( | VALUE | z | ) |

Definition at line 1263 of file complex.c.

References CLASS_OF, f_negate, and get_dat1.

Referenced by Init_Complex().

## ◆ rb_complex_div()

VALUE rb_complex_div | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 957 of file complex.c.

References f_quo, and id_quo.

Referenced by Init_Complex(), and rb_numeric_quo().

## ◆ rb_complex_imag()

VALUE rb_complex_imag | ( | VALUE | z | ) |

Definition at line 752 of file complex.c.

References get_dat1.

Referenced by Init_Complex().

## ◆ rb_complex_minus()

VALUE rb_complex_minus | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 821 of file complex.c.

References CLASS_OF, f_sub, get_dat1, get_dat2, rb_num_coerce_bin(), and T_COMPLEX.

Referenced by Init_Complex().

## ◆ rb_complex_mul()

VALUE rb_complex_mul | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 881 of file complex.c.

References CLASS_OF, f_mul, get_dat1, get_dat2, rb_num_coerce_bin(), and T_COMPLEX.

Referenced by Init_Complex().

## ◆ rb_complex_new()

VALUE rb_complex_new | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1542 of file complex.c.

References rb_cComplex.

Referenced by rb_dbl_complex_new_polar_pi().

## ◆ rb_complex_new_polar()

VALUE rb_complex_new_polar | ( | VALUE | abs,
|  | VALUE | arg
| ) |  |

Definition at line 1548 of file complex.c.

References rb_cComplex.

Referenced by rb_complex_polar().

## ◆ rb_complex_plus()

VALUE rb_complex_plus | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 787 of file complex.c.

References CLASS_OF, f_add, get_dat1, get_dat2, rb_num_coerce_bin(), and T_COMPLEX.

Referenced by Init_Complex().

## ◆ rb_complex_polar()

VALUE rb_complex_polar | ( | VALUE | abs,
|  | VALUE | arg
| ) |  |

Definition at line 1554 of file complex.c.

References rb_complex_new_polar().

## ◆ rb_complex_pow()

VALUE rb_complex_pow | ( | VALUE | base,
|  | VALUE | exp
| ) |  |

Definition at line 994 of file complex.c.

References CLASS_OF, f_abs, f_add, f_expt, f_mul, f_negate, f_reciprocal, f_sub, FIX2LONG, FIXNUM_P, get_dat1, id_expt, k_exact_zero_p, LONG2FIX, ONE, rb_int_uminus(), rb_num_coerce_bin(), rb_num_pow(), rb_warn(), RRATIONAL, T_BIGNUM, T_COMPLEX, T_RATIONAL, TWO, and ZERO.

Referenced by Init_Complex(), and rb_num_pow().

## ◆ rb_complex_raw()

VALUE rb_complex_raw | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1536 of file complex.c.

References rb_cComplex.

Referenced by rb_dbl_complex_new().

## ◆ rb_complex_real()

VALUE rb_complex_real | ( | VALUE | z | ) |

Definition at line 735 of file complex.c.

References get_dat1.

Referenced by Init_Complex().

## ◆ rb_complex_uminus()

VALUE rb_complex_uminus | ( | VALUE | z | ) |

Definition at line 767 of file complex.c.

References CLASS_OF, f_negate, and get_dat1.

Referenced by Init_Complex().

## ◆ rb_dbl_complex_new()

VALUE rb_dbl_complex_new | ( | double | real,
|  | double | imag
| ) |  |

Creates a Complex object.

Parameters

  real | real part value
  imag | imaginary part value

Returns
  a new Complex object

Definition at line 1576 of file complex.c.

References DBL2NUM, and rb_complex_raw().