forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 8:00 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  [ 8 posts ] 
Author Message
 Post subject: New to Alglib
PostPosted: Tue May 24, 2011 9:03 pm 
Offline

Joined: Tue May 24, 2011 8:59 pm
Posts: 4
Hi,

I am new to ALGLIB, I am trying to get the library to compile but i keep getting the follow error, I am not sure what I am doing wrong.

Thanks for the help,
xynergy

Code:

//#include <stdafx.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
//#include <interpolation.h>
#include "ap.h"
// disable some irrelevant warnings
#if (AE_COMPILER==AE_MSVC)
#pragma warning(disable:4100)
#pragma warning(disable:4127)
#pragma warning(disable:4702)
#pragma warning(disable:4996)
#endif
#include "alglibmisc.h"
#include "alglibinternal.h"
#include "linalg.h"
#include "statistics.h"
#include "dataanalysis.h"
#include "specialfunctions.h"
#include "solvers.h"
#include "optimization.h"
#include "diffequations.h"
#include "fasttransforms.h"
#include "integration.h"
#include "interpolation.h"

using namespace alglib_impl;






int main(int argc, char* argv[]){

alglib::real_1d_array    x("[0,1,2,3]");
alglib::real_1d_array    y("[1,5,3,9]");
alglib::real_1d_array   y2("[1,5,3,9,0]");
alglib::spline1dinterpolant s;

}



Quote:
obj\Debug\main.o||In function `main':|
C:\Users\G\Desktop\ALGLIB\main.cpp|36|undefined reference to `alglib::real_1d_array::real_1d_array(char const*)'|
C:\Users\G\Desktop\ALGLIB\main.cpp|37|undefined reference to `alglib::real_1d_array::real_1d_array(char const*)'|
C:\Users\G\Desktop\ALGLIB\main.cpp|38|undefined reference to `alglib::real_1d_array::real_1d_array(char const*)'|
C:\Users\G\Desktop\ALGLIB\main.cpp|39|undefined reference to `alglib::spline1dinterpolant::spline1dinterpolant()'|
C:\Users\G\Desktop\ALGLIB\main.cpp|39|undefined reference to `alglib::spline1dinterpolant::~spline1dinterpolant()'|
C:\Users\G\Desktop\ALGLIB\main.cpp|39|undefined reference to `alglib::real_1d_array::~real_1d_array()'|
C:\Users\G\Desktop\ALGLIB\main.cpp|39|undefined reference to `alglib::real_1d_array::~real_1d_array()'|
C:\Users\G\Desktop\ALGLIB\main.cpp|39|undefined reference to `alglib::real_1d_array::~real_1d_array()'|
C:\Users\G\Desktop\ALGLIB\main.cpp|39|undefined reference to `alglib::real_1d_array::~real_1d_array()'|
C:\Users\G\Desktop\ALGLIB\main.cpp|39|undefined reference to `alglib::real_1d_array::~real_1d_array()'|
obj\Debug\main.o:C:\Users\G\Desktop\ALGLIB\main.cpp|39|more undefined references to `alglib::real_1d_array::~real_1d_array()' follow|
||=== Build finished: 11 errors, 0 warnings ===|




Top
 Profile  
 
 Post subject: Re: New to Alglib
PostPosted: Wed May 25, 2011 4:39 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
First, you should add all .cpp files from ALGLIB directory to your project. Do not include them - you should add them in the list of cpp units being compiled. Second, you should remove "using namespace alglib_impl" from your code - you don't need it. Take a look at examples for 1-dimensional spline interpolation.


Top
 Profile  
 
 Post subject: Re: New to Alglib
PostPosted: Wed May 25, 2011 6:43 pm 
Offline

Joined: Tue May 24, 2011 8:59 pm
Posts: 4
Thanks alot for your response, I got the code to compile properly. I've included it below for any beginners making the same silly mistakes I was. I am actually interested in the Chi-square inverse cumulative distribution function.

What I am trying to do is reproduce similiar result to Matlab's.

Quote:
>> (chi2inv(1-0.01,1))
ans =

6.6349


Currently, when I try, I get a run time error. Any suggestions?



