top of page
  • Writer's pictureAdisorn O.

How to Create Matrix and Vector in modern Fortran (from 2003)

The way modern Fortran provides to create matrix and vector is more convenient, let's check the example below.


OUTPUT:


A = 1.00000000 2.00000000 3.00000000 4.00000000

A = 1.00000000 2.00000000 3.00000000 4.00000000

A+B 3.00000000 4.00000000 3.00000000 20.0000000

A = 1.00000000 2.00000000 3.00000000 4.00000000

A.*B = 3.00000000 4.00000000 3.00000000 20.0000000

A*B = 9.00000000 14.0000000 16.0000000 22.0000000

A = 1.00000000 2.00000000 3.00000000 4.00000000

A.*B = 3.00000000 4.00000000 3.00000000 20.0000000

A*B = 9.00000000 14.0000000 16.0000000 22.0000000

C = 1.00000000 1.00000000 1.00000000 1.00000000

D = 1.00000000 1.00000000 1.00000000 1.00000000 2.00000000 2.00000000 2.00000000 2.00000000 0.00000000 0.00000000 0.00000000

However, the modern version of Fortran still doesn't provide an easy way to display the matrix in its proper form. We still need to know how these elements are stored (column-wise) and understand where they are located.


Fortran provides the concatenation of vector (1D array) in a similar way as MATLAB. Also note the function SPREAD(number,start,end) that works similarly like ones() and zeros() functions in MATLAB.


It's not possible to concatenate the higher dimensional array at this time.

2 views

Comments


bottom of page