begin # blocking entire file function GramSchmidt(given, orthonorm) begin # Jim Worthey, 1999 December 27 # given and orthonorm should be matrices of # the same dimensions, usually many rows and a # few columns. The column vectors within given # will be orthonormalized to produce the column # vectors of orthonorm. last = coldim( given ) # coldim returns # of columns of the array aCol = double( given.col(1) ) # 1st column, forced to double precision SumSq = aCol'*aCol # ' denotes transpose NormFac = 1.0d0/sqrt(SumSq) # 1.0d0 is double-precision 1.0 orthonorm.col(1) = NormFac*aCol # 1st result column for j = 2 to last begin aCol = double( given.col(j) ) # again extract 1 column to work with for i = 1 to (j-1) begin dot = orthonorm.col(i)'*aCol aCol = aCol - dot*orthonorm.col(i) end # for i = 1 to (j-1) SumSq = aCol'*aCol NormFac = 1.0d0/sqrt(SumSq) orthonorm.col(j) = NormFac*aCol # normalize the new vector end # for j = 2 to last end # end GramSchmidt() end # blocking entire file