Created
September 10, 2011 08:58
-
-
Save autumnharmony/1208131 to your computer and use it in GitHub Desktop.
pascal complex var operations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{complex var operations} | |
procedure cmul(a,b:complex; var c:complex); | |
begin | |
c.x := a.x * b.x - a.y * b.y; | |
c.y := a.x * b.y + b.x * a.y; | |
end; | |
procedure csum(a,b:complex; var c:complex); | |
begin | |
c.x := a.x + b.x; | |
c.y := a.y + b.y; | |
end; | |
procedure cdiv(a,b:complex; var c:complex); | |
begin | |
c.x := (a.x*b.x + a.y*b.y) / (b.x*b.x + b.y*b.y); | |
c.y := (b.x*a.y - a.x*b.y) / (b.x*b.x + b.y*b.y); | |
end; | |
procedure csqr(a:complex; var c:complex); | |
begin | |
cmul(a,a,c); | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment