Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
27
Task/Arithmetic-Complex/Icon/arithmetic-complex-2.icon
Normal file
27
Task/Arithmetic-Complex/Icon/arithmetic-complex-2.icon
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
link complex # for complex number support
|
||||
|
||||
procedure SetupComplex() #: used to setup safe complex
|
||||
COMPLEX() # replace complex record constructor
|
||||
SetupComplex := 1 # never call here again
|
||||
return
|
||||
end
|
||||
|
||||
procedure COMPLEX(rpart,ipart) #: new safe record constructor and coercion
|
||||
initial complex :=: COMPLEX # get in front of record constructor
|
||||
return if /ipart & (type(rpart) == "complex")
|
||||
then rpart # already complex
|
||||
else COMPLEX( real(\rpart | 0.0), real(\ipart|0) ) # create a new complex number
|
||||
end
|
||||
|
||||
procedure cpxneg(z) #: negate z
|
||||
z := complex(z) # coerce
|
||||
return complex( -z.rpart, -z.ipart)
|
||||
end
|
||||
|
||||
procedure cpxinv(z) #: inverse of z
|
||||
local denom
|
||||
z := complex(z) # coerce
|
||||
|
||||
denom := z.rpart ^ 2 + z.ipart ^ 2
|
||||
return complex(z.rpart / denom, z.ipart / denom)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue