Question on book Numerical recipes, 2nd ed.: allocation/deallocation of memory for vectors











up vote
1
down vote

favorite












The book Numerical recipes, 2nd edition (http://numerical.recipes) uses the following code to allocate/deallocate a memory for a vector v with subscripts [nl..nh]:



#define NR_END 1
#define FREE_ARG char*

float *vector(long nl, long nh)
/* allocate a float vector with subscript range v[nl..nh] */
{
float *v;

v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
if (!v) nrerror("allocation failure in vector()");
return v-nl+NR_END;
}

void free_vector(float *v, long nl, long nh)
/* free a float vector allocated with vector() */
{
free((FREE_ARG) (v+nl-NR_END));
}


Question 1: What is the purpose of adding/subtracting NR_END elements?



Question 2: What is the purpose of converting float * to char * in free_vector?



I understand that +1 in malloc is due to the inclusive right boundary of the array (which is non-inclusive usually in C).










share|improve this question






















  • 1) Numerical Recipes uses first_index=1 indexing ( because it is basically converted FORTRAN code, which used offset=1 indexes) 2) before ANSI /c89 /c90 there was no void* and malloc and free used char pointers.
    – joop
    Nov 19 at 16:32












  • @joop It doesn't use 1 indexing, the function lets you choose the first index.
    – interjay
    Nov 19 at 16:32










  • For nl=0 it returns something different from what malloc returned.
    – joop
    Nov 19 at 16:36










  • stackoverflow.com/q/41489210/2235885 for an example of someone assuming zero-based indexing.
    – joop
    Nov 19 at 17:38










  • @joop, thanks for the explanation of char * in C before the 1989 standard.
    – Dmitry Kabanov
    Nov 19 at 18:53















up vote
1
down vote

favorite












The book Numerical recipes, 2nd edition (http://numerical.recipes) uses the following code to allocate/deallocate a memory for a vector v with subscripts [nl..nh]:



#define NR_END 1
#define FREE_ARG char*

float *vector(long nl, long nh)
/* allocate a float vector with subscript range v[nl..nh] */
{
float *v;

v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
if (!v) nrerror("allocation failure in vector()");
return v-nl+NR_END;
}

void free_vector(float *v, long nl, long nh)
/* free a float vector allocated with vector() */
{
free((FREE_ARG) (v+nl-NR_END));
}


Question 1: What is the purpose of adding/subtracting NR_END elements?



Question 2: What is the purpose of converting float * to char * in free_vector?



I understand that +1 in malloc is due to the inclusive right boundary of the array (which is non-inclusive usually in C).










share|improve this question






















  • 1) Numerical Recipes uses first_index=1 indexing ( because it is basically converted FORTRAN code, which used offset=1 indexes) 2) before ANSI /c89 /c90 there was no void* and malloc and free used char pointers.
    – joop
    Nov 19 at 16:32












  • @joop It doesn't use 1 indexing, the function lets you choose the first index.
    – interjay
    Nov 19 at 16:32










  • For nl=0 it returns something different from what malloc returned.
    – joop
    Nov 19 at 16:36










  • stackoverflow.com/q/41489210/2235885 for an example of someone assuming zero-based indexing.
    – joop
    Nov 19 at 17:38










  • @joop, thanks for the explanation of char * in C before the 1989 standard.
    – Dmitry Kabanov
    Nov 19 at 18:53













up vote
1
down vote

favorite









up vote
1
down vote

favorite











