forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 3:03 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: get alglib running
PostPosted: Wed Jan 05, 2011 6:16 pm 
Offline

Joined: Wed Jan 05, 2011 5:55 pm
Posts: 2
Hello!

I have problems initializing alglib. At first i wanted to try out the spline1d_d_linear example and copied the code nearly exactly.

Code:
//#include <stdafx.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
//#include <interpolation.h>
#include "C:/Qt/projects/MyProject/alglib/src/interpolation.h"  //<--this is the path to the place where i put all the c++-files

using namespace alglib;

int main(int argc, char **argv)
{
    //
    // We use piecewise linear spline to interpolate f(x)=x^2 sampled
    // at 5 equidistant nodes on [-1,+1].
    //
    real_1d_array x = "[-1.0,-0.5,0.0,+0.5,+1.0]";
    real_1d_array y = "[+1.0,0.25,0.0,0.25,+1.0]";
    double t = 0.25;
    double v;
    spline1dinterpolant s;

    // build spline
    spline1dbuildlinear(x, y, s);

    // calculate S(0.25) - it is quite different from 0.25^2=0.0625
    v = spline1dcalc(s, t);
    printf("%.4f\n", double(v)); // EXPECTED: 0.125
    return 0;
}


Like suggested in the manual I picked the packages I needed ... and added them to my project! Or do I need to install something first?
Anyway I get a lot of warnings like:
undefined reference to `alglib::real_1d_array::real_1d_array(char const*)'
and finally an error message that the linking went wrong.

I use:
OS:Windows Vista
Qt 4.5.2 (32 bit)
Compiler:MinGw

So what may be the problem?
Thanks for your help!


Top
 Profile  
 
 Post subject: Re: get alglib running
PostPosted: Wed Jan 05, 2011 7:17 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
You've forgot to compile several dependencies of interpolation.cpp At least one of them - ap.cpp, which defines real_1d_array class - is missing.

Take a look at the beginning of interpolation.h to get list of all ALGLIB units which are needed for successful compilation.


Top
 Profile  
 
 Post subject: Re: get alglib running
PostPosted: Wed Jan 05, 2011 8:39 pm 
Offline

Joined: Wed Jan 05, 2011 5:55 pm
Posts: 2
Thank you, Sergey. It works now.

So i just have to add all the files i need for my splines,
(which are:
"ap.h" +"ap.cpp"
"alglibinternal.h" +"alglibinternal.cpp"
"alglibmisc.h" + "alglibmisc.cpp"
"linalg.h" + "linalg.cpp"
"solvers.h" +"solvers.cpp"
"optimization.h" + "optimization.cpp"
"specialfunctions.h" + "specialfunctions.cpp"
"integration.h" + "integration.cpp"
)
compile them once along with my project and then i can delete them?
I thought it would do just to include the interpolation.h


Top
 Profile  
 
 Post subject: Re: get alglib running
PostPosted: Thu Jan 06, 2011 1:01 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
List of units is correct, but you shouldn't delete them after successful compilation. You may recompile your project in the future, with different compiler settings, so in any case you need these files.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group