Expression numerical C reference

These private reducers and scalar kernels implement the expression adapters. They are not installed C API entry points. See Expression reductions and scalar kernels for sample selection, formulas, ownership and compatibility caveats.

Scalar kernel arguments are copied values, while reducers borrow a live real or complex internal vector. Neither form acquires vector ownership. Parameter contracts state the input interpretation; the surrounding adapters control error and finite-value handling. See Expression parser and adapter internals and C calling conventions.

Reducers document selected versus full-length input explicitly. Numeric return values, Tcl statuses and output-pointer writes have different failure contracts; see Expression reductions and scalar kernels before reusing a helper outside its adapter.

group Expression numerical kernels

Private reductions and scalar kernels used by the expression adapters.

Functions

static double Random(double value)

Draw one real random value, ignoring the input value.

Delegates to Rbc_RandomDouble and advances its random state. Invocation count is controlled by the component adapter; this helper does not seed or create an independent generator.

Parameters:
  • value – [in] Ignored real input; the shared random state advances. The scalar is passed by value; no vector storage or ownership is transferred.

static Rbc_Complex ComplexRandom(Rbc_Complex value)

Draw independent real and imaginary random components.

Ignores the supplied pair and calls Rbc_RandomDouble twice in real-then-imaginary order. Uses the shared random helper, not a vector-owned generator.

Parameters:
  • value – [in] Ignored complex input; the shared random state advances twice. The scalar is passed by value; no vector storage or ownership is transferred.

static double Mean(Rbc_Vector *vecPtr)

Compute the real mean over finite selected values.

Uses First/Next and ordinary double summation. Divides by the finite count; no finite values produce a nonfinite result rejected by expression evaluation. Does not modify storage or selection.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject passed through its Rbc_Vector prefix, with valid inclusive first/last bounds. Storage and selection remain unchanged.

Returns:

Arithmetic mean, nonfinite when no finite sample exists.

static double Sum(Rbc_Vector *vecPtr)

Sum finite real values in the selected interval.

Starts at zero and accumulates in storage order without compensation. Empty or entirely nonfinite selections return zero. No allocation, notification or Tcl evaluation.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject passed through its Rbc_Vector prefix, with valid inclusive first/last bounds. Storage and selection remain unchanged.

Returns:

Sum, or zero when no finite sample exists.

static double Product(Rbc_Vector *vecPtr)

Multiply finite real values in the selected interval.

Starts at one; empty or entirely nonfinite selections return one. Ordinary multiplication can overflow or underflow; final validation belongs to the adapter/evaluator.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject passed through its Rbc_Vector prefix, with valid inclusive first/last bounds. Storage and selection remain unchanged.

Returns:

Product, or one when no finite sample exists.

static int Sort(VectorObject *vPtr)

Sort the selected real interval through an index permutation.

Selections of at most one value are unchanged. Allocates an index array and a temporary value array, copies sorted values back only after allocation succeeds, then frees both arrays. Returns TCL_ERROR on size/allocation failure. Intended for detached expression storage; sends no notifications.

Parameters:
  • vPtr – [inout] Caller-owned detached real temporary with a valid inclusive first/last interval. Only selected values are rearranged.

Returns:

TCL_OK after sorting or for at most one selected value; TCL_ERROR on size/allocation failure, with values unchanged.

static double Length(Rbc_Vector *vecPtr)

Count finite real values in the selected interval.

Returns the count as double, not allocated capacity or unfiltered vector length. Uses First/Next and does not mutate the record.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject passed through its Rbc_Vector prefix, with valid inclusive first/last bounds. Storage and selection remain unchanged.

Returns:

Finite selected sample count as a double.

static double Median(Rbc_Vector *vecPtr)

Return the real middle order statistic without rearranging data.

Allocates a sort index and frees it before returning. Uses full vector length to choose one middle value or the average of two; requires the selected interval to cover the full vector, as expression copies normally do. Empty input or sort-index failure returns the finite sentinel -DBL_MAX rather than a Tcl status.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject with selection covering its entire used length. The sort index is temporary; source values are not rearranged.

Returns:

Median, or -DBL_MAX for empty input or sort-index allocation failure; this sentinel is finite.

static double Variance(Rbc_Vector *vecPtr)

