If you use a FEM (on the variational formulation), you can discretize some continuous eigenvalue problem, $$L u = \lambda u \ \ \text{on} \ \Omega,$$
into some discrete, generalized eigenvalue problem, $$ K v = \lambda M v, $$
(here with K the stiffness and M the mass matrix; both symmetric and M additionally positive definite)
with $v_i$ being the the value of the eigenvector $v$ on the i'th node of some triangulation of the domain $\Omega$.
Since every PDE needs proper boundary conditions, we have to force the entries $v_k = 0$ for all $k$ corresponding to nodes with homogenous Dirchlet b.c.
One way to do such is zeroing all rows and columns of $K$ and $M$ according to these $k$'s, only letting the $k$'s diagonal entries of the matrix $K$ be non-zero (for example setting it to $1$). For Computation, here i use here the SLEPc library with lanzcos or krylov-schur solvers (with or without spectral transformations), working with large matrices $K$ and $M$ in CSR-format, so doing such transformations might be very costly. Probably more serious is the problem that i make the right-hand Matrix $M$ singular; solving the generalized eigenvalue problem basically is about solving the corresponding simple problem:
$$ M^{-1} K v = \lambda x. $$
Now i wanted to ask some people with more experience in this how to apply the Dirichlet b.c. for this type of problem in an optimal way.