Ruby 3.4.5p51 (2025-07-16 revision 20cda200d3ce092571d0b5d342dadca69636cb0f)
|
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) |
Shorthand of x+0i. | |
#define | rb_complex_raw2(x, y) |
Just another name of rb_complex_raw. | |
#define | rb_complex_new1(x) |
Shorthand of x+0i. | |
#define | rb_complex_new2(x, y) |
Just another name of rb_complex_new. | |
#define | rb_complex_add rb_complex_plus |
Just another name of rb_complex_plus. | |
#define | rb_complex_sub rb_complex_minus |
Just another name of rb_complex_minus. | |
#define | rb_complex_nagate rb_complex_uminus |
Just another name of rb_complex_uminus. | |
#define | rb_Complex1(x) |
Shorthand of x+0i. | |
#define | rb_Complex2(x, y) |
Just another name of rb_Complex. |
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. | |
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. | |
VALUE | rb_complex_new_polar (VALUE abs, VALUE arg) |
Constructs a Complex using polar representations. | |
VALUE | rb_complex_polar (VALUE abs, VALUE arg) |
Old name of rb_complex_new_polar. | |
VALUE | rb_complex_real (VALUE z) |
Queries the real part of the passed Complex. | |
VALUE | rb_complex_imag (VALUE z) |
Queries the imaginary part of the passed Complex. | |
VALUE | rb_complex_plus (VALUE x, VALUE y) |
Performs addition of the passed two objects. | |
VALUE | rb_complex_minus (VALUE x, VALUE y) |
Performs subtraction of the passed two objects. | |
VALUE | rb_complex_mul (VALUE x, VALUE y) |
Performs multiplication of the passed two objects. | |
VALUE | rb_complex_div (VALUE x, VALUE y) |
Performs division of the passed two objects. | |
VALUE | rb_complex_uminus (VALUE z) |
Performs negation of the passed object. | |
VALUE | rb_complex_conjugate (VALUE z) |
Performs complex conjugation of the passed object. | |
VALUE | rb_complex_abs (VALUE z) |
Queries the absolute (or the magnitude) of the passed object. | |
VALUE | rb_complex_arg (VALUE z) |
Queries the argument (or the angle) of the passed object. | |
VALUE | rb_complex_pow (VALUE base, VALUE exp) |
Performs exponentiation of the passed two objects. | |
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. | |
VALUE | rb_Complex (VALUE real, VALUE imag) |
Converts various values into a Complex. |
Public APIs related to rb_cComplex.
Definition in file complex.h.
#define rb_Complex1 | ( | x | ) |
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. |
#define rb_Complex2 | ( | 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 | ) |
Shorthand of x+0i.
It practically converts x into a Complex of the identical value.
[in] | x | Any numeric value. |
#define rb_complex_new2 | ( | x, | |
y ) |
Just another name of rb_complex_new.
#define rb_complex_raw1 | ( | x | ) |
Shorthand of x+0i.
It practically converts x into a Complex of the identical value.
[in] | x | Any numeric except Complex. |
#define rb_complex_raw2 | ( | 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:
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. |
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. |
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. |
Performs multiplication of the passed two objects.
[in] | x | An instance of rb_cComplex. |
[in] | y | Arbitrary ruby object. |
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. |
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. |
Performs addition of the passed two objects.
[in] | x | An instance of rb_cComplex. |
[in] | y | Arbitrary ruby object. |
Performs exponentiation of the passed two objects.
[in] | base | An instance of rb_cComplex. |
[in] | exp | Arbitrary ruby object. |
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. |
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. |
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. |