# Library of functions¶

In the library folder a set of commonly used functions and linear operators is provided that can be used to formulate problems (see also How to use ForBES). Each of these functions is provided as a constructor taking as input all the parameters that define the function, and returning an object: this will contain all the information needed to compute the value, the gradient or the proximal mapping of the correspondent function or its conjugate.

You can access the help file of each of these function directly from MATLAB with:

```
help <function-name>
```

## Distances¶

Name | Description |
---|---|

`distBall_l2` |
Distance from a Euclidean ball |

`distBox` |
Distance from a box |

`distPos` |
Distance from the nonnegative orthant |

`distNeg` |
Distance from the nonpositive orthant |

`dist2Ball_l2` |
Squared distance from a Euclidean ball |

`dist2Box` |
Squared distance from a box |

`dist2Pos` |
Squared distance from the nonnegative orthant |

`dist2Neg` |
Squared distance from the nonpositive orthant |

## Indicator functions¶

Name | Description |
---|---|

`indZero` |
Indicator of the singleton set containing the origin |

`indBall_l0` |
Indicator of an L0 pseudo-norm ball |

`indBall_l2` |
Indicator of a Euclidean ball |

`indBox` |
Indicator of a box |

`indPos` |
Inticator of the nonnegative orthant |

`indNeg` |
Indicator of the nonpositive orthant |

`indRankBall` |
Indicator of the set of matrices with given rank |

`indBin` |
Indicator function of a binary set |

## Norms and regularization functions¶

Name | Description |
---|---|

`l0Norm` |
L0 pseudo-norm |

`l1Norm` |
L1 norm (sum of the absolute values) |

`l2Norm` |
Euclidean norm |

`l2NormSum` |
Sum of Euclidean norms of variable blocks |

`nuclearNorm` |
Nuclear norm (sum of the singular values) |

`elasticNet` |
Elastic-net regularization function |

## Other functions¶

Name | Description |
---|---|

`quadratic` |
Quadratic function with given Hessian and linear term |

`quadraticOverAffine` |
Quadratic function subject to linear equality constraints |

`quadLoss` |
Squared weighted Euclidean distance from a given vector |

`quadLossOverAffine` |
Squared weighted Euclidean distance subject to linear equalities |

`logLoss` |
Logistic loss function (used in logistic regression models for classification) |

`huberLoss` |
Huber loss function (for robust least-squares regression) |

`hingeLoss` |
Hinge loss function (used for example in SVM) |

`matFac` |
Squared Frobenius norm of a matrix factorization residual |

## Linear operators¶

Linear operators composing the objective or the constraints can either be MATLAB’s matrices (dense or sparse) or constructed using the functions here listed. Additionally, operators from the comprehensive Spot toolbox can be readily used in defining problems, as they override standard MATLAB notation for handling matrices.

Name | Description |
---|---|

`linOp` |
Constructs an operator given a linear map and its adjoint in the form of anonymous functions |

`hankelOp` |
Operator computing the Hankel matrix of a given size associated with a vector |