[comp.lang.c] Numerical Recipes in C for Macintosh

tow@arisia.Xerox.COM (Rob Tow) (09/01/88)

Does anyone have any idea when a Macintosh version of Numerical Recipes in
C will be available? I tried calling the U.S. offices of Cambridge University
Press, and was not able to get any information.

I would even be willing to be a beta site, if the porter of the code is
watching this group.  :-)



---

Rob Tow
Member Research Staff
Electronic Document Lab
Xerox PARC
3333 Coyote Hill Drive
Palo Alto, CA 94303
(415)-494-4087

gwyn@smoke.ARPA (Doug Gwyn ) (09/01/88)

In article <422@arisia.Xerox.COM> tow@arisia.Xerox.COM (Rob Tow) writes:
>Does anyone have any idea when a Macintosh version of Numerical Recipes in
>C will be available?

It's already out -- it's called "Numerical Recipes in C".

dhesi@bsu-cs.UUCP (Rahul Dhesi) (09/01/88)

In article <8416@smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>In article <422@arisia.Xerox.COM> tow@arisia.Xerox.COM (Rob Tow) writes:
>>Does anyone have any idea when a Macintosh version of Numerical Recipes in
>>C will be available?
>
>It's already out -- it's called "Numerical Recipes in C".

Actually, for each book on, about, or in, the C programing language,
you need a separate Macintosh version, or at least an appendix.  The
reason is that on the Macintosh there is no provision for supplying
argc and argv to a program.
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi

chpf127@ut-emx.UUCP (J. Eaton) (09/02/88)

>  Rob Tow writes:
>
>   Does anyone have any idea when a Macintosh version of Numerical Recipes
>   in C will be available?

>  Doug Gwyn writes:
>
>   It's already out -- it's called "Numerical Recipes in C".
 
>  Rahul Dhesi writes:
>
>   Actually, for each book on, about, or in, the C programing language,
>   you need a separate Macintosh version, or at least an appendix.  The
>   reason is that on the Macintosh there is no provision for supplying
>   argc and argv to a program.

  Finally, I write:

  Last I checked, Numerical Recipes was simply a collection of
  {subroutines|procedures|functions} --- no main programs to be found.
  It's up to you to provide the drivers to mix and match the procedures
  to suit yourself.  If you happen to be working in an environment that's
  so lame (1/2 :-) it won't let you get argv and argc, then you can:

    (a)  move to a new, possibly less restrictive environment
    (b)  adapt your main program to get options etc. in another way
    (c)  die


  J. Eaton                                    Not really doing anything
  UT Department of Chemical Engineering                 with chemicals.

rob@kaa.eng.ohio-state.edu (Rob Carriere) (09/02/88)

In article <3834@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes:
>In article <8416@smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) 
>writes:
>>In article <422@arisia.Xerox.COM> tow@arisia.Xerox.COM (Rob Tow) writes:
>>>Does anyone have any idea when a Macintosh version of Numerical Recipes in
>>>C will be available?
>>It's already out -- it's called "Numerical Recipes in C".
>Actually, [ you need a ] Macintosh version, or [...] an appendix.
>[ because ] there is no provision for supplying argc and argv to a program.

Since NR only gives you a set of functions for performing various
tasks, not complete programs, there shouldn't be any such problems in
this particular case.

Rob Carriere
Guess I found the exceptio that confirms your rule :-)

johns@calvin.EE.CORNELL.EDU (John Sahr) (09/02/88)

I failed to include the text of an article stating (I paraphrase):

A special edition of Numerical Recipes (in Language X) is needed for
the Macintosh, because there is no way to get argc and argv in main.

There are two things wrong with this. First, Everything in NR (I think)
is a subroutine call, so the main() command line isn't really an issue.

Also, it is simple enough to write a patch which simply queries the 
user for the command line upon invocation.  Lightspeed C even provides
the code, although it is really quite simple.

These opinions are, of course, my own.

-- 
John Sahr,                          School of Elect. Eng.,  Upson Hall   
                                    Cornell University, Ithaca, NY 14853

ARPA: johns@calvin.ee.cornell.edu; UUCP: {rochester,cmcl2}!cornell!calvin!johns

swilson%thetone@Sun.COM (Scott Wilson) (09/03/88)

>The
>reason is that on the Macintosh there is no provision for supplying
>argc and argv to a program.

There are at least three (and probably more like five) C programming
environments for the Macintosh.  At least one (the one I own), THINK C
does have provisions for supplying argc and argv to a program.  It's
a bit kludegy, but there nonetheless.  I don't think it is a good idea
to make generalizations about C programming on the Mac.