The book Numerical recipes, 2nd edition (http://numerical.recipes) uses the following code to allocate/deallocate a memory for a vector v with subscripts [nl..nh]:



#define NR_END 1
#define FREE_ARG char*

float *vector(long nl, long nh)
/* allocate a float vector with subscript range v[nl..nh] */
{
float *v;

v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
if (!v) nrerror("allocation failure in vector()");
return v-nl+NR_END;
}

void free_vector(float *v, long nl, long nh)
/* free a float vector allocated with vector() */
{
free((FREE_ARG) (v+nl-NR_END));
}


Question 1: What is the purpose of adding/subtracting NR_END elements?



Question 2: What is the purpose of converting float * to char * in free_vector?



I understand that +1 in malloc is due to the inclusive right boundary of the array (which is non-inclusive usually in C).










share|improve this question













The book Numerical recipes, 2nd edition (http://numerical.recipes) uses the following code to allocate/deallocate a memory for a vector v with subscripts [nl..nh]:



#define NR_END 1
#define FREE_ARG char*

float *vector(long nl, long nh)
/* allocate a float vector with subscript range v[nl..nh] */
{
float *v;

v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
if (!v) nrerror("allocation failure in vector()");
return v-nl+NR_END;
}

void free_vector(float *v, long nl, long nh)
/* free a float vector allocated with vector() */
{
free((FREE_ARG) (v+nl-NR_END));
}


Question 1: What is the purpose of adding/subtracting NR_END elements?



Question 2: What is the purpose of converting float * to char * in free_vector?



I understand that +1 in malloc is due to the inclusive right boundary of the array (which is non-inclusive usually in C).







c numerical-recipes






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 at 16:25









Dmitry Kabanov

136110




136110












  • 1) Numerical Recipes uses first_index=1 indexing ( because it is basically converted FORTRAN code, which used offset=1 indexes) 2) before ANSI /c89 /c90 there was no void* and malloc and free used char pointers.
    – joop
    Nov 19 at 16:32












  • @joop It doesn't use 1 indexing, the function lets you choose the first index.
    – interjay
    Nov 19 at 16:32










  • For nl=0 it returns something different from what malloc returned.
    – joop
    Nov 19 at 16:36










  • stackoverflow.com/q/41489210/2235885 for an example of someone assuming zero-based indexing.
    – joop
    Nov 19 at 17:38










  • @joop, thanks for the explanation of char * in C before the 1989 standard.
    – Dmitry Kabanov
    Nov 19 at 18:53


















  • 1) Numerical Recipes uses first_index=1 indexing ( because it is basically converted FORTRAN code, which used offset=1 indexes) 2) before ANSI /c89 /c90 there was no void* and malloc and free used char pointers.
    – joop
    Nov 19 at 16:32












  • @joop It doesn't use 1 indexing, the function lets you choose the first index.
    – interjay
    Nov 19 at 16:32










  • For nl=0 it returns something different from what malloc returned.
    – joop
    Nov 19 at 16:36










  • stackoverflow.com/q/41489210/2235885 for an example of someone assuming zero-based indexing.
    – joop
    Nov 19 at 17:38










  • @joop, thanks for the explanation of char * in C before the 1989 standard.
    – Dmitry Kabanov
    Nov 19 at 18:53
















1) Numerical Recipes uses first_index=1 indexing ( because it is basically converted FORTRAN code, which used offset=1 indexes) 2) before ANSI /c89 /c90 there was no void* and malloc and free used char pointers.
– joop
Nov 19 at 16:32






1) Numerical Recipes uses first_index=1 indexing ( because it is basically converted FORTRAN code, which used offset=1 indexes) 2) before ANSI /c89 /c90 there was no void* and malloc and free used char pointers.
– joop
Nov 19 at 16:32














@joop It doesn't use 1 indexing, the function lets you choose the first index.
– interjay
Nov 19 at 16:32




@joop It doesn't use 1 indexing, the function lets you choose the first index.
– interjay
Nov 19 at 16:32












For nl=0 it returns something different from what malloc returned.
– joop
Nov 19 at 16:36




For nl=0 it returns something different from what malloc returned.
– joop
Nov 19 at 16:36












stackoverflow.com/q/41489210/2235885 for an example of someone assuming zero-based indexing.
– joop
Nov 19 at 17:38




stackoverflow.com/q/41489210/2235885 for an example of someone assuming zero-based indexing.
– joop
Nov 19 at 17:38












@joop, thanks for the explanation of char * in C before the 1989 standard.
– Dmitry Kabanov
Nov 19 at 18:53




