Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 42 additions & 17 deletions lib/qdistrnd.g
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# Valerii K. Kozin <kozin.valera@gmail.com>
# Leonid P. Pryadko <leonid.pryadko@gmail.com>



############################
#! @Chapter AllFunctions
#! @Section HelperFunctions
Expand Down Expand Up @@ -465,7 +463,7 @@ BindGlobal("QDR_ProcEntry",
#DeclareGlobalFunction("ReadMTXE");
BindGlobal("ReadMTXE",
function(StrPath, opt... ) # supported option: "field"
local input, data, fmt, line, pair, F, rowsG, colsG, G, G1, i, infile,
local input, data, fmt, line, pair, F, rowsG, colsG, G, G1, i,
iCommentStart,iComment;
# local variables:
# input - file converted to a string
Expand All @@ -483,9 +481,7 @@ BindGlobal("ReadMTXE",
# i - dummy for "for" loop
# iCommentStart, iComment - range of line numbers for comment section

infile := InputTextFile(StrPath);
input := ReadAll(infile);; # read the file in
CloseStream(infile);
input := ReadAll(InputTextFile(StrPath));; # read the file in
data := SplitString(input, "\n");; # separate into lines
line := SplitString(data[1], " ");; # separate into records

Expand Down Expand Up @@ -814,16 +810,26 @@ BindGlobal("QDR_MakeH",
#! see Section <Ref Sect="Section_Empirical"/>. Not set by default.
#! See Section <Ref Sect="Section_SimpleVersion"/> for the
#! description of the algorithm.
#! @Arguments HX, HZ, num, mindist[, debug] :field:=GF(2), maxav:=fail
#! @Arguments HX, HZ, num, mindist[, debug] :field:=GF(2), maxav:=fail, CW=fail
#! @Returns An upper bound on the CSS distance $d_Z$
#DeclareGlobalFunction("DistRandCSS");
BindGlobal("DistRandCSS",
function (GX,GZ,num,mindist,opt...) # supported options: field, maxav
function (GX,GZ,num,mindist,opt...) # supported options: field, maxav, CW

local DistBound, i, j, dimsWZ, rowsWZ, colsWZ, F, debug, pos, CodeWords, mult,
VecCount, maxav, WZ, WZ1, WZ2, WX,
TempVec, FirstVecFound, TempWeight, per;

TempVec, FirstVecFound, TempWeight, per,
savecws,posi,res, CW;

if ValueOption("CW") <> fail then
if IsList(ValueOption("CW")) then
CW := List(ValueOption("CW"));
savecws := List([1..Length(ValueOption("CW"))], x -> []);
else
Error("'CW' must be a list.\n");
fi;
fi;

if ValueOption("field")<>fail then
if not IsField(ValueOption("field")) then
Error("invalid option 'field'=",ValueOption("field"),"\n");
Expand Down Expand Up @@ -864,6 +870,14 @@ BindGlobal("DistRandCSS",
for j in [1..rowsWZ] do
TempVec:=WZ2[j]; # this samples low-weight vectors from the code
TempWeight:=WeightVecFFE(TempVec);
######
if ValueOption("CW") <> fail then
if TempWeight in CW and WeightVecFFE(WX*TempVec)>0 then
posi:=Position(CW,TempWeight);
Add(savecws[posi],TempVec);
fi;
fi;
######
if (TempWeight > 0) and (TempWeight <= DistBound) then
if WeightVecFFE(WX*TempVec)>0 then # lin-indep from rows of GX
if debug[2]=1 then # Check that H*c = 0
Expand All @@ -883,9 +897,9 @@ BindGlobal("DistRandCSS",
if debug[4] = 1 or ValueOption("maxav")<> fail then
CodeWords := [TempVec];;
mult := [1];;
fi;
fi;
if debug[1] = 1 then
FirstVecFound := TempVec;;
FirstVecFound := TempVec;;
fi;

elif TempWeight=DistBound then
Expand Down Expand Up @@ -929,7 +943,7 @@ BindGlobal("DistRandCSS",

if (debug[1] = 1) then # print additional information
Print(i," rounds of ", num," were made.", "\n");
if colsWZ <= 100 then
if colsWZ <= 1000 then
Print("First vector found with lowest weight:\n");
Display([FirstVecFound]);
fi;
Expand All @@ -940,11 +954,22 @@ BindGlobal("DistRandCSS",

if (debug[4] = 1) then
# Display(CodeWords);
QDR_DoProbOut(mult,colsWZ,i);
QDR_DoProbOut(mult,colsWZ,i);
fi;

return DistBound;

######
res:=[];
if ValueOption("CW") <> fail then
Add(res,DistBound);
for i in [1..Length(savecws)] do
Add(res,Set(savecws[i]));
od;
else
Add(res,DistBound);
fi;

#return DistBound;
#Print("qdis: ",res,"\n")
return res;
end
);

Expand Down
Loading
Loading