def readvec(fid, ilen=None, keyword='vec'):
    """
    vec, olen = readvec(fid, ilen=None)
    Read a vector of values from a ascii (norms) file, return it and its size <olen>. 
    If provided, <ilen> is the expected size, raise an error if mismatched.
    """
    tokens = fid.readline().split()
    assert tokens[0] == keyword
    olen = int(tokens[1])
    if ilen != None:
        assert olen == ilen
    return ([float(fid.readline()) for i in range(olen)], 
            olen)