<jupyter_start><jupyter_text>**Binary matrix or QUBO matrix**<jupyter_code>#########  Binary matrix or QUBO matrix #########

a1 = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])  #with only upper triangular term from numpy array
m1 = BinaryMatrix(3, a1)
print(m1,'\n')


a2 = np.array([1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0])  # with all terms in 1d numpy array
m2 = BinaryMatrix(3, a2)
print(m2,'\n')


a3 = np.array([[1.0, 2.0, 3.0], [0.0, 4.0, 5.0], [0.0, 0.0, 6.0]])  # with 2d numy array
m3 = BinaryMatrix(a3)
print(m3)

print(m1==m2==m3)
#### Changing entry of binary matrix (numpy indexing)

m3[2,2] = 9

print(m3)<jupyter_output>[[1, 2, 3],
 [0, 4, 5],
 [0, 0, 9]]<jupyter_text>Binary matrix methods<jupyter_code>print(m3.to_Poly())  # to Binary polynomial
print(m3.to_IsingMatrix())  # to ising matrix
print(m3.to_numpy())  # to numpy array
print(m3.size())  # dimension of Binary matrix or QUBO<jupyter_output>3<jupyter_text>**Evaluating value of Binary matrix**<jupyter_code>print(m3.evaluate([1,1,0]))  ## with binary string

print(m3.evaluate([2,-1,5]))  # with mixed integers<jupyter_output>7.0
234.0
{'fraction_non_alphanumeric': 0.20197486535008977, 'fraction_numerical': 0.08976660682226212, 'mean_word_length': 4.747422680412371, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '616324', 'license': 'MIT', 'n_tokens_mistral': 549, 'n_tokens_neox': 499, 'n_words': 118, 'path': 'Amplify tutorials/2.Binary Matrix as Input Layer.ipynb', 'repo_name': 'speQtrum/Ising_Annealing_Machines', 'size': '1114'}