#### 34.4.2 Operator Overloading ¶

The following table shows, for each built-in numerical operation, the
corresponding function name to use when providing an overloaded method for a
user class.

Operation | Method | Description |

`a + b` | `plus (a, b)` | Binary addition |

`a - b` | `minus (a, b)` | Binary subtraction |

`+a` | `uplus (a)` | Unary addition |

`-a` | `uminus (a)` | Unary subtraction |

`a .* b` | `times (a, b)` | Element-wise multiplication |

`a * b` | `mtimes (a, b)` | Matrix multiplication |

`a ./ b` | `rdivide (a, b)` | Element-wise right division |

`a / b` | `mrdivide (a, b)` | Matrix right division |

`a .\ b` | `ldivide (a, b)` | Element-wise left division |

`a \ b` | `mldivide (a, b)` | Matrix left division |

`a .^ b` | `power (a, b)` | Element-wise power |

`a ^ b` | `mpower (a, b)` | Matrix power |

`a < b` | `lt (a, b)` | Less than |

`a <= b` | `le (a, b)` | Less than or equal to |

`a > b` | `gt (a, b)` | Greater than |

`a >= b` | `ge (a, b)` | Greater than or equal to |

`a == b` | `eq (a, b)` | Equal to |

`a != b` | `ne (a, b)` | Not equal to |

`a & b` | `and (a, b)` | Logical and |

`a | b` | `or (a, b)` | Logical or |

`!a` | `not (a)` | Logical not |

`a'` | `ctranspose (a)` | Complex conjugate transpose |

`a.'` | `transpose (a)` | Transpose |

`a:b` | `colon (a, b)` | Two element range |

`a:b:c` | `colon (a, b, c)` | Three element range |

`[a, b]` | `horzcat (a, b)` | Horizontal concatenation |

`[a; b]` | `vertcat (a, b)` | Vertical concatenation |

`a(s`*_1*,…,s*_n*) | `subsref (a, s)` | Subscripted reference |

`a(s`*_1*,…,s*_n*) = b | `subsasgn (a, s, b)` | Subscripted assignment |

`b(a)` | `subsindex (a)` | Convert object to index |

`disp` | `disp (a)` | Object display |

**Table 34.1: **Available overloaded operators and their corresponding class method

An example `mtimes`

method for the polynomial class might look like

function p = mtimes (a, b)
p = polynomial (conv (double (a), double (b)));
endfunction