forum.alglib.net
http://forum.alglib.net/

New to Alglib
http://forum.alglib.net/viewtopic.php?f=2&t=363
Page 1 of 1

Author:  xynergy [ Tue May 24, 2011 9:03 pm ]
Post subject:  New to Alglib

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 ===|



Author:  Sergey.Bochkanov [ Wed May 25, 2011 4:39 am ]
Post subject:  Re: New to Alglib

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.

Author:  xynergy [ Wed May 25, 2011 6:43 pm ]
Post subject:  Re: New to Alglib

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;

}


Author:  Doug Jenkins [ Thu May 26, 2011 1:17 pm ]
Post subject:  Re: New to Alglib

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.

Author:  xynergy [ Fri May 27, 2011 4:35 am ]
Post subject:  Re: New to Alglib

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

Author:  Doug Jenkins [ Sat May 28, 2011 2:04 am ]
Post subject:  Re: New to Alglib

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

Author:  Doug Jenkins [ Sat May 28, 2011 2:05 am ]
Post subject:  Re: New to Alglib

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

Author:  xynergy [ Sat May 28, 2011 7:21 pm ]
Post subject:  Re: New to Alglib

Everything worked out beautiful!

Thanks alot!

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/