EMath++
Classes for mathematical concepts
Loading...
Searching...
No Matches
emth::Monomial Class Reference

Class for representing and operating monomials. More...

#include <emath.h>

Public Member Functions

 Monomial () noexcept
 Default constructor for when initialized with no arguments.
 
 Monomial (const double cf, const int dgr) noexcept
 Normal constructor for initialization with coeff and degree.
 
 Monomial (const Monomial &ogn) noexcept
 Copy constructor for when initialized with an lvalue Monomial object.
 
 Monomial (Monomial &&ogn) noexcept
 Move constructor for when initialized with an rvalue Monomial object.
 
Monomialoperator= (const Monomial &ogn) noexcept
 Assigment operator overload for when called with an lvalue.
 
Monomialoperator= (Monomial &&ogn) noexcept
 Move assigment operator overload for when called with an rvalue.
 
bool operator== (const Monomial &ogn) const noexcept
 Equal logic operator overload.
 
bool operator!= (const Monomial &ogn) const noexcept
 Not equal logic operator overload.
 
bool operator> (const Monomial &ogn) const noexcept
 Greater than logic operator overload.
 
bool operator< (const Monomial &ogn) const noexcept
 Less than logic operator overload.
 
bool operator>= (const Monomial &ogn) const noexcept
 Greater or equal than logic operator overload.
 
bool operator<= (const Monomial &ogn) const noexcept
 Less or equal than logic operator overload.
 
Monomial operator+ (const Monomial &ogn) const noexcept
 Addition operator overload.
 
Monomial operator- (const Monomial &ogn) const noexcept
 Substraction operator overload.
 
Monomial operator* (const Monomial &ogn) const noexcept
 Multiplication operator overload.
 
Monomial operator/ (const Monomial &ogn) const noexcept
 Division operator overload.
 
Monomial operator% (const Monomial &ogn) const noexcept
 Modulus operator overload.
 
Monomialoperator+= (const Monomial &ogn) noexcept
 Addition assigment operator overload.
 
Monomialoperator-= (const Monomial &ogn) noexcept
 Substraction assigment operator overload.
 
Monomialoperator*= (const Monomial &ogn) noexcept
 Multiplication assigment operator overload.
 
Monomialoperator/= (const Monomial &ogn) noexcept
 Division assigment operator overload.
 
Monomialoperator%= (const Monomial &ogn) noexcept
 Modulus assigment operator overload.
 
double get_coeff () const noexcept
 Getter function for getting the coefficient of the Monomial.
 
int get_degree () const noexcept
 Getter function for getting the degree of the Monomial.
 
void set_coeff (double cf) noexcept
 Setter function for setting the coefficient of the Monomial.
 
void set_degree (int dgr) noexcept
 Setter function for setting the degree of the Monomial.
 
std::string get_expression () const noexcept
 Getter function for getting the expression of the Monomial.
 
double get_value (const double &x) const noexcept
 Calculus function for getting the value of the Monomial at a point.
 
 ~Monomial ()
 The class destructor.
 

Friends

std::stringstream & operator<< (std::stringstream &ss, const Monomial &m)
 A friend operator to insert the Monomial into a std::stringstream.
 
std::ostream & operator<< (std::ostream &out, const Monomial &m)
 A friend operator to insert the Monomial into a std::ostream.
 

Detailed Description

Class for representing and operating monomials.

The class consists of the constructors, the operators, the getters, the properties and some private functions.

Definition at line 187 of file emath.h.

Constructor & Destructor Documentation

◆ Monomial() [1/4]

emth::Monomial::Monomial ( )
noexcept

Default constructor for when initialized with no arguments.

Definition at line 30 of file emath.cpp.

◆ Monomial() [2/4]

emth::Monomial::Monomial ( const double  cf,
const int  dgr 
)
noexcept

Normal constructor for initialization with coeff and degree.

Parameters
cfThe coefficient as a double.
dgrThe degree as a integer.

Definition at line 36 of file emath.cpp.

◆ Monomial() [3/4]

emth::Monomial::Monomial ( const Monomial ogn)
noexcept

Copy constructor for when initialized with an lvalue Monomial object.

Parameters
ognThe lvalue Monomial object.

