Go to the documentation of this file.
81 int ff_pca(
PCA *pca,
double *eigenvector,
double *eigenvalue){
87 memset(eigenvector, 0,
sizeof(
double)*n*n);
91 eigenvector[j + j*n] = 1.0;
101 for(pass=0; pass < 50; pass++){
112 if(eigenvalue[j] > maxvalue){
113 maxvalue= eigenvalue[j];
117 eigenvalue[k]= eigenvalue[
i];
118 eigenvalue[
i]= maxvalue;
120 double tmp= eigenvector[k + j*n];
121 eigenvector[k + j*n]= eigenvector[
i + j*n];
122 eigenvector[
i + j*n]=
tmp;
129 for(j=
i+1; j<n; j++){
131 double t,
c,
s,tau,theta,
h;
133 if(pass < 3 &&
fabs(covar) < sum / (5*n*n))
135 if(
fabs(covar) == 0.0)
137 if(pass >=3 &&
fabs((eigenvalue[j]+z[j])/covar) > (1LL<<32) &&
fabs((eigenvalue[
i]+z[
i])/covar) > (1LL<<32)){
142 h= (eigenvalue[j]+z[j]) - (eigenvalue[
i]+z[
i]);
144 t=1.0/(
fabs(theta)+sqrt(1.0+theta*theta));
145 if(theta < 0.0) t = -t;
153 #define ROTATE(a,i,j,k,l) {\
154 double g=a[j + i*n];\
155 double h=a[l + k*n];\
156 a[j + i*n]=g-s*(h+g*tau);\
157 a[l + k*n]=h+s*(g-h*tau); }
167 for (
i=0;
i<n;
i++) {
168 eigenvalue[
i] += z[
i];
#define ROTATE(a, i, j, k, l)
void ff_pca_free(PCA *pca)
static __device__ float fabs(float a)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define i(width, name, range_min, range_max)
#define av_malloc_array(a, b)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void * av_calloc(size_t nmemb, size_t size)
int ff_pca(PCA *pca, double *eigenvector, double *eigenvalue)
void ff_pca_add(PCA *pca, const double *v)