From 84567e2deaac89283c5c99ee08f80a1861d00ebc Mon Sep 17 00:00:00 2001 From: lfainsin Date: Wed, 16 Dec 2020 20:43:17 +0000 Subject: [PATCH] more fixes git-svn-id: http://cregut.svn.enseeiht.fr/2020/1sn/pim/projets/GH-05@209146 e13453a9-b01f-0410-a051-f404c4f0c485 --- src/google_naive.adb | 15 ++++++++------- src/google_naive.ads | 7 +++++-- src/{pageRank.adb => pagerank.adb} | 5 ++--- 3 files changed, 15 insertions(+), 12 deletions(-) rename src/{pageRank.adb => pagerank.adb} (97%) diff --git a/src/google_naive.adb b/src/google_naive.adb index 26f4ca3..1c836b5 100644 --- a/src/google_naive.adb +++ b/src/google_naive.adb @@ -1,3 +1,5 @@ +with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; + package body Google_Naive is function "*"(left : T_Vecteur; right : T_Google) return T_Vecteur is @@ -21,7 +23,7 @@ package body Google_Naive is initialize(mat); for i in 0..N-1 loop for j in 0..N-1 loop - mat(i,j) := T_Element(left)*right(i,j); + mat(i,j) := left*right(i,j); end loop; end loop; return mat; @@ -33,7 +35,7 @@ package body Google_Naive is initialize(mat); for i in 0..N-1 loop for j in 0..N-1 loop - mat(i,j) := left(i,j)/T_Element(right); + mat(i,j) := left(i,j)/right; end loop; end loop; return mat; @@ -110,7 +112,7 @@ package body Google_Naive is end loop; else -- sum == 0 for j in 0..N-1 loop - mat(i,j) := 1.0 / T_Element(N); + mat(i,j) := 1.0/T_Element(N); end loop; end if; end loop; @@ -124,7 +126,7 @@ package body Google_Naive is procedure put(vec: in T_Vecteur) is begin for i in 0..N-1 loop - put(Float(vec(i))); new_line; + put(vec(i)); new_line; end loop; end put; @@ -132,7 +134,7 @@ package body Google_Naive is begin for i in 0..N-1 loop for j in 0..N-1 loop - put(Float(mat(i,j))); + put(mat(i,j)); end loop; new_line; end loop; @@ -141,7 +143,7 @@ package body Google_Naive is procedure put(file: in out Ada.Text_IO.File_Type; vec: in T_Vecteur) is begin for i in 0..N-1 loop - put(file, Float(vec(i))); + put(file, vec(i)); new_line(file); end loop; end put; @@ -176,5 +178,4 @@ package body Google_Naive is end loop; end sort_with_index_desc; - end Google_Naive; diff --git a/src/google_naive.ads b/src/google_naive.ads index b979cfe..cc8a2f7 100644 --- a/src/google_naive.ads +++ b/src/google_naive.ads @@ -1,6 +1,4 @@ with Ada.Text_IO; use Ada.Text_IO; -with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; -with Ada.Float_Text_IO; use Ada.Float_Text_IO; generic @@ -9,6 +7,11 @@ generic package Google_Naive is + -- on permet l'affichage direct des T_Element + package Text_T_Element is + new Ada.Text_IO.Float_IO(Num => T_Element); + use Text_T_Element; + type T_Google is private; type T_Vecteur is private; diff --git a/src/pageRank.adb b/src/pagerank.adb similarity index 97% rename from src/pageRank.adb rename to src/pagerank.adb index c0d8bd4..8880c5b 100644 --- a/src/pageRank.adb +++ b/src/pagerank.adb @@ -84,8 +84,7 @@ procedure pageRank is new Google_Naive(T_Element => T_Double, N => N); use Google; - procedure algorithm_naif(N: in Positive; - file: in out Ada.Text_IO.File_Type; + procedure algorithm_naif(file: in out Ada.Text_IO.File_Type; alpha: in T_Double; ite_max: in Natural; pi: out T_Vecteur) is @@ -149,7 +148,7 @@ procedure pageRank is begin if naif then - algorithm_naif(N, file, alpha, ite_max, pi); + algorithm_naif(file, alpha, ite_max, pi); else --algorithm_creux(N, file, alpha, ite_max, pi); put_line("TODO");