parrotcode: Complex Numbers PMC Class | |
Contents | PMCs |
src/pmc/complex.pmc - Complex Numbers PMC Class
Complex
provides a representation of complex numbers.
It handles string parsing/generating and basic mathematical operations.
static void complex_parse_string(Interp *interp, FLOATVAL *re, FLOATVAL *im, STRING *value)
value
to produce a complex number,
represented by the real (*re
) and imaginary (*im
) parts.
Raises an exception if it cannot understand the string.
The string should be of the form a+bi
with optional spaces around +
and before i
.
You can also use j
instead of i
.static FLOATVAL *complex_locate_keyed_num(Interp *interp, PMC *self, STRING *key)
key
; valid keys are real
and imag
,
representing the real and imaginary parts of the complex number.PMC *instantiate(PMC *sig)
void *invoke(void *next)
complex
object according to 2.1.
Built-in Functions.void init()
void init_pmc (PMC *initializer)
void destroy ()
PMC *clone ()
INTVAL get_integer ()
FLOATVAL get_number ()
STRING *get_string ()
a+bi
.INTVAL get_bool ()
INTVAL get_integer_keyed (PMC *key)
INTVAL get_integer_keyed_str (STRING *key)
FLOATVAL get_number_keyed (PMC *key)
FLOATVAL get_number_keyed_str (STRING *key)
PMC *get_pmc_keyed (PMC *key)
PMC *get_pmc_keyed_str (STRING *key)
real
and imaginary for imag
).PMC *get_pmc_keyed_int (INTVAL key)
0
and imaginary for 1
).FLOATVAL get_number_keyed_int(INTVAL key)
key = 0 ... get real part
key = 1 ... get imag part
void set_number_keyed_int(INTVAL key, FLOATVAL v)
void set_string_native (STRING *value)
value
into a complex number; raises an exception on failure.void set_pmc (PMC *value)
value
is a Complex PMC then the complex number is set to its value; otherwise value
's string representation is parsed with set_string_native()
.void set_integer_native (INTVAL value)
void set_number_native (FLOATVAL value)
value
and the imaginary part to 0.0
void set_integer_keyed (PMC *key, INTVAL value)
void set_integer_keyed_str (STRING *key, INTVAL value)
void set_number_keyed (PMC *key, FLOATVAL value)
void set_number_keyed_str (STRING *key, FLOATVAL value)
void set_pmc_keyed (PMC *key, PMC *value)
void set_pmc_keyed_str (STRING *key, PMC *value)
real
and imaginary for imag
) to value
.PMC *add (PMC *value, PMC *dest)
PMC *add_int (INTVAL value, PMC *dest)
PMC *add_float (FLOATVAL value, PMC *dest)
value
to the complex number, placing the result in dest
.PMC *subtract (PMC *value, PMC *dest)
PMC *subtract_int (INTVAL value, PMC *dest)
PMC *subtract_float (FLOATVAL value, PMC *dest)
value
from the complex number, placing the result in dest
.PMC *multiply (PMC *value, PMC *dest)
PMC *multiply_int (INTVAL value, PMC *dest)
PMC *multiply_float (FLOATVAL value, PMC *dest)
value
, placing the result in dest
.void i_multiply (PMC *value)
void i_multiply_int (INTVAL value)
void i_multiply_float (FLOATVAL value)
value
.PMC *divide (PMC *value, PMC *dest)
PMC *divide_int (INTVAL value, PMC *dest)
PMC *divide_float (FLOATVAL value, PMC *dest)
value
, placing the result in dest
.void i_divide (PMC *value, PMC *dest)
void i_divide_int (INTVAL value, PMC *dest)
void i_divide_float (FLOATVAL value, PMC *dest)
SELF
by value
inplace.PMC *neg(PMC *dest)
void neg()
dest
to the negated value of SELF
.INTVAL is_equal (PMC *value)
value
and returns true if they are equal.PMC *absolute(PMC *dest)
void i_absolute()
dest
to the absolute value of SELF that is the distance from (0.0).METHOD PMC *ln()
METHOD PMC *exp()
METHOD PMC *sin()
METHOD PMC *cos()
METHOD PMC *tan()
METHOD PMC *csc()
METHOD PMC *sec()
METHOD PMC *cot()
FUNC
(SELF).METHOD PMC *asin()
METHOD PMC *acos()
METHOD PMC *atan()
METHOD PMC *acsc()
METHOD PMC *asec()
METHOD PMC *acot()
METHOD PMC *sinh()
METHOD PMC *cosh()
METHOD PMC *tanh()
METHOD PMC *asinh()
METHOD PMC *acosh()
METHOD PMC *atanh()
METHOD PMC *acsch()
METHOD PMC *asech()
METHOD PMC *acoth()
func(a+bi) = c+di
, |c|
and |d|
will be correct, confusingly enough.PMC *pow(PMC *value, PMC *dest)
value
th power and return result in dest
.METHOD PMC *sqrt()
|