Definition at line 41 of file emath.cpp.

◆ Monomial() [4/4]

emth::Monomial::Monomial ( Monomial &&  ogn)
noexcept

Move constructor for when initialized with an rvalue Monomial object.

Parameters
ognThe rvalue Monomial object.

Definition at line 46 of file emath.cpp.

Member Function Documentation

◆ get_coeff()

double emth::Monomial::get_coeff ( ) const
noexcept

Getter function for getting the coefficient of the Monomial.

Returns
(double) The coefficient of the Monomial.

Definition at line 221 of file emath.cpp.

◆ get_degree()

int emth::Monomial::get_degree ( ) const
noexcept

Getter function for getting the degree of the Monomial.

Returns
(int) The degree of the Monomial.

Definition at line 226 of file emath.cpp.

◆ get_expression()

std::string emth::Monomial::get_expression ( ) const
noexcept

Getter function for getting the expression of the Monomial.

Returns
(std::string) The expression of the Monomial.

Definition at line 241 of file emath.cpp.

◆ get_value()

double emth::Monomial::get_value ( const double &  x) const
noexcept

Calculus function for getting the value of the Monomial at a point.

Parameters
xThe point to evaluate.
Returns
(double) The result of the evaluation of the Monomial.

Definition at line 247 of file emath.cpp.

◆ operator!=()

bool emth::Monomial::operator!= ( const Monomial ogn) const
noexcept

Not equal logic operator overload.

Parameters
ognThe Monomial object to compare to.
Returns
(true) If Monomial objects coefficients and degrees dont match.
(false) If Monomial objects coefficients and degrees match.

Definition at line 72 of file emath.cpp.

◆ operator%()

emth::Monomial emth::Monomial::operator% ( const Monomial ogn) const
noexcept

Modulus operator overload.

Parameters
ognThe Monomial object to divide by.
Returns
(Monomial) A brand new Monomial that represents the result.

Definition at line 130 of file emath.cpp.

◆ operator%=()

emth::Monomial & emth::Monomial::operator%= ( const Monomial ogn)
noexcept

Modulus assigment operator overload.

Parameters
ognThe Monomial object to divide by.
Returns
(Monomial&) A reference to the lvalue of the operation.

Definition at line 182 of file emath.cpp.

◆ operator*()

emth::Monomial emth::Monomial::operator* ( const Monomial ogn) const
noexcept

Multiplication operator overload.

Parameters
ognThe Monomial object to multiply by.
Returns
(Monomial) A brand new Monomial that represents the result.

Definition at line 118 of file emath.cpp.

◆ operator*=()

emth::Monomial & emth::Monomial::operator*= ( const Monomial ogn)
noexcept

Multiplication assigment operator overload.

Parameters
ognThe Monomial object to multiply by.
Returns
(Monomial&) A reference to the lvalue of the operation.

Definition at line 160 of file emath.cpp.

◆ operator+()

emth::Monomial emth::Monomial::operator+ ( const Monomial ogn) const
noexcept

Addition operator overload.

Parameters
ognThe Monomial object to add.
Returns
(Monomial) A brand new Monomial that represents the result.

Definition at line 106 of file emath.cpp.

◆ operator+=()

emth::Monomial & emth::Monomial::operator+= ( const Monomial ogn)
noexcept

Addition assigment operator overload.

Parameters
ognThe Monomial object to add.
Returns
(Monomial&) A reference to the lvalue of the operation.

Definition at line 136 of file emath.cpp.

◆ operator-()

emth::Monomial emth::Monomial::operator- ( const Monomial ogn) const
noexcept

Substraction operator overload.

Parameters
ognThe Monomial object to substract by.
Returns
(Monomial) A brand new Monomial that represents the result.

Definition at line 112 of file emath.cpp.

◆ operator-=()

emth::Monomial & emth::Monomial::operator-= ( const Monomial ogn)
noexcept

Substraction assigment operator overload.

Parameters
ognThe Monomial object to substract by.
Returns
(Monomial&) A reference to the lvalue of the operation.

Definition at line 148 of file emath.cpp.

◆ operator/()

emth::Monomial emth::Monomial::operator/ ( const Monomial ogn) const
noexcept

