forum.alglib.net

ALGLIB forum
It is currently Mon Dec 23, 2024 1:44 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  [ 10 posts ] 
Author Message
 Post subject: splinebuild2cubic
PostPosted: Mon Apr 25, 2011 10:49 pm 
Offline

Joined: Mon Apr 25, 2011 10:42 pm
Posts: 4
Hi,

I'm getting this message when I call spline2dbuildcubic:

terminate called after throwing an instance of 'alglib::ap_error'
Aborted

Here is the code:
==========================================
using namespace alglib;


int main(){

ae_int_t w = 2;

real_1d_array a = "[0,1]";

real_1d_array b = "[0,1]";

real_2d_array f = "[2.2,3.3,1.1,4.4]";

spline2dinterpolant s;

spline2dbuildbicubic(a,b,f,w,w,s);

return 0;
}
==============================================
The error msg didn't give me enough to go on so any ideas on what I'm doing wrong would be great.

Thanks much,
Estevan


Top
 Profile  
 
 Post subject: Re: splinebuild2cubic
PostPosted: Tue Apr 26, 2011 4:30 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
F must be 2-dimensional array, "[[2.2,3.3],[1.1,4.4]]", for example.


Top
 Profile  
 
 Post subject: Re: splinebuild2cubic
PostPosted: Tue Apr 26, 2011 3:29 pm 
Offline

Joined: Mon Apr 25, 2011 10:42 pm
Posts: 4
Thanks Sergey. Got past my error. Greatly appreciate it.


Top
 Profile  
 
 Post subject: Re: splinebuild2cubic
PostPosted: Tue Apr 26, 2011 4:50 pm 
Offline

Joined: Mon Apr 25, 2011 10:42 pm
Posts: 4
One other thing --

when I go to a non-square array it's throwing alglib::ap_error again.

it throws it at the real_2d_array declaration.

Code:
int main(){
double value;
ae_int_t m = 2;
ae_int_t n = 3;
real_1d_array x = "[0,1,2]";
real_1d_array y = "[0,1]";
real_2d_array f = "[[1,2],[1,2,3]]";
spline2dinterpolant s;
spline2dbuildbicubic(x,y,f,m,n,s);
value = spline2dcalc(s,.5,.5);
printf("value=%f\n",value);
return 0;
}


it's a 2 row x 3 col array and I can't see what the problem is. any ideas would be great.

thanks.


Top
 Profile  
 
 Post subject: Re: splinebuild2cubic
PostPosted: Tue Apr 26, 2011 7:40 pm 
Offline

Joined: Tue Apr 26, 2011 7:23 pm
Posts: 2
Hi. I have a litle problem with my code
(Qt 4.7.0 with MinGW and Qt creator.)
Code:
int main(int argc, char *argv[])
{
    QCoreApplication proga(argc, argv);

alglib::ae_int_t  max_x, max_y;
alglib::spline2dinterpolant c;

    max_x=15;
    max_y=15;


XX.setlength(max_x);
YY.setlength(max_y);
FF.setlength(max_y, max_x);

for (int i=0; i<max_x-1; i++)
{
    XX[i]=1.0*i;
}

for (int j=0; j<max_y-1; j++)
{
    YY[j]=1.0+j;
}

for (int i=0; i<max_x-1; i++)
for (int j=0; j<max_y-1; j++)
{
    FF[j][i]=YY[j]*XX[i];
}
/**********************************************/
spline2dbuildbicubic(XX, YY, FF, max_x, max_y, &c);
/**********************************************/
return proga.exec();
}

My compiler tells me about error in line between stars.
it tells, that "no mathcing functions for call to "splie2dbicubic(alglib::real_1d_array&, alglib::real_1d_array&, alglib::real_2d_array&, alglib::ae_int_t&, alglib::ae_int_t&, alglib_impl::spline2dinterpolant*)

Where is my error?
I am sorry for my non-excelent C++


Top
 Profile  
 
 Post subject: Re: splinebuild2cubic
PostPosted: Wed Apr 27, 2011 4:41 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
2estevan: "[[1,2],[1,2,3]]" is a non-rectangular array, you have to add one more element to the first row.


Top
 Profile  
 
 Post subject: Re: splinebuild2cubic
PostPosted: Wed Apr 27, 2011 4:43 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
2Sergey_Bikovsky: you should remove & from last parameter, i.e. it should be "spline2dbuildbicubic(XX, YY, FF, max_x, max_y, c)"


Top
 Profile  
 
 Post subject: Re: splinebuild2cubic
PostPosted: Wed Apr 27, 2011 4:53 pm 
Offline

Joined: Tue Apr 26, 2011 7:23 pm
Posts: 2
Thanks.
It Works now :)


Top
 Profile  
 
 Post subject: Re: splinebuild2cubic
PostPosted: Wed Apr 27, 2011 5:33 pm 
Offline

Joined: Mon Apr 25, 2011 10:42 pm
Posts: 4
Thanks Sergey - I realized this about 30mins ago as I drew it out on a plot. tested with a function field that is 2 by 3 and with one that is 3 by 2. Just wanted to be ready for any dimension as I will be using this for wind fields.

--estevan


Top
 Profile  
 
 Post subject: Re: splinebuild2cubic
PostPosted: Sat Jan 11, 2014 1:08 pm 
Offline

Joined: Sat Jan 11, 2014 1:02 pm
Posts: 1
Hi there,

I have a similar problem as some of the people who have already submitted code snippets. This is my code:

Code:
void interpn(double *outgrid, double *gridx, double *gridy, double *gridxy, double *agrid1, double *agrid2, int ngrid, int ngrid2) {
alglib::real_1d_array gridxx;
gridxx.setcontent(ngrid,gridx);

alglib::real_1d_array gridyy;
gridyy.setcontent(ngrid2,gridy);

alglib::real_1d_array ingrid;
ingrid.setcontent(ngrid*ngrid2,gridxy);

alglib::spline1dinterpolant splone;

// build spline
alglib::spline2dbuildbicubicv(gridxx,ngrid,gridyy,ngrid2,ingrid,1,splone);

for (int ii=0; ii<ngrid; ii++) {
    for (int jj=0; jj<ngrid2; jj++) {
        for (int kk=0; kk<nstates_as; kk++){
            for (int ll=0; ll<nstates_is; ll++){
                outgrid[ii*ngrid2+jj+(kk+ll)*(ngrid*ngrid2)] = alglib::spline2dcalc(splone, agrid1[ii*ngrid2+jj], agrid2[ii*ngrid2+jj]);
           }
        }
    }
}

}
.
.
.
interpn(&k2prime_bu[0][0][0][0],kkgrid,kmgrid,tempmat,&kprime[0][0][0][0],&kmprime[0][0][0][0],ngrid,ngrid2);



Most but not all of the arrays I pass to the function are from the C++ Boost library's multidimensional array library. Running this code gives me the dreaded
terminate called after throwing an instance of 'alglib::ap_error'. I know that the error is thrown at the point where the spline is build, i.e. at the point

Code:
alglib::spline2dbuildbicubicv(gridxx,ngrid,gridyy,ngrid2,ingrid,1,splone);


Any suggestions where I may be making a mistake here?

Thanks,
Eric


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 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