Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > NUMERICAL RECIPES

Reply
Thread Tools

NUMERICAL RECIPES

 
 
James Dow Allen
Guest
Posts: n/a
 
      01-03-2011
On Jan 3, 3:39*am, glen herrmannsfeldt <(E-Mail Removed)> wrote:
> ... fix up those problems, in the end you learn more about
> how it works. *It did that at least once, and it took a while
> to get right. *(Especially all the loops indexing arrays
> from zero instead of one.)


I also went through the NR routines I needed and rewrote them
to index from zero; am glad to discover now I wasn't the only
one so perverse. But, no ... I didn't learn how Jacobi's
pivots work while I was at it, just being in "copy faithfully"
mode.

Doing this rewrite, I felt somewhat anal-retentive, since the
N.R. routines could be treated as a black box, and the funny
indexing disguised via macros. It was my obsessive-compulsive
behavior, I think, that made me "fix" the indexing ...
but at least I don't wash my hands 10 hours per day like
some OCD sufferers.

James Dow Allen
 
Reply With Quote
 
 
 
 
Richard Maine
Guest
Posts: n/a
 
      01-05-2011
Phil Hobbs <(E-Mail Removed)> wrote:

> ...once you put them [NR codes] in a shared library, it
> becomes a useful prototyping tool and doesn't contaminate your code with
> copylefts and suchlike.


Have you read the license conditions on the NR code? Regardless of what
one might think about copylefts, the copyright on the NR code is more
restrictive than any copyleft. Copylefts place conditions on
redistributing the code or programs built from it. The NR copyright
places an even stronger condition - namely that you cannot do it at all.

Quoting exactly from my copy of NR in Fortran 90

"Immediate License....You are not allowed to transfer or distribute
machine-readable copies to any other person, or to use the routines
on more than one machine, or to distribute executable programs
containing our routines. This is the only free license."