Compute real sample variance over finite selected values.

Computes Mean first, then sums squared deviations and divides by count-1. Fewer than two finite samples return zero. Uses ordinary double arithmetic without compensated summation or overflow scaling.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject passed through its Rbc_Vector prefix, with valid inclusive first/last bounds. Storage and selection remain unchanged.

Returns:

Sample variance, or zero for fewer than two finite samples.

static double Skew(Rbc_Vector *vecPtr)

Compute the legacy absolute standardized third moment.

Accumulates absolute cubed deviations and divides by count times sample variance to the power 3/2. Fewer than two finite samples return zero; constant samples of length at least two yield a nonfinite division. This is not conventional signed skewness; symmetry does not generally give zero.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject passed through its Rbc_Vector prefix, with valid inclusive first/last bounds. Storage and selection remain unchanged.

Returns:

Legacy absolute standardized third moment; constant samples may yield a nonfinite result.

static double Skewness(Rbc_Vector *vecPtr)

Compute signed skewness using population central moments.

Uses finite selected real samples and returns m3/(m2*sqrt(m2)), where mk=sum((x-mean)^k)/count. This is the unadjusted moment coefficient, not a bias-corrected sample estimator. Scales inputs by their maximum magnitude before accumulation to avoid overflow/underflow from cubing raw values. Returns NaN for empty or constant input; final expression validation reports a domain error. Does not modify storage or change the legacy Skew formula.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject passed through its Rbc_Vector prefix, with valid inclusive first/last bounds. Storage and selection remain unchanged.

Returns:

Signed population-moment skewness, or NaN for fewer than two samples or zero variance.

static double StdDeviation(Rbc_Vector *vecPtr)

Return the square root of positive real sample variance.

Delegates to Variance. Returns zero when variance is not greater than zero, including a NaN comparison; does not independently propagate a Tcl status.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject passed through its Rbc_Vector prefix, with valid inclusive first/last bounds. Storage and selection remain unchanged.

Returns:

Square root of positive variance, otherwise zero.

static double AvgDeviation(Rbc_Vector *vecPtr)

Compute mean absolute real deviation from the finite-sample mean.

Uses finite selected values, divides by their count, and returns zero for fewer than two. Does not use sample count-1 normalization.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject passed through its Rbc_Vector prefix, with valid inclusive first/last bounds. Storage and selection remain unchanged.

Returns:

Mean absolute deviation, or zero for fewer than two finite samples.

static double Kurtosis(Rbc_Vector *vecPtr)

Compute the legacy fourth-moment excess statistic.

Uses finite selected values and sample variance. Returns sum of fourth powers divided by count*variance*variance, minus three. Returns zero for fewer than two samples or zero variance. This is not a bias-corrected estimator and is not population-moment normalization.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject passed through its Rbc_Vector prefix, with valid inclusive first/last bounds. Storage and selection remain unchanged.

Returns:

Legacy excess statistic, or zero for fewer than two finite samples or zero variance.

static double Q1(Rbc_Vector *vecPtr)

Return the legacy lower quartile from a sorted index.

Empty input or index allocation failure returns -DBL_MAX. Lengths below four select the minimum. Otherwise mid=(length-1)/2 and q=mid/2; odd mid selects q, even mid averages q and q+1. Requires a full-length selection. Frees the index without rearranging source data.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject with selection covering its entire used length. The sort index is temporary; source values are not rearranged.

Returns:

Legacy lower quartile, or -DBL_MAX for empty input or sort-index allocation failure; this sentinel is finite.

static double Q3(Rbc_Vector *vecPtr)

Return the legacy upper quartile from a sorted index.

Empty input or index allocation failure returns -DBL_MAX. Lengths below four select the maximum. Otherwise mid=(length-1)/2 and q=mid+(length-mid)/2; odd mid selects q, even mid averages q and q+1. Requires a full-length selection. These are legacy index rules, not a selectable percentile convention.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject with selection covering its entire used length. The sort index is temporary; source values are not rearranged.

Returns:

Legacy upper quartile, or -DBL_MAX for empty input or sort-index allocation failure; this sentinel is finite.

static int Norm(Rbc_Vector *vecPtr)

Normalize every real value using full-vector finite extrema.

