One of the most important steps in a Kohn-Sham (KS) type density funct
ional theory calculation is the construction of the matrix of the KS o
perator (the ''Fock'' matrix). It is desirable to develop an algorithm
for this step that scales linearly with system size. We discuss attem
pts to achieve linear scaling for the calculation of the matrix elemen
ts of the exchange-correlation and Coulomb potentials within a particu
lar implementation (the Amsterdam density functional, ADF, code) of th
e KS method. In the ADF scheme the matrix elements are completely dete
rmined by 3D numerical integration, the value of the potentials in eac
h grid point being determined with the help of an auxiliary function r
epresentation of the electronic density. Nearly linear scaling for bui
lding the total Fock matrix is demonstrated for systems of intermediat
e size (in the order of 1000 atoms). For larger systems further develo
pment is desirable for the treatment of the Coulomb potential.