@joop, thanks for the explanation of char * in C before the 1989 standard.
– Dmitry Kabanov
Nov 19 at 18:53












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted












  1. Suppose you had nl=1 and NR_END=0. Then the returned pointer would be out of bounds (it points before the allocated block). This is undefined behavior and can lead to incorrect results, although it is unlikely to cause problems on major compilers because the pointer would be incremented back before it is dereferenced.



    To avoid this undefined behavior, you can set NR_END to the maximum expected value of nl (which is 1 in the book). This guarantees that the returned pointer is valid. However, the implementation given in the question is still incorrect, because v-nl+NR_END decrements by nl before incrementing by NR_END. A correct implementation would be v+NR_END-nl.



    Note that if nl only ever has non-negative values, a much simpler implementation would be to simply allocate nh+1 values, and then you don't need any pointer arithmetic after malloc or before free.



    Here you can see a quote from the book explaining this, from pages 940-941 of the second edition. Some quotes:




    it might
    happen in rare cases (and probably only on a segmented machine) that the expression b-1
    has no representation at all. If this occurs, then there is no guarantee that the relation
    b=(b-1)+1 is satisfied.




    [....]




    the parameter NR_END is used as a number of extra storage
    locations allocated at the beginning of every vector or matrix block, simply for the purpose
    of making offset pointer references guaranteed-representable.




  2. The cast to char* is not needed in any standardized version of C. It may have been needed in ancient versions. Casting the return value of malloc is also not needed.







share|improve this answer



















  • 1




    I'm not buying your explanation of NR_END. What you say is true, but if indeed values of nl different from 0 and 1 are not supported then it is sufficient to add NR_END to the size of the allocation, as indeed is done. vector() could then simply return the value from malloc() without doing any arithmetic on it, and vector_free() would not need to account for the same.
    – John Bollinger
    Nov 19 at 17:29












  • @JohnBollinger It isn't my explanation, it is the book's explanation, See here. I did say in my answer that it would be much simpler to not perform any pointer arithmetic. It is in general quite bad code.
    – interjay
    Nov 19 at 17:30










  • @interjay, thanks for the explanation! I wish I were more patient and looked at the book more carefully before asking my question here :-) I accept your answer.
    – Dmitry Kabanov
    Nov 19 at 19:19










  • @interjay, regarding your third paragraph (starting with 'Note that if nl only ever has non-negative values'). Are you sure what you say is correct? I think, it is applicable only if you whant array to be indexed by 0, 1, ..., nh (inclusive). This routine expects the caller to index an array by nl, nl+1, ..., nh (inclusive).
    – Dmitry Kabanov
    Nov 19 at 19:20






  • 1




    Thanks for the assumption of bad faith
    – Tim Randall
    Nov 19 at 21:39











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53378855%2fquestion-on-book-numerical-recipes-2nd-ed-allocation-deallocation-of-memory-f%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted












  1. Suppose you had nl=1 and NR_END=0. Then the returned pointer would be out of bounds (it points before the allocated block). This is undefined behavior and can lead to incorrect results, although it is unlikely to cause problems on major compilers because the pointer would be incremented back before it is dereferenced.



    To avoid this undefined behavior, you can set NR_END to the maximum expected value of nl (which is 1 in the book). This guarantees that the returned pointer is valid. However, the implementation given in the question is still incorrect, because v-nl+NR_END decrements by nl before incrementing by NR_END. A correct implementation would be v+NR_END-nl.



    Note that if nl only ever has non-negative values, a much simpler implementation would be to simply allocate nh+1 values, and then you don't need any pointer arithmetic after malloc or before free.



    Here you can see a quote from the book explaining this, from pages 940-941 of the second edition. Some quotes:




    it might
    happen in rare cases (and probably only on a segmented machine) that the expression b-1
    has no representation at all. If this occurs, then there is no guarantee that the relation
    b=(b-1)+1 is satisfied.




    [....]




    the parameter NR_END is used as a number of extra storage
    locations allocated at the beginning of every vector or matrix block, simply for the purpose
    of making offset pointer references guaranteed-representable.




  2. The cast to char* is not needed in any standardized version of C. It may have been needed in ancient versions. Casting the return value of malloc is also not needed.







