Singular https://www.singular.uni-kl.de/forum/ |
|
Looking at code in the libraries https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=1762 |
Page 1 of 1 |
Author: | Ravi [ Mon Jul 27, 2009 6:14 am ] |
Post subject: | Looking at code in the libraries |
Hello, How does one print out the code of procedures in the built-in libraries? For example, I want to examine the code of the procedure called "invariant_basis" in finvar.lib. Is that possible? Ravi |
Author: | bulygin [ Mon Jul 27, 2009 11:55 am ] |
Post subject: | Re: Looking at code in the libraries |
All the standard distributed libraries are contained in the LIB folder of your distribution. Since they are in plaintext, you may simply look for LIB/finvar.lib and then find the realization of "invariant_basis" by a search command. |
Author: | malex [ Mon Jul 27, 2009 4:12 pm ] |
Post subject: | Re: Looking at code in the libraries |
Dear Ravi, you can get the code of any procedure (e.g. invariant_basis) via string(invariant_basis); but for this to work you have to call the procedure at least once. Therefore i suggest you to do the following: Code: LIB "finvar.lib"; // load lib example invariant_basis; // take a look at the example string(invariant_basis); // view its source I hope that helps. Regards, Oleksandr |
Author: | Guest [ Mon Jul 27, 2009 6:32 pm ] |
Post subject: | Re: Looking at code in the libraries |
Hello, The finvar.lib file in the LIB folder is a binary file (with text annotations), so I found it easier to use the "string" command suggested by Oleksandr. The string command only prints to the terminal, so to print to file for easy reading, do this: Code: > write("a-file-name.txt", name-of-procedure) Thanks for the help, Ravi |
Author: | malex [ Mon Jul 27, 2009 7:37 pm ] |
Post subject: | Re: Looking at code in the libraries |
Dear Ravi, how do you detect that finvar.lib file in the LIB folder is a binary file (with text annotations)? AFAIK, LIB/*.lib should be plain text files. If you cannot read/edit them with a plain text editor then something went wrong... Besides, you still need to call you procedure before doing: "write("a-file-name.txt", name-of-procedure);" Regards, Oleksandr |
Author: | Ravi [ Tue Jul 28, 2009 5:23 am ] |
Post subject: | Re: Looking at code in the libraries |
Hello, Yes, I am calling the procedure before calling the write function. (And the second argument is string(proc_name).) I had opened the finvar.lib file using TextPad (a text editor on Windows) and it actually appears as a binary file there! Maybe something about the way TextPad treats the lib extension? I checked that it is a plain text file in another plain text editor. Thanks Ravi |
Author: | dreyer [ Tue Jul 28, 2009 8:42 am ] |
Post subject: | Re: Looking at code in the libraries |
Ravi wrote: I had opened the finvar.lib file using TextPad (a text editor on Windows) and it actually appears as a binary file there! Maybe something about the way TextPad treats the lib extension? Right .lib means static library on Windows, so it is assumed to be something binary. Also text files are different (different end of line markers) between Windows and Unix, and therefore some Windows-editors cannot deal with them (notepad can't, while wordpad can). Regards, Alexander |
Page 1 of 1 | All times are UTC + 1 hour [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |