1. -- with Ada.Text_IO; use Ada.Text_IO; 
  2. with Basic_Io;               use Basic_Io; 
  3. with Ada.Characters.Handling; 
  4. with Ada.Strings; 
  5. with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; 
  6. with Ada.Exceptions;         use Ada.Exceptions; 
  7. with Mathematics;            use Mathematics; 
  8. with LaTex;                  use LaTex; 
  9. package body Geometric_Algebra_Generic is 
  10.  
  11.    procedure Put (Value : Bit_Type); 
  12.  
  13. -------------------------------------------------------------------------------- 
  14.    function Get_Dimension return Natural is 
  15.    begin 
  16.       return Dimension; 
  17.    end Get_Dimension; 
  18. -------------------------------------------------------------------------------- 
  19.  
  20. -------------------------------------------------------------------------------- 
  21.    function Get_Max_Blade_Length return Natural is 
  22.       Length : Natural := 0; 
  23.       Result : Natural := 0; 
  24.    begin 
  25.       for i in 0 .. Dimension loop 
  26.          Result := N_over_K (Dimension, i); 
  27.          if Result > Length then 
  28.             Length := Result; 
  29.          end if; 
  30.       end loop; 
  31.       return Length; 
  32.    end Get_Max_Blade_Length; 
  33. -------------------------------------------------------------------------------- 
  34.  
  35. -------------------------------------------------------------------------------- 
  36.    function "*" 
  37.      (Left  : Canonic_Base_Element_Type; 
  38.       Right : Canonic_Base_Element_Type) return Canonic_Base_Element_Type is 
  39.       Product          : Canonic_Base_Element_Type; 
  40.       Element_Exists   : Boolean := True; 
  41.       Further_Elements : Boolean := False; 
  42.       Sub_is_Opened    : Boolean := False; 
  43.       use Ada.Strings; 
  44.       Signum_Value : Integer := 1; 
  45.    begin 
  46.       Signum_Value := Signum (Left.Base, Right.Base); 
  47.  
  48.       Product.Value := Left.Value * Right.Value * Float (Signum_Value); 
  49.  
  50.       for j in Product.Base'range loop 
  51.          Element_Exists := (Left.Base (j) /= Right.Base (j)); 
  52.          if Element_Exists then 
  53.             Product.Base (j) := 1; 
  54.          else 
  55.             Product.Base (j) := 0; 
  56.          end if; 
  57.       end loop; 
  58.  
  59.       if Signum_Value = -1 then 
  60.          Append (Product.Name, "-"); 
  61.          Append (Product.HTML_Name, "-"); 
  62.       end if; 
  63.  
  64.       for j in Product.Base'range loop 
  65.          if Product.Base (j) = 1 then 
  66.             Append 
  67.               (Product.Name, 
  68.                "e" & Trim (Source => (To_Unbounded_String (Integer'image (j))), Side => Ada.Strings.Left)); 
  69.             Append 
  70.               (Product.HTML_Name, 
  71.                "e<sub>" & Trim (Source => (To_Unbounded_String (Integer'image (j))), Side => Ada.Strings.Left)); 
  72.             Sub_is_Opened := True; 
  73.             if j = Product.Base'last then 
  74.                if Sub_is_Opened then 
  75.                   Append (Product.HTML_Name, "</sub>"); 
  76.                   Sub_is_Opened := False; 
  77.                end if; 
  78.                exit; 
  79.             end if; 
  80.  
  81.             -- Append a wedge symbole if it is not the last element 
  82.             for k in (j + 1) .. Product.Base'last loop 
  83.                if Product.Base (k) = 1 then 
  84.                   Further_Elements := True; 
  85.                   exit; 
  86.                end if; 
  87.             end loop; 
  88.  
  89.             if (Further_Elements) then 
  90.                Append (Product.Name, "^"); 
  91.                Append (Product.HTML_Name, "</sub>&and;"); 
  92.                Further_Elements := False; 
  93.                Sub_is_Opened    := False; 
  94.             else 
  95.                if Sub_is_Opened then 
  96.                   Append (Product.HTML_Name, "</sub>"); 
  97.                   Sub_is_Opened := False; 
  98.                end if; 
  99.             end if; 
  100.          end if; 
  101.          if Sub_is_Opened then 
  102.             Append (Product.HTML_Name, "</sub>"); 
  103.             Sub_is_Opened := False; 
  104.          end if; 
  105.       end loop; 
  106.  
  107.       if Product.Name = Null_Unbounded_String or Product.Name = To_Unbounded_String ("-") then 
  108.          Append (Product.Name, "1"); 
  109.          Append (Product.HTML_Name, "1"); 
  110.       end if; 
  111.  
  112.       return Product; 
  113.    exception 
  114.       when Error : others => 
  115.          Put_Line 
  116.            ("Error in function * (Left  : Canonic_Base_Element_Type; Right : Canonic_Base_Element_Type) return Canonic_Base_Element_Type"); 
  117.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  118.          raise; 
  119.    end "*"; 
  120. -------------------------------------------------------------------------------- 
  121.  
  122. -------------------------------------------------------------------------------- 
  123.    function Create_Canonic_Base return Multi_Vector_Type is 
  124.       Canonic_Base     : Multi_Vector_Type; 
  125.       Further_Elements : Boolean := False; 
  126.       Sub_is_Opened    : Boolean := False; 
  127.       Grade            : Natural := 0; 
  128.       use Ada.Strings; 
  129.    begin 
  130.       -- create the canonic base 
  131.       for I in Canonic_Base'range loop 
  132.          Canonic_Base (I).Value := 1.0; 
  133.          if I > Canonic_Base'first then 
  134.             Canonic_Base (I) := Canonic_Base (I - 1); 
  135.             Inner : 
  136.             for J in Canonic_Base (I).Base'range loop 
  137.                if (Canonic_Base (I).Base (J) = 0) then 
  138.                   Canonic_Base (I).Base (J) := 1; 
  139.                   exit Inner; 
  140.                else 
  141.                   Canonic_Base (I).Base (J) := 0; 
  142.                end if; 
  143.             end loop Inner; 
  144.          end if; 
  145.       end loop; 
  146.  
  147.       -- Define the grade of the base vector 
  148.       for I in Canonic_Base'range loop 
  149.          for j in Canonic_Base (I).Base'range loop 
  150.             if Canonic_Base (I).Base (j) = 1 then 
  151.                Grade := Grade + 1; 
  152.             end if; 
  153.          end loop; 
  154.          Canonic_Base (I).Grade := Grade; 
  155.          Grade                  := 0; 
  156.       end loop; 
  157.  
  158.       -- construct the name strings 
  159.       for I in Canonic_Base'range loop 
  160.          if I = 0 then 
  161.             Canonic_Base (I).Name       := Canonic_Base (I).Name & "1"; 
  162.             Canonic_Base (I).HTML_Name  := Canonic_Base (I).HTML_Name & "1"; 
  163.             Canonic_Base (I).Latex_Name := Canonic_Base (I).Latex_Name & "1"; 
  164.          else 
  165.             for j in Canonic_Base (I).Base'range loop 
  166.                if Canonic_Base (I).Base (j) = 1 then 
  167.                   Append 
  168.                     (Canonic_Base (I).Name, 
  169.                      "e" & Trim (Source => (To_Unbounded_String (Integer'image (j))), Side => Left)); 
  170.                   Append 
  171.                     (Canonic_Base (I).HTML_Name, 
  172.                      "e<sub>" & Trim (Source => (To_Unbounded_String (Integer'image (j))), Side => Left)); 
  173.                   Append 
  174.                     (Canonic_Base (I).Latex_Name, 
  175.                      "e_{" & Trim (Source => (To_Unbounded_String (Integer'image (j))), Side => Left)); 
  176.                   Sub_is_Opened := True; 
  177.                   if ((j = Canonic_Base (I).Base'last)) then 
  178.                      exit; 
  179.                   end if; 
  180.  
  181.                   -- Append a wedge symbole if it is not the last element 
  182.                   for k in (j + 1) .. Canonic_Base (I).Base'last loop 
  183.                      if Canonic_Base (I).Base (k) = 1 then 
  184.                         Further_Elements := True; 
  185.                         exit; 
  186.                      end if; 
  187.                   end loop; 
  188.  
  189.                   if (Further_Elements) then 
  190.                      Append (Canonic_Base (I).Name, "^"); 
  191.                      if Sub_is_Opened then 
  192.                         Append (Canonic_Base (I).HTML_Name, "</sub>&and;"); 
  193.                         Append (Canonic_Base (I).Latex_Name, "}\wedge "); 
  194.                         Sub_is_Opened := False; 
  195.                      end if; 
  196.                      Further_Elements := False; 
  197.                   else 
  198.                      if Sub_is_Opened then 
  199.                         Append (Canonic_Base (I).HTML_Name, "</sub>"); 
  200.                         Append (Canonic_Base (I).Latex_Name, "}"); 
  201.                         Sub_is_Opened := False; 
  202.                      end if; 
  203.                   end if; 
  204.                end if; 
  205.             end loop; 
  206.             if Sub_is_Opened then 
  207.                Append (Canonic_Base (I).HTML_Name, "</sub>"); 
  208.                Append (Canonic_Base (I).Latex_Name, "}"); 
  209.                Sub_is_Opened := False; 
  210.             end if; 
  211.          end if; 
  212.       end loop; 
  213.  
  214.       return Canonic_Base; 
  215.    exception 
  216.       when Error : others => 
  217.          Put_Line ("Error in function Create_Canonic_Base."); 
  218.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  219.          raise; 
  220.    end Create_Canonic_Base; 
  221. -------------------------------------------------------------------------------- 
  222.  
  223. -------------------------------------------------------------------------------- 
  224.    function Create_Zero_Multivector return Multi_Vector_Type is 
  225.       Zero_Multivector : Multi_Vector_Type; 
  226.    begin 
  227.       Zero_Multivector := Create_Canonic_Base; 
  228.       for i in Zero_Multivector'range loop 
  229.          Zero_Multivector (i).Value := 0.0; 
  230.       end loop; 
  231.       return Zero_Multivector; 
  232.    end Create_Zero_Multivector; 
  233.  
  234.    procedure Put_Multi_Vector (Value : Multi_Vector_Type) is 
  235.    begin 
  236.       for I in Value'range loop 
  237.          Put ("Element: "); 
  238.          if I < 10 then 
  239.             Put (" " & Integer'image (I) & ": "); 
  240.          else 
  241.             Put (Integer'image (I) & ": "); 
  242.          end if; 
  243.  
  244.          Put ("Value: " & Float'image (Value (I).Value)); 
  245.          Put (" Grade:" & Integer'image (Value (I).Grade) & " Base: "); 
  246.  
  247.          for j in Value (I).Base'range loop 
  248.             Put (Value (I).Base (j)); 
  249.          end loop; 
  250.          Put (" Name: " & To_String (Value (I).Name)); 
  251.          New_Line; 
  252.       end loop; 
  253.    end Put_Multi_Vector; 
  254. -------------------------------------------------------------------------------- 
  255.  
  256. -------------------------------------------------------------------------------- 
  257.    procedure Set_Element (Multi_Vector : in out Multi_Vector_Type; Element : Natural; Value : Float) is 
  258.    begin 
  259.       Multi_Vector (Element).Value := Value; 
  260.    end Set_Element; 
  261. -------------------------------------------------------------------------------- 
  262.  
  263. -------------------------------------------------------------------------------- 
  264.    procedure Put_Line (Value : Multi_Vector_Type) is 
  265.    begin 
  266.       for I in Value'range loop 
  267.          Put ("Value: " & Float'image (Value (I).Value) & " Name: " & To_String (Value (I).Name)); 
  268.          New_Line; 
  269.       end loop; 
  270.    end Put_Line; 
  271. -------------------------------------------------------------------------------- 
  272.  
  273. -------------------------------------------------------------------------------- 
  274.    function Get_Base_of_Same_Grad (Grade : Natural) return Unbounded_String is 
  275.       Base_Same_Grad : Unbounded_String  := Null_Unbounded_String; 
  276.       Canonic_Base   : Multi_Vector_Type := Create_Canonic_Base; 
  277.       First          : Boolean           := True; 
  278.    begin 
  279.       for i in Canonic_Base'range loop 
  280.          if Canonic_Base (i).Grade = Grade then 
  281.             if First then 
  282.                Append (Base_Same_Grad, Canonic_Base (i).Name); 
  283.                First := False; 
  284.             else 
  285.                Append (Base_Same_Grad, ", " & Canonic_Base (i).Name); 
  286.             end if; 
  287.          end if; 
  288.       end loop; 
  289.       return Base_Same_Grad; 
  290.    end Get_Base_of_Same_Grad; 
  291. -------------------------------------------------------------------------------- 
  292.  
  293. -------------------------------------------------------------------------------- 
  294.    function Number_of_Elements (Grade : Natural) return Natural is 
  295.       Number_of_Elements : Natural           := 0; 
  296.       Canonic_Base       : Multi_Vector_Type := Create_Canonic_Base; 
  297.       First              : Boolean           := True; 
  298.    begin 
  299.       for i in Canonic_Base'range loop 
  300.          if Canonic_Base (i).Grade = Grade then 
  301.             Number_of_Elements := Number_of_Elements + 1; 
  302.          end if; 
  303.       end loop; 
  304.       return Number_of_Elements; 
  305.    end Number_of_Elements; 
  306. -------------------------------------------------------------------------------- 
  307.  
  308. -------------------------------------------------------------------------------- 
  309.    function Prepare_Base_Name_Table_ASCII return String_Matrix_Type is 
  310.       Matrix                   : String_Matrix_Type (-1 .. Dimension, -2 .. Max_Blade_Length - 1); 
  311.       Number_of_Grade_Elements : array (0 .. Dimension) of Integer := (others => 0); 
  312.    begin 
  313.       Append (Matrix (-1, -2), "Grade"); 
  314.       Append (Matrix (-1, -1), "Elements"); 
  315.       for K in 0 .. Dimension loop 
  316.          Matrix (K, -2) := To_Unbounded_String (Integer'image (K)); 
  317.          Matrix (K, -1) := To_Unbounded_String (Integer'image (Number_of_Elements (K))); 
  318.       end loop; 
  319.       for i in Canonic_Base'first .. Canonic_Base'last loop 
  320.          Put_Line (To_String (Canonic_Base (i).Name)); 
  321.          Put_Line ("Grade:    " & Integer'image (Canonic_Base (i).Grade)); 
  322.          Matrix (Canonic_Base (i).Grade, Number_of_Grade_Elements (Canonic_Base (i).Grade)) := Canonic_Base (i).Name; 
  323.          Number_of_Grade_Elements (Canonic_Base (i).Grade) := Number_of_Grade_Elements (Canonic_Base (i).Grade) + 1; 
  324.          Put_Line ("Element:  " & Integer'image (Number_of_Grade_Elements (Canonic_Base (i).Grade))); 
  325.          New_Line; 
  326.       end loop; 
  327.       return Matrix; 
  328.  
  329.    end Prepare_Base_Name_Table_ASCII; 
  330. -------------------------------------------------------------------------------- 
  331.  
  332. -------------------------------------------------------------------------------- 
  333.    function Prepare_Base_Name_Table_HTML return String_Matrix_Type is 
  334.       Matrix                   : String_Matrix_Type (-1 .. Dimension, -2 .. Max_Blade_Length - 1); 
  335.       Number_of_Grade_Elements : array (0 .. Dimension) of Integer := (others => 0); 
  336.    begin 
  337.       Append (Matrix (-1, -2), "Grade"); 
  338.       Append (Matrix (-1, -1), "Elements"); 
  339.  
  340.       for K in 0 .. Dimension loop 
  341.          Matrix (K, -2) := To_Unbounded_String (Integer'image (K)); 
  342.          Matrix (K, -1) := To_Unbounded_String (Integer'image (Number_of_Elements (K))); 
  343.       end loop; 
  344.  
  345.       for i in Canonic_Base'first .. Canonic_Base'last loop 
  346.          Matrix (Canonic_Base (i).Grade, Number_of_Grade_Elements (Canonic_Base (i).Grade)) := 
  347.            Canonic_Base (i).HTML_Name; 
  348.          Number_of_Grade_Elements (Canonic_Base (i).Grade) := Number_of_Grade_Elements (Canonic_Base (i).Grade) + 1; 
  349.       end loop; 
  350.  
  351.       return Matrix; 
  352.    end Prepare_Base_Name_Table_HTML; 
  353. -------------------------------------------------------------------------------- 
  354.  
  355. -------------------------------------------------------------------------------- 
  356.    function Prepare_Base_Name_Table_LaTex return String_Matrix_Type is 
  357.       Matrix                   : String_Matrix_Type (-1 .. Dimension, -2 .. Max_Blade_Length - 1); 
  358.       Number_of_Grade_Elements : array (0 .. Dimension) of Integer := (others => 0); 
  359.    begin 
  360.       Append (Matrix (-1, -2), "Grade"); 
  361.       Append (Matrix (-1, -1), "Elements"); 
  362.  
  363.       for K in 0 .. Dimension loop 
  364.          Matrix (K, -2) := To_Unbounded_String (Integer'image (K)); 
  365.          Matrix (K, -1) := To_Unbounded_String (Integer'image (Number_of_Elements (K))); 
  366.       end loop; 
  367.  
  368.       for i in Canonic_Base'first .. Canonic_Base'last loop 
  369.          Matrix (Canonic_Base (i).Grade, Number_of_Grade_Elements (Canonic_Base (i).Grade)) := 
  370.            Canonic_Base (i).Latex_Name; 
  371.          Number_of_Grade_Elements (Canonic_Base (i).Grade) := Number_of_Grade_Elements (Canonic_Base (i).Grade) + 1; 
  372.       end loop; 
  373.  
  374.       return Matrix; 
  375.    end Prepare_Base_Name_Table_LaTex; 
  376. -------------------------------------------------------------------------------- 
  377.  
  378. -------------------------------------------------------------------------------- 
  379.    procedure Create_Base_Vector_Table_HTML (File_Name : String := "base_vectors_table.html") is 
  380.       Out_File      : File_Type; 
  381.       Table         : Unbounded_String   := Null_Unbounded_String; 
  382.       String_Matrix : String_Matrix_Type := Prepare_Base_Name_Table_HTML; 
  383.  
  384.       Head_Contens_Default : Unbounded_String := 
  385.         To_Unbounded_String 
  386.           ("<style type=" & 
  387.            Quotation & 
  388.            "text/css" & 
  389.            Quotation & 
  390.            ">" & 
  391.            "div, h1, h2, table, tr, td, img { margin:0px; padding:0px; }" & 
  392.            "</style>"); 
  393.    begin 
  394.       Create (File => Out_File, Name => File_Name); 
  395.       Table := HTML.Table (String_Matrix, Mark_first_Column => True); 
  396.       Put_Line (Out_File, To_String (HTML.HTML_Document (Head_Contens => Head_Contens_Default, Body_Contens => Table))); 
  397.       Close (Out_File); 
  398.    exception 
  399.       when Error : others => 
  400.          Put_Line ("Error in procedure Create_Base_Vector_Table_HTML"); 
  401.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  402.          raise; 
  403.    end Create_Base_Vector_Table_HTML; 
  404. -------------------------------------------------------------------------------- 
  405.  
  406. -------------------------------------------------------------------------------- 
  407.    function Create_Multiplikation_Table return String_Matrix_Type is 
  408.       Matrix  : String_Matrix_Type (-1 .. Base_Dimension - 1, -1 .. Base_Dimension - 1); 
  409.       Product : Canonic_Base_Element_Type; 
  410.    begin 
  411.       Put_Line ("begin Create_Multiplikation_Table"); 
  412.       for i in One'range loop 
  413.          Matrix (-1, i) := One (i).HTML_Name; 
  414.          Matrix (i, -1) := One (i).HTML_Name; 
  415.       end loop; 
  416.  
  417.       for i in One'range loop 
  418.          for j in One'range loop 
  419.             Product       := One (i) * One (j); 
  420.             Matrix (i, j) := Product.HTML_Name; 
  421.          end loop; 
  422.       end loop; 
  423.       Put_Line ("end   Create_Multiplikation_Table"); 
  424.       return Matrix; 
  425.    exception 
  426.       when Error : others => 
  427.          Put_Line ("Error in function Create_Multiplikation_Table"); 
  428.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  429.          raise; 
  430.    end Create_Multiplikation_Table; 
  431. -------------------------------------------------------------------------------- 
  432.  
  433. -------------------------------------------------------------------------------- 
  434.    function Prepare_Multiplikation_Table_Short_Form_HTML return String_Matrix_Type is 
  435.       Matrix       : String_Matrix_Type (0 .. Base_Dimension - 1, 0 .. Base_Dimension - 1); 
  436.       Product      : Canonic_Base_Element_Type; 
  437.       Element_Name : Unbounded_String := Null_Unbounded_String; 
  438.       First_Time   : Boolean          := True; 
  439.       use Ada.Strings; 
  440.    begin 
  441.       Put_Line ("begin Prepare_Multiplikation_Table_Short_Form"); 
  442.  
  443.       for i in One'range loop 
  444.          for j in One'range loop 
  445.             Product := One (i) * One (j); 
  446.             if Product.Name = "1" then 
  447.                Matrix (i, j) := To_Unbounded_String ("1"); 
  448.             elsif Product.Name = "-1" then 
  449.                Matrix (i, j) := To_Unbounded_String ("-1"); 
  450.             else 
  451.                if Product.Value < 0.0 then 
  452.                   Matrix (i, j) := To_Unbounded_String ("-"); 
  453.                else 
  454.                   Matrix (i, j) := To_Unbounded_String (" "); 
  455.                end if; 
  456.                Append (Matrix (i, j), "e<sub>"); 
  457.                for k in Product.Base'range loop 
  458.                   if Product.Base (k) = 1 then 
  459.                      Append (Matrix (i, j), Trim (Source => (To_Unbounded_String (Integer'image (k))), Side => Left)); 
  460.                   end if; 
  461.                end loop; 
  462.                Append (Matrix (i, j), "</sub>"); 
  463.             end if; 
  464.          end loop; 
  465.       end loop; 
  466.       Put_Line ("end   Prepare_Multiplikation_Table_Short_Form"); 
  467.       return Matrix; 
  468.    exception 
  469.       when Error : others => 
  470.          Put_Line ("Error in function Create_Multiplikation_Table_Short_Form"); 
  471.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  472.          raise; 
  473.    end Prepare_Multiplikation_Table_Short_Form_HTML; 
  474. -------------------------------------------------------------------------------- 
  475.  
  476. -------------------------------------------------------------------------------- 
  477.    procedure Create_Multipikation_Table_HTML (File_Name : String := "multiplication_table.html") is 
  478.       Out_File      : File_Type; 
  479.       String_Matrix : String_Matrix_Type := Create_Multiplikation_Table; 
  480.       Table         : Unbounded_String   := Null_Unbounded_String; 
  481.    begin 
  482.       Put_Line ("begin Create_Multipikation_Table_HTML"); 
  483.       Create (File => Out_File, Name => File_Name); 
  484.       Put_Line ("File opened!"); 
  485.       Table := HTML.Table (String_Matrix, Head_Line => True, Mark_first_Column => True); 
  486.       Put_Line ("HTML.Table is defined!"); 
  487.       declare 
  488.          Document : String := To_String (HTML.HTML_Document (Body_Contens => Table)); 
  489.       begin 
  490.          Put_Line ("HTML Document defined!"); 
  491.          delay 2.0; 
  492.          for j in Document'range loop 
  493.             Put (Out_File, Document (j)); 
  494.          end loop; 
  495.       exception 
  496.          when Error : others => 
  497.             Put_Line ("Error while defining HTML-Document"); 
  498.             Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  499.       end; 
  500.       Put_Line ("HTML document is written!"); 
  501.       Close (Out_File); 
  502.       Put_Line ("end   Create_Multipikation_Table_HTML"); 
  503.    exception 
  504.       when Error : others => 
  505.          Put_Line ("Error in procedure Create_Multipikation_Table_HTML"); 
  506.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  507.          raise; 
  508.    end Create_Multipikation_Table_HTML; 
  509. -------------------------------------------------------------------------------- 
  510.  
  511. -------------------------------------------------------------------------------- 
  512.    procedure Create_Multipikation_Table_HTML_Short_Form (File_Name : String := "multiplication_table_short.html") is 
  513.       Out_File      : File_Type; 
  514.       String_Matrix : String_Matrix_Type := Prepare_Multiplikation_Table_Short_Form_HTML; 
  515.       Table         : Unbounded_String   := Null_Unbounded_String; 
  516.    begin 
  517.       Put_Line ("begin Create_Multipikation_Table_HTML_Short_form"); 
  518.       Create (File => Out_File, Name => File_Name); 
  519.       Put_Line ("File opened!"); 
  520.       Table := HTML.Table (String_Matrix, Head_Line => False, Mark_first_Column => False, Text_Align => Center); 
  521.       Put_Line ("HTML.Table is defined!"); 
  522.       declare 
  523.          Document : String := To_String (HTML.HTML_Document (Body_Contens => Table)); 
  524.       begin 
  525.          Put_Line ("HTML Document defined!"); 
  526.          delay 2.0; 
  527.          for j in Document'range loop 
  528.             Put (Out_File, Document (j)); 
  529.          end loop; 
  530.       exception 
  531.          when Error : others => 
  532.             Put_Line ("Error while defining HTML-Document"); 
  533.             Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  534.       end; 
  535.       Put_Line ("HTML document is written!"); 
  536.       Close (Out_File); 
  537.       Put_Line ("end   Create_Multipikation_Table_HTML_Short_Form"); 
  538.    exception 
  539.       when Error : others => 
  540.          Put_Line ("Error in procedure Create_Multipikation_Table_HTML_Short_Form"); 
  541.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  542.          raise; 
  543.    end Create_Multipikation_Table_HTML_Short_Form; 
  544. -------------------------------------------------------------------------------- 
  545.  
  546. -------------------------------------------------------------------------------- 
  547.    procedure Create_Multiplication_Table_Latex (File_Name : String := "multiplication_table.lat") is 
  548.       Out_File      : File_Type; 
  549.       String_Matrix : String_Matrix_Type := Create_Multiplikation_Table; 
  550.       Table         : Unbounded_String   := Null_Unbounded_String; 
  551.    begin 
  552.       Put_Line ("begin Create_Multipikation_Table_Latex "); 
  553.       Create (File => Out_File, Name => File_Name); 
  554.       Table := LaTex.Table (String_Matrix); 
  555.       Put_Line (Out_File, To_String (Table)); 
  556.       Close (Out_File); 
  557.       Put_Line ("end   Create_Multipikation_Table_Latex "); 
  558.    exception 
  559.       when Error : others => 
  560.          Put_Line ("Error in procedure Create_Multiplikation_Table_LaTex"); 
  561.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  562.          raise; 
  563.    end Create_Multiplication_Table_Latex; 
  564. -------------------------------------------------------------------------------- 
  565.  
  566. -------------------------------------------------------------------------------- 
  567.    procedure Create_Multiplication_Table_Latex_Short_Form (File_Name : String := "multiplication_table.lat") is 
  568.       Out_File      : File_Type; 
  569.       String_Matrix : String_Matrix_Type := Prepare_Multiplikation_Table_Short_Form_HTML; 
  570.       Table         : Unbounded_String   := Null_Unbounded_String; 
  571.    begin 
  572.       Put_Line ("begin Create_Multiplication_Table_Latex_Short_Form"); 
  573.       Create (File => Out_File, Name => File_Name); 
  574.       Table := LaTex.Table_Short_Form (String_Matrix); 
  575.       Put_Line (Out_File, To_String (Table)); 
  576.       Close (Out_File); 
  577.       Put_Line ("end   Create_Multiplication_Table_Latex_Short_Form "); 
  578.    exception 
  579.       when Error : others => 
  580.          Put_Line ("Error in procedure Create_Multiplication_Table_LaTex_Short_Form"); 
  581.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  582.          raise; 
  583.    end Create_Multiplication_Table_Latex_Short_Form; 
  584. -------------------------------------------------------------------------------- 
  585.  
  586. -------------------------------------------------------------------------------- 
  587.    procedure Create_Base_Vector_Table_LaTex (File_Name : String := "base_vectors_table.lat"; Formular_Elements : Boolean := true) is 
  588.       Out_File      : File_Type; 
  589.       Table         : Unbounded_String   := Null_Unbounded_String; 
  590.       String_Matrix : String_Matrix_Type := Prepare_Base_Name_Table_LaTex; 
  591.    begin 
  592.       Put_Line ("begin Create_Base_Vector_Table_LaTex"); 
  593.       Create (File => Out_File, Name => File_Name); 
  594.       Table := LaTex.Table (String_Matrix, Head_Line => true, Formular_Elements => Formular_Elements); 
  595.       Put_Line (Out_File, To_String (Table)); 
  596.       Close (Out_File); 
  597.       Put_Line ("end Create_Base_Vector_Table_LaTex"); 
  598.    exception 
  599.       when Error : others => 
  600.          Put_Line ("Error in procedure Create_Base_Vector_Table_LaTex"); 
  601.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  602.          raise; 
  603.    end Create_Base_Vector_Table_LaTex; 
  604. -------------------------------------------------------------------------------- 
  605.  
  606. -------------------------------------------------------------------------------- 
  607.    procedure Put (Value : Bit_Type) is 
  608.    begin 
  609.       Put (Bit_Type'image (Value)); 
  610.    end Put; 
  611. -------------------------------------------------------------------------------- 
  612.  
  613. -------------------------------------------------------------------------------- 
  614.    function Scalar_Product (Left, Right : Vector_Type) return Float is 
  615.       Product : Float := 0.0; 
  616.    begin 
  617.       for I in Left'range loop 
  618.          Product := Product + Left (I) * Right (I); 
  619.       end loop; 
  620.       return Product; 
  621.    end Scalar_Product; 
  622. -------------------------------------------------------------------------------- 
  623.  
  624. -------------------------------------------------------------------------------- 
  625. --     function "*" (Left, Right : Vector_Type) return Multi_Vector_Type is 
  626. --        Product : Multi_Vector_Type := Zero_Multivector; 
  627. --     begin 
  628. --        Product (0).Value := Scalar_Product (Left, Right); 
  629. --        return Product; 
  630. --     end "*"; 
  631. -------------------------------------------------------------------------------- 
  632.  
  633. -------------------------------------------------------------------------------- 
  634.    function "+" (Left : Multi_Vector_Type; Right : Multi_Vector_Type) return Multi_Vector_Type is 
  635.       Sum : Multi_Vector_Type := Zero_Multivector; 
  636.    begin 
  637.       for i in Sum'range loop 
  638.          Sum (i).Value := Left (i).Value + Right (i).Value; 
  639.       end loop; 
  640.       return Sum; 
  641.    end "+"; 
  642. -------------------------------------------------------------------------------- 
  643.  
  644. -------------------------------------------------------------------------------- 
  645.    function "-" (Left : Multi_Vector_Type; Right : Multi_Vector_Type) return Multi_Vector_Type is 
  646.       Diff : Multi_Vector_Type := Zero_Multivector; 
  647.    begin 
  648.       for i in Diff'range loop 
  649.          Diff (i).Value := Left (i).Value - Right (i).Value; 
  650.       end loop; 
  651.       return Diff; 
  652.    end "-"; 
  653. -------------------------------------------------------------------------------- 
  654.  
  655. -------------------------------------------------------------------------------- 
  656.    function "*" (Left : Float; Right : Multi_Vector_Type) return Multi_Vector_Type is 
  657.       Product : Multi_Vector_Type := Zero_Multivector; 
  658.    begin 
  659.       for i in Product'range loop 
  660.          Product (i).Value := Left * Right (i).Value; 
  661.       end loop; 
  662.       return Product; 
  663.    end "*"; 
  664. -------------------------------------------------------------------------------- 
  665.  
  666. -------------------------------------------------------------------------------- 
  667.    function "*" (Left : Multi_Vector_Type; Right : Float) return Multi_Vector_Type is 
  668.       Product : Multi_Vector_Type := Zero_Multivector; 
  669.    begin 
  670.       for i in Product'range loop 
  671.          Product (i).Value := Left (i).Value * Right; 
  672.       end loop; 
  673.       return Product; 
  674.    end "*"; 
  675. -------------------------------------------------------------------------------- 
  676.  
  677. -------------------------------------------------------------------------------- 
  678.    function Signum (Left : Bit_Array_Type; Right : Bit_Array_Type) return Integer is 
  679.       Count       : Integer                 := 0; 
  680.       Max         : Integer                 := 0; 
  681.       Shifted     : Bit_Array_Type          := Right; 
  682.       Zero        : constant Bit_Array_Type := (others => 0); 
  683.       End_Reached : Boolean                 := False; 
  684.    begin 
  685.       for j in Left'range loop 
  686.          Shifted := Zero; 
  687.          for k in Shifted'range loop 
  688.             End_Reached := j + k > Left'last; 
  689.             exit when End_Reached; 
  690.             Shifted (k) := Left (k + j); 
  691.          end loop; 
  692.  
  693. --           for j in Left'range loop 
  694. --              Put (Left (j)); 
  695. --           end loop; 
  696. --           New_Line; 
  697. -- 
  698. --           for j in Shifted'range loop 
  699. --              Put (Shifted (j)); 
  700. --           end loop; 
  701. --           New_Line; 
  702.  
  703.          for K in Left'range loop 
  704.             if Right (K) = Shifted (K) and Shifted (K) = 1 then 
  705.                Count := Count + 1; 
  706.             end if; 
  707.          end loop; 
  708.       end loop; 
  709.  
  710. --      Put_Line (Integer'image (Count)); 
  711.  
  712.       if (Count mod 2) = 0 then 
  713.          return 1; 
  714.       else 
  715.          return -1; 
  716.       end if; 
  717.    exception 
  718.       when Error : others => 
  719.          Put_Line ("Error in function Signum"); 
  720.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  721.          raise; 
  722.    end Signum; 
  723. -------------------------------------------------------------------------------- 
  724.  
  725. -------------------------------------------------------------------------------- 
  726.    function "*" (Left : Multi_Vector_Type; Right : Multi_Vector_Type) return Multi_Vector_Type is 
  727.       Product : Multi_Vector_Type := Zero_Multivector; 
  728.    begin 
  729.       Put_Line ("Function not implemented!"); 
  730.       return Product; 
  731.    exception 
  732.       when Error : others => 
  733.          Put_Line 
  734.            ("Error in function: * (Left : Multi_Vector_Type; Right : Multi_Vector_Type) return Multi_Vector_Type"); 
  735.          Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error)); 
  736.          return Zero_Multivector; 
  737.    end "*"; 
  738. -------------------------------------------------------------------------------- 
  739.  
  740. -------------------------------------------------------------------------------- 
  741.    function "/" (Left : Multi_Vector_Type; Right : Multi_Vector_Type) return Multi_Vector_Type is 
  742.       Fraction : Multi_Vector_Type := Zero_Multivector; 
  743.    begin 
  744.       Put_Line ("Function not implemented!"); 
  745.       return Fraction; 
  746.    end "/"; 
  747. -------------------------------------------------------------------------------- 
  748.  
  749. -------------------------------------------------------------------------------- 
  750. end Geometric_Algebra_Generic; ------------------------------------------------- 
  751. --------------------------------------------------------------------------------