Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WriteToFile does not do what it name suggests #17

Open
fingolfin opened this issue Mar 10, 2016 · 1 comment
Open

WriteToFile does not do what it name suggests #17

fingolfin opened this issue Mar 10, 2016 · 1 comment

Comments

@fingolfin
Copy link
Member

In tblgener.gi, you can find this code snippet around line 420:

    ##LR - This trick is not yet working in GAP4.  Until it does, 
        ##  the tables will not be printed to the file.  
    if info then Print("\nSaving the bound tables...\n"); fi;
    #file := Filename(LOADED_PACKAGES.guava,
    #                    Concatenation("tbl/bdtable",String(q),".g") );
    # The LOADED_PACKAGES record is now defunct.  The following was suggested by Alex Konovalov. --JEF (1/18/2016)
    file := Filename( DirectoriesPackageLibrary("guava", "tbl"),
                         Concatenation("bdtable",String(q),".g") );
    PrintTo(file, "#A  BOUNDS FOR q = ", String(q), help,
            "\n\nGUAVA_BOUNDS_TABLE[1", WriteToFile(LBT),
            "\n\nGUAVA_BOUNDS_TABLE[2", WriteToFile(UBT) );

I am not quite sure which "trick" the first comment refers to. But what I can confirm is that this code won't print much to the given file -- indeed, I would suspect that it would run into an error, because WriteToFile returns nothing, yet its (non-existant) return value is passed to PrintTo.

Anyway, my guess is that the speed problem refered to using PrintTo(filename, ...) repeatedly, which is indeed very slow: Each such call opens the file, appends a line to it, then closes it again. That causes significant overhead.

If you want to fix this, you could open a stream, print to that, and finally close it, as in this example:

stream := OutputTextFile( name, true );
SetPrintFormattingStatus( stream, false ); # disable automatic line breaks
PrintTo( stream, "Hallo\n", "You\n" );
CloseStream(stream);

Then, change WriteToFile to take the stream as a parameter, and change its Print calls to PrintTo(stream, ...).

@osj1961
Copy link
Collaborator

osj1961 commented Mar 12, 2016

The entire CreateBoundsTable function is broken. In my local devel branch I have a fixed version using String manipulations to get the WriteToFile function working. I'll rework that to use the Stream approach you've suggested and commit to master shortly. Sadly the outputted bounds tables bear very little relation to the existing tables in guava/tbl/. For instance none of the codes from Brouwer's tables get installed, so most of the constructed lower bounds are made w/ concatenations of U|U+V constructions. I thing Cen Tjhai began revamping the CreateBoundsTable code but didn't get it finished and instead hand-edited the bounds tables. I need to work out a way to run the bounds functions (e.g. BestKnownLinearCode) with a choice of whether the legacy bounds table or the new "created" table gets used so the two approaches can be compared (and compare both to Marcus Grassl's database).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants