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 8418023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:12:14+00:00 2026-06-10T02:12:14+00:00

Pretty noob question so please bear with me. I am following the example given

  • 0

Pretty noob question so please bear with me.

I am following the example given here–>
http://www.codeproject.com/Articles/268589/odeint-v2-Solving-ordinary-differential-equations

In particular, I am looking at this function:

void lorenz( state_type &x , state_type &dxdt , double t )
{                                                         
dxdt[0] = sigma * ( x[1] - x[0] );
dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
dxdt[2] = x[0]*x[1] - b * x[2];
 } 

In my case, R takes on a series of values (vector with 100 doubles).

odeint is called as:

integrate_const( runge_kutta4< state_type >() , lorenz , x , 0.0 , 10.0 , dt );

I would like to do this for each value of R. How can I accomplish this? My knowledge of C++/OOP is limited, but I am willing to learn.

Thank you.

  • 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-06-10T02:12:15+00:00Added an answer on June 10, 2026 at 2:12 am

    You can use the “class” version, but modify it so that it is initialized with the R value of interest to you.

    class lorenz_class {
        double R_;
    public:
        lorenz_class (double r) : R_(r) {}
        void operator()( state_type &x , state_type &dxdt , double t ) {
            dxdt[0] = sigma * ( x[1] - x[0] );
            dxdt[1] = R_ * x[0] - x[1] - x[0] * x[2];
            dxdt[2] = x[0]*x[1] - b * x[2];
        }
    };
    

    Then, iterate over your vector R and pass in the value to the lorenz_class instance that you pass to the integrate_const template function.

    for (unsigned i = 0; i < myR.size(); ++i) {
        lorenz_class lorenz(myR[i]);
        integrate_const( runge_kutta4< state_type >() , lorenz , x , 0.0 , 10.0 , dt );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Noob question here. Please see code below. Where can I read more on this?
I've got a pretty noob question for ya. I keep seeing this syntax: <%=
Noob question here, every time I change a certain record in an SQL Server
This is pretty noob question, if I have an html button: and when the
I'm pretty new to php so this might be a noob question. I'm using
I'm a database noob so please bear with me. I'm trying to join three
I think this is a pretty noob question, but I've thought about it for
I'm pretty sure that this question is very noob but I'm not used to
I'm pretty new at bash so this is a pretty noob question.. Suppose I
I'm still pretty new to programming so I have somewhat of a noob question.

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.