Polynomials
[libbn (numerical functions)]

Collaboration diagram for Polynomials:


Files

file  poly.c

Data Structures

struct  bn_poly

Defines

#define BN_MAX_POLY_DEGREE   4
#define BN_POLY_MAGIC   0x506f4c79
#define BN_CK_POLY(_p)   BU_CKMAG(_p, BN_POLY_MAGIC, "struct bn_poly")
#define BN_POLY_NULL   ((struct bn_poly *)NULL)
#define Abs(a)   ((a) >= 0 ? (a) : -(a))
#define Max(a, b)   ((a) > (b) ? (a) : (b))
#define M_PI   3.14159265358979323846
#define PI_DIV_3   (M_PI/3.0)
#define SQRT3   1.732050808
#define THIRD   0.333333333333333333333333333
#define INV_TWENTYSEVEN   0.037037037037037037037037037
#define CUBEROOT(a)   (( (a) >= 0.0 ) ? pow( a, THIRD ) : -pow( -(a), THIRD ))

Typedefs

typedef bn_poly bn_poly_t

Functions

bn_polybn_poly_mul (struct bn_poly *product, const struct bn_poly *m1, const struct bn_poly *m2)
bn_polybn_poly_scale (struct bn_poly *eqn, double factor)
bn_polybn_poly_add (struct bn_poly *sum, const struct bn_poly *poly1, const struct bn_poly *poly2)
bn_polybn_poly_sub (struct bn_poly *diff, const struct bn_poly *poly1, const struct bn_poly *poly2)
void bn_poly_synthetic_division (struct bn_poly *quo, struct bn_poly *rem, const struct bn_poly *dvdend, const struct bn_poly *dvsor)
int bn_poly_quadratic_roots (struct bn_complex roots[], const struct bn_poly *quadrat)
int bn_poly_cubic_roots (struct bn_complex roots[], const struct bn_poly *eqn)
int bn_poly_quartic_roots (struct bn_complex roots[], const struct bn_poly *eqn)
void bn_pr_poly (const char *title, const struct bn_poly *eqn)
void bn_pr_roots (const char *title, const struct bn_complex roots[], int n)
bn_polybn_poly_mul (register struct bn_poly *product, register const struct bn_poly *m1, register const struct bn_poly *m2)
 multiply two polynomials
bn_polybn_poly_scale (register struct bn_poly *eqn, double factor)
 scale a polynomial
bn_polybn_poly_add (register struct bn_poly *sum, register const struct bn_poly *poly1, register const struct bn_poly *poly2)
 add two polynomials
bn_polybn_poly_sub (register struct bn_poly *diff, register const struct bn_poly *poly1, register const struct bn_poly *poly2)
 subtract two polynomials
void bn_poly_synthetic_division (register struct bn_poly *quo, register struct bn_poly *rem, register const struct bn_poly *dvdend, register const struct bn_poly *dvsor)
 Divides any polynomial into any other polynomial using synthetic division. Both polynomials must have real coefficients.
int bn_poly_quadratic_roots (register struct bn_complex *roots, register const struct bn_poly *quadrat)
 Uses the quadratic formula to find the roots (in `complex' form) of any quadratic equation with real coefficients.
HIDDEN void bn_catch_FPE (int sig)
int bn_poly_cubic_roots (register struct bn_complex *roots, register const struct bn_poly *eqn)
int bn_poly_quartic_roots (register struct bn_complex *roots, register const struct bn_poly *eqn)
 Uses the quartic formula to find the roots ( in `complex' form ) of any quartic equation with real coefficients.
void bn_pr_poly (const char *title, register const struct bn_poly *eqn)
void bn_pr_roots (const char *title, const struct bn_complex *roots, int n)

Define Documentation

#define BN_MAX_POLY_DEGREE   4
 

Definition at line 895 of file bn.h.

Referenced by bn_poly_mul().

#define BN_POLY_MAGIC   0x506f4c79
 

Definition at line 904 of file bn.h.

Referenced by bu_identify_magic().

#define BN_CK_POLY _p   )     BU_CKMAG(_p, BN_POLY_MAGIC, "struct bn_poly")
 

Definition at line 905 of file bn.h.

#define BN_POLY_NULL   ((struct bn_poly *)NULL)
 

Definition at line 906 of file bn.h.

Referenced by bn_poly_mul().

#define Abs  )     ((a) >= 0 ? (a) : -(a))
 

Definition at line 53 of file poly.c.

Referenced by bn_poly_add(), bn_poly_cubic_roots(), bn_poly_quartic_roots(), and bn_poly_sub().

#define Max a,
 )     ((a) > (b) ? (a) : (b))
 

Definition at line 54 of file poly.c.

#define M_PI   3.14159265358979323846
 

Definition at line 57 of file poly.c.

#define PI_DIV_3   (M_PI/3.0)
 

Definition at line 59 of file poly.c.

Referenced by bn_poly_cubic_roots().

#define SQRT3   1.732050808
 

Definition at line 275 of file poly.c.

Referenced by bn_poly_cubic_roots().

#define THIRD   0.333333333333333333333333333
 

Definition at line 276 of file poly.c.

Referenced by bn_poly_cubic_roots().

#define INV_TWENTYSEVEN   0.037037037037037037037037037
 

Definition at line 277 of file poly.c.

