Skip to content

Instantly share code, notes, and snippets.

@autumnharmony
Created September 10, 2011 08:58
Show Gist options
  • Save autumnharmony/1208131 to your computer and use it in GitHub Desktop.
Save autumnharmony/1208131 to your computer and use it in GitHub Desktop.
pascal complex var operations
{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