text stringlengths 0 234 |
|---|
if To_string(chaine)(position_virgule) = '.' then |
virgule_trouvee := True; |
end if; |
position_virgule := position_virgule + 1 ; |
end loop ; |
position_virgule := position_virgule -1; -- la sortie du while se fait avec position + 1 |
-- Extraire la partie entière du nombre |
for i in 1..position_virgule-1 loop |
chaine_partie_entiere := chaine_partie_entiere & To_string(chaine)(i) ; |
end loop; |
-- Convertir la partie entière en T_Element |
partie_entiere := To_Integer(chaine_partie_entiere); |
-- Extraire la partie décimale |
chaine_partie_decimal := To_Unbounded_String(To_String(chaine)(position_virgule+1..Taille_chaine)); |
taille_partie_decimal := Length(chaine_partie_decimal); |
-- Convertir la partie décimale |
if taille_partie_decimal <= 8 then -- cette condition est due au fait que les réels <= 10⁸en ADA |
partie_decimal:= T_Element(To_Integer(chaine_partie_decimal)); |
partie_decimal := partie_decimal*T_Element(puissance_10(taille_partie_decimal)); |
else |
-- Découper la partie décimale en deux pour convertir des entiers de plus de 8 digits ! |
partie_decimal := T_Element(To_Integer(To_Unbounded_String(To_String(chaine_partie_decimal)(1..8)))); |
partie_decimal := partie_decimal*T_Element(puissance_10(8)); -- partie "gauche" |
partie_decimal := partie_decimal + T_Element(To_Integer(To_Unbounded_String(To_String(chaine_partie_decimal)(9..taille_partie_decimal))))*T_Element(puissance_10(taille_partie_decimal)); |
end if; |
return partie_decimal + T_Element(partie_entiere); |
end if; |
end To_reel; |
procedure Integer_or_reel( chaine : in Unbounded_String; reel : out T_Element; |
entier : out Integer; indicateur : out Character) is |
begin |
entier:= -1; |
-- Déterminer si c'est un réel |
begin |
reel := To_reel(chaine); |
indicateur := 'f'; |
exception |
when Bad_Type_Conversion_Error|CONSTRAINT_ERROR => -- le constraint error apparait si on cherche la virgule dans un réel ! |
-- Déterminer si c'est un entier |
begin |
entier := To_Integer(chaine); |
indicateur := 'i'; |
exception |
-- Déterminer si c'est autre choses |
when Bad_Type_Conversion_Error =>indicateur := 'o'; |
Function Definition: procedure pagerank is |
Function Body: type T_precision is digits 6; -- type réel des coefficients |
taille_tableau : constant Integer := 10000; -- à adapter selon l'exemple testé ! |
-- Import de tous les paquets nécessaires |
package Real_IO is new Ada.Text_IO.Float_IO(T_precision); use Real_IO; -- pour afficher les coeffs |
package vecteur is new Google_Naive(nombre_max_ligne => 1 , -- pour stocker et traiter PI |
nombre_max_colonne => taille_tableau, |
T_Element => T_precision); |
package tri is new Tri_par_tas(1,taille_tableau ,T_precision,vecteur); -- pour trier |
package recup is new Recuperation_Argument(T_alpha => T_precision); -- pour récupérer les arguments de la ligne de commande |
-- Procédures utiles pour le debugage et l'affichage des matrices |
--procedure Afficher_element (nombre : T_precision ) is |
--begin |
-- Put(nombre,1,16); |
--end Afficher_element; |
-- Nom : Creer_vect_occurrence |
-- Semantique : Construire le vecteur avec les occurences de chaque noeud |
-- Paramètres : |
-- noeuds_occurence : out matrice_pleine.T_Google_Naive; -- vecteur occurence |
-- N : in Integer; -- nombre de noeuds |
-- fichier_net : in Ada.Text_IO.File_Type; -- objet fichier pas le nom |
-- Pre : True; |
-- Post : trop complexe pour être exprimée; |
-- Tests |
-- Entrée : Sujet; Sortie : [2,0,3,2,2,1] |
-- Exception : Aucune |
procedure Creer_vect_occurence(noeuds_occurence : out vecteur.T_Google_Naive; |
N : in Integer; |
fichier_net : in Ada.Text_IO.File_Type ) is |
entier : Integer; -- coefficient sur la première colonne d'un fichier .net |
useless : Integer; -- coefficient sur la deuxième colonne d'un fichier .net |
ancien_coefficient : T_precision; -- occurence à incrémenter |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.