--
Scott Wilson		arpa: swilson@sun.com
Sun Microsystems	uucp: ...!sun!swilson
Mt. View, CA

peter@ficc.uu.net (Peter da Silva) (09/07/88)

In article <3834@bsu-cs.UUCP>, dhesi@bsu-cs.UUCP (Rahul Dhesi) writes:
> Actually, for each book on, about, or in, the C programing language,
> you need a separate Macintosh version, or at least an appendix.  The
> reason is that on the Macintosh there is no provision for supplying
> argc and argv to a program.

Well since there is stdio emulation (according to recent articles):

#ifndef MAC
main(argc, argv)
int argc;
char *argv[];
#else
main()
{
	char args[80], *argv[80];
	int argc;

	printf("Args: ");
	gets(args)
	argc = 1;
	while(*args) {
		while(isspace(*args))
			args++;
		if(*args) {
			argv[argc++] = args;
			while(*args && !isspace(*args))
				args++;
			if(*args)
				*args++ = 0;
		}
	}
	argv[argc] = 0;
#endif
-- 
Peter da Silva  `-_-'  Ferranti International Controls Corporation.
"Have you hugged  U  your wolf today?"            peter@ficc.uu.net

dhesi@bsu-cs.UUCP (Rahul Dhesi) (09/08/88)

In article <1415@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes:
>#ifndef MAC
[usual argv, argc code]
>#else
[code for Macintosh that reads a line, splits into arguments]
#endif

How do we use wildcards then?

And what happens if program A wants to invoke program B and supply it
arguments?
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi

earleh@eleazar.dartmouth.edu (Earle R. Horton) (09/08/88)

In article <3874@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes:
>In article <1415@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes:
...
>[code for Macintosh that reads a line, splits into arguments]
...
>How do we use wildcards then?

     Many methods come to mind.  You can parse the command line, then
use system calls to find which files exist, filling in the wild cards.
Alternately, you can purchase a command line interpreter or alternate
shell which supports command lines.  For programs which must have
main(argc,arcv) (or which I am too lazy to rewrite) I run the program
as an MPW Shell Tool.  The MPW Shell provides a UNIX-like environment
with command line arguments, fake pipes, and all sorts of goodies too
numerous to mention here.  The preferred method is to take the main()
function from Numerical Recipes or whatever source, and make it into a
subroutine which is called by a mouse and menu event parser which you
write.  The Finder also provides a function, GetAppFiles(), which can
be used to fill in the argument list prior to calling main().

     The programmer interface to the Macintosh does not readily
support the concept of a command line, but there are many ways for a
clever programmer to implement it.  Published or public domain code
can then be readily transported to the Macintosh with varying degrees
of extra work for the programmer.  Usually this means NO extra work if
you purchase a shell.  A separate book on Numerical Recipes for the
Macintosh is therefore NOT required, but books on how to use the
Macintosh-specific user interface usually are if you want to make your
programs visually appealing or use graphics, menus, etc.

>And what happens if program A wants to invoke program B and supply it
>arguments?

     This is possible, but is considerably more complicated than
system("program arg1 arg2 ...").  If you purchase a good shell
program, this is rarely necessary since you can write shell scripts to
do this kind of thing.

     The Macintosh provides a very different set of constraints for
programmers to work within, and provides different capabilities from
those which UNIX and other system users are typically accustomed to.
Nevertheless, this machine can be used as a serious number-crunching
tool, particular if you get one with the MC68881 numeric data
processor installed.  You can also draw pretty pictures at the same
time, and with much less work than on other graphics-oriented systems,
once you get the hang of it.

     Programs which use main(argc,argv) and which make the results of
their computations known by piping stdin to stdout can in most cases
be directly compiled and run using one of the another of the commonly
available development systems or shells.  On the Macintosh, such
programs tend to be boring in comparison with programs specially
written to manipulate windows, menus, Icons, and all that stuff
directly.  You can, however, have both.
Earle R. Horton. 23 Fletcher Circle, Hanover, NH 03755
(603) 643-4109

gwyn@smoke.ARPA (Doug Gwyn ) (09/08/88)

In article <3874@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes:
>How do we use wildcards then?
>And what happens if program A wants to invoke program B and supply it
>arguments?

Why, you use your shell.  What! You don't have a pipe icon?
And I thought the Macintosh was supposed to be "user friendly"!

Maybe someone should write a UNIX-like shell (or use A/UX).