Project: s41467-024-51491-7 | Function: Eigensystem.calc_eigenvalues_and_eigenvectors (python)

system: You are an expert Python programmer implementing algorithms from scientific papers.
Complete the masked function based on the algorithm description.
Follow Python best practices and maintain consistent code style.
Return **only** the complete Python function code.

user: Complete this Python function:

**DESCRIPTION:** Calculate eigenvalues and eigenvectors of the 6x6 system matrix K for the beam-on-elastic-foundation problem. This fundamental calculation determines the characteristic behavior of the slab-weak layer system under various loading conditions.

**KEY TERMS:** {
  "system_matrix": "system matrix K",
  "ew": "eigenvalues",
  "ev": "eigenvectors",
  "ewC": "complex eigenvalues",
  "ewR": "real eigenvalues",
  "sR": "positive eigenvalue shifts",
  "sC": "complex eigenvalue shifts"
}

**CONTEXT CODE:**         the ODE system is written in the form Az' + Bz = d
        and rearranged to z' = -(A^-1)Bz + (A^-1)d = Kz + q

        Returns
        -------
        NDArray[np.float64]
            System matrix K (6x6).
        """
        kn = kn or self.weak_layer.kn
        kt = kt or self.weak_layer.kt
        H = self.slab.H  # total slab thickness
        h = self.weak_layer.h  # weak layer thickness

        # Abbreviations
        K21 = kt * (-2 * self.D11 + self.B11 * (H + h)) / (2 * self.K0)
        K24 = (
            2 * self.D11 * kt * h
            - self.B11 * kt * h * (H + h)
            + 4 * self.B11 * self.kA55
        ) / (4 * self.K0)
        K25 = (
            -2 * self.D11 * H * kt
            + self.B11 * H * kt * (H + h)
            + 4 * self.B11 * self.kA55
        ) / (4 * self.K0)
        K43 = kn / self.kA55
        K61 = kt * (2 * self.B11 - self.A11 * (H + h)) / (2 * self.K0)
        K64 = (
            -2 * self.B11 * kt * h
            + self.A11 * kt * h * (H + h)
            - 4 * self.A11 * self.kA55
        ) / (4 * self.K0)
        K65 = (
            2 * self.B11 * H * kt
            - self.A11 * H * kt * (H + h)
            - 4 * self.A11 * self.kA55
        ) / (4 * self.K0)

        # System matrix
        K = [
            [0, 1, 0, 0, 0, 0],
            [K21, 0, 0, K24, K25, 0],
            [0, 0, 0, 1, 0, 0],
            [0, 0, K43, 0, 0, -1],
            [0, 0, 0, 0, 0, 1],
            [K61, 0, 0, K64, K65, 0],
        ]

        return np.array(K, dtype=np.float64)

    def calc_eigenvalues_and_eigenvectors(
        self, system_matrix: NDArray[np.float64]
    ) -> tuple[
        NDArray[np.complex128],
        NDArray[np.float64],
        NDArray[np.complex128],
        NDArray[np.float64],
        NDArray[np.float64],
        NDArray[np.float64],
    ]:
        """
        Calculate eigenvalues and eigenvectors of the system matrix.

        Parameters:
        -----------
        system_matrix: NDArray          # system_matrix size (6x6) of the eigenvalue problem

        Return:
        -------
        ewC: NDArray[np.complex128]     # shape (k): Complex Eigenvalues
        ewR: NDArray[np.float64]        # shape (g): Real Eigenvalues
        evC: NDArray[np.complex128]     # shape (6, k): Complex Eigenvectors
        evR: NDArray[np.float64]        # shape (6, g): Real Eigenvectors
        sR: NDArray[np.float64]         # shape (k): Real positive eigenvalue shifts
                                        # (for numerical robustness)
        sC: NDArray[np.float64]         # shape (g): Complex positive eigenvalue shifts
                                        # (for numerical robustness)
        """
        # MASKED: Calculate eigenvalues and eigenvectors of the 6x6 system matrix K for the beam-on-elastic-foundation problem. This fundamental calculation determines the characteristic behavior of the slab-weak layer system under various loading conditions.
        raise NotImplementedError("Function has been masked for testing purposes")

    def zh(self, x: float, length: float = 0, has_foundation: bool = True) -> NDArray:
        """
        Compute bedded or free complementary solution at position x.

        Arguments
        ---------
        x : float
            Horizontal coordinate (mm).
        length : float, optional
            Segment length (mm). Default is 0.
        has_foundation : bool
            Indicates whether segment has foundation or not. Default
            is True.

        Returns
        -------
        zh : ndarray
            Complementary solution matrix (6x6) at position x.
        """
        if has_foundation:
            zh = np.concatenate(
                [
                    # Real
                    self.evR * np.exp(self.ewR * (x + length * self.sR)),
                    # Complex
                    np.exp(self.ewC.real * (x + length * self.sC))
                    * (
                        self.evC.real * np.cos(self.ewC.imag * x)
                        - self.evC.imag * np.sin(self.ewC.imag * x)
                    ),
                    # Complex
                    np.exp(self.ewC.real * (x + length * self.sC))
                    * (
                        self.evC.imag * np.cos(self.ewC.imag * x)
                        + self.evC.real * np.sin(self.ewC.imag * x)
                    ),
                ],
                axis=1,
            )
        else:
            # Abbreviations
            H14 = 3 * self.B11 / self.A11 * x**2
            H24 = 6 * self.B11 / self.A11 * x
            H54 = -3 * x**2 + 6 * self.K0 / (self.A11 * self.kA55)
            # Complementary solution matrix of free segments
            zh = np.array(
                [
                    [0, 0, 0, H14, 1, x],
                    [0, 0, 0, H24, 0, 1],
                    [1, x, x**2, x**3, 0, 0],
                    [0, 1, 2 * x, 3 * x**2, 0, 0],
                    [0, -1, -2 * x, H54, 0, 0],
                    [0, 0, -2, -6 * x, 0, 0],
                ]
            )

        return zh

    def zp(
        self, x: float, phi: float = 0, has_foundation=True, qs: float = 0
    ) -> NDArray:
        """
        Compute bedded or free particular integrals at position x.

        Arguments
        ---------
        x : float
            Horizontal coordinate (mm).
        phi : float


Complete the function implementation replacing "raise NotImplementedError".