forum.alglib.net

ALGLIB forum
It is currently Sat Apr 20, 2024 9:53 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  [ 2 posts ] 
Author Message
 Post subject: pcabuildbasis errors with 3 independent variables
PostPosted: Sat Oct 23, 2010 3:39 am 
Offline

Joined: Sat Oct 23, 2010 3:34 am
Posts: 1
I'm trying to use the pcabuildbasis function to find the basis vectors of a group of 3D points. But the returned matrix of eigenvectors contains -1.#INF00 values for the last 2 principle components. Here's the values for the S2 and V arrays.

S2[0] = 15784.371094
S2[1] = 2748.227783
S3[2] = 0.000000

V[0] = 0.985108
V[1] = 0.171937
V[2] = 0.000000
V[3] = -1.#INF000
V[4] = -0.17937
V[5] = 0.985108
V[6] = 0.000000
V[7] = -1.#INF000
V[8] = 0.000000

Any ideas on why this would happen? I'm sure I'm filling the data structures correctly. My code for doing so is below.

int numComponents = 3;
double* data = new double[points.size() * numComponents];
for (int i = 0; i < points.size(); i++)
{
data[i*numComponents+0] = points[i].x;
data[i*numComponents+1] = points[i].y;
data[i*numComponents+2] = points[i].z;
}

alglib::real_2d_array arr;
arr.setcontent(points.size(), numComponents, data);

alglib::ae_int_t info;
alglib::real_1d_array s2;
alglib::real_2d_array v;
pcabuildbasis(arr, points.size(), numComponents, info, s2, v);


Top
 Profile  
 
 Post subject: Re: pcabuildbasis errors with 3 independent variables
PostPosted: Sat Oct 23, 2010 5:11 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
ALGLIB arrays are aligned, i.e. 2-dimensional array V is stored in memory as "V V V P V V V P ....", where V is value, and P is additional padding to ensure that each row is aligned on 16-byte boundary.

You try to access V directly, by obtaining pointer to the first element, right? These "-1.#INF000" are padding values. Use overloaded operator[] to access elements of V.


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

All times are UTC


Who is online

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