Module: BigMathR::ComplexPlane

Defined in:
ext/bigdecimal/math_r/nucomp.c,
ext/bigdecimal/math_r/math_r.c

Overview

A module that provides whole of functions related to the complex plane. It is used internally.

Synopsis

The function names defined are the same as those in the C/C++ standard.

  • Complex argument: :carg

  • Complex absolute: :cabs

Follow, the name defined in C/C++ standard though, the function names are different.

  • Quadrant XY: :quadrant ( :atan2 in C/C++ )

Class Method Summary collapse

Class Method Details

.cabs(z, prec) ⇒ BigDecimal

Return complex absolute of z.

Parameters:

  • z (Numeric)

    Complex variable

  • prec (Integer)

    Arbitrary precision

Returns:

  • (BigDecimal)

    Real solution

Raises:

  • (ArgumentError)

    Occurs when prec is not a positive integer.

  • (TypeError)

    Occurs when z is not a numeric class.

Since:

  • 0.1.0



72
73
74
75
76
77
# File 'ext/bigdecimal/math_r/nucomp.c', line 72

static VALUE
__impl_nucomp_cabs(VALUE unused_obj, VALUE z, VALUE prec)
{
  z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
  return rb_bigmath_cabs(z, prec);
}

.carg(z, prec) ⇒ BigDecimal

Return complex argument of z.

Parameters:

  • z (Numeric)

    Complex variable

  • prec (Integer)

    Arbitrary precision

Returns:

  • (BigDecimal)

    Real solution

Raises:

  • (ArgumentError)

    Occurs when prec is not a positive integer.

  • (TypeError)

    Occurs when z is not a numeric class.

Since:

  • 0.1.0



125
126
127
128
129
130
# File 'ext/bigdecimal/math_r/nucomp.c', line 125

static VALUE
__impl_nucomp_carg(VALUE unused_obj, VALUE z, VALUE prec)
{
  z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
  return rb_bigmath_carg(z, prec);
}

.l2norm(*args, prec) ⇒ BigDecimal

Return solve of the euclidean norm (L2-norm) for argument as numerical sequence.

Examples:

BigMathR::ComplexPlane.l2norm(2, 4, 5, 20)
#=> 0.670820393249936908923e1

Parameters:

  • *args (Array)

    Numerical sequence

  • prec (Integer)

    Arbitrary precision

Returns:

  • (BigDecimal)

    Real solution

Raises:

  • (ArgumentError)

    Occurs when prec is not a positive integer.

  • (TypeError)

    Occurs when z is not a numeric class.

Since:

  • 0.1.0



26
27
28
29
30
31
32
33
34
35
36
# File 'ext/bigdecimal/math_r/nucomp.c', line 26

static VALUE
__impl_nucomp_l2norm(VALUE unused_obj, VALUE args)
{
  if (RARRAY_LEN(args) < 2)
    rb_raise(rb_eArgError, 
      "wrong number of arguments (given %ld, expected 2..)", 
      RARRAY_LEN(args));
  VALUE prec = rb_ary_pop(args);
  rb_check_precise(prec);
  return rb_bigmath_l2norm(args, prec);
}

.quadrant(x, y, prec) ⇒ BigDecimal, Complex

Consider where the value is in quadrant XY and computes the inverse tangent of y/x.

Parameters:

  • x (Numeric)

    X-axis

  • y (Numeric)

    Y-axis

  • prec (Integer)

    Arbitrary precision

Returns:

  • (BigDecimal)

    Real solution

  • (Complex)

    Complex solution

Raises:

  • (ArgumentError)

    Occurs when prec is not a positive integer.

  • (TypeError)

    Occurs when x is not a numeric class.

Since:

  • 0.1.0



91
92
93
94
95
# File 'ext/bigdecimal/math_r/nucomp.c', line 91

static VALUE
__impl_nucomp_quadrant(VALUE unused_obj, VALUE x, VALUE y, VALUE prec)
{
  return rb_bigmath_quadrant(x, y, prec);
}