nonabelian $p$-group contains an elementary abelian maximal subgroup Given an elementary abelian $p$-group $A$ of order $p^n$ for $n\geq 2$ and choose a subgroup $H$ of order $p$ from $Aut(A)\cong GL(n,p)$. We can use semi-direct product $A\rtimes B$ to construct a nonabelian $p$-group containing an elementary abelian maximal subgroup. Is there any other example and a complete characterization of $p$-groups satisfying this property?
 A: Not every such group has this form, but they can be classified.
Let $G$ be a $p$-group containing an elementary abelian $p$-group $A$ as a maximal subgroup.
Being maximal, it is an index $p$ normal subgroup. Let $g$ be a generator of the quotient $G/A$. Then $g$ acts by conjugation on $A$ as a matrix $\sigma \in GL_n(\mathbb F_p)$
The unique eigenvalue of $\sigma$ is $1$ and thus it can be put in Jordan normal form, writing it as a block-diagonal matrix with $m_k$ unipotent blocks of size $k$ for some sequence $m_k$ satisfying $\sum_k k m_k =n$. Furthermore, since a unipotent block of size $k$ has order $>p$ if $k>p$, we must have $m_k =0 $ for $k>p$.
Let $\alpha \in A = g^p$. We can express any element of $G$ as $a g^r$ with $a\in A$ and $r \in \{0,\dots, p-1\}$. The multiplication table of $G$ is determined by the relations $ ga g^{-1} = \sigma(a)$ and $g^p = \alpha$. We obtain a group with $A$ as an index $p$ subgroup this way if and only if $\alpha$ is $\sigma$-invariant.
The space of $\sigma$-invariants in unipotent block of size $k$ for $\sigma$ is one-dimensional. So it might seem that the space of choices of $\alpha$ is $\mathbb F_p^{\sum_{k=1}^p m_k}$. However, up to automorphisms of $\mathbb F_p^n$ commuting with $\sigma$, if $\alpha$ has a nontrivial component in any block of size $k$ then we can cancel the component in every other block of size $k$ and every block of greater size. Thus, the only information that matters is the least $k$ such that $\alpha$ has a component in a block of size $k$, or equivalently, the least $k$ such that $\alpha$ is not in the image of $(\sigma-1)^k$. Call this $k_\alpha$, and if $\alpha=0$, set $k_\alpha=\infty$.
The groups with relation $g^p=\alpha_1$ and $g^p=\alpha_2$ are equivalent if we can write $ g^p =\alpha_1, (ag)^p=\alpha_2$, or in other words if $a + \sigma(a) + \sigma^2(a) + \dots + \sigma^{p-1}(a) = \alpha_2- \alpha_1 $. Restricting to any block of size $<p-1$, $a + \sigma(a) + \sigma^2(a) + \dots + \sigma^{p-1}(a)=0$, so $\alpha_1,\alpha_2$ become equivalent under this if and only if their difference is supported in blocks of size $p$. In other words, the cases $k_{\alpha}=p$ and $k_\alpha=\infty$ are equivalent.
The last source of equivalence of the pair $(G,A)$ is changing $g$ for a power of $g$, but this just has the effect of multiplying $a$ by a constant and thus is already accounted for.
So the classification of pairs $(G,A)$ where $G$ is a $p$-group and $A$ is a maximal elementary abelian subgroup is given by tuples $(m_1,\dots, m_p,k_{\alpha})$ of nonnegative integers where $\sum_{k=1}^p k m_k = n$, $1\leq k_{\alpha} \leq p-1$ or $k_{\alpha}=\infty$, and $m_{k_\alpha}>0$ unless $k_\alpha=\infty$.
$G$ is nonabelian if and only if $m_1 \neq n$.
Semidirect products only occur in the case $k_\alpha=\infty$, so there are lots of nonabelian groups that aren't semidirect products.
