function [Aq , Bq] = SkalGlsSparse (A , B)

[m ,n ] = size (A) ;
[mb,nb] = size (B) ;

if (m ~= mb)  
    error ('Zeilenanzahl von A und B muessen uebereinstimmen') 
end

nzMax     = nzmax(A)  ;
[ii,jj,S] = find (A') ;

Bq = zeros (mb,nb) ;

i = 1 ;
for irow=1:m
    k    = i ;
    kend = 0 ;
    while (jj(k) == irow)
        kend = k ;
        k = k+1 ;
        if (k > nzMax) break; end
    end
    if (kend > 0)
        maxi = max(abs(S(i:kend)))  ;
        S(i:kend)  = S(i:kend)/maxi ;
        Bq(irow,:) = B(irow,:)/maxi ;
        i = kend + 1 ;
    end
end

Aq = sparse (jj , ii , S , m , n) ;