Array of objects in numpy.
Pepijn Kenter
pepijn.kenter at nospam.dlr.nl
Mon Aug 23 04:32:14 EDT 2004
David M. Cooke wrote:
> At some point, Pepijn Kenter <pepijn.kenter at nospam.dlr.nl> wrote:
>
>> Hi all.
>>
>> I'm new to python and want to use it for an assignment.
>>
>> I have succesfully implemented a galois field class including the
>> _repr__, __mul__, __div__, __add__ and __sub__ methods.
>
> including __r* variants too?
>
>> Basically a galois field is
>> an integer modulo a prime number. Now I want to make a matrix of these
>> galois field objects using the numpy library. Constructing, printing and
>> multiplying arrays of GF's works fine. However there are several
>> functions that give problems, most importantly: dot, repeat.
>>
>> I'm affraid I've forgotten my memmory stick with the code and error
>> messages :-(, so I have to keep my question general.
>
> I'm shooting in the dark here, as I presume you're using Numeric, as
> opposed to numarray.
>
>> If I recall correctly,
>> the repeat function complained that my GF object didn't have the
>> __getelem__ method implemented (IMO this should not be necessary),
>
> My guess is that you're using Numeric.repeat incorrectly. Note that for
> Numeric.repeat(a, repeats), a has to be array-like (more specifically,
> array(a) can work).
>
No, I'm using numarray.
>> the dot function complained about an unsupported type.
>
> Don't know about that one. Maybe if you haven't added __rmul__ or
> __radd__ to your class.
>
Thanks, I'll give it a try.
Pepijn.
More information about the Python-list
mailing list