Answer the question
In order to leave comments, you need to log in
Move text to variable for use in function?
There is a program for calculating integrals (not the point). I enter various data into different fields and according to a certain algorithm, it should read me the answer.
Well, here it is. It reads the first three values normally, because they are numbers (the first two types are doubles and the third is int).
In the fourth box, I enter an integrable expression. Those. in fact, this is a piece of text, which in a certain place should be inserted into one of the functions and the whole rhyme will go on. Attention to the question: how and where can I write it down? So far it looks like: x = Convert::ToDouble(intText->Text);
but, of course, it does not work, because it is fundamentally wrong. Because, in fact, climbs to the function where it is used. I used this variable like this.
There is a function that looks like
double f (double x1)
{
return x1;
}
private: System::Void otvetButton_Click(System::Object^ sender, System::EventArgs^ e) {
double a, b, h, I, F, x;
int n;
a = Convert::ToDouble(aPredelText->Text);
b = Convert::ToDouble(bPredelText->Text);
n = Convert::ToInt32(nText->Text);
x = Convert::ToDouble(intText->Text);
F = f(x);
I = Integr(a, b, n);
otvet->Text = I.ToString("n");
}
Answer the question
In order to leave comments, you need to log in
A good option: You need to compile your sub-integral function, and then dynamically link it with your program:
The same thing, only in profile - take OpenCL. Then all the work of compiling the kernel and linking will be hidden from you, and the calculations can be done on the GPU
Bad option: write your own math function interpreter (using the marshalling yard algorithm). It will be a wild brake.
The third option is to throw your program in the trash and count in Maxima, Maple, Octave and other smart programs. Although it is also slow.
And yes, what kind of bike do you consider the integral? Because it is rare when a self-made integrator can compete with GSL.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question