'Generate a suitable work array if one does not already exist.'

def _gen_work(self):

    n = self.data.x.shape[(-1)]
    p = self.beta0.shape[0]
    if (len(self.data.x.shape) == 2):
        m = self.data.x.shape[0]
    else:
        m = 1
    if self.model.implicit:
        q = self.data.y
    elif (len(self.data.y.shape) == 2):
        q = self.data.y.shape[0]
    else:
        q = 1
    if (self.data.we is None):
        ldwe = ld2we = 1
    elif (len(self.data.we.shape) == 3):
        (ld2we, ldwe) = self.data.we.shape[1:]
    else:
        ldwe = 1
        ld2we = self.data.we.shape[1]
    if ((self.job % 10) < 2):
        lwork = ((((((((((((18 + (11 * p)) + (p * p)) + m) + (m * m)) + ((4 * n) * q)) + ((6 * n) * m)) + (((2 * n) * q) * p)) + (((2 * n) * q) * m)) + (q * q)) + (5 * q)) + (q * (p + m))) + ((ldwe * ld2we) * q))
    else:
        lwork = ((((((((((18 + (11 * p)) + (p * p)) + m) + (m * m)) + ((4 * n) * q)) + ((2 * n) * m)) + (((2 * n) * q) * p)) + (5 * q)) + (q * (p + m))) + ((ldwe * ld2we) * q))
    if (isinstance(self.work, numpy.ndarray) and (self.work.shape == (lwork,)) and self.work.dtype.str.endswith('f8')):
        return
    else:
        self.work = numpy.zeros((lwork,), float)