Computes min/max, then writes (value-min)/(max-min) in place over the full length. Has no zero-range guard: constant nonempty input produces nonfinite values rejected later by the expression evaluator. Returns TCL_OK after the loop and does not notify; operates on detached expression storage.

Parameters:
  • vecPtr – [inout] Caller-owned detached real VectorObject passed through its Rbc_Vector prefix. Rewrites all used values and refreshes extrema while computing the range.

Returns:

TCL_OK after normalization; this status does not imply finite output for a zero range.

static double Nonzeros(Rbc_Vector *vecPtr)

Count nonzero finite real values in the selected interval.

Uses exact comparison with zero, so both signed zeros are excluded. Returns a double count; no tolerance or magnitude threshold is applied.

Parameters:
  • vecPtr – [in] Borrowed real RBC VectorObject passed through its Rbc_Vector prefix, with valid inclusive first/last bounds. Storage and selection remain unchanged.

Returns:

Count of finite selected samples unequal to zero, as a double.

static double Identity(double value)

Return a real component unchanged.

Used by real branches of component adapters. Does not validate finiteness or normalize signed zero.

Parameters:
  • value – [in] Real component returned unchanged. The scalar is passed by value; no vector storage or ownership is transferred.

static double Zero(double value)

Return real zero regardless of the input.

Supplies the imaginary-part adapter for real input. Finite-input iteration belongs to the enclosing adapter.

Parameters:
  • value – [in] Ignored real component. The scalar is passed by value; no vector storage or ownership is transferred.

static double Arg(double value)

Return the phase of a real value in radians.

Uses atan2 with positive zero as the imaginary argument. Branch and signed-zero behavior follow that libm call, rather than a hand-coded sign test.

Parameters:
  • value – [in] Real component whose phase is requested. The scalar is passed by value; no vector storage or ownership is transferred.

static double ComplexAbs(Rbc_Complex value)

Return a complex value’s Euclidean magnitude.

Uses hypot to avoid unnecessary overflow in intermediate squares. The magnitude itself can exceed the finite double range.

Parameters:
  • value – [in] Complex value whose magnitude is requested. The scalar is passed by value; no vector storage or ownership is transferred.

static double ComplexArg(Rbc_Complex value)

Return complex phase in radians.

Uses atan2(imag, real), including its branch and signed-zero behavior. Does not alter the value or report a Tcl status.

Parameters:
  • value – [in] Complex value whose phase is requested. The scalar is passed by value; no vector storage or ownership is transferred.

static double ComplexReal(Rbc_Complex value)

Extract the real component.

Returns the stored double directly; validation is the adapter’s responsibility.

Parameters:
  • value – [in] Complex value whose real component is copied. The scalar is passed by value; no vector storage or ownership is transferred.

static double ComplexImag(Rbc_Complex value)

Extract the imaginary component.

Returns the stored double directly; validation is the adapter’s responsibility.

Parameters:
  • value – [in] Complex value whose imaginary component is copied. The scalar is passed by value; no vector storage or ownership is transferred.

static Rbc_Complex ComplexConj(Rbc_Complex value)

Return the complex conjugate.

Negates only the imaginary component, including its sign bit for zero. Does not allocate or validate the pair.

Parameters:
  • value – [in] Complex value to conjugate. The scalar is passed by value; no vector storage or ownership is transferred.

static Rbc_Complex ComplexSqrt(Rbc_Complex value)

Compute the square-root branch with nonnegative real part.

Returns complex zero unchanged. Scales very large components before hypot/2 to avoid avoidable overflow. For negative real input, imaginary sign uses imag<0, so negative zero takes the same branch as positive zero. The adapter checks errno and finite components; this is not a full C99 signed-zero branch guarantee.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Square root on the implemented branch. The caller validates errno and component finiteness; no Tcl status is returned.

static Rbc_Complex ComplexExp(Rbc_Complex value)

Compute exp(real) times the unit complex phase.

Uses exp(real), cos(imag) and sin(imag). Can overflow or underflow; the component adapter owns errno and finite-result checks.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Complex exponential. The caller validates errno and component finiteness; no Tcl status is returned.

static double LogHypot(double x, double y)

Compute log of a magnitude without first forming that magnitude.

