summaryrefslogtreecommitdiff
path: root/src/complex_fixed_points.ads
diff options
context:
space:
mode:
Diffstat (limited to 'src/complex_fixed_points.ads')
-rw-r--r--src/complex_fixed_points.ads117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/complex_fixed_points.ads b/src/complex_fixed_points.ads
new file mode 100644
index 0000000..97667b1
--- /dev/null
+++ b/src/complex_fixed_points.ads
@@ -0,0 +1,117 @@
+
+generic
+ type Real is delta <> digits <>;
+package Complex_Fixed_Points is
+
+ pragma Pure (Complex_Fixed_Points);
+
+ type Complex is private;
+ type Imaginary is private;
+ pragma Preelaborable_Initialization (Imaginary);
+
+ i : constant Imaginary;
+ j : constant Imaginary;
+
+ Zero : constant Complex;
+ One : constant Complex;
+
+ function Re (X : in Complex) return Real'Base;
+ function Im (X : in Complex) return Real'Base;
+ function Im (X : in Imaginary) return Real'Base;
+
+ procedure Set_Re
+ (X : in out Complex;
+ Re : in Real'Base);
+ procedure Set_Im
+ (X : in out Complex;
+ Im : in Real'Base);
+ procedure Set_Im
+ (X : in out Imaginary;
+ Im : in Real'Base);
+
+ function Cartesian (Re, Im : in Real'Base) return Complex;
+ function Cartesian (Re : in Real'Base) return Complex;
+ function Cartesian (Im : in Imaginary) return Complex;
+
+ function Modulus (X : in Complex) return Real'Base;
+ function "abs" (Right : in Complex) return Real'Base renames Modulus;
+
+ -- Like hell am I writing fixed point trig functions right now.
+
+ -- function Argument (X : in Complex) return Real'Base;
+ -- function Argument (X : in Complex; Cycle : in Real'Base) return Real'Base;
+
+ -- function Polar (Modulus, Argument : in Real'Base) return Complex;
+ -- function Polar (Modulus, Argument, Cycle : in Real'Base) return Complex;
+
+ function "+" (Right : in Complex) return Complex;
+ function "-" (Right : in Complex) return Complex;
+ function Conjugate (X : in Complex) return Complex;
+
+ function "+" (Left, Right : in Complex) return Complex;
+ function "-" (Left, Right : in Complex) return Complex;
+ function "*" (Left, Right : in Complex) return Complex;
+ function "/" (Left, Right : in Complex) return Complex;
+
+ function "**" (Left : in Complex; Right : in Integer) return Complex;
+
+ function "+" (Right : in Imaginary) return Imaginary;
+ function "-" (Right : in Imaginary) return Imaginary;
+ function Conjugate (X : in Imaginary) return Imaginary renames "-";
+ function "abs" (Right : in Imaginary) return Real'Base;
+
+ function "+" (Left, Right : in Imaginary) return Imaginary;
+ function "-" (Left, Right : in Imaginary) return Imaginary;
+ function "*" (Left, Right : in Imaginary) return Real'Base;
+ function "/" (Left, Right : in Imaginary) return Real'Base;
+
+ function "**" (Left : in Imaginary; Right : in Integer) return Complex;
+
+ function "<" (Left, Right : in Imaginary) return Boolean;
+ function "<=" (Left, Right : in Imaginary) return Boolean;
+ function ">" (Left, Right : in Imaginary) return Boolean;
+ function ">=" (Left, Right : in Imaginary) return Boolean;
+
+ function "+" (Left : in Complex; Right : in Real'Base) return Complex;
+ function "+" (Left : in Real'Base; Right : in Complex) return Complex;
+ function "-" (Left : in Complex; Right : in Real'Base) return Complex;
+ function "-" (Left : in Real'Base; Right : in Complex) return Complex;
+ function "*" (Left : in Complex; Right : in Real'Base) return Complex;
+ function "*" (Left : in Real'Base; Right : in Complex) return Complex;
+ function "/" (Left : in Complex; Right : in Real'Base) return Complex;
+ function "/" (Left : in Real'Base; Right : in Complex) return Complex;
+
+ function "+" (Left : in Complex; Right : in Imaginary) return Complex;
+ function "+" (Left : in Imaginary; Right : in Complex) return Complex;
+ function "-" (Left : in Complex; Right : in Imaginary) return Complex;
+ function "-" (Left : in Imaginary; Right : in Complex) return Complex;
+ function "*" (Left : in Complex; Right : in Imaginary) return Complex;
+ function "*" (Left : in Imaginary; Right : in Complex) return Complex;
+ function "/" (Left : in Complex; Right : in Imaginary) return Complex;
+ function "/" (Left : in Imaginary; Right : in Complex) return Complex;
+
+ function "+" (Left : in Imaginary; Right : in Real'Base) return Complex;
+ function "+" (Left : in Real'Base; Right : in Imaginary) return Complex;
+ function "-" (Left : in Imaginary; Right : in Real'Base) return Complex;
+ function "-" (Left : in Real'Base; Right : in Imaginary) return Complex;
+ function "*" (Left : in Imaginary; Right : in Real'Base) return Imaginary;
+ function "*" (Left : in Real'Base; Right : in Imaginary) return Imaginary;
+ function "/" (Left : in Imaginary; Right : in Real'Base) return Imaginary;
+ function "/" (Left : in Real'Base; Right : in Imaginary) return Imaginary;
+
+private
+
+ type Complex is record
+ Re, Im : Real'Base;
+ end record;
+
+ type Imaginary is new Real'Base;
+
+ i : constant Imaginary := 1.0;
+ j : constant Imaginary := 1.0;
+
+ Zero : constant Complex := (Re => 0.0, Im => 0.0);
+ One : constant Complex := (Re => 1.0, Im => 0.0);
+
+end Complex_Fixed_Points;
+