Klaudia

15 Reputation

One Badge

11 years, 310 days

MaplePrimes Activity


These are replies submitted by Klaudia

@Carl Love A,B shoul have symbols for 1 to n. For exmaple for n = 5 we have 4 orthogonal latin square:

And so A,B should look.

 

I found this procedure in article "Some properties of latin squares - study of mutually orthogonal latin squares". 

Note: The package with(linalg) is needed for these procedures.
6.1 Computing orthogonality for sets of two latin squares
First we have a procedure that given two latin squares (of the same order) and the
order, computes r-orthogonality.
rOrt := proc (A, B, n)
local freq, i, j;
freq := Array(0 .. n^2-1);
for i to n do
for j to n do
freq[A[i][j]+n*B[i][j]] := 1
end do;
end do;
freq := convert(freq, list);
return numboccur(freq, 1)
end proc:
6.2 Computing orthogonality for sets of two or more latin
squares
Here we have a procedure that given a set of t  2 latin squares (of the same order)
and the order, uses the rst procedure to compute the r-orthogonality of every pair
of distinct latin squares in the set, and nally adds them all up to give the
rt-orthogonality.
rtOrt := proc (SET, n)
local numls, compList, i, r;
numls := nops(SET);
compList := [];
for i to numls do
compList := [op(compList), i]
end do;
with(combinat);
compList := choose(compList, 2);
r := 0;
for i in compList do
r := r+rOrt(SET[i[1]], SET[i[2]], n);
end do;
return r
end proc:

Finally we have two procedures that given a latin square, a permutation matrix and
the order, generates a set of latin squares. The rst one does it by permuting rows
(the permutation matrix is the lefthand operand):
genLSsetPF:=proc(LS::Matrix, T::Matrix, q::integer)
local LSs, LSq, i:
LSs := [LS]:
LSq:=LS:
for i from 1 to q-2 do
LSq := multiply(T, LSq):
LSs := [op(LSs), eval(LSq)]:
end do:
RETURN(LSs)
end proc:
The second one does it by permuting columns (the permutation matrix is the
righthand operand):
genLSsetPC := proc (LS::Matrix, T::Matrix, n::integer) local LSs, LSn, i:
LSs := [LS]:
LSn:=LS:
for i from 1 to n-2 do
LSn := multiply(LSn, T):
LSs := [op(LSs), eval(LSn)]:
end do:
RETURN(LSs)
end proc:

I need help, because the last time when I used Maple was five years ago and I really do not remember anything

 

Page 1 of 1