Code:
#include "ap.cpp"
#include "alglibinternal.cpp"
//#include "alglibmisc.cpp"
//#include "linalg.cpp"
#include "specialfunctions.cpp"

#include <iostream>

using namespace std;
int main(int argc, char* argv[]){


double x= alglib::invchisquaredistribution( 1-0.01, 1 );
cout << x << endl;

}



Top
 Profile  
 
 Post subject: Re: New to Alglib
PostPosted: Thu May 26, 2011 1:17 pm 
Offline

Joined: Sun May 16, 2010 11:42 pm
Posts: 63
xynergy - the link below has an Excel spreadsheet you might finde useful. It has all the Alglib stats functions (from Alglib Rel 2.6), and comparative output from the Excel built in functions, where applicable:

http://newtonexcelbach.wordpress.com/20 ... functions/

If you make the second parameter positive the InvChiSquareDistribution gives the same result as the Matlab output.

_________________
Doug Jenkins
http://newtonexcelbach.wordpress.com/


Top
 Profile  
 
 Post subject: Re: New to Alglib
PostPosted: Fri May 27, 2011 4:35 am 
Offline

Joined: Tue May 24, 2011 8:59 pm
Posts: 4
Hey Doug,

Thanks alot for recommending the spread sheet, it is pretty neat.

I am not sure what you meant by make the second parameter positive because both parameters are positive.

invchisquaredistribution( 0.99, 1 ) = #VALUE!
(chi2inv(0.99,1)) = 6.6349


Top
 Profile  
 
 Post subject: Re: New to Alglib
PostPosted: Sat May 28, 2011 2:04 am 
Offline

Joined: Sun May 16, 2010 11:42 pm
Posts: 63
xynergy wrote:
Hey Doug,

Thanks alot for recommending the spread sheet, it is pretty neat.

I am not sure what you meant by make the second parameter positive because both parameters are positive.

invchisquaredistribution( 0.99, 1 ) = #VALUE!
(chi2inv(0.99,1)) = 6.6349


Sorry, I misread it.

The order of the parameters should be reversed, and use 1-0.99 rather than 0.99:

From the code:
Code:
'Chi-square distribution
'
'Returns the area under the left hand tail (from 0 to x)
'of the Chi square probability density function with
'v degrees of freedom.
'
'
'                                  x
'                                   -
'                       1          | |  v/2-1  -t/2
' P( x | v )   =   -----------     |   t      e     dt
'                   v/2  -       | |
'                  2    | (v/2)   -
'                                  0
'
'where x is the Chi-square variable.


=InvChiSquareDistribution(1,0.01) = 6.634896601

_________________
Doug Jenkins
http://newtonexcelbach.wordpress.com/


Top
 Profile  
 
 Post subject: Re: New to Alglib
PostPosted: Sat May 28, 2011 2:05 am 
Offline

Joined: Sun May 16, 2010 11:42 pm
Posts: 63
xynergy wrote:
Hey Doug,

Thanks alot for recommending the spread sheet, it is pretty neat.

I am not sure what you meant by make the second parameter positive because both parameters are positive.

invchisquaredistribution( 0.99, 1 ) = #VALUE!
(chi2inv(0.99,1)) = 6.6349


Sorry, I misread it.

The order of the parameters should be reversed, and use 1-0.99 rather than 0.99:

From the code:
Code:
'Chi-square distribution
'
'Returns the area under the left hand tail (from 0 to x)
'of the Chi square probability density function with
'v degrees of freedom.
'
'
'                                  x
'                                   -
'                       1          | |  v/2-1  -t/2
' P( x | v )   =   -----------     |   t      e     dt
'                   v/2  -       | |
'                  2    | (v/2)   -
'                                  0
'
'where x is the Chi-square variable.


=InvChiSquareDistribution(1,0.01) = 6.634896601

_________________
Doug Jenkins
http://newtonexcelbach.wordpress.com/


Top
 Profile  
 
 Post subject: Re: New to Alglib
PostPosted: Sat May 28, 2011 7:21 pm 
Offline

Joined: Tue May 24, 2011 8:59 pm
Posts: 4
Everything worked out beautiful!

Thanks alot!


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 27 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group