1"""
2Copyright, the CVXPY authors
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8    http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
16from cvxpy.atoms.elementwise.inv_pos import inv_pos
17from cvxpy.atoms.elementwise.power import power
18from cvxpy.atoms.geo_mean import geo_mean
19
20
21def inv_prod(value):
22    """The reciprocal of a product of the entries of a vector ``x``.
23
24    Parameters
25    ----------
26    x : Expression or numeric
27        The expression whose reciprocal product is to be computed. Must have
28        positive entries.
29
30    Returns
31    -------
32    Expression
33        .. math::
34            \\left(\\prod_{i=1}^n x_i\\right)^{-1},
35
36        where :math:`n` is the length of :math:`x`.
37    """
38    return power(inv_pos(geo_mean(value)), sum(value.shape))
39