Hi, xman-ga:
Yes, I remember the earlier question!
There is an open source mathematical modeling package Octave that has
a pretty good degree of compatibility with Matlab syntax. I
downloaded version 2.1.50 from one of the mirror sites here (package
octave-forge-windows):
[GNU Octave - SourceForge.net]
http://sourceforge.net/projects/octave
Running under Windows requires first the installation of a
Unix-compatibility layer called Cygwin. The Cygwin package was
already installed by me on my Windows XP Pro laptop, so I didn't
repeat that step, but see the instructions here:
[Downloading Octave - Latest Release]
http://www.octave.org/download.html
"For Windows, you may follow these directions to install Cygwin and
Octave, or you may use one of the binary packages found at
http://sourceforge.net/projects/octave.
"There is also a FAQ for Octave on Windows systems."
[Cygwin Information and Installation]
http://www.cygwin.com/
[Octave under Windows]
http://octave.sourceforge.net/Octave_Windows.htm
I need to update my Cygwin installation anyway, so I will circle back
and give an account of my adventures doing this in a follow-up post.
But let me proceed with the account of installing Octave and getting
the .m files you've asked about to run.
I first "uninstalled" my old version of Octave in a brute force
fashion (deleting directories) which I'll not detail. I then
downloaded (to my XP "desktop") the executable installation program
octave-2.1.50a-inst.exe which you can get from the links above. (I
had trouble with the North Carolina mirror, and wound up cancelling
that download and pulling from the Minneapolis one. It very likely
was just an intermittent load problem; you can pick a site "near"
you.)
When you run the install program (double-click after the download to
your desktop is finished), if it finds a previous Cygwin installation
it will prompt you with a warning that the installation is not
designed to run _within_ the Cygwin environment. That's okay; just
click yes to proceed as you will be running it from Windows (not from
inside a Cygwin terminal, unless you are more adventurous than I am!).
There's a terms of use license to accept, the reknowned GNU/Free
Software Foundation GPL (General Public License). If you are
philosophically opposed to the open source movement, this package is
not for you! Otherwise I hope you will find the terms of the license
acceptable, as I did.
After installing Cygwin and Octave (which provides a desktop icon, a
Start Menu entry, and a handy uninstall program in this version), you
are almost set to go.
I downloaded these two "function scripts" from the link you gave:
comb_unrank.m
combin2.m
and saved them (basically just as text pages from my Mozilla Firefox
browser) into the directory:
C:\Program Files\GNU Octave 2.1.50\octave_files
The point here is that if you put .m files that define functions in
this directory, then Octave can find them while its running. You
don't need to do anything special to "compile" them or to let the
Octave environment know where to look.
Now as a first exercise (since I saw that comb_unrank( m, n, rank) was
using it) I tried to invoke combin2(45, 6) from the Octave command
line. I got this error:
>> combin2(45,6)
parse error near line 48 of file /octave_files/combin2.m
>>> for ( i = 2 : mn )
^
error: `combin2' undefined near line 13 column 1
Despite the error this was good news in that it shows Octave was
finding the right file. A quick consultation of the Octave
documentation suggested that the problem was the parentheses around
the "for loop" range. I edited the source file in Textpad (without
closing Octave) and made a similar change to the other file
(comb_unrank.m also has one for loop). Because Octave uses the
timestamp on files that define functions to determine if the
definitions need to be re-interpreted, I could then use the corrected
source file without restarting:
>> combin2(45,6)
ans = 8145060
>> comb_unrank(45,6,1)
ans =
1 2 3 4 5 6
>> comb_unrank(45,6,4072530)
ans =
5 13 14 25 27 29
So, to summarize, download and install the Cygwin and Octave packages,
download the two .m script files, and make the edits to these "Matlab"
scripts (removing parentheses from one line in each file that starts a
for loop). Run the Octave program interactively and use the functions
as you wish.
Let me know if you have difficulties, and again, I'll post a follow-up
about installing/reinstalling the Cygwin package (basically a DLL).
regards, mathtalk-ga
P.S. Thanks, andyt-ga, for the suggestion of using the Matlab
compiler. The programs SUBSET are also available from links at the
page xman-ga gave in C++ and in Fortran versions, so there are several
options to obtain compiled code. I found the interactive version to
be fast enough in Octave, but we'll see how well it suits xman-ga. |
Clarification of Answer by
mathtalk-ga
on
24 Jul 2004 07:46 PDT
Hi, xman-ga:
Thanks for the generous comments... the encouragement is appreciated!
I put together these notes for you about Cygwin installation.
[The Cygwin FAQ]
http://www.cygwin.com/faq/
Under: "What version of Cygwin is this, anyway?"
"So, how do you get the most up-to-date version of Cygwin? Easy. Just
download the Cygwin Setup program from http://cygwin.com/setup.exe.
This program will handle the task of updating the packages on your
system to the latest version. For more information about using
Cygwin's 'setup.exe', see Setting Up Cygwin in the Cygwin User's
Guide."
[Setting up Cygwin]
http://cygwin.com/cygwin-ug-net/setup-net.html
"Internet Setup"
"To install the Cygwin net release, go to http://cygwin.com/ and click
on 'Install Cygwin Now!'. This will download a GUI installer called
setup.exe which can be run to download a complete cygwin installation
via the internet. Follow the instructions on each screen to install
Cygwin."
[GNU + Cygnus + Windows = Cygwin]
http://cygwin.com/
"Install Cywin Now" button at upper right and also linked at least
three other places on the page.
"Latest Cygwin DLL release version is 1.5.10-3"
* * * * * * * * * * * * * * * * * * *
As a reality check I found the "tailored" instructions here quite
helpful. Although the author is describing the installation of Cygwin
for a purpose other than Octave, it gave "depth" perspective to see
what a large beast the total Cygwin package is. It _can_ provide a
Unix-like bash shell interface to Windows OS, but many of the standard
Unix commands are _not_ part of the "default" Cygwin installation, eg.
clear and less among other items described here:
[ftpSYNC Windows Installation - Windows 9x , XP, NT running cygwin]
http://home.earthlink.net/~fredclrk/ftpsync/docs/install.html
It gives a checklist of commands to run from the bash prompt to verify
installation, and recommends adding a dialog/menu management engine
(link provided on that page).
* * * * * * * * * * * * * * * * * * *
That being said I opted for the default installation, using DOS-style
text files (vs. Unix-style, a radio button option on the setup's first
configuration screen), to the directory C:\cygwin. Because I'd done
an Octave installation before, it seemed to pick up the "old"
(nonexistent) directory as the default this time, but warned me not to
choose a "root path" with embedded spaces (as in C:\Program
Files\...).
* * * * * * * * * * * * * * * * * * *
At the last screen of the setup program there are checkboxes to create
Start Menu and desktop icons for the Cygwin shell, which I accepted.
If you are running a firewall (as I do), you'll be alerted a few times
as the setup program and the Cygwin shell, at least the first time you
launch it, seek access to the Internet. The shell in particular seems
to use uname and hostname to construct a default "prompt" string.
* * * * * * * * * * * * * * * * * * *
Finally it must be admitted that the Octave package on my laptop
exhibits one annoying visual distraction, a scatter of black vertical
strokes (against a white background) delimiting my typing (but not in
general with the system's output to the screen). I'd hoped upgrading
to the latest Cygwin package would eliminate this, but alas it did
not.
When necessary I minimize the window in which Octave is running and
restore it, which removes these display artifacts.
regards, mathtalk-ga
|