Skip to content

Commit

Permalink
Added checking positivity of Y matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
arsalan-motamedi committed Oct 22, 2024
1 parent 7397513 commit 8f95221
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mrmustard/lab_dev/transformations/gaussrandnoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""

from __future__ import annotations

from mrmustard import math, settings
from typing import Sequence
from mrmustard.utils.typing import RealMatrix
from .base import Channel
Expand Down Expand Up @@ -70,6 +70,9 @@ def __init__(
f"The number of modes {len(modes)} does not match the dimension of the "
f"Y matrix {Y.shape[-1] // 2}."
)

if (math.eigvals(Y) >= -settings.ATOL).min() == 0:
raise ValueError(f"The input Y matrix has negative eigen-values.")

super().__init__(modes_out=modes, modes_in=modes, name="GRN")
self._add_parameter(make_parameter(Y_trainable, value=Y, name="Y", bounds=(None, None)))
Expand Down

0 comments on commit 8f95221

Please sign in to comment.