def linearly_indep_tuples(self): bd = PrecisionDeg2(self.strum_bound()) dim = self.dimension() tpls = sorted(bd.group_by_reduced_forms().keys(), key=lambda x: (x[0] + x[2], max(x[0], x[2]))) ml = [[f[t] for f in self.basis()] for t in tpls] idcs = linearly_indep_rows_index_list(ml, dim) return [tpls[i] for i in idcs]
def _linearly_indep_tuples_of_given_bd(self, bd): basis = self.basis() dim = self.dimension() if is_number(bd): bd = list(PrecisionDeg2(bd)) tpls = sorted(list(bd), key=lambda x: (x[0] + x[2], max(x[0], x[2]))) tpls_w_idx = reduce(operator.add, [[(t, i) for i in range(self.sym_wt + 1)] for t in tpls], []) ml = [[f.forms[i][t] for f in basis] for t, i in tpls_w_idx] index_list = linearly_indep_rows_index_list(ml, dim) res = [tpls_w_idx[i] for i in index_list] return res
def test_lin_indep(self): A = [[1, 0, 0], [0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 1, 0], [0, 0, 1]] self.assertEqual(linearly_indep_rows_index_list(A, 3), [0, 3, 5]) A = [[1, 0], [0, 0], [1, 0], [0, 1]] self.assertEqual(linearly_indep_rows_index_list(A, 2), [0, 3])