def grade_Q2(): a = np.random.rand(100, 10) b = np.random.rand(100, 10) c = prj01.Q2(a, b) if not hasattr(c, "shape"): return False if c.shape != (100, 10): return False return all([ abs(c[i, j] - a[i, j] - b[i, j]) < 1e-9 for i in range(100) for j in range(10) ])
def grade_Q8(): A = np.random.rand(100, 100) x = np.random.rand(100, 1) b = np.random.rand(100, 1) y = prj01.Q8(A, b).compile(golden.Builder())(x=x) return np.allclose(y, prj01.Q2(prj01.Q3(A, x), b))
def grade_Q7(): a = np.random.rand(100, 50) b = np.random.rand(100, 10) c = np.random.rand(10, 50) d = prj01.Q7().compile(golden.Builder())(a=a, b=b, c=c) return np.allclose(d, prj01.Q2(a, prj01.Q3(b, c)))
def grade_Q6(): a = np.random.rand(100, 10) b = np.random.rand(100, 10) c = prj01.Q6().compile(golden.Builder())(a=a, b=b) return np.allclose(c, prj01.Q2(a, b))