CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::Constraint::ConstraintSolver::Row Class Reference

Public Types

using CellMap = MapType< Symbol, double >
 

Public Member Functions

 Row ()
 
 Row (const double constant)
 
 Row (const Row &other)=default
 
 ~Row ()=default
 
const CellMapgetCells () const
 
double getConstant () const
 
double add (double value)
 Add a constant value to the row constant.
 
void insert (const Symbol &symbol, double coefficient=1.0)
 Insert a symbol into the row with a given coefficient.
 
void insert (const Row &other, double coefficient=1.0)
 Insert a row into this row with a given coefficient.
 
void remove (const Symbol &symbol)
 Remove the given symbol from the row.
 
void reverseSign ()
 Reverse the sign of the constant and all cells in the row.
 
void solveFor (const Symbol &symbol)
 Solve the row for the given symbol.
 
void solveFor (const Symbol &lhs, const Symbol &rhs)
 Solve the row for the given symbols.
 
double coefficientFor (const Symbol &symbol) const
 Get the coefficient for the given symbol.
 
void substitute (const Symbol &symbol, const Row &row)
 Substitute a symbol with the data from another row.
 

Private Attributes

CellMap mCells
 
double mConstant
 

Member Typedef Documentation

◆ CellMap

Constructor & Destructor Documentation

◆ Row() [1/3]

CeresEngine::Constraint::ConstraintSolver::Row::Row ( )
inline

◆ Row() [2/3]

CeresEngine::Constraint::ConstraintSolver::Row::Row ( const double  constant)
inline

◆ Row() [3/3]

CeresEngine::Constraint::ConstraintSolver::Row::Row ( const Row other)
default

◆ ~Row()

CeresEngine::Constraint::ConstraintSolver::Row::~Row ( )
default

Member Function Documentation

◆ add()

double CeresEngine::Constraint::ConstraintSolver::Row::add ( double  value)

Add a constant value to the row constant.

The new value of the constant is returned.

◆ coefficientFor()

double CeresEngine::Constraint::ConstraintSolver::Row::coefficientFor ( const Symbol symbol) const

Get the coefficient for the given symbol.

If the symbol does not exist in the row, zero will be returned.

◆ getCells()

const CellMap & CeresEngine::Constraint::ConstraintSolver::Row::getCells ( ) const
inline

◆ getConstant()

double CeresEngine::Constraint::ConstraintSolver::Row::getConstant ( ) const
inline

◆ insert() [1/2]

void CeresEngine::Constraint::ConstraintSolver::Row::insert ( const Row other,
double  coefficient = 1.0 
)

Insert a row into this row with a given coefficient.

The constant and the cells of the other row will be multiplied by the coefficient and added to this row. Any cell with a resulting coefficient of zero will be removed from the row.

◆ insert() [2/2]

void CeresEngine::Constraint::ConstraintSolver::Row::insert ( const Symbol symbol,
double  coefficient = 1.0 
)

Insert a symbol into the row with a given coefficient.

If the symbol already exists in the row, the coefficient will be added to the existing coefficient. If the resulting coefficient is zero, the symbol will be removed from the row.

◆ remove()

void CeresEngine::Constraint::ConstraintSolver::Row::remove ( const Symbol symbol)

Remove the given symbol from the row.

◆ reverseSign()

void CeresEngine::Constraint::ConstraintSolver::Row::reverseSign ( )

Reverse the sign of the constant and all cells in the row.

◆ solveFor() [1/2]

void CeresEngine::Constraint::ConstraintSolver::Row::solveFor ( const Symbol lhs,
const Symbol rhs 
)

Solve the row for the given symbols.

This method assumes the row is of the form x = b * y + c and will solve the row such that y = x / b - c / b. The rhs symbol will be removed from the row, the lhs added, and the result divided by the negative inverse of the rhs coefficient.

The lhs symbol must not exist in the row, and the rhs symbol must exist in the row.

◆ solveFor() [2/2]

void CeresEngine::Constraint::ConstraintSolver::Row::solveFor ( const Symbol symbol)

Solve the row for the given symbol.

This method assumes the row is of the form a * x + b * y + c = 0 and (assuming solve for x) will modify the row to represent the right hand side of x = -b/a * y - c / a. The target symbol will be removed from the row, and the constant and other cells will be multiplied by the negative inverse of the target coefficient.

The given symbol must exist in the row.

◆ substitute()

void CeresEngine::Constraint::ConstraintSolver::Row::substitute ( const Symbol symbol,
const Row row 
)

Substitute a symbol with the data from another row.

Given a row of the form a * x + b and a substitution of the form x = 3 * y + c the row will be updated to reflect the expression 3 * a * y + a * c + b.

If the symbol does not exist in the row, this is a no-op.

Member Data Documentation

◆ mCells

CellMap CeresEngine::Constraint::ConstraintSolver::Row::mCells
private

◆ mConstant

double CeresEngine::Constraint::ConstraintSolver::Row::mConstant
private

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