code 34132;
    procedure LSQDGLINV(A, M, AID, CI, DIAG); value M; integer M;
    array A, AID, DIAG; integer array CI;
    begin integer J, K, CIK;
        real W;

        for K:= 1 step 1 until M do 
        begin DIAG[K]:= 1 / AID[K];
            for J:= K + 1 step 1 until M do 
            DIAG[J]:= - TAMVEC(K, J - 1, J, A, DIAG) / AID[J];
            DIAG[K]:= VECVEC(K, M, 0, DIAG, DIAG)
        end;
        for K:= M step - 1 until 1 do 
        begin CIK:= CI[K]; if CIK ^= K then 
            begin W:= DIAG[K]; DIAG[K]:= DIAG[CIK]; DIAG[CIK]:= W
            end 
        end 
    end LSQDGLINV;
        eop