[GAP Forum] Overloading functions
Marek Mitros
marek at mitros.org
Mon Nov 19 13:29:33 GMT 2012
Dear Alexander,
I do not know how to install function ComplexConjugate for octonions.
I believe I should use "InstallMethod(..." instead of
"ComplexConjugate:=function(x)...". I below quote example for a list.
It seems advanced technique for standard GAP user :) But maybe I will
try it next time.
Regarding the ReflectionMat I discovered that I can pass parameter
"conj" which is function which conjugate matrix element. So I managed
with my original problem.
Regards,
Marek
Here is example I found in lib/cyclotom.gi
InstallMethod( ComplexConjugate,
"for a list",
[ IsList ],
function( list )
local result, i;
result:= [];
for i in [ 1 .. Length( list ) ] do
if IsBound( list[i] ) then
result[i]:= ComplexConjugate( list[i] );
fi;
od;
return result;
end );
On 11/19/12, Alexander Konovalov <alexk at mcs.st-andrews.ac.uk> wrote:
> On 11 May 2012, at 11:49, Marek Mitros wrote:
>
>> Hi,
>>
>> I tried to define ComplexConjugate function for octonions - see below.
>> In this <conj> is my function for conjugating the octonion.
>>
>> gap> ComplexConjugate:=function(o) return conj(o); end;
>> Variable: 'ComplexConjugate' is read only
>>
>> I would like to use <ReflectionMat> function which use
>> <ComplexConjugate>. Is there way in GAP to overload standard
>> <ComplexConjugate> function, so it works also for my octonions ?
>>
>> The workaround would be to copy function from lib/matrix.gi and modify
>> but it is less convenient.
>
> Dear Marek, dear Forum,
>
> I've seen that this old message in the Forum was not answered by anyone.
>
> In case this question still makes sense, then is is possible for you just
> to install a method for ComplexConjugate for octonions?
>
> ComplexConjugate is an attribute, and the GAP library already has several
> methods for ComplexConjugate installed for different kinds of objects -
> you may find examples in the files from the 'lib' directory.
>
> Hope this helps,
> Alexander
>
>
>
More information about the Forum
mailing list