For finite inputs, factors out the larger absolute component and uses log(max)+log(1+ratio*ratio)/2. Both zero calls log(0), preserving libm error behavior. Does not clear errno or set Tcl errors.

Parameters:
  • x – [in] First real component of the magnitude.

  • y – [in] Second real component of the magnitude.

Returns:

Logarithmic magnitude; two zero components invoke log(0), leaving error handling to the caller.

static Rbc_Complex ComplexLog(Rbc_Complex value)

Return logarithmic magnitude and principal atan2 phase.

Uses LogHypot for the real part and atan2(imag, real) for the imaginary part. Zero input is singular; the adapter reports its libm/nonfinite failure.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Logarithmic magnitude plus imaginary principal phase. The caller validates errno and component finiteness; no Tcl status is returned.

static Rbc_Complex ComplexLog10(Rbc_Complex value)

Scale the complex natural logarithm to base ten.

Multiplies both components by 1/ln(10), retaining the same phase branch and zero singularity as ComplexLog.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Complex logarithm divided by ln(10). The caller validates errno and component finiteness; no Tcl status is returned.

static Rbc_Complex ComplexSin(Rbc_Complex value)

Compute complex sine using real trigonometric and hyperbolic functions.

Returns sin(x)*cosh(y) + i*cos(x)*sinh(y). Intermediate hyperbolic overflow is not scaled away; caller validates errno and result components.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Complex sine. The caller validates errno and component finiteness; no Tcl status is returned.

static Rbc_Complex ComplexCos(Rbc_Complex value)

Compute complex cosine from real trigonometric/hyperbolic functions.

Returns cos(x)*cosh(y) - i*sin(x)*sinh(y). Does not independently handle overflow or report a Tcl error.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Complex cosine. The caller validates errno and component finiteness; no Tcl status is returned.

static Rbc_Complex ComplexSinh(Rbc_Complex value)

Compute complex hyperbolic sine.

Returns sinh(x)*cos(y) + i*cosh(x)*sin(y). Caller owns errno and finite-result validation.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Complex hyperbolic sine. The caller validates errno and component finiteness; no Tcl status is returned.

static Rbc_Complex ComplexCosh(Rbc_Complex value)

Compute complex hyperbolic cosine.

Returns cosh(x)*cos(y) + i*sinh(x)*sin(y). Caller owns errno and finite-result validation.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Complex hyperbolic cosine. The caller validates errno and component finiteness; no Tcl status is returned.

static Rbc_Complex ComplexTan(Rbc_Complex value)

Compute complex tangent using a decaying exponential formulation.

On the real axis delegates to tan and preserves imaginary zero. Otherwise uses exp(-2*abs(imag)) and a denominator arranged to reduce cancellation near poles. For abs(imag)>350 sets the exponential term to zero to avoid irrelevant underflow errno. Does not suppress true singular or nonfinite results.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Complex tangent. The caller validates errno and component finiteness; no Tcl status is returned.

static Rbc_Complex ComplexTanh(Rbc_Complex value)

Compute complex hyperbolic tangent with scaled exponential terms.

On the imaginary axis uses i*tan(imag) and preserves real zero. Otherwise uses exp(-2*abs(real)), setting it to zero above 350, with a cancellation-reduced denominator. Caller checks singularities/nonfinite results.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Complex hyperbolic tangent. The caller validates errno and component finiteness; no Tcl status is returned.

static double RealAcosh(double value)

Compute real acosh for an argument at least one.

Uses log(value+sqrt(value-1)*sqrt(value+1)); above DBL_MAX/2 uses log(value)+ln(2). Does not validate its domain; ComplexAsin clamps its argument before calling.

Parameters:
  • value – [in] Real scalar at least one; the caller establishes the domain.

Returns:

Real inverse hyperbolic cosine; no independent domain or finite-output check is performed.

static Rbc_Complex ComplexAsin(Rbc_Complex value)

Compute an inverse-sine branch from distances to plus/minus one.

Forms alpha as two half magnitudes to avoid adding them before division. Clamps alpha to at least one and beta=real/alpha into [-1,1], then combines asin(beta) and signed acosh(alpha). Uses copysign for imaginary sign. Individual magnitudes can still overflow for extreme finite inputs.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Inverse sine on the implemented branch. The caller validates errno and component finiteness; no Tcl status is returned.

