Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7529557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:41:31+00:00 2026-05-30T04:41:31+00:00

I’m working on a variation of the Nelder-Mead algorithm from Numerical Recipes , that

  • 0

I’m working on a variation of the Nelder-Mead algorithm from Numerical Recipes, that would allow the user to specify a maximum number of target function calls to be made.

From my main routine, here is how I call the amoeba() function that implements the Nelder-Mead algorithm:

amoeba(p,y,params->ndim,params->tol,params->nmax,internal_funk,&nfunc);

But here is how it got implemented:

void amoeba(float **p, float y[], int ndim, unsigned nmax, float ftol, float (*funk)(float []), int *nfunk) {
....
}

Notice that I inverted the nmax and the ftol arguments in my function call.

Astonishingly, amoeba() still works. Stepping through it in a debugger confirms that the right values were assigned to nmax and ftol.

My main routine #included a header file that defines the signature of the amoeba() routine, and compiling the main routine yielded no errors. However, the amoeaba() source file did not include that header (a mistake of mine), and so the compiler did not generate any errors either.

So how come my linked program still functions as it should, even though the arguments are not given in the right order?

UPDATE

@Binyamin Sharet, I’m showing here the assembly right before the call to amoeba and in amoeba. Does it support your hypothesis?

Before call to <code>amoeba</code>

Inside <code>amoeba</code>

UPDATE 2

@Binyamin Sharet sure, here it is:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:41:33+00:00Added an answer on May 30, 2026 at 4:41 am

    The reason is probably, because the floating points parameters are not passed on the stack, but on the co-processor stack, so the order of those two didn’t matter.

    For example, the function expects this order of arguments:

       |         p              |                             |
       |         y              |                             |
       |         ndim           |                             |
       |         nmax           |                             |
       |         funk           |                             |
       |         nfunk          |          ftol               |
       +------------------------+-----------------------------+
       |        stack           |        coprocessor stack    |
    

    It didn’t matter if you switch nmax and ftol, because the order on the stacks would be the same, and when the amoeba tries to read them, it doesn’t get confused for the same reason.


    Edit

    Reading the disassembly shows that I was off a bit, but that because of SSE, the instruction used for passing the float variable is movss, which you can see in both assemblt listing you added, one time to xmm0 register (in the caller), and one time from xmm0 (in the callee). so you can replace the words coprocessor-stack with xmm registers and that’s your situation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.