Arithmetic Operators
[Modules]

Facilities for addition, subtraction, multiplication, division, and other basic operations. More...

Functions

ml_matrixml_matrix::operator *= (const ml_matrix &m)
 Matrix multiplication operator.

ml_matrixml_matrix::operator *= (double a)
 Scalar multiplication operator.

ml_matrixml_matrix::dotstar_eq (const ml_matrix &m)
 Element by element multiplication, inserting the results into the original matrix.

ml_matrixml_matrix::operator/= (const ml_matrix &m)
 Matrix division operator.

ml_matrixml_matrix::operator/= (double a)
 Scalar division operator.

ml_matrixml_matrix::dotslash_eq (const ml_matrix &m)
 Element by element division, inserting the results into the original matrix.

ml_matrixml_matrix::operator+= (const ml_matrix &m)
 Matrix addition operator, adds corresponding elements.

ml_matrixml_matrix::operator+= (double a)
 Scalar addition operator.

ml_matrixml_matrix::operator-= (const ml_matrix &m)
 Matrix subtraction operator, adds corresponding elements.

ml_matrixml_matrix::operator-= (double a)
 Scalar subtraction operator.

ml_matrix operator * (double b, const ml_matrix &a)
 Scalar multiplication operator.

ml_matrix operator * (const ml_matrix &a, double b)
 Scalar multiplication operator.

ml_matrix operator * (const ml_matrix &a, const ml_matrix &b)
 Matrix multiplication operator.

ml_matrix dotstar (const ml_matrix &a, const ml_matrix &b)
 Element by element multiplication, returning the results as a new matrix.

ml_matrix operator/ (const ml_matrix &a, double b)
 Scalar division operator.

ml_matrix operator/ (const ml_matrix &a, const ml_matrix &b)
 Matrix division operator.

ml_matrix backslash (const ml_matrix &a, const ml_matrix &b)
 Backslash operator performs inverse(a) * b.

ml_matrix dotslash (const ml_matrix &a, const ml_matrix &b)
 Element by element division, returning the results as a new matrix.

ml_matrix operator+ (double b, const ml_matrix &a)
 Scalar addition operator.

ml_matrix operator+ (const ml_matrix &a, double b)
 Scalar addition operator.

ml_matrix operator+ (const ml_matrix &a, const ml_matrix &b)
 Matrix addition operator, adds corresponding elements.

ml_matrix operator- (double b, const ml_matrix &a)
 Scalar subtraction operator.

ml_matrix operator- (const ml_matrix &a, double b)
 Scalar subtraction operator.

ml_matrix operator- (const ml_matrix &a, const ml_matrix &b)
 Matrix subtraction operator, adds corresponding elements.

ml_matrix operator- (const ml_matrix &a)
 Matrix negation operator, returns the negative of each element.


Detailed Description

The standard *=, +=, -=, and /= operators are overloaded for use with matrices. Member versions of the MATLAB dotslash and dotstar operations are also provided.

Function Documentation

ml_matrix & ml_matrix::operator *= const ml_matrix m  )  [inherited]
 

Matrix multiplication operator. If one of the matrices is 1x1, the function will cast that matrix to a double and call the scalar multiplication function.

This function can return an error matrix of type ml_size_mismatch if the matrix sizes do not match for multiplication.

Parameters:
m The matrix to be multiplied
Returns:
Returns the resulting matrix. Returns the original matrix if the indices of the 2 matrices do not match for multiplication.

ml_matrix & ml_matrix::operator *= double  a  )  [inherited]
 

Scalar multiplication operator.

Parameters:
a Multiply all elements by this scalar.
Returns:
Returns the matrix

ml_matrix & ml_matrix::dotstar_eq const ml_matrix m  )  [inherited]
 

Element by element multiplication, inserting the results into the original matrix.

This function can return an error matrix of type ml_size_mismatch if the two matrices are not of matching sizes.

Parameters:
m The matrix to multiply with
Returns:
Returns the dotstar of the 2 matrices

ml_matrix & ml_matrix::operator/= const ml_matrix m  )  [inherited]
 

Matrix division operator.

Parameters:
m Divide by this matrix.
Returns:
Returns the matrix

ml_matrix & ml_matrix::operator/= double  a  )  [inherited]
 

Scalar division operator.

This function can return an error matrix of type ml_bad_operand if the specified scalar is 0.

Parameters:
a Divide all elements by this scalar.
Returns:
Returns the matrix

ml_matrix & ml_matrix::dotslash_eq const ml_matrix m  )  [inherited]
 

Element by element division.

This function can return an error matrix of type ml_size_mismatch if the two matrices are not of matching sizes.