static Rbc_Complex ComplexAcos(Rbc_Complex value)

Compute inverse cosine from the inverse-sine branch.

Returns pi/2 minus the real part of ComplexAsin and negates its imaginary part. Inherits that helper’s numerical limits and branch behavior.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Inverse cosine derived from ComplexAsin. The caller validates errno and component finiteness; no Tcl status is returned.

static Rbc_Complex ComplexAtan(Rbc_Complex value)

Compute complex inverse tangent with scaled angle and logarithmic distances.

Scales the quadratic terms used by atan2 and uses LogHypot for distances to plus/minus i. Returns half the angle and half the log-distance difference. Poles at plus/minus i remain singular; caller validates errno and finite components.

Parameters:
  • value – [in] Complex scalar passed by value; no vector or Tcl-object ownership is transferred.

Returns:

Inverse tangent on the implemented branch. The caller validates errno and component finiteness; no Tcl status is returned.

static int ComplexPower(Tcl_Interp *interp, Rbc_Complex base, Rbc_Complex exponent, Rbc_Complex *resultPtr)

Compute complex powers with a separate integral-exponent path.

Finite real integer exponents use exponentiation by squaring with the exponent kept as double. Zero exponent returns one, including zero-to-zero; negative powers of zero fail. For zero base, positive nonintegral real powers return zero and finite nonreal exponents fail. Other cases use exp(exponent*Log(base)). Returns Tcl status; successful computation can still be nonfinite and requires outer validation.

Parameters:
  • interp – [in] Diagnostic interpreter; see Interpreter arguments.

  • base – [in] Complex base passed by value.

  • exponent – [in] Complex exponent passed by value; finite integral real exponents use the separate squaring path.

  • resultPtr – [out] Non-NULL caller-owned result storage, written on TCL_OK and left unchanged on TCL_ERROR. Success does not guarantee finite components.

Returns:

TCL_OK after computation, or TCL_ERROR with a diagnostic for an unsupported power of zero.

static Rbc_Complex ComplexSum(VectorObject *vPtr)

Sum selected complex values having two finite components.

Starts at 0+0i and skips the entire sample if either component is nonfinite. Uses ordinary complex addition in storage order; empty input returns complex zero.

Parameters:
  • vPtr – [in] Borrowed complex vector with valid inclusive first/last bounds. Samples with either component nonfinite are skipped; storage and selection remain unchanged.

Returns:

Complex sum, or 0+0i when no sample qualifies.

static Rbc_Complex ComplexMean(VectorObject *vPtr)

Compute the componentwise mean of finite complex samples.

Both components must be finite for a sample to count. Divides real and imaginary sums by the same selected sample count. No finite samples return NaN in both components; the evaluator rejects that result.

Parameters:
  • vPtr – [in] Borrowed complex vector with valid inclusive first/last bounds. Samples with either component nonfinite are skipped; storage and selection remain unchanged.

Returns:

Componentwise mean, or a pair of NaNs when no sample qualifies.

static Rbc_Complex ComplexProduct(VectorObject *vPtr)

Multiply selected finite complex samples.

Starts at 1+0i and skips samples with either component nonfinite. Empty input returns complex one. Uses Rbc_ComplexMul; does not promise overflow-free accumulation.

Parameters:
  • vPtr – [in] Borrowed complex vector with valid inclusive first/last bounds. Samples with either component nonfinite are skipped; storage and selection remain unchanged.

Returns:

Complex product, or 1+0i when no sample qualifies.

static double ComplexLength(VectorObject *vPtr)

Count selected complex samples with both components finite.

Returns a double count. A sample with only one finite component is excluded entirely; this is not raw vector length.

Parameters:
  • vPtr – [in] Borrowed complex vector with valid inclusive first/last bounds. Samples with either component nonfinite are skipped; storage and selection remain unchanged.

Returns:

Qualifying sample count as a real double.

static double ComplexNonzeros(VectorObject *vPtr)

Count finite selected complex samples other than complex zero.

A sample counts when both components are finite and at least one is nonzero. No tolerance is used.

Parameters:
  • vPtr – [in] Borrowed complex vector with valid inclusive first/last bounds. Samples with either component nonfinite are skipped; storage and selection remain unchanged.

