def test_constructors(): int_row = 10 int_col = 20 # int row/col m1 = Matrix(int_row, int_col) check_dense_mat(m1, int_row, int_col) # int row/col w/ name m2 = Matrix("m2", int_row, int_col) check_dense_mat(m2, int_row, int_col, "m2") dim_row = Dimension([3, 2, 1, 4]) dim_col = Dimension([4, 2, 0, 2]) # dim row/col (default sym) m3 = Matrix("m3", dim_row, dim_col) check_block_sparse_mat(m3, 4, dim_row, dim_col, "m3") # dim row/col symm specified m4 = Matrix("m4", dim_row, dim_col, 2) check_block_sparse_mat(m4, 4, dim_row, dim_col, "m4", 2)
a_name = "A^T" else: a_name = "A " if bt: b_name = "B^T" else: b_name = "B " return f" N(G){gsz} || G(A): {Ga} || G(B): {Gb} || doublet({a_name} x {b_name}) || {sq_or_rec.upper()}" dim_choices1 = [2, 3, 4, 5, 6, 7, 8, 9] dim_choices2 = [x + 1 for x in dim_choices1] doublet_args = [] group_size = 4 for group_size in [1, 2, 4, 8]: d1 = Dimension([dim_choices1[x] for x in range(group_size)]) d2 = Dimension([dim_choices2[x] for x in range(group_size)]) a11_set = [(d1, d1, H) for H in range(group_size)] b11_set = [(d1, d1, H) for H in range(group_size)] for aargs, bargs, at, bt in itertools.product(a11_set, b11_set, [True, False], [True, False]): adl, adr, Ga = aargs bdl, bdr, Gb = bargs doublet_args.append( (group_size, adl, adr, Ga, bdl, bdr, Gb, at, bt, 'square')) a12_set = [(d1, d2, H) for H in range(group_size)] b12_set = [(d1, d2, H) for H in range(group_size)] b21_set = [(d2, d1, H) for H in range(group_size)]
def test_clone(): dim = Dimension([1, 2, 3]) vec = Vector(dim) copy = vec.clone() assert copy.dimpi() == dim