import numpy as np
from linear_solver_float import LinearSolverFloat

# set floating point accuracy 
R = 5

M = np.array([[-4,6,1],
              [8,-11,-2],
              [-3,4,1]]) # Test 2(f)

Y = np.array([0.75,-1.25,0.25])

M_inv = np.linalg.inv(M)

M_inv.dot(Y)

num_reads = 1000
min_occurrence = 2
lsf = LinearSolverFloat(M,Y,R=R,num_reads=num_reads, min_occurrence = min_occurrence)
sampleset = lsf.sample()
sampleset.to_pandas_dataframe()

solutions = lsf.getSolutions(10)
list(solutions)

M = np.array([[6.1795,11.8207,2.0583],
              [15.673,-7.56717,-3.852],
              [-5.6457,7.96872,15.9418]]) #Test 2(g)

Y = np.array([1.4114,0.9972,9.9643])

M_inv = np.linalg.inv(M)
M_inv.dot(Y)

M.dot(np.array([0,0.25,-0.75]))

lsf = LinearSolverFloat(M,Y,R=R,num_reads=num_reads, min_occurrence = min_occurrence)
sampleset = lsf.sample()
sampleset.to_pandas_dataframe()

list(lsf.getSolutions(10))