Example #1
0
 def __mul__(self, other):
     shape = self.shape * other.shape
     sign = Sign.mul(self.sign, self.shape.size,
                     other.sign, other.shape.size)
     curvature = Curvature.sign_mul(self.sign, self.shape.size,
                                    other.curvature, other.shape.size)
     return DCPAttr(sign, curvature, shape)
Example #2
0
    def __mul__(self, other):
        """Determines the DCP attributes of two expressions multiplied together.

        Assumes one of the arguments has constant curvature.

        Args:
            self: The DCPAttr of the left-hand expression.
            other: The DCPAttr of the right-hand expression.

        Returns:
            The DCPAttr of the product.
        """
        shape = self.shape * other.shape
        sign = self.sign * other.sign
        if self.curvature.is_constant():
            curvature = Curvature.sign_mul(self.sign, other.curvature)
        else:
            curvature = Curvature.sign_mul(other.sign, self.curvature)
        return DCPAttr(sign, curvature, shape)
Example #3
0
    def __mul__(self, other):
        """Determines the DCP attributes of two expressions multiplied together.

        Assumes one of the arguments has constant curvature.

        Args:
            self: The DCPAttr of the left-hand expression.
            other: The DCPAttr of the right-hand expression.

        Returns:
            The DCPAttr of the product.
        """
        shape = self.shape * other.shape
        sign = self.sign * other.sign
        if self.curvature.is_constant():
            curvature = Curvature.sign_mul(self.sign, other.curvature)
        else:
            curvature = Curvature.sign_mul(other.sign, self.curvature)
        return DCPAttr(sign, curvature, shape)
Example #4
0
    def mul_elemwise(lh_expr, rh_expr):
        """Determines the DCP attributes of expressions multiplied elementwise.

        Assumes the left-hand argument has constant curvature and both
        arguments have the same shape.

        Args:
            lh_expr: The DCPAttr of the left-hand expression.
            rh_expr: The DCPAttr of the right-hand expression.

        Returns:
            The DCPAttr of the product.
        """
        shape = lh_expr.shape + rh_expr.shape
        sign = lh_expr.sign * rh_expr.sign
        curvature = Curvature.sign_mul(lh_expr.sign, rh_expr.curvature)
        return DCPAttr(sign, curvature, shape)
Example #5
0
    def mul_elemwise(lh_expr, rh_expr):
        """Determines the DCP attributes of expressions multiplied elementwise.

        Assumes the left-hand argument has constant curvature and both
        arguments have the same shape.

        Args:
            lh_expr: The DCPAttr of the left-hand expression.
            rh_expr: The DCPAttr of the right-hand expression.

        Returns:
            The DCPAttr of the product.
        """
        shape = lh_expr.shape + rh_expr.shape
        sign = lh_expr.sign * rh_expr.sign
        curvature = Curvature.sign_mul(lh_expr.sign, rh_expr.curvature)
        return DCPAttr(sign, curvature, shape)
Example #6
0
    def __mul__(self, other):
        """Determines the DCP attributes of two expressions multiplied together.

        Assumes one of the arguments has constant curvature.

        Args:
            self: The DCPAttr of the left-hand expression.
            other: The DCPAttr of the right-hand expression.

        Returns:
            The DCPAttr of the product.
        """
        shape = self.shape * other.shape
        lh_sign = self.sign.promote(*self.shape.size)
        rh_sign = other.sign.promote(*other.shape.size)
        sign = lh_sign * rh_sign
        rh_curvature = other.curvature.promote(*other.shape.size)
        curvature = Curvature.sign_mul(lh_sign, rh_curvature)
        return DCPAttr(sign, curvature, shape)
Example #7
0
    def __mul__(self, other):
        """Determines the DCP attributes of two expressions multiplied together.

        Assumes one of the arguments has constant curvature.

        Args:
            self: The DCPAttr of the left-hand expression.
            other: The DCPAttr of the right-hand expression.

        Returns:
            The DCPAttr of the product.
        """
        shape = self.shape * other.shape
        lh_sign = self.sign.promote(*self.shape.size)
        rh_sign = other.sign.promote(*other.shape.size)
        sign = lh_sign * rh_sign
        rh_curvature = other.curvature.promote(*other.shape.size)
        curvature = Curvature.sign_mul(lh_sign, rh_curvature)
        return DCPAttr(sign, curvature, shape)