function res = matrisspecial (matr)
    dim = columns(matr);
    if (dim != rows(matr))
        res = 0;
        return;
    else
        m = matr(2:end, :);
        for i = 1:dim-1
            if (m(i, i) != 1)
                res = 0;
                return;
            endif
            for j = 1:dim
                if (m(i, j) && (i != j))
                    res = 0;
                    return;
                endif
            endfor
        endfor
    endif
    res = 1;
endfunction
