fortran90 - Error when using the function "transpose" in Fortran -


this question has answer here:

i know "transpose" in fortran operator flips matrix on diagonal. however, in code below, met error , did not know why.

the code is:

program main   implicit none   real(8)::a(3,2),b(2,1)    a=reshape((/1.0,2.0,3.0,4.0,5.0,6.0/),(/3,2/))   b=reshape((/1.0,2.0/),(/2,1/))   write(*,*)a(1,1:2)    !next sentence throw error   a(1,1:2)=transpose(b) end program 

the error is:

error #6366: shapes of array expressions not conform. [a]

i think "a(1,1:2)" 1 line , 2 columns, same "transpose(b)", why compiler told me "the shape not conform"?

you wrong, a(1,1:2) not 2d array (which call matrix), 1d array.

bu using a(1,.. selecting definite "row" in "matrix" take "row vector" 1:2).

you must use

a(1:1,1:2)

for 2d array of shape 1x2 (matrix 1 line , 2 columns if want).


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -