コード例 #1
0
ファイル: dcp_attr.py プロジェクト: Russell91/cvxpy
    def __getitem__(self, key):
        shape = Shape(*ku.size(key, self.shape))

        neg_mat = bu.index(self.sign.neg_mat, key)
        pos_mat = bu.index(self.sign.pos_mat, key)
        cvx_mat = bu.index(self.curvature.cvx_mat, key)
        conc_mat = bu.index(self.curvature.conc_mat, key)
        constant = self.curvature.constant

        return DCPAttr(Sign(neg_mat, pos_mat),
                       Curvature(cvx_mat, conc_mat, constant), 
                       shape)
コード例 #2
0
ファイル: dcp_attr.py プロジェクト: nicaiseeric/cvxpy
    def __getitem__(self, key):
        """Determines the DCP attributes of an index/slice.

        Args:
            key: A (slice, slice) tuple.

        Returns:
            The DCPAttr of the index/slice into the matrix expression.
        """
        shape = Shape(*ku.size(key, self.shape))

        # Reduce 1x1 matrices to scalars.
        neg_mat = bu.to_scalar(bu.index(self.sign.neg_mat, key))
        pos_mat = bu.to_scalar(bu.index(self.sign.pos_mat, key))
        cvx_mat = bu.to_scalar(bu.index(self.curvature.cvx_mat, key))
        conc_mat = bu.to_scalar(bu.index(self.curvature.conc_mat, key))
        nonconst_mat = bu.to_scalar(bu.index(self.curvature.nonconst_mat, key))

        return DCPAttr(Sign(neg_mat, pos_mat), Curvature(cvx_mat, conc_mat, nonconst_mat), shape)
コード例 #3
0
ファイル: dcp_attr.py プロジェクト: r0k3/cvxpy
    def __getitem__(self, key):
        """Determines the DCP attributes of an index/slice.

        Args:
            key: A (slice, slice) tuple.

        Returns:
            The DCPAttr of the index/slice into the matrix expression.
        """
        shape = Shape(*ku.size(key, self.shape))

        # Reduce 1x1 matrices to scalars.
        neg_mat = bu.to_scalar(bu.index(self.sign.neg_mat, key))
        pos_mat = bu.to_scalar(bu.index(self.sign.pos_mat, key))
        cvx_mat = bu.to_scalar(bu.index(self.curvature.cvx_mat, key))
        conc_mat = bu.to_scalar(bu.index(self.curvature.conc_mat, key))
        nonconst_mat = bu.to_scalar(bu.index(self.curvature.nonconst_mat, key))

        return DCPAttr(Sign(neg_mat, pos_mat),
                       Curvature(cvx_mat, conc_mat, nonconst_mat), shape)