import torch


def MS_mult(x, y):
    """A function that takes a given input complex matrix (y) and multiplies it by a complex scalar (x).
    
    :param x: A complex scalar.
    :type x: torch.doubleTensor
    :param y: A complex matrix.
    :type y: torch.doubleTensor
    
    :raises ValueError: If y is not a complex tensor (i.e. has 3 dimensions) and if its first dimension is not 2, OR if x's dimension is not 2, the function will not execute.
    
    :returns: The matrix-scalar product - x*y.
    :rtype: torch.doubleTensor
    """
    if len(list(y.size())) != 3 or list(y.size())[0] != 2 or list(x.size())[0] != 2:
        raise ValueError('An input is not of the right dimension.')
    z = torch.zeros_like(y)
    z[0] = x[0]*y[0] - x[1]*y[1]
    z[1] = x[0]*y[1] + x[1]*y[0]

    return z