Referenced by bn_poly_cubic_roots().

#define CUBEROOT  )     (( (a) >= 0.0 ) ? pow( a, THIRD ) : -pow( -(a), THIRD ))
 

Definition at line 278 of file poly.c.

Referenced by bn_poly_cubic_roots().


Typedef Documentation

typedef struct bn_poly bn_poly_t
 

Polynomial data type


Function Documentation

struct bn_poly* bn_poly_mul struct bn_poly product,
const struct bn_poly m1,
const struct bn_poly m2
 

struct bn_poly* bn_poly_scale struct bn_poly eqn,
double  factor
 

struct bn_poly* bn_poly_add struct bn_poly sum,
const struct bn_poly poly1,
const struct bn_poly poly2
 

struct bn_poly* bn_poly_sub struct bn_poly diff,
const struct bn_poly poly1,
const struct bn_poly poly2
 

void bn_poly_synthetic_division struct bn_poly quo,
struct bn_poly rem,
const struct bn_poly dvdend,
const struct bn_poly dvsor
 

int bn_poly_quadratic_roots struct bn_complex  roots[],
const struct bn_poly quadrat
 

Referenced by bn_poly_quartic_roots().

int bn_poly_cubic_roots struct bn_complex  roots[],
const struct bn_poly eqn
 

Referenced by bn_poly_quartic_roots().

int bn_poly_quartic_roots struct bn_complex  roots[],
const struct bn_poly eqn
 

void bn_pr_poly const char *  title,
const struct bn_poly eqn
 

void bn_pr_roots const char *  title,
const struct bn_complex  roots[],
int  n
 

Referenced by bend_pipe_shot(), rt_eto_shot(), rt_superell_shot(), and rt_tor_shot().

struct bn_poly* bn_poly_mul register struct bn_poly product,
register const struct bn_poly m1,
register const struct bn_poly m2
 

multiply two polynomials

bn_poly_mul

Definition at line 69 of file poly.c.

References BN_MAX_POLY_DEGREE, BN_POLY_NULL, and bn_poly::dgr.

struct bn_poly* bn_poly_scale register struct bn_poly eqn,
double  factor
 

scale a polynomial

bn_poly_scale

Definition at line 123 of file poly.c.

References bn_poly::cf.

struct bn_poly* bn_poly_add register struct bn_poly sum,
register const struct bn_poly poly1,
register const struct bn_poly poly2
 

add two polynomials

bn_poly_add

Definition at line 140 of file poly.c.

References Abs, bn_poly::cf, and LOCAL.

struct bn_poly* bn_poly_sub register struct bn_poly diff,
register const struct bn_poly poly1,
register const struct bn_poly poly2
 

subtract two polynomials

bn_poly_sub

Definition at line 174 of file poly.c.

References Abs, bn_poly::cf, and LOCAL.

void bn_poly_synthetic_division register struct bn_poly quo,
register struct bn_poly rem,
register const struct bn_poly dvdend,
register const struct bn_poly dvsor
 

Divides any polynomial into any other polynomial using synthetic division. Both polynomials must have real coefficients.

s y n D i v ( )

Definition at line 210 of file poly.c.

References bn_poly::dgr.

int bn_poly_quadratic_roots register struct bn_complex roots,
register const struct bn_poly quadrat
 

Uses the quadratic formula to find the roots (in `complex' form) of any quadratic equation with real coefficients.

q u a d r a t i c ( )

Definition at line 242 of file poly.c.

References bu_log(), LOCAL, NEAR_ZERO, and SQRT_SMALL_FASTF.

Here is the call graph for this function:

HIDDEN void bn_catch_FPE int  sig  ) 
 

Definition at line 311 of file poly.c.

References bu_bomb(), bu_is_parallel(), and void().

Referenced by bn_poly_cubic_roots().

Here is the call graph for this function:

int bn_poly_cubic_roots register struct bn_complex roots,
register const struct bn_poly eqn
 

Definition at line 324 of file poly.c.

References A, Abs, bn_catch_FPE(), bu_is_parallel(), bu_log(), CUBEROOT, FAST, INV_TWENTYSEVEN, LOCAL, PI_DIV_3, SQRT3, SQRT_MAX_FASTF, THIRD, and void().

Here is the call graph for this function:

int bn_poly_quartic_roots register struct bn_complex roots,
register const struct bn_poly eqn
 

Uses the quartic formula to find the roots ( in `complex' form ) of any quartic equation with real coefficients.

B N _ P O L Y _ Q U A R T I C _ R O O T S

Returns:
1 for success

0 for fail.

Definition at line 431 of file poly.c.

References Abs, bn_poly_cubic_roots(), bn_poly_quadratic_roots(), bn_poly::cf, bn_poly::dgr, LOCAL, and Max3.

Here is the call graph for this function:

void bn_pr_poly const char *  title,
register const struct bn_poly eqn
 

B N _ P R _ P O L Y

Definition at line 509 of file poly.c.

References bu_vls_extend(), bu_vls_init(), and bu_vls_strcat().

Here is the call graph for this function:

void bn_pr_roots const char *  title,
const struct bn_complex roots,
int  n
 

Definition at line 552 of file poly.c.

References bu_log().

Here is the call graph for this function:


Generated on Mon Sep 18 01:25:24 2006 for BRL-CAD by  doxygen 1.4.6