share|improve this answer



















  • 1




    I'm not buying your explanation of NR_END. What you say is true, but if indeed values of nl different from 0 and 1 are not supported then it is sufficient to add NR_END to the size of the allocation, as indeed is done. vector() could then simply return the value from malloc() without doing any arithmetic on it, and vector_free() would not need to account for the same.
    – John Bollinger
    Nov 19 at 17:29












  • @JohnBollinger It isn't my explanation, it is the book's explanation, See here. I did say in my answer that it would be much simpler to not perform any pointer arithmetic. It is in general quite bad code.
    – interjay
    Nov 19 at 17:30










  • @interjay, thanks for the explanation! I wish I were more patient and looked at the book more carefully before asking my question here :-) I accept your answer.
    – Dmitry Kabanov
    Nov 19 at 19:19










  • @interjay, regarding your third paragraph (starting with 'Note that if nl only ever has non-negative values'). Are you sure what you say is correct? I think, it is applicable only if you whant array to be indexed by 0, 1, ..., nh (inclusive). This routine expects the caller to index an array by nl, nl+1, ..., nh (inclusive).
    – Dmitry Kabanov
    Nov 19 at 19:20






  • 1




    Thanks for the assumption of bad faith
    – Tim Randall
    Nov 19 at 21:39















up vote
1
down vote



accepted












  1. Suppose you had nl=1 and NR_END=0. Then the returned pointer would be out of bounds (it points before the allocated block). This is undefined behavior and can lead to incorrect results, although it is unlikely to cause problems on major compilers because the pointer would be incremented back before it is dereferenced.



    To avoid this undefined behavior, you can set NR_END to the maximum expected value of nl (which is 1 in the book). This guarantees that the returned pointer is valid. However, the implementation given in the question is still incorrect, because v-nl+NR_END decrements by nl before incrementing by NR_END. A correct implementation would be v+NR_END-nl.



    Note that if nl only ever has non-negative values, a much simpler implementation would be to simply allocate nh+1 values, and then you don't need any pointer arithmetic after malloc or before free.



    Here you can see a quote from the book explaining this, from pages 940-941 of the second edition. Some quotes:




    it might
    happen in rare cases (and probably only on a segmented machine) that the expression b-1
    has no representation at all. If this occurs, then there is no guarantee that the relation
    b=(b-1)+1 is satisfied.




    [....]




    the parameter NR_END is used as a number of extra storage
    locations allocated at the beginning of every vector or matrix block, simply for the purpose
    of making offset pointer references guaranteed-representable.




  2. The cast to char* is not needed in any standardized version of C. It may have been needed in ancient versions. Casting the return value of malloc is also not needed.







share|improve this answer



















  • 1




    I'm not buying your explanation of NR_END. What you say is true, but if indeed values of nl different from 0 and 1 are not supported then it is sufficient to add NR_END to the size of the allocation, as indeed is done. vector() could then simply return the value from malloc() without doing any arithmetic on it, and vector_free() would not need to account for the same.
    – John Bollinger
    Nov 19 at 17:29












  • @JohnBollinger It isn't my explanation, it is the book's explanation, See here. I did say in my answer that it would be much simpler to not perform any pointer arithmetic. It is in general quite bad code.
    – interjay
    Nov 19 at 17:30










  • @interjay, thanks for the explanation! I wish I were more patient and looked at the book more carefully before asking my question here :-) I accept your answer.
    – Dmitry Kabanov
    Nov 19 at 19:19










  • @interjay, regarding your third paragraph (starting with 'Note that if nl only ever has non-negative values'). Are you sure what you say is correct? I think, it is applicable only if you whant array to be indexed by 0, 1, ..., nh (inclusive). This routine expects the caller to index an array by nl, nl+1, ..., nh (inclusive).
    – Dmitry Kabanov
    Nov 19 at 19:20






  • 1




    Thanks for the assumption of bad faith
    – Tim Randall
    Nov 19 at 21:39