As the last sentence quoted above implies, there are other license
options, but you have to pay for all of them (paying for the book
doesn't count).

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
 
Reply With Quote
 
 
 
 
Uno
Guest
Posts: n/a
 
      01-09-2011
On 1/7/2011 5:09 AM, rosario wrote:
> "rosario"<(E-Mail Removed)> ha scritto nel messaggio
> news:4d25757b$0$10583$(E-Mail Removed) ...
>>
>> "rosario"<(E-Mail Removed)> ha scritto nel messaggio
>> news:4d2571d4$0$10573$(E-Mail Removed) ...
>>>
>>> "rosario"<(E-Mail Removed)> ha scritto nel messaggio
>>> news:4d249126$0$10574$(E-Mail Removed) ...
>>>>
>>>> "robin"<(E-Mail Removed)> ha scritto nel messaggio
>>>> news:4d2055cd$0$99356$(E-Mail Removed)...
>>>>> "Ron Shepard"<(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>
>>>>> | I think the
>>>>> | Numerical Recipes books are excellent introductions to many
>>>>> | computational problems, including linear algebra. I do agree that
>>>>> | the code itself that is given in the book is sometimes not the most
>>>>> | robust, but on the other hand, something like LAPACK code is robust
>>>>> | but too complicated for a beginner to understand easily.
>>>>>
>>>>> Numerical Recipes is an authoritative source of information
>>>>> about a vast number of numerical procedures.
>>>>
>>>> better write code in one macro asm that allow multi instruction for line
>>>> and indentation
>>>>
>>>> all compiler science == 0 for me, and it go to the wrong way
>>>> [the way the human lost what the machine do]
>>>
>>> excuse me possibily, i'm one extremis don't believe all the people say
>>> i believe what i see

>>
>> and i see something like this:
>>
>> ; a inizializzaRNDFile(u32* RNDvar, u8* fname)
>> ; Questa funzione inizializza i vettori delle basi e dei seed per la variabile
>> random RNDvar
>> ; prendendo i dati per l'inizializzazione da un file esterno.
>> ; RNDvar: variabile random ritornata da rtnRNDmem() o inizializzata da
>> iniRNDmem
>> [in/out]
>> ; fname: stringa che contiene il nome del file i cui dati servono a
>> inizializzare RNDvar [in]
>> ; ritorna: [0 ed CF==1 per errore; 1 ed CF==0 tutto ok]
>> ; uso tipico:
>> ; rtnRNDmem(6, 31415821, 1234) |jc .e|j=a
>> ; inizializzaRNDFile(j, "filedati")|jc .e
>> ; 0j,4i,8Ra, 12P_RNDvar, 16P_fname + 5120
>> ; 5132 5136
>> align 4
>> inizializzaRNDFile:
>> <i,j
>> s-=5120
>> << RNDvar=5132, fname=5136, KeyHandle=16
>> i=^fname|j=^RNDvar
>> i==0#.e |j==0 #.e|D*j==0#.e ; la basea non puo' essere zero
>> D*j+ini== -1 #.e ; l'array di basi non puo' essere inizializzato
>> D*j+nbs>100000#.e ; il numero delle basi non puo' essere> 100000
>> #.1
>> .e1: a=^KeyHandle|CloseHandle(a)
>> .e: a^=a|stc|#.z ; errore: ritorna 0
>> .1: CreateFileA(i,&GENERIC_READ, 0, 0,&OPEN_EXISTING,
>> &FILE_ATTRIBUTE_NORMAL,0)
>> a==&INVALID_HANDLE_VALUE#.e|^KeyHandle=a
>> r=&*s+24|c=s|ReadFile(a, r, 4064, c, 0)
>> a==0#.e1|a=D*s|a<4?#.e1 ; se ha elementi in numero<4 esci errore
>> a=^KeyHandle|CloseHandle(a)|a==0#.e
>> ; prepara la variabile random definendo l'array di
>> basi e seed
>> ; con i dati provenienti dal file
>> r=&*s+24|a=^0|PreparaRND(j, r, a)|jc .e
>> a=1|clc
>> .z:
>>>> RNDvar, fname, KeyHandle

>> s=&*s+5120
>>> i,j

>> ret 8

>
> so i'm just one troll?
>
>


I would say more like a scribbler. That's alright, if you're five.
--
Uno
 
Reply With Quote
 
Uno
Guest
Posts: n/a
 
      01-09-2011
On 1/5/2011 2:11 PM, Richard Maine wrote:
> Phil Hobbs<(E-Mail Removed)> wrote:
>
>> ...once you put them [NR codes] in a shared library, it
>> becomes a useful prototyping tool and doesn't contaminate your code with
>> copylefts and suchlike.

>
> Have you read the license conditions on the NR code? Regardless of what
> one might think about copylefts, the copyright on the NR code is more
> restrictive than any copyleft. Copylefts place conditions on
> redistributing the code or programs built from it. The NR copyright
> places an even stronger condition - namely that you cannot do it at all.
>
> Quoting exactly from my copy of NR in Fortran 90
>
> "Immediate License....You are not allowed to transfer or distribute
> machine-readable copies to any other person, or to use the routines
> on more than one machine, or to distribute executable programs
> containing our routines. This is the only free license."
>
> As the last sentence quoted above implies, there are other license
> options, but you have to pay for all of them (paying for the book
> doesn't count).
>


My problem with the treatment was the large, proprietary module that
needed to be included in order to make the smallest of examples work.

I'm not saying that would be a problem for others, presumably people
with deeper pockets than me, which is a lot of people.

They sure are amazing, quick, and robust, tho.
--
Uno
 
Reply With Quote
 
Uno
Guest
Posts: n/a
 
      01-09-2011
On 1/2/2011 7:34 PM, Seebs wrote:
> On 2011-01-02, robin<(E-Mail Removed)> wrote:
>> "bert"<(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Practically all of the C code had
>>> been transliterated quite mindlessly from Fortran,
>>> making hardly any use of C idioms which would
>>> have made the code cleaner and neater. In
>>> particular, there was scarcely any use of pointers.

>
>> Pointers are probably best avoided.

>
> Not in a book that's supposed to be useful to C programmers.


By what process do you get that? Programs without pointers aren't useful?

Usually, when the rest of us talk about "avoiding pointers," we mean the
unnecessary ones that obfuscate.

Of course, I'll never stand between Seebs and his calling to make C a
useless abstraction.
--
Uno
 
Reply With Quote
 
nmm1@cam.ac.uk
Guest
Posts: n/a
 
      01-09-2011
In article <(E-Mail Removed)>, Uno <(E-Mail Removed)> wrote:
>On 1/2/2011 7:34 PM, Seebs wrote:
>> On 2011-01-02, robin<(E-Mail Removed)> wrote:
>>
>>> Pointers are probably best avoided.

>>
>> Not in a book that's supposed to be useful to C programmers.

>
>By what process do you get that? Programs without pointers aren't useful?


In C, that is true. All of strings, arrays and (when used as objects)
functions are actually pointers, and it is important to know and use
that when passing them as function arguments.

It is not true in Fortran.


Regards,
Nick Maclaren.
 
Reply With Quote
 
aruzinsky
Guest
Posts: n/a
 
      01-09-2011
Proper implementation of C pointers increases program speed but the
source code is relatively unreadable. C and, more so, C++ can be
written to be either very readable or very unreadable. I much rather
read C source code written to resemble pseudo-code. Afterwards, it is
easy enough for me to implement pointers (which later I have
difficulty reading).

On Jan 8, 9:42*pm, Uno <(E-Mail Removed)> wrote:
> On 1/2/2011 7:34 PM, Seebs wrote:
>
> > On 2011-01-02, robin<(E-Mail Removed)> *wrote:
> >> "bert"<(E-Mail Removed)> *wrote in message
> >>news:(E-Mail Removed)....
> >>> Practically all of the C code had
> >>> been transliterated quite mindlessly from Fortran,
> >>> making hardly any use of C idioms which would
> >>> have made the code cleaner and neater. *In
> >>> particular, there was scarcely any use of pointers.

>
> >> Pointers are probably best avoided.

>
> > Not in a book that's supposed to be useful to C programmers.

>
> By what process do you get that? *Programs without pointers aren't useful?
>
> Usually, when the rest of us talk about "avoiding pointers," we mean the
> unnecessary ones that obfuscate.
>
> Of course, I'll never stand between Seebs and his calling to make C a
> useless abstraction.
> --
> Uno


 
Reply With Quote
 
Seebs
Guest
Posts: n/a
 
      01-09-2011
On 2011-01-09, aruzinsky <(E-Mail Removed)> wrote:
> Proper implementation of C pointers increases program speed but the
> source code is relatively unreadable.


No, it isn't.

> I much rather
> read C source code written to resemble pseudo-code. Afterwards, it is
> easy enough for me to implement pointers (which later I have
> difficulty reading).


There are tons of algorithms which are elegant and clear using pointers,
and hard to write clearly at all without them. Perhaps you should just
practice more until pointers are more comfortable for you.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
 
Reply With Quote
 
Beliavsky
Guest
Posts: n/a
 
      01-09-2011
On Jan 8, 10:33*pm, Uno <(E-Mail Removed)> wrote:
> On 1/5/2011 2:11 PM, Richard Maine wrote:
>
>
>
>
>
>
>
>
>
> > Phil Hobbs<(E-Mail Removed)> *wrote:

>
> >> ...once you put them [NR codes] in a shared library, it
> >> becomes a useful prototyping tool and doesn't contaminate your code with
> >> copylefts and suchlike.

>
> > Have you read the license conditions on the NR code? Regardless of what
> > one might think about copylefts, the copyright on the NR code is more
> > restrictive than any copyleft. Copylefts place conditions on
> > redistributing the code or programs built from it. The NR copyright
> > places an even stronger condition - namely that you cannot do it at all..

>
> > Quoting exactly from my copy of NR in Fortran 90

>
> > * *"Immediate License....You are not allowed to transfer or distribute
> > * * machine-readable copies to any other person, or to use the routines
> > * * on more than one machine, or to distribute executable programs
> > * * containing our routines. This is the only free license."

>
> > As the last sentence quoted above implies, there are other license
> > options, but you have to pay for all of them (paying for the book
> > doesn't count).

>
> My problem with the treatment was the large, proprietary module that
> needed to be included in order to make the smallest of examples work.


I think that part of the Numerical Recipes is in the public domain .
See http://www.nr.com/public-domain.html .
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      01-09-2011
(E-Mail Removed) writes:
> In article <(E-Mail Removed)>, Uno <(E-Mail Removed)> wrote:
>>On 1/2/2011 7:34 PM, Seebs wrote:
>>> On 2011-01-02, robin<(E-Mail Removed)> wrote:
>>>
>>>> Pointers are probably best avoided.
>>>
>>> Not in a book that's supposed to be useful to C programmers.

>>
>>By what process do you get that? Programs without pointers aren't useful?

>
> In C, that is true. All of strings, arrays and (when used as objects)
> functions are actually pointers, and it is important to know and use
> that when passing them as function arguments.
>
> It is not true in Fortran.


It's not true in C either.

Strings are not pointers. Arrays are not pointers. Functions are not
pointers.

All three are typically managed using pointers, and a declaration that
looks like a parameter of array or function type is really a pointer
parameter.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chicken Recipes - The Web's Largest Chicken Recipes Collection Lew Java 1 02-21-2009 02:44 AM
Java numerical recipes online... Al Murphy Java 1 02-05-2004 06:14 PM
Error in Numerical Recipes lubksb routine mma C Programming 5 12-09-2003 09:36 AM
Re: numerical recipes book E. Robert Tisdale C Programming 0 07-31-2003 02:02 AM
Re: numerical recipes book Rouben Rostamian C Programming 0 07-30-2003 02:04 PM



Advertisments