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

pcabuildbasis errors with 3 independent variables
http://forum.alglib.net/viewtopic.php?f=2&t=86
Page 1 of 1

Author:  oconnellseanm [ Sat Oct 23, 2010 3:39 am ]
Post subject:  pcabuildbasis errors with 3 independent variables

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);

Author:  Sergey.Bochkanov [ Sat Oct 23, 2010 5:11 am ]
Post subject:  Re: pcabuildbasis errors with 3 independent variables

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.

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