Parameters:
m The matrix to divide by
Returns:
Returns the dotslash of the 2 matrices

ml_matrix & ml_matrix::operator+= const ml_matrix m  )  [inherited]
 

Matrix addition operator, adds corresponding elements.

This function can return an error matrix of type ml_size_mismatch if the two matrices are not of matching sizes.

Parameters:
m Add this matrix to the values in the current matrix.
Returns:
Returns the matrix or an error if the matrix dimensions do not match

ml_matrix & ml_matrix::operator+= double  a  )  [inherited]
 

Scalar addition operator.

Parameters:
a Add this scalar to all elements.
Returns:
Returns the matrix

ml_matrix & ml_matrix::operator-= const ml_matrix m  )  [inherited]
 

Matrix subtraction operator, adds corresponding elements.

This function can return an error matrix of type ml_size_mismatch if the two matrices are not of matching sizes.

Parameters:
m Subtract this matrix from the values in the current matrix.
Returns:
Returns the matrix

ml_matrix & ml_matrix::operator-= double  a  )  [inherited]
 

Scalar subtraction operator.

Parameters:
a Subtract this scalar from all elements.
Returns:
Returns the matrix

ml_matrix operator * double  a,
const ml_matrix m
 

Multiply a matrix by a double.

Parameters:
a Multiply all elements by this scalar.
m The matrix to be multiplied.
Returns:
Returns the resulting matrix, a*m.

ml_matrix operator * const ml_matrix m,
double  a
 

Multiply a matrix by a double.

Parameters:
m The matrix to be multiplied.
a Multiply all elements by this scalar.
Returns:
Returns the resulting matrix, m*a.

ml_matrix operator * const ml_matrix m,
const ml_matrix n
 

Matrix multiplication.

Parameters:
m First matrix.
n Second matrix.
Returns:
Returns the resulting matrix m*n.

ml_matrix dotstar const ml_matrix m,
const ml_matrix n
 

Element-by-element matrix multiplication. Matrices must be of the same size.

Parameters:
m The first matrix.
n The second matrix.
Returns:
Returns the resulting matrix, m.*n.

ml_matrix operator/ const ml_matrix m,
double  a
 

Scalar division.

Parameters:
m The matrix.
a Divide all elements by this scalar.
Returns:
Returns the resulting matrix, m/a.

ml_matrix operator/ const ml_matrix m,
const ml_matrix n
 

Matrix right division. Divide one matrix by another.

Parameters:
m First matrix.
n Second matrix, to be divided into m.
Returns:
Returns the resulting matrix, m/n.

ml_matrix backslash const ml_matrix m,
const ml_matrix n
 

Matrix left division. This is the same as inv(m)*n.

Parameters:
m First matrix, to be divided into n.
n Second matrix.
Returns:
Returns the resulting matrix, m
.

ml_matrix dotslash const ml_matrix m,
const ml_matrix n
 

Element-by-element matrix division. Matrices must be of the same size.

Parameters:
m The first matrix.
n The second matrix.
Returns:
Returns the resulting matrix, m./n.

ml_matrix operator+ double  a,
const ml_matrix m
 

Addition of a scalar to all elements of a matrix.

Parameters:
a Scalar to be added.
m Matrix to be added.
Returns:
Returns the result, a + m.

ml_matrix operator+ const ml_matrix m,
double  a
 

Addition of a scalar to all elements of a matrix.

Parameters:
m Matrix to be added.
a Scalar to be added.
Returns:
Returns the result, m + a.

ml_matrix operator+ const ml_matrix m,
const ml_matrix n
 

Matrix addition. Matrices must be of the same size.

Parameters:
m First matrix.
n Second matrix.
Returns:
Returns the resulting matrix, m + n.

ml_matrix operator- double  a,
const ml_matrix m
 

Subtract each element of a matrix from a scalar.

Parameters:
a Scalar to be subtracted from.
m Matrix.
Returns:
Returns the result, a - m.

ml_matrix operator- const ml_matrix m,
double  a
 

Subtraction of a scalar from all elements of a matrix.

Parameters:
m Matrix.
a Scalar to be subtracted.
Returns:
Returns the result, m - a.

ml_matrix operator- const ml_matrix m,
const ml_matrix n
 

Matrix subtraction.

Parameters:
m First matrix.
n Second matrix.
Returns:
Returns the result, m - n.

ml_matrix operator- const ml_matrix m  ) 
 

Unary operator, returns the negative of a matrix by subtracting all elements from zero.

Parameters:
m The matrix.
Returns:
Returns a matrix of the opposite sign.