Ruby
3.4.0dev (2024-11-05 revision 348a53415339076afc4a02fcd09f3ae36e9c4c61)
|
Public APIs related to rb_cComplex. More...
#include "ruby/internal/attr/deprecated.h"
#include "ruby/internal/attr/pure.h"
#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)) |
Shorthand of x+0i . More... | |
#define | rb_complex_raw2(x, y) rb_complex_raw((x), (y)) |
Just another name of rb_complex_raw. More... | |
#define | rb_complex_new1(x) rb_complex_new((x), INT2FIX(0)) |
Shorthand of x+0i . More... | |
#define | rb_complex_new2(x, y) rb_complex_new((x), (y)) |
Just another name of rb_complex_new. More... | |
#define | rb_complex_add rb_complex_plus |
Just another name of rb_complex_plus. More... | |
#define | rb_complex_sub rb_complex_minus |
Just another name of rb_complex_minus. More... | |
#define | rb_complex_nagate rb_complex_uminus |
Just another name of rb_complex_uminus. More... | |
#define | rb_Complex1(x) rb_Complex((x), INT2FIX(0)) |
Shorthand of x+0i . More... | |
#define | rb_Complex2(x, y) rb_Complex((x), (y)) |
Just another name of rb_Complex. More... | |
Functions | |
VALUE | rb_complex_raw (VALUE real, VALUE imag) |
Identical to rb_complex_new(), except it assumes both arguments are not instances of rb_cComplex. More... | |
VALUE | rb_complex_new (VALUE real, VALUE imag) |
Constructs a Complex, by first multiplying the imaginary part with 1i then adds it to the real part. More... | |
VALUE | rb_complex_new_polar (VALUE abs, VALUE arg) |
Constructs a Complex using polar representations. More... | |
VALUE | rb_complex_polar (VALUE abs, VALUE arg) |
Old name of rb_complex_new_polar. More... | |
VALUE | rb_complex_real (VALUE z) |
Queries the real part of the passed Complex. More... | |
VALUE | rb_complex_imag (VALUE z) |
Queries the imaginary part of the passed Complex. More... | |
VALUE | rb_complex_plus (VALUE x, VALUE y) |
Performs addition of the passed two objects. More... | |
VALUE | rb_complex_minus (VALUE x, VALUE y) |
Performs subtraction of the passed two objects. More... | |
VALUE | rb_complex_mul (VALUE x, VALUE y) |
Performs multiplication of the passed two objects. More... | |
VALUE | rb_complex_div (VALUE x, VALUE y) |
Performs division of the passed two objects. More... | |
VALUE | rb_complex_uminus (VALUE z) |
Performs negation of the passed object. More... | |
VALUE | rb_complex_conjugate (VALUE z) |
Performs complex conjugation of the passed object. More... | |
VALUE | rb_complex_abs (VALUE z) |
Queries the absolute (or the magnitude) of the passed object. More... | |
VALUE | rb_complex_arg (VALUE z) |
Queries the argument (or the angle) of the passed object. More... | |
VALUE | rb_complex_pow (VALUE base, VALUE exp) |
Performs exponentiation of the passed two objects. More... | |
VALUE | rb_dbl_complex_new (double real, double imag) |
Identical to rb_complex_new(), except it takes the arguments as C's double instead of Ruby's object. More... | |
VALUE | rb_Complex (VALUE real, VALUE imag) |
Converts various values into a Complex. More... | |
Public APIs related to rb_cComplex.
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. __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.
#define rb_Complex1 | ( | x | ) | rb_Complex((x), INT2FIX(0)) |
Shorthand of x+0i
.
It practically converts x
into a Complex of the identical value.
[in] | x | rb_cNumeric, rb_cString, or something that responds to #to_c . |
x + 0i
. #define rb_Complex2 | ( | x, | |
y | |||
) | rb_Complex((x), (y)) |
Just another name of rb_Complex.
#define rb_complex_add rb_complex_plus |
Just another name of rb_complex_plus.
#define rb_complex_nagate rb_complex_uminus |
Just another name of rb_complex_uminus.
#define rb_complex_new1 | ( | x | ) | rb_complex_new((x), INT2FIX(0)) |
Shorthand of x+0i
.
It practically converts x
into a Complex of the identical value.
[in] | x | Any numeric value. |
x + 0i
. #define rb_complex_new2 | ( | x, | |
y | |||
) | rb_complex_new((x), (y)) |
Just another name of rb_complex_new.
#define rb_complex_raw1 | ( | x | ) | rb_complex_raw((x), INT2FIX(0)) |
Shorthand of x+0i
.
It practically converts x
into a Complex of the identical value.
[in] | x | Any numeric except Complex. |
x + 0i
. #define rb_complex_raw2 | ( | x, | |
y | |||
) | rb_complex_raw((x), (y)) |
Just another name of rb_complex_raw.
#define rb_complex_sub rb_complex_minus |
Just another name of rb_complex_minus.
Converts various values into a Complex.
This function accepts:
0i
),#to_c
.It (possibly recursively) applies #to_c
until both sides become a Complex value, then computes imag * 1i + real
.
As a special case, passing RUBY_Qundef to imag
is the same as passing RB_INT2NUM(0)
.
[in] | real | Real part (see above). |
[in] | imag | Imaginary part (see above). |
rb_eTypeError | Passed something not described above. |
1i * imag + real
. Queries the absolute (or the magnitude) of the passed object.
[in] | z | An instance of rb_cComplex. |
Queries the argument (or the angle) of the passed object.
[in] | z | An instance of rb_cComplex. |
Performs complex conjugation of the passed object.
[in] | z | An instance of rb_cComplex. |
Performs division of the passed two objects.
[in] | x | An instance of rb_cComplex. |
[in] | y | Arbitrary ruby object. |
x / y
evaluates to. Queries the imaginary part of the passed Complex.
[in] | z | An instance of rb_cComplex. |
Performs subtraction of the passed two objects.
[in] | x | An instance of rb_cComplex. |
[in] | y | Arbitrary ruby object. |
x - y
evaluates to. Performs multiplication of the passed two objects.
[in] | x | An instance of rb_cComplex. |
[in] | y | Arbitrary ruby object. |
x * y
evaluates to. Constructs a Complex, by first multiplying the imaginary part with 1i
then adds it to the real part.
This definition doesn't need both arguments be real numbers. It can happily combine two instances of rb_cComplex (with rotating the latter one).
[in] | real | An instance of rb_cNumeric. |
[in] | imag | Another instance of rb_cNumeric. |
imag * 1i + real
. Constructs a Complex using polar representations.
Unlike rb_complex_new() it makes no sense to pass non-real instances to this function.
[in] | abs | Magnitude, in any numeric except Complex. |
[in] | arg | Angle, in radians, in any numeric except Complex. |
Definition at line 1761 of file complex.c.
Referenced by rb_complex_polar().
Performs addition of the passed two objects.
[in] | x | An instance of rb_cComplex. |
[in] | y | Arbitrary ruby object. |
x + y
evaluates to. Performs exponentiation of the passed two objects.
[in] | base | An instance of rb_cComplex. |
[in] | exp | Arbitrary ruby object. |
base ** exp
evaluates to. Identical to rb_complex_new(), except it assumes both arguments are not instances of rb_cComplex.
It is thus dangerous for extension libraries.
[in] | real | Real part, in any numeric except Complex. |
[in] | imag | Imaginary part, in any numeric except Complex. |
real + (imag)i
. Definition at line 1749 of file complex.c.
Referenced by rb_dbl_complex_new().
Queries the real part of the passed Complex.
[in] | z | An instance of rb_cComplex. |
Performs negation of the passed object.
[in] | z | An instance of rb_cComplex. |
-z
evaluates to. VALUE rb_dbl_complex_new | ( | double | real, |
double | imag | ||
) |
Identical to rb_complex_new(), except it takes the arguments as C's double instead of Ruby's object.
[in] | real | Real part. |
[in] | imag | Imaginary part. |
real + (imag)i
.