22 static int num_pairs = 4;
35 eigs =
N_GNEW(new_dim,
double *);
36 for (i = 0; i < new_dim; i++)
37 eigs[i] =
N_GNEW(dim,
double);
38 evals =
N_GNEW(new_dim,
double);
40 DD =
N_GNEW(dim,
double *);
41 storage_ptr =
N_GNEW(dim * dim,
double);
42 for (i = 0; i < dim; i++) {
47 for (i = 0; i < dim; i++) {
48 for (j = 0; j <= i; j++) {
51 for (k = 0; k < n; k++) {
52 sum += coords[i][k] * coords[j][k];
54 DD[i][j] = DD[j][i] = sum;
60 for (j = 0; j < new_dim; j++) {
61 for (i = 0; i < n; i++) {
63 for (k = 0; k < dim; k++) {
64 sum += coords[k][i] * eigs[j][k];
66 new_coords[j][i] = sum;
70 for (i = 0; i < new_dim; i++)
108 double dist(
double **coords,
int dim,
int p1,
int p2)
113 for (i = 0; i < dim; i++) {
115 (coords[i][p1] - coords[i][p2]) * (coords[i][p1] -
122 void weight_laplacian(
double **X,
int n,
int dim,
vtx_data * laplacian)
128 for (i = 0; i < n; i++) {
129 edges = laplacian[i].
edges;
130 ewgts = laplacian[i].
ewgts;
132 for (j = 1; j < laplacian[i].
nedges; j++) {
135 float (-1.0 / (
dist(X, dim, i, neighbor) + 1e-10));
boolean iterativePCA_1D(double **coords, int dim, int n, double *new_direction)
int power_iteration(double **square_mat, int n, int neigs, double **eigs, double *evals, int initialize)
void closest_pairs2graph(double *place, int n, int num_pairs, vtx_data **graph)
void mult_sparse_dense_mat_transpose(vtx_data *A, double **B, int dim1, int dim2, float ***CC)
void mult_dense_mat_d(double **A, float **B, int dim1, int dim2, int dim3, double ***CC)
void PCA_alloc(DistType **coords, int dim, int n, double **new_coords, int new_dim)
double dist(Site *s, Site *t)