debut du module googlenaive
git-svn-id: http://cregut.svn.enseeiht.fr/2020/1sn/pim/projets/GH-05@207225 e13453a9-b01f-0410-a051-f404c4f0c485
This commit is contained in:
parent
2b20817839
commit
05d2d4dddf
|
@ -1,5 +1,108 @@
|
||||||
package body googleNaive is
|
package body googleNaive is
|
||||||
|
|
||||||
-- TODO
|
function "*"(left, right: T_Google) return T_Google is
|
||||||
|
M : T_Google;
|
||||||
|
n, m, o: Positive;
|
||||||
|
Compteur : Integer;
|
||||||
|
begin
|
||||||
|
n:=left.dimension(0);
|
||||||
|
m:=right.dimension(1);
|
||||||
|
o :=left.dimension(1);
|
||||||
|
initialize(M,n,m);
|
||||||
|
for i in 0..n loop
|
||||||
|
for j in 0..m loop
|
||||||
|
Compteur:=0;
|
||||||
|
for l in 0..o loop
|
||||||
|
Compteur:= Compteur + left.matrix(i,l)*right.matrix(l,j);
|
||||||
|
end loop;
|
||||||
|
M.matrix(i,j):=Compteur;
|
||||||
|
end loop;
|
||||||
|
end loop;
|
||||||
|
return M;
|
||||||
|
end "*";
|
||||||
|
|
||||||
end googleNaive;
|
function "+"(left, right: T_Google) return T_Google is
|
||||||
|
n, m : Positive;
|
||||||
|
M : T_Google;
|
||||||
|
begin
|
||||||
|
n := left.dimension(0);
|
||||||
|
m := left.dimension(1);
|
||||||
|
initialize(M,n,m);
|
||||||
|
for i in 0..n loop
|
||||||
|
for j in 0..m loop
|
||||||
|
M(i,j):=left.matrix(i,j) + right.matrix(i,j);
|
||||||
|
end loop;
|
||||||
|
end loop;
|
||||||
|
return M;
|
||||||
|
end "+";
|
||||||
|
|
||||||
|
function "*"(left: T_Google; right: Integer) return T_Google is
|
||||||
|
n, m : Positive;
|
||||||
|
M : T_Google;
|
||||||
|
begin
|
||||||
|
n := left.dimension(0);
|
||||||
|
m := left.dimension(1);
|
||||||
|
initialize(M,n,m);
|
||||||
|
for i in 0..n loop
|
||||||
|
for j in 0..m loop
|
||||||
|
M(i,j):=right*left.matrix(i,j);
|
||||||
|
end loop;
|
||||||
|
end loop;
|
||||||
|
return M;
|
||||||
|
end "*";
|
||||||
|
|
||||||
|
function "/"(left: T_Google; right: Integer) return T_Google is
|
||||||
|
n, m : Positive;
|
||||||
|
M : T_Google;
|
||||||
|
begin
|
||||||
|
n := left.dimension(0);
|
||||||
|
m := left.dimension(1);
|
||||||
|
initialize(M,n,m);
|
||||||
|
for i in 0..n loop
|
||||||
|
for j in 0..m loop
|
||||||
|
M(i,j):=left.matrix(i,j)/right;
|
||||||
|
end loop;
|
||||||
|
end loop;
|
||||||
|
return M;
|
||||||
|
end "/";
|
||||||
|
|
||||||
|
function zeros(rows, cols: in Positive) return T_Google is
|
||||||
|
M : T_Google;
|
||||||
|
begin
|
||||||
|
initialize(M,rows,cols);
|
||||||
|
for i in 1..cows loop
|
||||||
|
for j in 1..cols loop
|
||||||
|
M(i,j):=0;
|
||||||
|
end loop;
|
||||||
|
end loop;
|
||||||
|
end zeros;
|
||||||
|
|
||||||
|
function ones(rows, cols: in Positive) return T_Google is
|
||||||
|
M : T_Google;
|
||||||
|
begin
|
||||||
|
initialize(M,rows,cols);
|
||||||
|
for i in 1..cows loop
|
||||||
|
for j in 1..cols loop
|
||||||
|
M(i,j):=1;
|
||||||
|
end loop;
|
||||||
|
end loop;
|
||||||
|
end ones;
|
||||||
|
|
||||||
|
procedure insert(mat: in out T_Google; i, j: Natural; elm: T_Element) is
|
||||||
|
begin
|
||||||
|
mat.matrix(i,j):=elm;
|
||||||
|
end insert;
|
||||||
|
|
||||||
|
procedure initialize(mat: out T_Google; rows, cols : Positive ) is
|
||||||
|
|
||||||
|
begin
|
||||||
|
mat.dimension(0):=rows;
|
||||||
|
mat.dimension(1):=cols;
|
||||||
|
end initialize;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end googleNaive;
|
||||||
|
|
|
@ -8,17 +8,22 @@ package googleNaive is
|
||||||
type T_Row is limited private;
|
type T_Row is limited private;
|
||||||
type T_Google is limited private;
|
type T_Google is limited private;
|
||||||
|
|
||||||
function "*"(left, right: T_Google) return T_Google;
|
function "*"(left, right: T_Google) return T_Google with
|
||||||
function "+"(left, right: T_Google) return T_Google;
|
Pre => left.dimension(1)=right.dimension(0),
|
||||||
|
Post => "*"'Result.dimension(0)= left.dimension(0) and "*"'Result.dimension(1)= right.dimension(1);
|
||||||
|
|
||||||
|
function "+"(left, right: T_Google) return T_Google with
|
||||||
|
Pre => left.dimension=right.dimension;
|
||||||
|
|
||||||
function "*"(left: T_Google; right: Integer) return T_Google;
|
function "*"(left: T_Google; right: Integer) return T_Google;
|
||||||
function "/"(left: T_Google; right: Integer) return T_Google;
|
function "/"(left: T_Google; right: Integer) return T_Google with
|
||||||
|
Pre => right/=0;
|
||||||
|
|
||||||
procedure initialize(mat: in out T_Google) with
|
procedure initialize(mat: out T_Google; rows, cols : Positive )with
|
||||||
Post => isEmpty(mat);
|
Post => isEmpty(mat);
|
||||||
|
|
||||||
function ones(rows, cols: Positive) return T_Google;
|
function ones(rows, cols: in Positive) return T_Google;
|
||||||
function zeros(rows, cols: Positive) return T_Google;
|
function zeros(rows, cols: in Positive) return T_Google;
|
||||||
|
|
||||||
procedure insert(mat: in out T_Google; i, j: Natural; elm: T_Element);
|
procedure insert(mat: in out T_Google; i, j: Natural; elm: T_Element);
|
||||||
|
|
||||||
|
@ -32,4 +37,4 @@ private
|
||||||
matrix: array (0..CAPACITY-1) of T_Row;
|
matrix: array (0..CAPACITY-1) of T_Row;
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
end googleNaive;
|
end googleNaive;
|
||||||
|
|
Loading…
Reference in a new issue