(* 2017 Oct 30 Minimal 4-tuple Program Input Data: a : positive definite symmetric matrix. data1 : candidates of 1st columns of minimal 4-tuples of a. data2 : candidates of 2nd columns of minimal 4-tuples of a. data3 : candidates of 3rd columns of minimal 4-tuples of a. data4 : candidates of 4th columns of minimal 4-tuples of a. (data1, data2, data3, data4 are computed by qfminim Pari/GP command.) Usage: countmin4v[a, data1, data2, data3, data4] : gives cardinality of a complete system of representatives of equivalent classes of minimal 4-tuples of a. *) Clear["Global'*"] countmin4v[a_, data1_, data2_, data3_, data4_] := Module[{amatrix,cdata1, cdata2, cdata3, cdata4, f, index4, listcolumns,mindex, minimalindexno,mwedge,mwedgelist,regularindexno,wedge4}, index4[n_] := Sort@Flatten[Table[{l,k+1,j+2, i+3}, {i, 1,n-3}, {j, 1, i}, {k,1,j}, {l,1,k}],3]; wedge4[x_] := Table[Det[x[[All, i]]], {i, index4[Last[Dimensions[x]]]}]; listcolumns[x_] := Table[x[[;;,i]],{i,1,Last[Dimensions[x]]}]; (* note that elements of this list are row vectors *) cdata1 = listcolumns[data1]; cdata2 = listcolumns[data2]; cdata3 = listcolumns[data3]; cdata4 = listcolumns[data4]; f[{n1_,n2_,n3_,n4_}] := {cdata1[[n1]], cdata2[[n2]], cdata3[[n3]], cdata4[[n4]]}; mindex = Tuples[{Range[Length[cdata1]], Range[Length[cdata2]], Range[Length[cdata3]], Range[Length[cdata4]]}]; regularindexno = Select[Range[Length[mindex]], MatrixRank[f[mindex[[#]]]] == 4 & ]; minimalindexno= MinimalBy[regularindexno, Det[f[mindex[[#]]].a.Transpose[f[mindex[[#]]]]] &]; mwedge[n_] := wedge4[f[mindex[[n]]]]; Clear[mwedgelist]; mwedgelist = {mwedge[minimalindexno[[1]]]}; Do[ If[ (MemberQ[mwedgelist, mwedge[minimalindexno[[i]]]]||MemberQ[mwedgelist, -mwedge[minimalindexno[[i]]]]), Null, AppendTo[mwedgelist, mwedge[minimalindexno[[i]]]]], {i, 2, Length[minimalindexno]} ]; Length[mwedgelist] ]