up vote
1
down vote



accepted







up vote
1
down vote



accepted








  1. Suppose you had nl=1 and NR_END=0. Then the returned pointer would be out of bounds (it points before the allocated block). This is undefined behavior and can lead to incorrect results, although it is unlikely to cause problems on major compilers because the pointer would be incremented back before it is dereferenced.



    To avoid this undefined behavior, you can set NR_END to the maximum expected value of nl (which is 1 in the book). This guarantees that the returned pointer is valid. However, the implementation given in the question is still incorrect, because v-nl+NR_END decrements by nl before incrementing by NR_END. A correct implementation would be v+NR_END-nl.



    Note that if nl only ever has non-negative values, a much simpler implementation would be to simply allocate nh+1 values, and then you don't need any pointer arithmetic after malloc or before free.



    Here you can see a quote from the book explaining this, from pages 940-941 of the second edition. Some quotes:




    it might
    happen in rare cases (and probably only on a segmented machine) that the expression b-1
    has no representation at all. If this occurs, then there is no guarantee that the relation
    b=(b-1)+1 is satisfied.




    [....]




    the parameter NR_END is used as a number of extra storage
    locations allocated at the beginning of every vector or matrix block, simply for the purpose
    of making offset pointer references guaranteed-representable.




  2. The cast to char* is not needed in any standardized version of C. It may have been needed in ancient versions. Casting the return value of malloc is also not needed.







share|improve this answer
















  1. Suppose you had nl=1 and NR_END=0. Then the returned pointer would be out of bounds (it points before the allocated block). This is undefined behavior and can lead to incorrect results, although it is unlikely to cause problems on major compilers because the pointer would be incremented back before it is dereferenced.



    To avoid this undefined behavior, you can set NR_END to the maximum expected value of nl (which is 1 in the book). This guarantees that the returned pointer is valid. However, the implementation given in the question is still incorrect, because v-nl+NR_END decrements by nl before incrementing by NR_END. A correct implementation would be v+NR_END-nl.



    Note that if nl only ever has non-negative values, a much simpler implementation would be to simply allocate nh+1 values, and then you don't need any pointer arithmetic after malloc or before free.



    Here you can see a quote from the book explaining this, from pages 940-941 of the second edition. Some quotes:




    it might
    happen in rare cases (and probably only on a segmented machine) that the expression b-1
    has no representation at all. If this occurs, then there is no guarantee that the relation
    b=(b-1)+1 is satisfied.




    [....]




    the parameter NR_END is used as a number of extra storage
    locations allocated at the beginning of every vector or matrix block, simply for the purpose
    of making offset pointer references guaranteed-representable.




  2. The cast to char* is not needed in any standardized version of C. It may have been needed in ancient versions. Casting the return value of malloc is also not needed.








share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 19 at 17:39

























answered Nov 19 at 17:09









interjay

83.3k16202210




