Actually even with integers there need not be a problem as long as each item is cast to `double` before doing the actual computations:

    for j in range(intptr[i], indptr[i + 1]):
        xj = <double>(data[j])
        sum_ += xj * xj

etc.