=========矩阵运算
create or replace FUNCTION f2(a1 float[], a2 float[], n int) RETURNS float AS $$
declarer float;
num integer;
begin
r = 0;
num = 1;
while num < n loop
r = r + a1[num]*a2[num];
num = num +1;
end loop;
return r;
end;
$$ LANGUAGE plpgsql ;
=======insert
create or replace FUNCTION f4(a1 float[]) RETURNS float AS $$
declare
r float;
num integer;
begin
r = 0;
num = 0;
while num < 10000 loop
insert into tbl4(id,feature) values (num+100, a1);
num = num +1;
end loop;
return r;
end;
$$ LANGUAGE plpgsql ;