Esempio n. 1
0
 def mul(lh_sign, lh_size, rh_sign, rh_size):
     neg_mat = BoolMat.mul(lh_sign.neg_mat, lh_size, 
                           rh_sign.pos_mat, rh_size) | \
               BoolMat.mul(lh_sign.pos_mat, lh_size, 
                           rh_sign.neg_mat, rh_size)
     pos_mat = BoolMat.mul(lh_sign.neg_mat, lh_size,
                           rh_sign.neg_mat, rh_size) | \
               BoolMat.mul(lh_sign.pos_mat, lh_size,
                           rh_sign.pos_mat, rh_size)
     return Sign(neg_mat, pos_mat)
Esempio n. 2
0
 def sign_mul(sign, lh_size, curv, rh_size):
     cvx_mat = BoolMat.mul(sign.pos_mat, lh_size, 
                           curv.cvx_mat, rh_size) | \
               BoolMat.mul(sign.neg_mat, lh_size, 
                           curv.conc_mat, rh_size)
     conc_mat = BoolMat.mul(sign.pos_mat, lh_size,
                            curv.conc_mat, rh_size) | \
                BoolMat.mul(sign.neg_mat, lh_size,
                            curv.cvx_mat, rh_size)
     return Curvature(cvx_mat, conc_mat, curv.constant)
Esempio n. 3
0
def mul(lh_mat, lh_size, rh_mat, rh_size):
    if lh_mat is True:
        if lh_size == (1, 1):
            return rh_mat
        else:
            lh_mat = BoolMat.promote(lh_mat, lh_size)
    elif lh_mat is False:
        return False

    if rh_mat is True:
        if rh_size == (1, 1):
            return lh_mat
        else:
            rh_mat = BoolMat.promote(rh_mat, rh_size)
    elif rh_mat is False:
        return False

    return lh_mat * rh_mat
Esempio n. 4
0
 def promote(self, size):
     neg_mat = BoolMat.promote(self.neg_mat, size)
     pos_mat = BoolMat.promote(self.pos_mat, size)
     return Sign(neg_mat, pos_mat)
Esempio n. 5
0
 def promote(self, size):
     cvx_mat = BoolMat.promote(self.cvx_mat, size)
     conc_mat = BoolMat.promote(self.conc_mat, size)
     return Curvature(cvx_mat, conc_mat, self.constant)