Reputation: 392
ab
is a 4 x 5
matrix i.e., ab(4,5)
and x
is an array of length 4
i.e., x(4)
x(4) = ab(4,5)/ab(4,4)
do i = 3, 1, -1
x(i) = ( ab(i,5) - ab(i,i+1:4) * x(i+1:4) ) / ab(i,i)
end do
The do
loop says incompatible rank 0 and 1.
Upvotes: 1
Views: 198
Reputation: 721
You can use the SUM
function in order to reduce the array multiplication to a scalar. i.e. x(i) = ( ab(i,5) - SUM(ab(i,i+1:4) * x(i+1:4)) ) / ab(i,i)
. Alternatively, the DOT_PRODUCT
function could be used DOT_PRODUCT(ab(i,i+1:4) , x(i+1:4))
Upvotes: 1