-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhitmds2.h
120 lines (91 loc) · 3.06 KB
/
hitmds2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* hitmds2.h
*
* Multidimensional Scaling according to best distance matrix reconstruction.
* Based on Fisher's z
*
*
* Copyright (C) 2006 Marc Strickert ([email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* A copy of the GNU General Public License (gp_license.txt) comes
* along with this program. (Free Software Foundation, Inc.)
*
*/
#ifndef __MDS_H
#define __MDS_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <float.h>
#include <signal.h>
#define SCANFMT "%lf"
/* linear learning rate annealing at . times cycles */
#define START_ANNEALING_RATIO .5
#define EPS 1e-16
#define frand() ((double) rand() / (RAND_MAX+1.0))
#define irand(X) ((int)((double)(X) * frand()))
#define error(X) fprintf(stderr, (X)), main_bye(), exit(1)
#define ABS(X) (((X) > 0) ? (X) : -(X))
/* address matrix components */
#define D(mat,i,j) (*(mat + ( \
(i<j) ? (j - 1 + ((((pattern_length<<1) - i - 3) * i) >> 1)) \
: ((i==j) ? matsize \
: (i - 1 + ((((pattern_length<<1) - j - 3) * j) >> 1))) \
)))
//void main_bye(const char*);
static int stop_calculation = 0;
static double (*distance)(int dim, double *d1, double *d2);
#define inline __inline
/* type of distance matrix elements */
typedef float FLT;
unsigned long matsize;
int correlation_exponent,/* (1/r^2)^k */
printqual, /* flag to rate embedding qualities (last column) */
target_dim, /* dimension of target space */
matrix_input; /* != 0 if data given as distance matrix */
long long pattern_length, /* Length of data series */
pattern_dimension; /* pattern dimension */
//matsize, /* number of distance matrix elements */
double **pattern, /* contains float data from STDIN */
**points,
points_distmat_mean,
points_distmat_mixed,
points_distmat_mono,
pattern_distmat_var_sum,
pattern_distmat_mean,
correps; /* correlation epsilon avoiding 1/0 */
/* save memory space */
FLT *pattern_distmat,
*points_distmat;
int *shuffle_index; /* helper for data shuffling */
unsigned randomize() {
int srd, tmp; /* auto-variable: not initialized -> random */
/* Compiler Warnings are welcome here ! */
time_t t;
struct tm *ts;
time(&t);
ts = localtime(&t);
tmp = ts->tm_mday | (ts->tm_min << 6) | (ts->tm_sec << 12);
if(srd == 0)
srd |= tmp;
else
srd *= tmp;
//srand((unsigned)srd);
//srand(42);
return (unsigned)srd;
}
#endif