Drake
RationalFunction Class Reference

Represents symbolic rational function. More...

#include <drake/common/symbolic_rational_function.h>

Public Member Functions

 RationalFunction ()
 Constructs a zero rational function 0 / 1. More...
 
 RationalFunction (const Polynomial &numerator, const Polynomial &denominator)
 Constructs the rational function: numerator / denominator. More...
 
 RationalFunction (const Polynomial &p)
 Constructs the rational function: p / 1. More...
 
 RationalFunction (double c)
 Constructs the rational function: c / 1. More...
 
 ~RationalFunction ()=default
 
const Polynomialnumerator () const
 Getter for the numerator. More...
 
const Polynomialdenominator () const
 Getter for the denominator. More...
 
RationalFunctionoperator+= (const RationalFunction &f)
 
RationalFunctionoperator+= (const Polynomial &p)
 
RationalFunctionoperator+= (double c)
 
RationalFunctionoperator-= (const RationalFunction &f)
 
RationalFunctionoperator-= (const Polynomial &p)
 
RationalFunctionoperator-= (double c)
 
RationalFunctionoperator*= (const RationalFunction &f)
 
RationalFunctionoperator*= (const Polynomial &p)
 
RationalFunctionoperator*= (double c)
 
RationalFunctionoperator/= (const RationalFunction &f)
 
RationalFunctionoperator/= (const Polynomial &p)
 
RationalFunctionoperator/= (double c)
 
bool EqualTo (const RationalFunction &f) const
 Returns true if this rational function and f are structurally equal. More...
 
Formula operator== (const RationalFunction &f) const
 Returns a symbolic formula representing the condition where this rational function and f are the same. More...
 
Formula operator!= (const RationalFunction &f) const
 Returns a symbolic formula representing the condition where this rational function and f are not the same. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 RationalFunction (const RationalFunction &)=default
 
RationalFunctionoperator= (const RationalFunction &)=default
 
 RationalFunction (RationalFunction &&)=default
 
RationalFunctionoperator= (RationalFunction &&)=default
 

Friends

std::ostream & operator<< (std::ostream &, const RationalFunction &f)
 

Detailed Description

Represents symbolic rational function.

A function f(x) is a rational function, if f(x) = p(x) / q(x), where both p(x) and q(x) are polynomials of x. Note that rational functions are closed under (+, -, x, /). One application of rational function is in polynomial optimization, where we represent (or approximate) functions using rational functions, and then convert the constraint f(x) = h(x) (where h(x) is a polynomial) to a polynomial constraint p(x) - q(x) * h(x) = 0, or convert the inequality constraint f(x) >= h(x) as p(x) - q(x) * h(x) >= 0 if we know q(x) > 0.

This class represents a special subset of the symbolic::Expression. While a symbolic::Expression can represent a rational function, extracting the numerator and denominator, generally, is quite difficult; for instance, from p1(x) / q1(x) + p2(x) / q2(x) + ... + pn(x) / qn(x). This class's explicit structure facilitates this decomposition.

Constructor & Destructor Documentation

◆ RationalFunction() [1/6]

Constructs a zero rational function 0 / 1.

◆ RationalFunction() [2/6]

RationalFunction ( const RationalFunction )
default

◆ RationalFunction() [3/6]

◆ RationalFunction() [4/6]

RationalFunction ( const Polynomial numerator,
const Polynomial denominator 
)

Constructs the rational function: numerator / denominator.

Parameters
numeratorThe numerator of the fraction.
denominatorThe denominator of the fraction.
Precondition
denominator cannot be structurally equal to 0.
None of the indeterminates in the numerator can be decision variables in the denominator; similarly none of the indeterminates in the denominator can be decision variables in the numerator.
Exceptions
std::logic_errorif the precondition is not satisfied.

◆ RationalFunction() [5/6]

RationalFunction ( const Polynomial p)
explicit

Constructs the rational function: p / 1.

Note that we use 1 as the denominator.

Parameters
pThe numerator of the rational function.

◆ RationalFunction() [6/6]

RationalFunction ( double  c)
explicit

Constructs the rational function: c / 1.

Note that we use 1 as the denominator.

Parameters
cThe numerator of the rational function.

◆ ~RationalFunction()

~RationalFunction ( )
default

Member Function Documentation

◆ denominator()

const Polynomial& denominator ( ) const
inline

Getter for the denominator.

◆ EqualTo()

bool EqualTo ( const RationalFunction f) const

Returns true if this rational function and f are structurally equal.

◆ numerator()

const Polynomial& numerator ( ) const
inline

Getter for the numerator.

◆ operator!=()

Formula operator!= ( const RationalFunction f) const

Returns a symbolic formula representing the condition where this rational function and f are not the same.

◆ operator*=() [1/3]

RationalFunction & operator*= ( const RationalFunction f)

◆ operator*=() [2/3]

RationalFunction & operator*= ( const Polynomial p)

◆ operator*=() [3/3]

RationalFunction & operator*= ( double  c)

◆ operator+=() [1/3]

RationalFunction & operator+= ( const RationalFunction f)

◆ operator+=() [2/3]

RationalFunction & operator+= ( const Polynomial p)

◆ operator+=() [3/3]

RationalFunction & operator+= ( double  c)

◆ operator-=() [1/3]

RationalFunction & operator-= ( const RationalFunction f)

◆ operator-=() [2/3]

RationalFunction & operator-= ( const Polynomial p)

◆ operator-=() [3/3]

RationalFunction & operator-= ( double  c)

◆ operator/=() [1/3]

RationalFunction & operator/= ( const RationalFunction f)

◆ operator/=() [2/3]

RationalFunction & operator/= ( const Polynomial p)

◆ operator/=() [3/3]

RationalFunction & operator/= ( double  c)

◆ operator=() [1/2]

RationalFunction& operator= ( RationalFunction &&  )
default

◆ operator=() [2/2]

RationalFunction& operator= ( const RationalFunction )
default

◆ operator==()

Formula operator== ( const RationalFunction f) const

Returns a symbolic formula representing the condition where this rational function and f are the same.

If f1 = p1 / q1, f2 = p2 / q2, then f1 == f2 <=> p1 * q2 == p2 * q1

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const RationalFunction f 
)
friend

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