variable.cc File Reference
#include "variable.h"
#include <fmt/format.h>
#include <math.h>
Include dependency graph for variable.cc:

Functions

std::ostream & operator<< (std::ostream &os, const Variable &var)
 
Variable operator+ (const double other, const Variable &var)
 
Variable operator- (const double other, const Variable &var)
 
Variable operator* (const double other, const Variable &var)
 
Variable operator/ (const double other, const Variable &var)
 
Variable dot_product (const std::vector< Variable > &a, const std::vector< Variable > &b)
 
Variable dot_product (const std::vector< Variable > &a, const std::vector< double > &b)
 

Function Documentation

◆ dot_product() [1/2]

Variable dot_product ( const std::vector< Variable > &  a,
const std::vector< double > &  b 
)

Calculates the dot product of a vector of variables and a vector of scalars.

Parameters
aThe vector of variables.
bThe vector of scalars.
Returns
The dot product of the two vectors.

◆ dot_product() [2/2]

Variable dot_product ( const std::vector< Variable > &  a,
const std::vector< Variable > &  b 
)

Calculates the dot product of two vectors of variables.

Parameters
aThe first vector of variables.
bThe second vector of variables.
Returns
The dot product of the two vectors.

◆ operator*()

Variable operator* ( const double  other,
const Variable var 
)

Overloads the multiplication operator to perform element-wise multiplication of a scalar and a variable.

Parameters
otherThe scalar to be multiplied.
varThe variable to be multiplied.
Returns
The result of the multiplication.

◆ operator+()

Variable operator+ ( const double  other,
const Variable var 
)

Overloads the addition operator to perform element-wise addition of a scalar and a variable.

Parameters
otherThe scalar to be added.
varThe variable to be added.
Returns
The result of the addition.

◆ operator-()

Variable operator- ( const double  other,
const Variable var 
)

Overloads the subtraction operator to perform element-wise subtraction of a scalar and a variable.

Parameters
otherThe scalar to be subtracted.
varThe variable to be subtracted.
Returns
The result of the subtraction.

◆ operator/()

Variable operator/ ( const double  other,
const Variable var 
)

Overloads the division operator to perform element-wise division of a scalar and a variable.

Parameters
otherThe scalar to be divided.
varThe variable to be divided.
Returns
The result of the division.

◆ operator<<()

std::ostream& operator<< ( std::ostream &  os,
const Variable var 
)

Overloads the stream insertion operator to print the value of the variable.

Parameters
osThe output stream.
varThe variable to be printed.
Returns
The modified output stream.