Quanlse/QPlatform/Utilities.py
def dictMatrixToNumpyMatrix(dictMatrix: Dict, valueType: Union[Type[complex], Type[float]]) -> numpy.ndarray:
    """
    Convert numpy matrix to a dictionary. Must be C-contiguous.

    :param dictMatrix: dictionary consisting the matrix
    :param valueType: select value type
    :return: returned numpy matrix
    """

    if len(dictMatrix) == 0:
        return numpy.empty(0, valueType)

    if valueType == complex:
        complexArray = [complex(complexValue['real'], complexValue['imag']) for complexValue in dictMatrix['array']]
    else:
        complexArray = [complexValue['real'] for complexValue in dictMatrix['array']]
    return numpy.array(complexArray).reshape(dictMatrix['shape'])

    Convert numpy matrix to a dictionary. Must be C-contiguous.

    :param dictMatrix: dictionary consisting the matrix
    :param valueType: select value type
    :return: returned numpy matrix
    
Convert numpy matrix to a dictionary. Must be C-contiguous.
Convert numpy matrix to a dictionary . Must be C - contiguous .
def dictMatrixToNumpyMatrix(dictMatrix: Dict, valueType: Union[Type[complex], Type[float]]) -> numpy.ndarray:
    if len(dictMatrix) == 0:
        return numpy.empty(0, valueType)
    if valueType == complex:
        complexArray = [complex(complexValue['real'], complexValue['imag']) for complexValue in dictMatrix['array']]
    else:
        complexArray = [complexValue['real'] for complexValue in dictMatrix['array']]
    return numpy.array(complexArray).reshape(dictMatrix['shape'])
def dictMatrixToNumpyMatrix ( dictMatrix : Dict , valueType : Union [ Type [ complex ] , Type [ float ] ] ) -> numpy . ndarray : if len ( dictMatrix ) == 0 : return numpy . empty ( 0 , valueType ) if valueType == complex : complexArray = [ complex ( complexValue [ 'real' ] , complexValue [ 'imag' ] ) for complexValue in dictMatrix [ 'array' ] ] else : complexArray = [ complexValue [ 'real' ] for complexValue in dictMatrix [ 'array' ] ] return numpy . array ( complexArray ) . reshape ( dictMatrix [ 'shape' ] )
Convert numpy matrix to a dictionary.
Convert numpy matrix to a dictionary .
"""
    Convert numpy matrix to a dictionary. Must be C-contiguous.

    :param dictMatrix: dictionary consisting the matrix
    :param valueType: select value type
    :return: returned numpy matrix
    """
returned numpy matrix
returned numpy matrix
dictMatrix
Dict
dictionary consisting the matrix
dictionary consisting the matrix
valueType
Union[Type[complex], Type[float]]
select value type
select value type