83.3k16202210








  • 1




    I'm not buying your explanation of NR_END. What you say is true, but if indeed values of nl different from 0 and 1 are not supported then it is sufficient to add NR_END to the size of the allocation, as indeed is done. vector() could then simply return the value from malloc() without doing any arithmetic on it, and vector_free() would not need to account for the same.
    – John Bollinger
    Nov 19 at 17:29












  • @JohnBollinger It isn't my explanation, it is the book's explanation, See here. I did say in my answer that it would be much simpler to not perform any pointer arithmetic. It is in general quite bad code.
    – interjay
    Nov 19 at 17:30










  • @interjay, thanks for the explanation! I wish I were more patient and looked at the book more carefully before asking my question here :-) I accept your answer.
    – Dmitry Kabanov
    Nov 19 at 19:19










  • @interjay, regarding your third paragraph (starting with 'Note that if nl only ever has non-negative values'). Are you sure what you say is correct? I think, it is applicable only if you whant array to be indexed by 0, 1, ..., nh (inclusive). This routine expects the caller to index an array by nl, nl+1, ..., nh (inclusive).
    – Dmitry Kabanov
    Nov 19 at 19:20






  • 1




    Thanks for the assumption of bad faith
    – Tim Randall
    Nov 19 at 21:39














  • 1




    I'm not buying your explanation of NR_END. What you say is true, but if indeed values of nl different from 0 and 1 are not supported then it is sufficient to add NR_END to the size of the allocation, as indeed is done. vector() could then simply return the value from malloc() without doing any arithmetic on it, and vector_free() would not need to account for the same.
    – John Bollinger
    Nov 19 at 17:29












  • @JohnBollinger It isn't my explanation, it is the book's explanation, See here. I did say in my answer that it would be much simpler to not perform any pointer arithmetic. It is in general quite bad code.
    – interjay
    Nov 19 at 17:30










  • @interjay, thanks for the explanation! I wish I were more patient and looked at the book more carefully before asking my question here :-) I accept your answer.
    – Dmitry Kabanov
    Nov 19 at 19:19










  • @interjay, regarding your third paragraph (starting with 'Note that if nl only ever has non-negative values'). Are you sure what you say is correct? I think, it is applicable only if you whant array to be indexed by 0, 1, ..., nh (inclusive). This routine expects the caller to index an array by nl, nl+1, ..., nh (inclusive).
    – Dmitry Kabanov
    Nov 19 at 19:20






  • 1




    Thanks for the assumption of bad faith
    – Tim Randall
    Nov 19 at 21:39








1




1




I'm not buying your explanation of NR_END. What you say is true, but if indeed values of nl different from 0 and 1 are not supported then it is sufficient to add NR_END to the size of the allocation, as indeed is done. vector() could then simply return the value from malloc() without doing any arithmetic on it, and vector_free() would not need to account for the same.
– John Bollinger
Nov 19 at 17:29






I'm not buying your explanation of NR_END. What you say is true, but if indeed values of nl different from 0 and 1 are not supported then it is sufficient to add NR_END to the size of the allocation, as indeed is done. vector() could then simply return the value from malloc() without doing any arithmetic on it, and vector_free() would not need to account for the same.
– John Bollinger
Nov 19 at 17:29














@JohnBollinger It isn't my explanation, it is the book's explanation, See here. I did say in my answer that it would be much simpler to not perform any pointer arithmetic. It is in general quite bad code.
– interjay
Nov 19 at 17:30




@JohnBollinger It isn't my explanation, it is the book's explanation, See here. I did say in my answer that it would be much simpler to not perform any pointer arithmetic. It is in general quite bad code.
– interjay
Nov 19 at 17:30












@interjay, thanks for the explanation! I wish I were more patient and looked at the book more carefully before asking my question here :-) I accept your answer.
– Dmitry Kabanov
Nov 19 at 19:19




@interjay, thanks for the explanation! I wish I were more patient and looked at the book more carefully before asking my question here :-) I accept your answer.
– Dmitry Kabanov
Nov 19 at 19:19












@interjay, regarding your third paragraph (starting with 'Note that if nl only ever has non-negative values'). Are you sure what you say is correct? I think, it is applicable only if you whant array to be indexed by 0, 1, ..., nh (inclusive). This routine expects the caller to index an array by nl, nl+1, ..., nh (inclusive).
– Dmitry Kabanov
Nov 19 at 19:20




@interjay, regarding your third paragraph (starting with 'Note that if nl only ever has non-negative values'). Are you sure what you say is correct? I think, it is applicable only if you whant array to be indexed by 0, 1, ..., nh (inclusive). This routine expects the caller to index an array by nl, nl+1, ..., nh (inclusive).
– Dmitry Kabanov
Nov 19 at 19:20




1




1




Thanks for the assumption of bad faith
– Tim Randall
Nov 19 at 21:39




Thanks for the assumption of bad faith
– Tim Randall
Nov 19 at 21:39


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53378855%2fquestion-on-book-numerical-recipes-2nd-ed-allocation-deallocation-of-memory-f%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Paul Cézanne

UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

Angular material date-picker (MatDatepicker) auto completes the date on focus out