aidevnn/FastGoat

Latin squares is not enough

Closed this issue · 1 comments

FastGoat/FastGoat/Group.cs

Lines 190 to 204 in 3b0cf27

public static bool IsGroup<T>(T[,] table) where T : struct, IElt<T>
{
var n = table.GetLength(0);
if (n != table.GetLength(1))
return false;
var lt = Enumerable.Range(0, n).ToArray();
var group = lt.Select(i => table[0, i]).ToHashSet();
if (group.Count != n)
return false;
var checkRows = lt.Select(i0 => lt.Select(j0 => table[i0, j0]).ToHashSet()).All(group.SetEquals);
var checkCols = lt.Select(i0 => lt.Select(j0 => table[j0, i0]).ToHashSet()).All(group.SetEquals);
return checkRows && checkCols;
}

Associativity is not verified.

Latin square is cheap, complexity is O(n2) when Associativity is more costly O(n3)

UserGroups and their elements are by construction associatives. Writing a custom Loop of order 5 which isnt a Group is possible and fixing this issue isnt the priority at this moment.