def testInitializeRegisterWithBitString(self):
        qcomp = get_functional_computer(nregisters=4, sqrt_size=3)
        value = "101100010"
        qcomp.execute(instr_initialize(0, value))

        cvalue = ComplexM(3, 3, bitstring_to_matrix(value, 3))

        self.assertEqual(cvalue, qcomp.registers[0].value)
    def _get_matrix_from_bitstring(self, bitstring):
        if not isinstance(bitstring, str):
            raise TypeError("Initialize expects an string value")

        if len(bitstring) != self.size:
            raise ValueError("Can't initialize a register of size {0} with a"
                             " bitstring of size {1}".format(self.size,
                                                             len(bitstring))
                             )

        if bitstring.count('0') + bitstring.count('1') != self.size:
            raise ValueError("A bitstring can only contains 0's and 1's")

        return bitstring_to_matrix(bitstring, self.sqrt_size)