NeoPZ
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TPZPolynomial Class Reference

Implements a polynomial. Utility. More...

#include <pzpolynomial.h>

Collaboration diagram for TPZPolynomial:
[legend]

Public Member Functions

 TPZPolynomial ()
 Default constructor. More...
 
 TPZPolynomial (const TPZVec< REAL > &coef, const REAL &tol)
 Constructor based on coef as coefficients and tol as tolerance value. More...
 
 TPZPolynomial (const TPZVec< REAL > &coef)
 Constructor based on coef as coefficients. More...
 
void SetTolerance (const REAL &tol)
 Sets the tolerance value to computes. More...
 
void GetTolerance (REAL &tol)
 Gets the tolerance value. More...
 
void SetCoef (const REAL &c0, const REAL &c1, const REAL &c2, const REAL &c3)
 Sets up four coefficients to polynomial. More...
 
void SetCoef (const TPZVec< REAL > &coef)
 Sets the coefficients of the polynomial. More...
 
int GetRoots (const TPZVec< REAL > &coef, TPZVec< REAL > &r)
 On given coefficients computes the roots of the polynomial in r. More...
 
int GetRoots (TPZVec< REAL > &r)
 Computes the roots of the polynomial in r. More...
 
int Tartaglia (const TPZVec< REAL > &coef, TPZVec< REAL > &real, REAL &imagem)
 Computes the roots of the cubic polynomial using Tartaglia method (until 3 degree) More...
 

Private Member Functions

int SetRoots ()
 Computes the roots of the polynomial and stores into the fReal. More...
 

Private Attributes

REAL fTolerance
 Tolerance value to computes. More...
 
TPZVec< REAL > fCo
 Polynomial coefficients. More...
 
TPZVec< REAL > fReal
 Roots of the polynomial. More...
 
REAL fImagem
 

Detailed Description

Implements a polynomial. Utility.

Definition at line 19 of file pzpolynomial.h.

Constructor & Destructor Documentation

◆ TPZPolynomial() [1/3]

TPZPolynomial::TPZPolynomial ( )

Default constructor.

Definition at line 281 of file pzpolynomial.cpp.

◆ TPZPolynomial() [2/3]

TPZPolynomial::TPZPolynomial ( const TPZVec< REAL > &  coef,
const REAL &  tol 
)

Constructor based on coef as coefficients and tol as tolerance value.

Definition at line 265 of file pzpolynomial.cpp.

References SetCoef(), and SetTolerance().

◆ TPZPolynomial() [3/3]

TPZPolynomial::TPZPolynomial ( const TPZVec< REAL > &  coef)

Constructor based on coef as coefficients.

Definition at line 276 of file pzpolynomial.cpp.

References SetCoef().

Member Function Documentation

◆ GetRoots() [1/2]

int TPZPolynomial::GetRoots ( const TPZVec< REAL > &  coef,
TPZVec< REAL > &  r 
)

On given coefficients computes the roots of the polynomial in r.

On given coefficients computes the roots of the polynomial in r, being $ r[0] >> r[1] >> r[2]. $

Definition at line 162 of file pzpolynomial.cpp.

◆ GetRoots() [2/2]

int TPZPolynomial::GetRoots ( TPZVec< REAL > &  r)

Computes the roots of the polynomial in r.

Computes the roots of the polynomial in r, being $ r[0] >> r[1] >> r[2] $

Definition at line 150 of file pzpolynomial.cpp.

◆ GetTolerance()

void TPZPolynomial::GetTolerance ( REAL &  tol)

Gets the tolerance value.

Definition at line 271 of file pzpolynomial.cpp.

References fTolerance.

◆ SetCoef() [1/2]

void TPZPolynomial::SetCoef ( const REAL &  c0,
const REAL &  c1,
const REAL &  c2,
const REAL &  c3 
)

Sets up four coefficients to polynomial.

Sets up four coefficients to polynomial into the fCo. $ fCo[3]x \geq + fCo[2]x \leq + fCo[1]x + fCo[0] = 0.0 $

Definition at line 120 of file pzpolynomial.cpp.

References fabs, and pztopology::SetTolerance().

Referenced by TPZPolynomial().

◆ SetCoef() [2/2]

void TPZPolynomial::SetCoef ( const TPZVec< REAL > &  coef)

Sets the coefficients of the polynomial.

Store the given coefficients into fCo. $ fCo[3]x \geq + fCo[2]x \leq + fCo[1]x + fCo[0] = 0.0 $

Definition at line 137 of file pzpolynomial.cpp.

References fabs, and pztopology::SetTolerance().

◆ SetRoots()

int TPZPolynomial::SetRoots ( )
private

Computes the roots of the polynomial and stores into the fReal.

Sets the roots of the polynomial in r, being $ fReal[0] >> fReal[1] >> fReal[2]. $

Calculo das outras duas raizes (X[1] e X[2]) b3*x² + b2*x + b1 = 0

Definition at line 169 of file pzpolynomial.cpp.

References fabs, sqrt, teste, and pzgeom::tol.

◆ SetTolerance()

void TPZPolynomial::SetTolerance ( const REAL &  tol)

Sets the tolerance value to computes.

Definition at line 260 of file pzpolynomial.cpp.

References pzgeom::tol.

Referenced by TPZPolynomial().

◆ Tartaglia()

int TPZPolynomial::Tartaglia ( const TPZVec< REAL > &  coef,
TPZVec< REAL > &  raiz,
REAL &  imagem 
)

Computes the roots of the cubic polynomial using Tartaglia method (until 3 degree)

Computes the polynomial roots using Tartaglia method. Returns 0 whether the polynomial is less than third degree.
Returns 1 if the equation has three distinct real roots. Returns 2 if it has three real roots but two of them are same.
Returns -1 if the equation has one real root and two conjudated complex roots.

Definition at line 20 of file pzpolynomial.cpp.

References acos, cos(), fabs, pow(), and sqrt.

Member Data Documentation

◆ fCo

TPZVec<REAL> TPZPolynomial::fCo
private

Polynomial coefficients.

Definition at line 59 of file pzpolynomial.h.

◆ fImagem

REAL TPZPolynomial::fImagem
private

Definition at line 63 of file pzpolynomial.h.

◆ fReal

TPZVec<REAL> TPZPolynomial::fReal
private

Roots of the polynomial.

Definition at line 62 of file pzpolynomial.h.

◆ fTolerance

REAL TPZPolynomial::fTolerance
private

Tolerance value to computes.

Definition at line 56 of file pzpolynomial.h.

Referenced by GetTolerance().


The documentation for this class was generated from the following files: