因此,我得到了一个分配,以读取一个文件,将数字放入两个矩阵中,将矩阵相乘,最后将输出结果放入.txt文件中。
我以前从未使用过Ada,所以我认为这将是一个很好的挑战。我陷入试图确定两个单独的数组的界限。
这是我目前拥有的:
currentSpread := I;
g := Ada.Numerics.Generic_Complex_Elementary_Functions.Sqrt(I);
while J < g loop
if(I mod J = 0) THEN
if(currentSpread > ((I/J - J)/2)) THEN
currentSpread := ((I/J - J)/2);
arrayBounds := J;
end if;
end if;
J := J + 1;
end loop;
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是sqrt函数。我想找到矩阵乘法最佳边界的因素,这是我认为实现该矩阵的唯一方法。
我得到的错误是:
invalid prefix in selected component "Ada.Numerics.Generic_Complex_Elementary_Functions"
Run Code Online (Sandbox Code Playgroud)
非常感谢您的帮助。
-更新
完整代码要求:
with Ada.Text_IO;use Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Numerics.Generic_Complex_Elementary_Functions;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Numerics.Complex_Elementary_Functions;
with Ada.Numerics.Generic_Complex_Types;
procedure Main is
dataFile : File_Type;
resultFile : File_Type;
value : …Run Code Online (Sandbox Code Playgroud)