On 09/07/2021 13:10, Clemens Heuberger wrote:
> Hi,
>
> Am 09.07.21 um 12:00 schrieb Thierry:
>> On Fri, Jul 09, 2021 at 06:30:57AM +0200, Clemens Heuberger wrote:
>>>
>>> Is there any recommendation on how to construct "block vectors" (in
>>> analogy
>>> to `sage.matrix.special.block_matrix`) in readable way?
You might want to use itertools' chain [1] or chain.from_iterable, for
example:
sage: from itertools import chain
sage: vector(chain([1,2,3], [4,5,6]))
(1, 2, 3, 4, 5, 6)
>>>
>>> Any objections to introduce something like
>>>
>>> def block_vector(iterable):
>>> return vector(sum((tuple(v) for v in iterable), tuple()))
>>>
>>> in `sage.modules.free_module_element.pyx` or other suggestions?
It might be convenient to have such a function, but if it is part of the
public API, then I think it should play nice with block_matrix. That is,
will a user be surprised if they call it with "subdivide=True" argument,
and so on. Otherwise, maybe finding a different name or recommend using
chain as above, might be better.
>>>
>>> I am currently reviewing #21235 and such "block vectors" are constructed
>>> repeatedly to work together with block matrices.
>
> Sorry, I always mistype it for some reason. It is #21325.
>
I will try to comment there.
Regards,
TB
[1] -
https://docs.python.org/3/library/itertools.html#itertools.chain