in matlab I am used to write something like this
A = [1,2;3,4]
B = A(:,1)
So I extract the first column of matrix A and store it in matrix B, which is just a vector or a 2x1 Matrix. However I can't do this in Fortran, since it regards A(:,1)
as an one dimensional array and thus gives me an error if I want to assign this to a "matrix" B of size 2x1.
This is an minimal example in Fortran:
program test
implicit none
double complex, dimension(:,:), allocatable :: A, B
allocate(A(2,2), B(2,1))
A = transpose(reshape((/ 1, 2, 3, 4/), shape(A)))
B = A(:,1) !gives error that shape mismatch
end program test
Since I don't want to treat vectors separately in my algorithm, how can I achieve Matlab like behaviour?