subroutine d4_dgemv312(amat, xvec, yvec, alpha, beta, trans)
real(dp), intent(in), contiguous, target :: amat(:, :, :)
real(dp), intent(in) :: xvec(:)
real(dp), intent(inout), contiguous, target :: yvec(:, :)
real(dp), intent(in), optional :: alpha
real(dp), intent(in), optional :: beta
character(len=1), intent(in), optional :: trans
real(dp), pointer :: aptr(:, :), yptr(:)
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)*size(amat, 2), 1:size(amat, 3)) => amat
yptr(1:size(yvec, 1)*size(yvec, 2)) => yvec
else
aptr(1:size(amat, 1), 1:size(amat, 2)*size(amat, 3)) => amat
yptr(1:size(yvec, 1) * size(yvec, 2)) => yvec
end if
call d4_gemv(aptr, xvec, yptr, alpha, beta, tra)
end subroutine d4_dgemv312