Beispiel #1
0
def extract_lines(a, indices):
    " returns a[indices, :] from a matrix a (this operation is slow in numpy) "
    _check_row_float32(a)
    _check_row_int32(indices)
    n, d = a.shape
    assert indices.size == 0 or indices.min() >= 0 and indices.max() < n
    out = numpy.empty((indices.size, d), dtype=numpy.float32)
    yael.fmat_get_columns(fvec_ref(a), d, indices.size, ivec_ref(indices),
                          fvec_ref(out))

    return out
def extract_lines(a, indices):
    " returns a[indices, :] from a matrix a (this operation is slow in numpy) "
    _check_row_float32(a)
    _check_row_int32(indices)
    n, d = a.shape
    assert indices.size == 0 or indices.min() >= 0 and indices.max() < n
    out = numpy.empty((indices.size, d), dtype=numpy.float32)
    yael.fmat_get_columns(
        yael.numpy_to_fvec_ref(a), d, indices.size, yael.numpy_to_ivec_ref(indices), yael.numpy_to_fvec_ref(out)
    )

    return out