subroutine d4_dgemv321(amat, xvec, yvec, alpha, beta, trans)
real(dp), intent(in), contiguous, target :: amat(:, :, :)
real(dp), intent(in), contiguous, target :: xvec(:, :)
real(dp), intent(inout) :: yvec(:)
real(dp), intent(in), optional :: alpha
real(dp), intent(in), optional :: beta
character(len=1), intent(in), optional :: trans
real(dp), pointer :: aptr(:, :), xptr(:)
character(len=1) :: tra
if (present(trans)) then
tra = trans
else
tra = 'n'
end if
if (any(tra == ['n', 'N'])) then
aptr(1:size(amat, 1), 1:size(amat, 2)*size(amat, 3)) => amat
xptr(1:size(xvec, 1)*size(xvec, 2)) => xvec
else
aptr(1:size(amat, 1)*size(amat, 2), 1:size(amat, 3)) => amat
xptr(1:size(xvec, 1) * size(xvec, 2)) => xvec
end if
call d4_gemv(aptr, xptr, yvec, alpha, beta, tra)
end subroutine d4_dgemv321