Returns:

Number of qualifying samples with either component nonzero, as a real double.

static Rbc_Complex ComplexCeil(Rbc_Complex value)

Apply ceil independently to both complex components.

Does not round magnitude or phase. The adapter validates errno and finite results.

Parameters:
  • value – [in] Complex value to round upward componentwise. The scalar is passed by value; no vector storage or ownership is transferred.

static Rbc_Complex ComplexFloor(Rbc_Complex value)

Apply floor independently to both complex components.

Does not round magnitude or phase. The adapter validates errno and finite results.

Parameters:
  • value – [in] Complex value to round downward componentwise. The scalar is passed by value; no vector storage or ownership is transferred.

static Rbc_Complex ComplexRound(Rbc_Complex value)

Round both components halfway away from zero.

Delegates each component to Round. Does not change a complex temporary into real storage.

Parameters:
  • value – [in] Complex value to round componentwise. The scalar is passed by value; no vector storage or ownership is transferred.

static double ComplexAvgDeviation(VectorObject *vPtr)

Compute mean complex-plane distance from the sample mean.

Uses hypot(realDiff, imagDiff) for each finite selected sample and divides by count. Returns real zero for fewer than two finite samples. Does not compute independent real/imaginary deviations.

Parameters:
  • vPtr – [in] Borrowed complex vector with valid inclusive first/last bounds. Samples with either component nonfinite are skipped; storage and selection remain unchanged.

Returns:

Mean complex-plane distance, or zero for fewer than two qualifying samples.

static double ComplexVariance(VectorObject *vPtr)

Compute real sample variance from squared complex magnitudes.

Computes the complex mean, accumulates hypot(realDiff, imagDiff) squared and divides by count-1. Returns zero for fewer than two finite samples. This is squared-magnitude variance, not the possibly complex mean of squared deviations; squaring can still overflow.

Parameters:
  • vPtr – [in] Borrowed complex vector with valid inclusive first/last bounds. Samples with either component nonfinite are skipped; storage and selection remain unchanged.

Returns:

Real squared-magnitude sample variance, or zero for fewer than two qualifying samples.

static double ComplexStdDeviation(VectorObject *vPtr)

Return the square root of positive complex sample variance.

Returns a real scalar. Delegates to ComplexVariance and returns zero when variance is not greater than zero; does not separately diagnose a nonfinite intermediate.

Parameters:
  • vPtr – [in] Borrowed complex vector with valid inclusive first/last bounds. Samples with either component nonfinite are skipped; storage and selection remain unchanged.

Returns:

Square root of positive squared-magnitude variance, otherwise zero.

static double Fabs(double value)

Return the legacy sign-test absolute value.

Negates values strictly below zero and otherwise returns the original value. Unlike fabs, negative zero retains its sign.

Parameters:
  • value – [in] Real scalar tested against zero; negative zero is preserved.

Returns:

Negated input when strictly negative, otherwise the unchanged input.

static double Round(double value)

Round a real value halfway away from zero as a double.

Uses ceil(value-0.5) for negative values and floor(value+0.5) otherwise. Performs no integer conversion or independent finite check.

Parameters:
  • value – [in] Real scalar to round without narrowing to an integer type.

Returns:

Rounded double using the implemented half-away-from-zero formula; the caller checks finiteness.

double Rbc_VecMin(Rbc_Vector *vecPtr)

Scan the full real vector for its finite minimum.

Requires real storage and a live record. Ignores first/last selection and nonfinite values, stores the result in the min cache and returns it. Empty or entirely nonfinite input returns NaN. Does not update extrema indices, clear cache-invalid flags, allocate storage or send notifications.

Parameters:
  • vecPtr – [inout] Borrowed live real vector; reads its complete value array and overwrites the corresponding extrema cache.

double Rbc_VecMax(Rbc_Vector *vecPtr)

Scan the full real vector for its finite maximum.

Requires real storage and a live record. Ignores first/last selection and nonfinite values, stores the result in the max cache and returns it. Empty or entirely nonfinite input returns NaN. Does not update extrema indices, clear cache-invalid flags, allocate storage or send notifications.

Parameters:
  • vecPtr – [inout] Borrowed live real vector; reads its complete value array and overwrites the corresponding extrema cache.