[GAP Forum] CanComputeSize

Thomas Breuer thomas.breuer at math.rwth-aachen.de
Wed Jan 18 18:07:52 GMT 2006


Dear GAP Forum,

Laurent Bartholdi wrote

> I try to understand Size(), HasSize() and CanComputeSize(). It seems very
> strange to me that
>
> gap> l := [];;
> gap> HasSize(l);
> false
> gap> CanComputeSize(l);
> false
>
> isn't there a missing method/attribute here? I would expect that all dense
> lists have these attributes set. However
>
> InstallTrueMethod(CanComputeSize,IsDenseList);
>
> doesn't change the results of the code above.
>
> My interest is that I want to display an object either by its size (if
> it exists or
> is easy to compute) or as an object by itself (in other cases).

According to the GAP Reference Manual,

- the operation `Size' is applicable to domains and lists
  (see Chapter "Collections"),

- the filter `HasSize' is `true' for an object if the `Size' value is
  known (See Section "Setter and Tester for Attributes"), and

- the filter `CanComputeSize' indicates whether it is not too complicated
  to compute the `Size' value of a domain
  (see Section "Tests for the Availability of Methods").

The term ``known'' in the second item means that it is very cheap to
get the value when `Size' is called (see Section "Attributes");
except perhaps in special cases, this means that the object actually
stores its `Size' value, and that the object lies in the filter
`IsAttributeStoringRep'; then this value has been computed using `Size'
or has been set using `SetSize'.
In principle, it would be possible to set `HasSize' to `true' for
internally represented lists; currently this is not the case.

`CanComputeSize' was not designed as a filter for lists.
Again, in principle it could be set automatically also for internally
represented lists.

The implication from `IsDenseList' to `CanComputeSize' does not work
for internally represented lists because these lists do not carry
around their individual types:
Only a small number of types is supported for these lists,
and `CanComputeSize' is not involved in these types.

Thanks to Laurent for these suggestions how to improve the behaviour
of GAP.
(I am not sure whether these rather technical questions are of general
interest for the GAP Forum.
Perhaps the address support at gap-system.org would be more appropriate.)

All the best,
Thomas




More information about the Forum mailing list