Division operator overload.

Parameters
ognThe Monomial object to divide by.
Returns
(Monomial) A brand new Monomial that represents the result.

Definition at line 124 of file emath.cpp.

◆ operator/=()

emth::Monomial & emth::Monomial::operator/= ( const Monomial ogn)
noexcept

Division assigment operator overload.

Parameters
ognThe Monomial object to divide by.
Returns
(Monomial&) A reference to the lvalue of the operation.

Definition at line 170 of file emath.cpp.

◆ operator<()

bool emth::Monomial::operator< ( const Monomial ogn) const
noexcept

Less than logic operator overload.

Parameters
ognThe Monomial object to compare to.
Returns
(true) If the Monomial object degree is less than the degree of the passed Monomial.
(false) If the Monomial object degree is equal or greater than the degree of the passed Monomial.

Definition at line 86 of file emath.cpp.

◆ operator<=()

bool emth::Monomial::operator<= ( const Monomial ogn) const
noexcept

Less or equal than logic operator overload.

Parameters
ognThe Monomial object to compare to.
Returns
(true) If the Monomial object degree is less or equal than the degree of the passed Monomial.
(false) If the Monomial object degree is greater than the degree of the passed Monomial.

Definition at line 100 of file emath.cpp.

◆ operator=() [1/2]

emth::Monomial & emth::Monomial::operator= ( const Monomial ogn)
noexcept

Assigment operator overload for when called with an lvalue.

Parameters
ognThe lvalue Monomial object.
Returns
(Monomial&) A reference to the lvalue of the operation

Definition at line 52 of file emath.cpp.

◆ operator=() [2/2]

emth::Monomial & emth::Monomial::operator= ( emth::Monomial &&  ogn)
noexcept

Move assigment operator overload for when called with an rvalue.

Parameters
ognThe rvalue Monomial object.
Returns
(Monomial&) A reference to the lvalue of the operation

Definition at line 58 of file emath.cpp.

◆ operator==()

bool emth::Monomial::operator== ( const Monomial ogn) const
noexcept

Equal logic operator overload.

Parameters
ognThe Monomial object to compare to.
Returns
(true) If Monomial objects coefficients and degrees match.
(false) If Monomial objects coefficients and degrees dont match.

Definition at line 65 of file emath.cpp.

◆ operator>()

bool emth::Monomial::operator> ( const Monomial ogn) const
noexcept

Greater than logic operator overload.

Parameters
ognThe Monomial object to compare to.
Returns
(true) If the Monomial object degree is greater than the degree of the passed Monomial.
(false) If the Monomial object degree is equal or less than the degree of the passed Monomial.

Definition at line 79 of file emath.cpp.

◆ operator>=()

bool emth::Monomial::operator>= ( const Monomial ogn) const
noexcept

Greater or equal than logic operator overload.

Parameters
ognThe Monomial object to compare to.
Returns
(true) If the Monomial object degree is greater or equal than the degree of the passed Monomial.
(false) If the Monomial object degree is less than the degree of the passed Monomial.

Definition at line 93 of file emath.cpp.

◆ set_coeff()

void emth::Monomial::set_coeff ( double  cf)
noexcept

Setter function for setting the coefficient of the Monomial.

Parameters
cfThe coefficient to set to.

Definition at line 231 of file emath.cpp.

◆ set_degree()

void emth::Monomial::set_degree ( int  dgr)
noexcept

Setter function for setting the degree of the Monomial.

Parameters
dgrThe degree to set to.

Definition at line 236 of file emath.cpp.

Friends And Related Function Documentation

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream &  out,
const Monomial m 
)
friend

A friend operator to insert the Monomial into a std::ostream.

Parameters
outThe std::ostream.
mThe Monomial object to insert.
Returns
(std::ostream&) A reference to the std::ostream.

◆ operator<< [2/2]

std::stringstream & operator<< ( std::stringstream &  ss,
const Monomial m 
)
friend

A friend operator to insert the Monomial into a std::stringstream.

Parameters
ssThe std::stringstream.
mThe Monomial object to insert.
Returns
(std::stringstream&) A reference to the std::stringstream.

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