Loading [MathJax]/extensions/TeX/boldsymbol.js

 

 

 

Programming classes

In Fortran a vector or matrix start with 1 , but it is easy to change a vector so that it starts with zero or even a negative number. If we have a double precision Fortran vector which starts at -10 and ends at 10 , we could declare it as REAL(KIND=8) :: vector(-10:10). Similarly, if we want to start at zero and end at 10 we could write REAL(KIND=8) :: vector(0:10). We have also seen that Fortran allows us to write a matrix addition \mathbf{A} = \mathbf{B}+\mathbf{C} as A = B + C. This means that we have overloaded the addition operator so that it translates this operation into two loops and an addition of two matrix elements a_{ij} = b_{ij}+c_{ij} .