├── .gitignore
├── src
├── mutual_information
│ ├── miutils.mexw64
│ ├── MIxnyn.exe
│ ├── milca_2.exe
│ ├── milca_2.ilk
│ ├── milca_2.pdb
│ ├── Project2.ilk
│ ├── Project2.pdb
│ ├── casting_test.mexw64
│ ├── casting_test.mexw64.pdb
│ ├── README.md
│ ├── MIhigherdim.m
│ ├── casting_test.cpp
│ ├── MIhigherdim.C
│ ├── MIxnyn.C
│ ├── fastfc_mi.cpp
│ └── miutils.h
├── generalized_sync
│ ├── fastfc_gs_ver2.mexw64
│ ├── README.md
│ ├── fastfc_gs_ver2.c
│ ├── fastfc_gs.c
│ └── LICENSE
├── filter
│ ├── README.md
│ ├── fastfc_filt.c
│ └── LICENSE
├── phase_sync
│ ├── README.md
│ ├── fastfc_wpli.c
│ ├── fastfc_ps.c
│ ├── fastfc_ps_filt.c
│ └── LICENSE
├── networks
│ ├── README.md
│ ├── fastfc_strength_wu.c
│ ├── fastfc_cluster_coef_wu.c
│ ├── fastfc_cluster_coef_bu.c
│ ├── fastfc_shortest_path_length_w.c
│ ├── fastfc_betweenness_cent_w.c
│ └── LICENSE
└── README.md
├── fastfc_gs.mexw64
├── fastfc_mi.mexw64
├── fastfc_ps.mexw64
├── libfftw3f-3.dll
├── fastfc_filt.mexw64
├── fastfc_wpli.mexw64
├── fastfc_gs_ver2.mexw64
├── fastfc_strength_wu.mexw64
├── fastfc_cluster_coef_bu.mexw64
├── fastfc_cluster_coef_wu.mexw64
├── fastfc_betweenness_cent_w.mexw64
├── fastfc_shortest_path_length_w.mexw64
├── .gitattributes
├── README.md
├── testing_fastFC.m
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | *.asv
--------------------------------------------------------------------------------
/src/mutual_information/miutils.mexw64:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/fastfc_gs.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/fastfc_gs.mexw64
--------------------------------------------------------------------------------
/fastfc_mi.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/fastfc_mi.mexw64
--------------------------------------------------------------------------------
/fastfc_ps.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/fastfc_ps.mexw64
--------------------------------------------------------------------------------
/libfftw3f-3.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/libfftw3f-3.dll
--------------------------------------------------------------------------------
/fastfc_filt.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/fastfc_filt.mexw64
--------------------------------------------------------------------------------
/fastfc_wpli.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/fastfc_wpli.mexw64
--------------------------------------------------------------------------------
/fastfc_gs_ver2.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/fastfc_gs_ver2.mexw64
--------------------------------------------------------------------------------
/fastfc_strength_wu.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/fastfc_strength_wu.mexw64
--------------------------------------------------------------------------------
/fastfc_cluster_coef_bu.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/fastfc_cluster_coef_bu.mexw64
--------------------------------------------------------------------------------
/fastfc_cluster_coef_wu.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/fastfc_cluster_coef_wu.mexw64
--------------------------------------------------------------------------------
/fastfc_betweenness_cent_w.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/fastfc_betweenness_cent_w.mexw64
--------------------------------------------------------------------------------
/src/mutual_information/MIxnyn.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/src/mutual_information/MIxnyn.exe
--------------------------------------------------------------------------------
/src/mutual_information/milca_2.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/src/mutual_information/milca_2.exe
--------------------------------------------------------------------------------
/src/mutual_information/milca_2.ilk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/src/mutual_information/milca_2.ilk
--------------------------------------------------------------------------------
/src/mutual_information/milca_2.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/src/mutual_information/milca_2.pdb
--------------------------------------------------------------------------------
/fastfc_shortest_path_length_w.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/fastfc_shortest_path_length_w.mexw64
--------------------------------------------------------------------------------
/src/mutual_information/Project2.ilk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/src/mutual_information/Project2.ilk
--------------------------------------------------------------------------------
/src/mutual_information/Project2.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/src/mutual_information/Project2.pdb
--------------------------------------------------------------------------------
/src/generalized_sync/fastfc_gs_ver2.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/src/generalized_sync/fastfc_gs_ver2.mexw64
--------------------------------------------------------------------------------
/src/mutual_information/casting_test.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/src/mutual_information/casting_test.mexw64
--------------------------------------------------------------------------------
/src/mutual_information/casting_test.mexw64.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/juangpc/FastFC/HEAD/src/mutual_information/casting_test.mexw64.pdb
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # These files are MEX compiled binary files and should be left untouched
5 | # (binary is a macro for -text -diff)
6 | *.mexw32 binary
7 | *.mexw64 binary
8 | *.mexa64 binary
9 | *.mexmaci64 binary
10 |
11 | # Standard to msysgit
12 | *.doc diff=astextplain
13 | *.DOC diff=astextplain
14 | *.docx diff=astextplain
15 | *.DOCX diff=astextplain
16 | *.dot diff=astextplain
17 | *.DOT diff=astextplain
18 | *.pdf diff=astextplain
19 | *.PDF diff=astextplain
20 | *.rtf diff=astextplain
21 | *.RTF diff=astextplain
22 |
--------------------------------------------------------------------------------
/src/generalized_sync/README.md:
--------------------------------------------------------------------------------
1 | # FastFC
2 | Fast Functional Connectivity Toolbox. This toolbox implements efficient C computing of different FC indices. It does so through C-MEX external interface appi and within Matlab's development environment.
3 | #
4 | Development branch for Generalized Synchronization measures.
5 |
6 | S, H, M, L indices will be developed following descriptions from Daniel Chicharro's work (Chicharro et al 2009).
7 |
8 | S, H, M with a much faster and less memory demanding version (version2). It perfomrs this by avoiding andy sorting by using an ordered register filled online while measurements take place.
9 |
10 | Maybe some other implementations will be added.
11 |
12 | # Related research:
13 | Efficient computation of functional brain networks: towards real-time functional connectivity
14 | Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
--------------------------------------------------------------------------------
/src/filter/README.md:
--------------------------------------------------------------------------------
1 | # FastFC
2 | Fast Functional Connectivity Toolbox. This toolbox implements efficient C computing of different FC indices. It does so through C-MEX external interface appi and within Matlab's development environment.
3 |
4 | Development branch for Filtering with zero phase distortion.
5 |
6 | This branch contains the source-code for implementation of a zero phase distortion filtering procedure.
7 |
8 | All in a single file in order to help ports to other toolboxes. Matlab's MEX external interface has been used to connect Matlab's environment variables to this C function.
9 |
10 | fastFC_filt function is developed after matlab's filtfilt function. It implements a two passes FIR filtering with previous circular padding of the original signal.
11 |
12 | # Related research:
13 | Efficient computation of functional brain networks: towards real-time functional connectivity
14 | Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
15 |
--------------------------------------------------------------------------------
/src/phase_sync/README.md:
--------------------------------------------------------------------------------
1 | # FastFC
2 | Fast Functional Connectivity Toolbox. This toolbox implements efficient C computing of different FC indices. It does so through C-MEX external interface appi and within Matlab's development environment.
3 |
4 | Development branch for Phase Connectivity measures.
5 |
6 | This branch contains the source-code for implementation of PLV, PLI, wPLI and the imaginary part of the Coherence measures.
7 |
8 | All in a single file in order to help ports to other toolboxes. Matlab's MEX external interface has been used to connect Matlab's environment variables to this C function.
9 |
10 | There is also a Phase Sync function version which implements FIR filtereing at the same time. However this version is not finished. There is aproblem with it and it blows matlab.
11 |
12 | # Related research:
13 | Efficient computation of functional brain networks: towards real-time functional connectivity
14 | Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
--------------------------------------------------------------------------------
/src/mutual_information/README.md:
--------------------------------------------------------------------------------
1 | # FastFC
2 | Fast Functional Connectivity Toolbox
3 | #
4 | This branch is only for developing of Mutual Information index.
5 |
6 | This implementation is built on top of MILCA implementation
7 | (see: http://www.ucl.ac.uk/ion/departments/sobell/Research/RLemon/MILCA/MILCA)
8 |
9 | Here you will find:
10 |
11 | - A modified version of binutils in order to be compatible with windows Visual Studio compatible version of binutils.cpp and binutils.h
12 | - A binary verson of MILCA but compiled directly with Visual Studio.
13 | - A Matlab version of Mutual Information index calculation which calls the binary program just preiously mentioned.
14 | - The source coude of a modified version of MILCA program but implemented so that it communicate with MATLAB through its external MEX interface, instead of through a text document.
15 | - A binary version of this last program, compiled with Visual Studio for Matlab in Windows 64bit systems.
16 | - Some other tools and tries that have been generated while development. See log for more details.
17 |
18 | # Related research:
19 | Efficient computation of functional brain networks: towards real-time functional connectivity
20 | Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
21 |
--------------------------------------------------------------------------------
/src/networks/README.md:
--------------------------------------------------------------------------------
1 | # FastFC
2 | Fast Functional Connectivity Toolbox. This toolbox implements efficient C computing of different FC indices. It does so through C-MEX external interface appi and within Matlab's development environment.
3 |
4 | This branch is dedicated to the development of network indices, graph theoretic measures of FC adjacency matrices.
5 | Be aware autolinks are forbidden. Thus, adjacency matrices' principal diagonal must be zeroed.
6 | ## Contents
7 | - Clustering Coefficient for binary undirected networks.
8 | - Clustering Coefficient for weighted undirected networks.
9 | - Strength for weighted undirected networks.
10 | - Shortest path length for weighted networks (both directed and undirected).
11 | - Betweenness centrality for weighted networks (both directed and undirected).
12 |
13 | ## Future Development
14 | - Shortest path length could perform much better if the inversion of the adj. matrix could be done by thread parallelization. At the same time double to float transformation could take place. And continue there as the program does now.
15 |
16 | # Related research:
17 | Efficient computation of functional brain networks: towards real-time functional connectivity
18 | Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FastFC
2 |
3 | Fast Functional Connectivity Toolbox. This toolbox implements efficient C computing of different FC indices. It does so through C-MEX external interface appi and within Matlab's development environment. The focus of FastFC is to be very small and easy to adapt to any existing toolbox within Matlab.
4 |
5 | This is the main release branch of the repo. It only includes the final executable files, a needed dll and an example script. Please see other branches for accesing source code for each set of functions.
6 |
7 | 'Hope it helps!
8 |
9 | # Related research:
10 | Efficient computation of functional brain networks: towards real-time functional connectivity
11 | Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
12 |
13 | # Installation
14 | The library has been implemented in standard C, although it uses OMP and FFTW (both open source projects). The only thing needed in order to use the functions is the FFTW dll which is included with the executables.
15 |
16 | # Filtering tool
17 | - Zero-phase distorsion FIR filtering.
18 | This filtering function has been built out of necessity. It closely resembles Matlab's filtfilt built-in function implementation. It performs an N-dimensional circular padding (N=filter order).
19 |
20 | # Functional Connectivity measures
21 | - Phase Synchronization measures: PLV, PLV's p-value, PLI, wPLI and imaginary part of the Coherence.
22 | - Mutual Information. (MILCA implementation).
23 | - Generalized Synchronization measures: S, H, M, L
24 | - Generalized Synchronization measrues (version 2. faster): S, H, M.
25 |
26 | # Complex Networks measures
27 | - Strength for weighted undirected networks.
28 | - Clustering Coefficient for binary undirected networks.
29 | - Clustering Coefficient for weighted undirected networks.
30 | - Shortest path length for weighted networks (both directed and undirected).
31 | - Betweenness centrality for weighted networks (both directed and undirected).
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/README.md:
--------------------------------------------------------------------------------
1 | # FastFC
2 |
3 | Fast Functional Connectivity Toolbox. This toolbox implements efficient C computing of different FC indices. It does so through C-MEX external interface appi and within Matlab's development environment. The focus of FastFC is to be very small and easy to adapt to any existing toolbox within Matlab.
4 |
5 | This is the development branch. It includes all the files writen during development of each index. Also object files for Visual Studio debugging and few other things. The C (all indices except MI) and C++ (for Mutual Information index) code can be found in the /src folder.
6 |
7 | 'Hope it helps!
8 |
9 | # Related research:
10 | Efficient computation of functional brain networks: towards real-time functional connectivity
11 | Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
12 |
13 | # Installation
14 | The library has been implemented in standard C, although it uses OMP and FFTW (both open source projects). The only thing needed in order to use the functions is the FFTW dll which is included with the executables.
15 |
16 | # Filtering tool
17 | - Zero-phase distorsion FIR filtering.
18 | This filtering function has been built out of necessity. It closely resembles Matlab's filtfilt built-in function implementation. It performs an N-dimensional circular padding (N=filter order).
19 |
20 | # Functional Connectivity measures
21 | - Phase Synchronization measures: PLV, PLV's p-value, PLI, wPLI and imaginary part of the Coherence.
22 | - Mutual Information. (MILCA implementation).
23 | - Generalized Synchronization measures: S, H, M, L
24 | - Generalized Synchronization measrues (version 2. faster): S, H, M.
25 |
26 | # Complex Networks measures
27 | - Strength for weighted undirected networks.
28 | - Clustering Coefficient for binary undirected networks.
29 | - Clustering Coefficient for weighted undirected networks.
30 | - Shortest path length for weighted networks (both directed and undirected).
31 | - Betweenness centrality for weighted networks (both directed and undirected).
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/networks/fastfc_strength_wu.c:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2014-2015 Juan Garcia-Prieto Cuesta
3 | //
4 | // This file is part of Fast Functional Connectivity (FastFC)
5 | //
6 | // FastFC is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // FastFC is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with FastFC. If not, see .
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 | #include
30 | #include
31 |
32 | void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
33 | {
34 | int node_i,node_j;
35 | double *W,*S,s_aux;
36 | const int n_nodes=(int)mxGetM(prhs[0]);
37 |
38 | plhs[0]=mxCreateDoubleMatrix(1,n_nodes,mxREAL);
39 | W=(double*)mxGetPr(prhs[0]);
40 | S=(double*)mxGetPr(plhs[0]);
41 |
42 | #pragma omp parallel
43 | {
44 | #pragma omp for private(node_i,node_j) reduction(+:s_aux)
45 | for(node_i=0;node_i.
15 | %-----------------------------------------------------------------------------------------
16 | % Contacts:
17 | %
18 | % Harald Stoegbauer
19 | % Alexander Kraskov
20 | %-----------------------------------------------------------------------------------------
21 | % Please reference
22 | %
23 | % A. Kraskov, H. Stogbauer, and P. Grassberger,
24 | % Estimating mutual information.
25 | % Phys. Rev. E 69 (6) 066138, 2004
26 | %
27 | % in your published research.
28 |
29 |
30 | function miout=MIhigherdim(x,kneig,emb_dim,emb_tau)
31 |
32 | % Calculate MI value of any high-dimensional vector - to include also
33 | % dependencies in time use embedding dimension >1 (see[1], Fig 14)
34 | % (rectangular version)
35 | % x....input data mxn m...channelnummer n...sampling points m<1 (default is 1)
39 |
40 | %default-values
41 | if ~exist('kneig'), kneig=6; end
42 | if ~exist('emb_dim'), emb_dim=1; end
43 | if ~exist('emb_tau'), emb_tau=1; end
44 |
45 | [Nd,N]=size(x);
46 |
47 |
48 | if Nd>N
49 | zwsp=x;
50 | [Nd,N]=size(x);
51 | else
52 | zwsp=x';
53 | end
54 |
55 | save('zwspMIhigh.txt','zwsp','-ascii')
56 |
57 | % execute C Programm
58 | [a unout]=system(['milca_2 zwspMIhigh.txt ',num2str(Nd),' ',num2str(emb_dim),' ',num2str(emb_tau),' ',num2str(N),' ',num2str(kneig)]);
59 | miout=str2num(unout);
60 |
61 |
62 |
--------------------------------------------------------------------------------
/src/mutual_information/casting_test.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | //
4 | // __inline double fastabs(double x){
5 | // unsigned long int *x_int=&x;
6 | // unsigned long int n=*x_int&0x7fffffff;
7 | // return (double)n;
8 | // }
9 |
10 | //
11 | // inline double fastabs(double x){
12 | // float a =(float)x;
13 | //
14 | // unsigned int b = *reinterpret_cast(&a);
15 | // return (double) (b&0x7fffffff) ;
16 | // }
17 | //
18 |
19 | // inline double fastabs(double x){
20 | // float x_f=(float)x;
21 | // unsigned int=
22 | // return (double&) (((unsigned int&)x_f)&0x7fffffff) ;
23 | // }
24 | //
25 |
26 | // double fastabs(double x){
27 | // double x_abs=fabs(x);
28 | // double *ptr_x;
29 | // ptr_x=(double*)mxMalloc(2*sizeof(double));
30 | // *ptr_x=x;
31 | // *(ptr_x+1)=0x7fffffffffffffff;
32 | // unsigned long int x_int=(((unsigned long int&)x)&0x7fff ffff ffff ffff);
33 | // //return (double&) x_int ;
34 | // return *(ptr_x+1);
35 | // }
36 |
37 | // double fastabs(double x)
38 | // {
39 | // double mask=9.2233720368547758e18;
40 | // unsigned long int xx=((unsigned long int&)x&(unsigned long int&)mask);
41 | // return (double&)xx;
42 | // }
43 |
44 | double fastabs(float x)
45 | {
46 | unsigned int int_x=((unsigned int&)x&0x7fffffff);
47 | return (double)(float&)int_x;
48 | }
49 |
50 |
51 |
52 |
53 | void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
54 | {
55 | // unsigned int int_in;
56 | double x;
57 | double in=mxGetScalar(prhs[0]);
58 |
59 | x=fastabs(in);
60 |
61 | plhs[0]=mxCreateDoubleScalar(x);
62 |
63 | }
64 |
65 |
66 |
67 | //
68 | // int_in=*(long int*)∈
69 | // p_in=(long int*)∈
70 | // // reinterpret_cast
71 | // // int_in_1=*p_in;
72 | // // int_in_2=3;
73 | // //
74 | // // int_in_1=int_in_1*int_in_2;
75 | // mexPrintf("\nsize of int: %d\n",sizeof(int));
76 | // mexPrintf("\nsize of double: %d\n",sizeof(double));
77 | // mexPrintf("\nsize of long int: %d\n",sizeof(long int));
78 | // mexPrintf("\nsize of long long int: %d\n",sizeof(long long int));
79 | // mexPrintf("\nsize of float: %d\n",sizeof(float));
80 | // mexPrintf("\nsize of pointer to int: %d\n",sizeof(int*));
81 | // mexPrintf("\nsize of pointer to double: %d\n",sizeof(double));
82 | // mexPrintf("\nsize of pointer to long int: %d\n",sizeof(long int*));
83 | // mexPrintf("\nsize of pointer to float: %d\n",sizeof(float*));
84 | //
85 |
86 | // mexPrintf("\nint_in: %f\n",int_in);
87 | // mexPrintf("\np_in: %f\n\n",*p_in);
88 |
89 |
90 |
--------------------------------------------------------------------------------
/src/networks/fastfc_cluster_coef_wu.c:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2014-2015 Juan Garcia-Prieto Cuesta
3 | //
4 | // This file is part of Fast Functional Connectivity (FastFC)
5 | //
6 | // FastFC is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // FastFC is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with FastFC. If not, see .
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 | #include
30 | #include
31 | #include
32 |
33 | void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
34 | {
35 | int *K,node_i,node_j,z;
36 | double *W,*W2,*C,cyc3,w2_aux;
37 |
38 | const int n_nodes=(int)mxGetM(prhs[0]);
39 | W=(double*)mxGetPr(prhs[0]);
40 | K=(int*)mxMalloc(n_nodes*sizeof(int));
41 | W2=(double*)mxCalloc(n_nodes*n_nodes,sizeof(double));
42 | plhs[0]=mxCreateDoubleMatrix(n_nodes,1,mxREAL);
43 | C=(double*)mxGetPr(plhs[0]);
44 |
45 | omp_set_num_threads(omp_get_num_procs());
46 | #pragma omp parallel
47 | {
48 | #pragma omp for private(node_i,node_j,z) reduction(+:w2_aux)
49 | for(node_i=0;node_i.
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 | #include
30 | #include
31 |
32 | void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
33 | {
34 |
35 | int *n_neis,*n_triangs,*neis,link_i,link_j,nei_i,nei_j;
36 | double *A,*C;
37 |
38 | const int n_links=(int)mxGetM(prhs[0]);
39 |
40 | A=(double*)mxGetPr(prhs[0]);
41 |
42 | neis=(int*)mxMalloc(n_links*(n_links-1)*sizeof(int));
43 | n_neis=(int*)mxCalloc(n_links,sizeof(int));
44 | n_triangs=(int*)mxCalloc(n_links,sizeof(int));
45 |
46 | plhs[0]=mxCreateDoubleMatrix(n_links,1,mxREAL);
47 | C=(double*)mxGetPr(plhs[0]);
48 |
49 | omp_set_num_threads(omp_get_num_procs());
50 | #pragma omp parallel
51 | {
52 | #pragma omp for private(link_i,link_j)
53 | for(link_i=0;link_i1)
72 | {
73 | C[link_i]=(double)n_triangs[link_i]/(n_neis[link_i]*(n_neis[link_i]-1)*.5);
74 | }else{
75 | C[link_i]=0;
76 | }
77 | }
78 | }
79 |
80 | mxFree(neis);
81 | mxFree(n_neis);
82 | mxFree(n_triangs);
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/mutual_information/MIhigherdim.C:
--------------------------------------------------------------------------------
1 | // Copyright 2009 Alexander Kraskov, Harald Stoegbauer, Peter Grassberger
2 | //-----------------------------------------------------------------------------------------
3 | // This program is free software: you can redistribute it and/or modify
4 | // it under the terms of the GNU General Public License as published by
5 | // the Free Software Foundation, either version 3 of the License, or
6 | // (at your option) any later version.
7 | //
8 | // This program is distributed in the hope that it will be useful,
9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | // GNU General Public License for more details.
12 | //
13 | // You should receive a copy of the GNU General Public License
14 | // along with this program. See also .
15 | //-----------------------------------------------------------------------------------------
16 | // Contacts:
17 | //
18 | // Harald Stoegbauer
19 | // Alexander Kraskov
20 | //-----------------------------------------------------------------------------------------
21 | // Please reference
22 | //
23 | // A. Kraskov, H. Stogbauer, and P. Grassberger,
24 | // Estimating mutual information.
25 | // Phys. Rev. E 69 (6) 066138, 2004
26 | //
27 | // in your published research.
28 |
29 | #define _CRT_SECURE_NO_WARNINGS
30 |
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | #include "miutils.h"
39 |
40 | int main(int argc, char **argv) {
41 |
42 | FILE *fin;
43 | int i;
44 | double **x;
45 | double *min;
46 | double *max;
47 | double *psi;
48 | int K,N;
49 | int d;
50 | double mir;
51 | int dim,edim,tau;
52 |
53 | double s,me;
54 | double addnoise=-1;
55 |
56 | if (argc<7) {
57 | fprintf(stderr,"\nMutual Infomation (MI) k-nearest neighbours statistics (rectangular)\n\n");
58 | fprintf(stderr,"Usage:\n%s <# points> <# neighbours> [addnoise]\n\n",argv[0]);
59 | fprintf(stderr,"Input:\n\t\ttext file with columns and <# points> rows\n");
60 | fprintf(stderr,"\t\t\tnumber of columns in file\n");
61 | fprintf(stderr,"\t\t\tembedding dimension\n");
62 | fprintf(stderr,"\t\t\tembedding delay\n");
63 | fprintf(stderr,"\t<# points>\tnumber of rows (length of characteristic vector)\n");
64 | fprintf(stderr,"\t<# neighbours>\tnumber of the nearest neighbours for MI estimator\n");
65 | fprintf(stderr,"\t[addnoise]\tnoise amplitude; default 1e-8\n");
66 | fprintf(stderr,"\nOutput:\n");
67 | fprintf(stderr,"\nMI\n");
68 | fprintf(stderr,"\nContact: kraskov@its.caltech.edu\n");
69 | exit(-1);
70 | }
71 |
72 | dim=atoi(argv[2]);
73 | edim=atoi(argv[3]);
74 | tau=atoi(argv[4]);
75 | N=atoi(argv[5]);
76 | K=atoi(argv[6]);
77 | if (argc==8) {addnoise=atof(argv[7]);}
78 | if (argc>=9) {fprintf(stderr,"Too many input arguments\n");exit(-1);}
79 |
80 | x=(double**)calloc(dim,sizeof(double*));
81 | for (d=0;dmax[d]) max[d]=x[d][i];
112 | }
113 | for (i=0;i.
16 | //-----------------------------------------------------------------------------------------
17 | // Contacts:
18 | //
19 | // Harald Stoegbauer
20 | // Alexander Kraskov
21 | //-----------------------------------------------------------------------------------------
22 | // Please reference
23 | //
24 | // A. Kraskov, H. Stogbauer, and P. Grassberger,
25 | // Estimating mutual information.
26 | // Phys. Rev. E 69 (6) 066138, 2004
27 | //
28 | // in your published research.
29 |
30 |
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | #include "miutils.h"
39 |
40 | int main(int argc, char **argv) {
41 |
42 | FILE *fin;
43 | int i;
44 | double **x;
45 | double *scal;
46 | double *min;
47 | double *max;
48 | double *psi;
49 | int K,N;
50 | int d;
51 | double mir;
52 | int dimx,dimy;
53 |
54 |
55 | int BOX1;
56 |
57 | double s,me;
58 | double addnoise=-1;
59 |
60 | if (argc<6) {
61 | fprintf(stderr,"\nMutual Infomation (MI) k-nearest neighbours statistics (rectangular)\n\n");
62 | fprintf(stderr,"Usage:\n%s <# points> <# neighbours> [addnoise]\n\n",argv[0]);
63 | fprintf(stderr,"Input:\n\t\ttext file with columns and <# points> rows\n");
64 | fprintf(stderr,"\t\t\tnumber of columns for X (dimension of X)\n");
65 | fprintf(stderr,"\t\t\tnumber of columns for Y (dimension of Y)\n");
66 | fprintf(stderr,"\t<# points>\tnumber of rows (length of characteristic vector)\n");
67 | fprintf(stderr,"\t<# neighbours>\tnumber of the nearest neighbours for MI estimator\n");
68 | fprintf(stderr,"\t[addnoise]\tnoise amplitude; default 1e-8\n");
69 | fprintf(stderr,"\nOutput:\n");
70 | fprintf(stderr,"\nMI\n");
71 | fprintf(stderr,"\nContact: kraskov@its.caltech.edu\n");
72 | exit(-1);
73 | }
74 |
75 |
76 |
77 | dimx=atoi(argv[2]);
78 | dimy=atoi(argv[3]);
79 | N=atoi(argv[4]);
80 | K=atoi(argv[5]);
81 | if (argc==7) {addnoise=atof(argv[6]);}
82 | if (argc>=8) {fprintf(stderr,"Too many input arguments\n");exit(-1);}
83 |
84 | x=(double**)calloc(dimx+dimy,sizeof(double*));
85 | for (d=0;dmax[d]) max[d]=x[d][i];
117 | }
118 | for (i=0;i.
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 |
30 | // Copyright 2009 Alexander Kraskov, Harald Stoegbauer, Peter Grassberger
31 | //-----------------------------------------------------------------------------------------
32 | // This program is free software: you can redistribute it and/or modify
33 | // it under the terms of the GNU General Public License as published by
34 | // the Free Software Foundation, either version 3 of the License, or
35 | // (at your option) any later version.
36 | //
37 | // This program is distributed in the hope that it will be useful,
38 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
39 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 | // GNU General Public License for more details.
41 | //
42 | // You should receive a copy of the GNU General Public License
43 | // along with this program. See also .
44 | //-----------------------------------------------------------------------------------------
45 | // Contacts:
46 | //
47 | // Harald Stoegbauer
48 | // Alexander Kraskov
49 | //-----------------------------------------------------------------------------------------
50 | // Please reference
51 | //
52 | // A. Kraskov, H. Stogbauer, and P. Grassberger,
53 | // Estimating mutual information.
54 | // Phys. Rev. E 69 (6) 066138, 2004
55 | //
56 | // in your published research.
57 | */
58 | #define _CRT_SECURE_NO_WARNINGS
59 |
60 | #include
61 | #include
62 | #include
63 |
64 | #include
65 | #include
66 | #include
67 | #include
68 | #include
69 | #include
70 |
71 | #include "miutils.h"
72 |
73 | void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
74 | {
75 | int N,edim,tau,K,n_sensors,sensor_i,sensor_j,i,d,n_threads;
76 | const int dim=2;
77 | double addnoise=-1;
78 | double *data,**x;//*min,*max;
79 | double *psi;
80 | // double s,me;
81 | double *out_mi,*mi,mi_value;
82 |
83 |
84 | data=(double*)mxGetPr(prhs[0]);
85 | N=(int)mxGetM(prhs[0]);
86 | n_sensors=(int)mxGetN(prhs[0]);
87 | edim=(int)mxGetScalar(prhs[1]);
88 | tau=(int)mxGetScalar(prhs[2]);
89 | K=(int)mxGetScalar(prhs[3]);
90 | const int n_indexes=n_sensors*n_sensors;
91 | n_threads=omp_get_num_procs();
92 |
93 |
94 | if (nrhs<4)
95 | mexErrMsgIdAndTxt("MATLAB:trial_mi_milca","Not enough input arguments\n");
96 | if (nrhs==6)
97 | addnoise=mxGetScalar(prhs[4]);
98 | if (nrhs>6)
99 | mexErrMsgIdAndTxt("MATLAB:trial_mi_milca","Too many input arguments\n");
100 |
101 | x=(double**)mxMalloc(dim*sizeof(double*));
102 |
103 | for (d=0;d.
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
35 | {
36 | int sensor_i,thread_i;
37 | mwSize i;
38 | float *b,**x;
39 | double *x_d,*b_d,*y;
40 | fftwf_complex **fft_x,*fft_b;
41 | fftwf_plan p_r2c,p_c2r;
42 |
43 | const mwSize l_b=(mwSize)mxGetN(prhs[0]);
44 | const mwSize n_samples=(mwSize)mxGetM(prhs[1]);
45 | const int n_sensors=(int)mxGetN(prhs[1]);
46 | const int mode=(int)mxGetScalar(prhs[2]);
47 | const int n_threads=omp_get_num_procs();
48 | const mwSize l_p=n_samples+2*(l_b-1);
49 | const float n_factor=(float)1./l_p;
50 |
51 | b_d=(double*)mxGetPr(prhs[0]);
52 | x_d=(double*)mxGetPr(prhs[1]);
53 |
54 | b=(float*)mxMalloc(l_p*sizeof(float));
55 | x=(float**)mxMalloc(n_threads*sizeof(float*));
56 | fft_x=(fftwf_complex**)mxMalloc(n_threads*sizeof(fftwf_complex*));
57 | fft_b=(fftwf_complex*)fftwf_malloc(l_p*sizeof(fftwf_complex));
58 |
59 | plhs[0]=mxCreateDoubleMatrix(n_samples,n_sensors,mxREAL);
60 | y=(double*)mxGetPr(plhs[0]);
61 |
62 | for(thread_i=0;thread_i.
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 | #include
30 | #include
31 | #include
32 |
33 | #define INF (float)mxGetInf();
34 |
35 | typedef struct _node{
36 | int val;
37 | struct _node* prev;
38 | struct _node* next;
39 | }node;
40 |
41 | node * flush_node(int i,node * list,int n,node * list_init)
42 | {
43 | if(i==list->val)
44 | return list->next;
45 | if(i==n-1)
46 | return list;
47 | else{
48 | list_init[i].prev->next=list_init[i].next;
49 | list_init[i].next->prev=list_init[i].prev;
50 | return list;
51 | }
52 | }
53 |
54 | node * init_nodes(int n,node * list)
55 | {
56 | int i=0;
57 | list->val=i;
58 | list->prev=NULL;
59 | list->next=&list[1];
60 | for(i=1;ival*n+inode]val])
116 | {
117 | D_i[node_i->val]=D_i[inode]+(float)L[node_i->val*n+inode];
118 | B_i[node_i->val]=B_i[inode]+1;
119 | }
120 | node_i=node_i->next;
121 | }
122 | node_i=nodes;
123 | min_d=D_i[node_i->val];
124 | min_node=node_i->val;
125 | for(i=0;ival]val];
130 | min_node=node_i->val;
131 | }
132 | node_i=node_i->next;
133 | }
134 | inode=min_node;
135 | nodes=flush_node(min_node,nodes,n,nodes_init[th_i]);
136 | l_nodes--;
137 | }
138 | }
139 | }
140 |
141 | plhs[0]=mxCreateDoubleMatrix(n,n,mxREAL);
142 | plhs[1]=mxCreateDoubleMatrix(n,n,mxREAL);
143 |
144 | //copiar resultado en D_d
145 | #pragma omp parallel sections private(i)
146 | {
147 | #pragma omp section
148 | {
149 | D_d=(double*)mxGetPr(plhs[0]);
150 | for(i=0;i.
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 | #define _2PI 6.283185307179586
35 |
36 | void calc_hamm_win(float*w,int wl)
37 | {
38 | int i;
39 | const int wlh=(wl%2)? wl/2:(wl+1)/2;
40 | const float k=(float)_2PI/(wl-1);
41 | for(i=0;i.
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 | #include
30 | #include
31 | #include
32 |
33 | #define INF (float)mxGetInf();
34 |
35 | typedef struct _node{
36 | int inode;
37 | int val;
38 | struct _node* prev;
39 | struct _node* next;
40 | }node;
41 |
42 | node * flush_node(int n,int i,node * list,node * list_init)
43 | {
44 | if(i==list->val)
45 | return list->next;
46 | if(i==n-1)
47 | return list;
48 | else{
49 | list_init[i].prev->next=list_init[i].next;
50 | list_init[i].next->prev=list_init[i].prev;
51 | return list;
52 | }
53 | }
54 |
55 | node * init_nodes(int n,int inode,node * list)
56 | {
57 | int i=0;
58 | list->inode=inode;
59 | list->val=i;
60 | list->prev=NULL;
61 | list->next=&list[1];
62 | for(i=1;ival*n+inode]val])
173 | {
174 | D_i[node_i->val]=D_i[inode]+(float)L[node_i->val*n+inode];
175 | B_i[node_i->val]=B_i[inode]+1;
176 | node_i->inode=inode;
177 | }
178 | node_i=node_i->next;
179 | }
180 | node_i=nodes;
181 | min_d=D_i[node_i->val];
182 | min_node=node_i->val;
183 | min_node_prev=node_i->inode;
184 | for(i=0;ival]val];
189 | min_node=node_i->val;
190 | min_node_prev=node_i->inode;
191 | }
192 | node_i=node_i->next;
193 | }
194 | inode=min_node;
195 | nodes=flush_node(n,min_node,nodes,nodes_init[th_i]);
196 | push_node2path(n,min_node_prev,inode,path[th_i]);
197 | l_nodes--;
198 | }
199 |
200 | count_path(n,n_i,Betw,path[th_i],itinerary[th_i]);
201 | }
202 | }
203 |
204 | plhs[0]=mxCreateDoubleMatrix(n,n,mxREAL);
205 | plhs[1]=mxCreateDoubleMatrix(n,n,mxREAL);
206 | plhs[2]=mxCreateDoubleMatrix(n,1,mxREAL);
207 |
208 | #pragma omp parallel sections private(i)
209 | {
210 | #pragma omp section
211 | {
212 | D_d=(double*)mxGetPr(plhs[0]);
213 | for(i=0;i
32 | #include
33 | #include
34 | #include
35 |
36 | void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
37 | {
38 | int sensor_i,sensor_j;
39 | mwSize sample_i,first_samp_sensor_i,f_i;
40 | mwIndex i;
41 | float *x_f,*x_f_i,*x_f_j,*adj_plv,*adj_pli,*pval_plv,plv_i,
42 | sum_cos,sum_sin,sum_sin_sign,phi,sin_phi;
43 | double *x_d,*out_plv,*out_pli,*out_pval;
44 | fftwf_complex *a,*h;
45 | fftwf_plan p_r2c, p_c2c;
46 |
47 | const mwSize n_samples=(mwSize)mxGetM(prhs[0]);
48 | const int n_sensors=(int)mxGetN(prhs[0]);
49 | const mwSize n_elements=n_samples*(mwSize)n_sensors;
50 | const int is_even=(n_samples%2)? 0:1;
51 | const mwSize n_f=n_samples/2+((is_even)? 0:1);
52 | const float factor_n=(float)1.0/n_samples;
53 | const mwSize n_indexes=n_sensors*n_sensors;
54 | const mwSize init_sample=(int)mxGetScalar(prhs[1]);
55 | const int n_threads=omp_get_num_procs();
56 | const mwSize last_sample=n_samples-init_sample;
57 | const mwSize n_samples_eff=n_samples-2*init_sample;
58 | const int mode=(int)mxGetScalar(prhs[2]);
59 |
60 | x_d=(double*)mxGetPr(prhs[0]);
61 |
62 | x_f=(float*)mxMalloc(n_elements*sizeof(float));
63 | h=(fftwf_complex*)fftwf_malloc(n_elements*sizeof(fftwf_complex));
64 | a=(fftwf_complex*)fftwf_malloc(n_elements*sizeof(fftwf_complex));
65 |
66 | if (mode==3)
67 | {
68 | p_r2c=fftwf_plan_dft_r2c_1d(n_samples,x_f,h,FFTW_EXHAUSTIVE);
69 | p_c2c=fftwf_plan_dft_1d(n_samples,h,a,FFTW_BACKWARD,FFTW_EXHAUSTIVE);
70 | }
71 | else if (mode==3)
72 | {
73 | p_r2c=fftwf_plan_dft_r2c_1d(n_samples,x_f,h,FFTW_PATIENT);
74 | p_c2c=fftwf_plan_dft_1d(n_samples,h,a,FFTW_BACKWARD,FFTW_PATIENT);
75 | }
76 | else if (mode==3)
77 | {
78 | p_r2c=fftwf_plan_dft_r2c_1d(n_samples,x_f,h,FFTW_MEASURE);
79 | p_c2c=fftwf_plan_dft_1d(n_samples,h,a,FFTW_BACKWARD,FFTW_MEASURE);
80 | }
81 | else
82 | {
83 | p_r2c=fftwf_plan_dft_r2c_1d(n_samples,x_f,h,FFTW_ESTIMATE);
84 | p_c2c=fftwf_plan_dft_1d(n_samples,h,a,FFTW_BACKWARD,FFTW_ESTIMATE);
85 | }
86 |
87 | omp_set_num_threads(n_threads);
88 | #pragma omp parallel
89 | {
90 | #pragma omp for private(sensor_i,sample_i,first_samp_sensor_i,f_i)
91 | for(sensor_i=0;sensor_i0.0)-(sin_phi<0.0);
156 | }
157 | sum_cos/=n_samples_eff;
158 | sum_sin/=n_samples_eff;
159 |
160 | plv_i=sqrtf(sum_cos*sum_cos+sum_sin*sum_sin);
161 | adj_pli[sensor_j+(n_sensors*sensor_i)]=fabsf(sum_sin_sign/n_samples_eff);
162 | adj_plv[sensor_j+(n_sensors*sensor_i)]=plv_i;
163 | pval_plv[sensor_j+(n_sensors*sensor_i)]=
164 | expf(sqrtf((float)(1+4*n_samples_eff)+4.0*(float)n_samples_eff*(float)n_samples_eff*(1.0-plv_i*plv_i))-(float)(1+2*n_samples_eff));
165 |
166 | adj_plv[sensor_i+(n_sensors*sensor_j)]=plv_i;
167 | adj_pli[sensor_i+(n_sensors*sensor_j)]=adj_pli[sensor_j+(n_sensors*sensor_i)];
168 | pval_plv[sensor_i+(n_sensors*sensor_j)]=pval_plv[sensor_j+(n_sensors*sensor_i)];
169 |
170 | }
171 | }
172 | }
173 |
174 | mxFree(x_f);
175 |
176 | plhs[0]=mxCreateDoubleMatrix(n_sensors,n_sensors,mxREAL);
177 | plhs[1]=mxCreateDoubleMatrix(n_sensors,n_sensors,mxREAL);
178 | plhs[2]=mxCreateDoubleMatrix(n_sensors,n_sensors,mxREAL);
179 |
180 |
181 | #pragma omp parallel sections private(i)
182 | {
183 | #pragma omp section
184 | {
185 | out_plv=(double*)mxGetPr(plhs[0]);
186 | for(i=0;i.
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 | #define INF (float)mxGetInf();
35 |
36 | typedef struct neighbour{
37 | int index;
38 | float dist;
39 | }neighbour;
40 |
41 | int cmp(const void *a,const void *b)
42 | {
43 | return (((neighbour*)a)->dist < ((neighbour*)b)->dist)?
44 | -1:(((neighbour*)a)->dist > ((neighbour*)b)->dist);
45 | }
46 |
47 | void init_knn(const int n_sensors,const int n_states,const int k,
48 | neighbour * k_nn)
49 | {
50 | int sensor_i,state_i,k_i;
51 | for(sensor_i=0;sensor_iW)
62 | {
63 | if(*k_ind)&(abs(i-j)>W))
66 | k_i++;
67 | for(k_ii=*k_in;k_ii>k_i;k_ii--)
68 | k_nn[k_ii]=k_nn[k_ii-1];
69 |
70 | k_nn[k_i].dist=d;
71 | k_nn[k_i].index=j;
72 | *k_in+=1;
73 | } else if(k_nn[k_i].dist>d) {
74 | k_i++;
75 | while((k_id))
76 | k_i++;
77 | for(k_ii=0;k_ii.
15 | %
16 | % ------------------------------------------
17 | % Please consider citing our work:
18 | %
19 | % Efficient computation of functional brain networks: towards real-time functional connectivity
20 | % Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
21 | %
22 | % ------------------------------------------
23 | % Contact: Juan Garcia-Prieto juangpc (at) gmail.com
24 | % ------------------------------------------
25 | %
26 |
27 |
28 | %% FastFC testing script
29 |
30 | % configure number of sensors and samples
31 | n_samples=1000;
32 | n_sensors=100;
33 | x=randn(n_samples,n_sensors); % remember columnwise matrix of each sensor.
34 |
35 | %%
36 | fprintf('\n\n *** FastFC testing script *** \n\n\n');
37 | fprintf(' This function is intended to check the correct installation of FastFC.\n');
38 | fprintf(' While it helps understanding how different functions can be used.\n\n');
39 | fprintf([' The testing setup will be a set of ' num2str(n_samples) ' samples and ' num2str(n_sensors) ' sensors.\n']);
40 | fprintf(' IMPORTANT: sensors must be stored as columns in the input data.\n\n\n');
41 |
42 | %% testing FastFC filtering function
43 | fprintf(' Starting Zero Phase Distortion filtering test:\n')
44 | b=fir1(ceil(n_samples/5),[0.0160 0.0240],'bandpass',hamming(ceil(n_samples/5)+1),'scale');
45 |
46 | % y=fastfc_filt(filter,data,mode)
47 | % Input parameters:
48 | % filter = row vector with filter denominator coefficients.
49 | % data = column matrix with data to be filtered. Each sensor should be each column.
50 | % mode = mode for FFT scheduling
51 | % mode = 0 , execute fastest but suboptimal.
52 | % mode = 1 , execute fast but in a suboptimal algorithm.
53 | % mode = 2 , execute slower the first time, but consider possible faster algorithms.
54 | % mode = 3 , execute slowest the first time, but consider the fastest algorithm.
55 | % Output parameters:
56 | % y = array the same size of data, with each column corresponding to each filtered column of data.
57 |
58 | y_filtfilt=filtfilt(b,1,x);
59 | tic;
60 | y_filtfilt=filtfilt(b,1,x);
61 | t_filtfilt=toc;
62 | y_fastfc=fastfc_filt(b,x,1); %this first call takes longer for optimization purposes.
63 | tic;y_fastfc=fastfc_filt(b,x,1);t_fastfc=toc;
64 | fprintf(' New filtfilt version called ''fastfc_filt'' is working properly.\n');
65 | fprintf([' FastFC is ' num2str(t_filtfilt/t_fastfc) ' times faster than Matlab''s filtfilt.\n\n']);
66 |
67 | %% Testing Phase Synchronization function
68 | fprintf(' Starting Phase Synchronization test:\n');
69 |
70 | % [plv,pval_plv,pli,wpli]=fastfc_ps(data,samples_to_discard,mode)
71 | %
72 | % Input parameters:
73 | % data = data (sensors by columns).
74 | % samples_to_discard = samples to discard at the beginning and samples to discard at the end of the phase signals. i.e. To discard 200 samples at the beginning and 200 samples at the end of each sensor, samples_to_discard should equal 200.
75 | % mode = 0 -> execute fastest but suboptimal.
76 | % mode = 1 -> execute fast but in a suboptimal algorithm.
77 | % mode = 2 -> execute slower the first time, but consider possible faster algorithms.
78 | % mode = 3 -> execute slowest the first time, but consider the fastest algorithm.
79 | % Output parameters:
80 | % plv = Phase Locking Value Functional Connectivity matrix.
81 | % pval_plv = pvalue for each index of the PLV matrix.
82 | % pli = Phase Locking Index Functional Connectivity matrix.
83 | % wPli = weighted Phase Locking Functional Connectivity matrix.
84 |
85 | tic;[plv,pval_plv,pli]=fastfc_ps(x,n_samples*.1,1);t_ps1=toc;
86 | tic;[wpli,imc]=fastfc_wpli(x);t_ps2=toc;
87 |
88 | fprintf(' Function ''fastfc_ps'' is working properly.\n');
89 | fprintf(' FastFC calculation of Phase Synch. indices: PLV and PLI took: %.03f seconds.\n',t_ps1);
90 | fprintf(' FastFC calculation of Phase Synch. indices: PLI, wPLI and ImC took: %.03f seconds.\n\n',t_ps2);
91 |
92 | %% Testing Mutual Info
93 | fprintf(' Starting Mutual Information test:\n');
94 |
95 | % [mi]=fastfc_mi(data,emb_dim,tau,k);
96 | % Input parameters:
97 | % data = eeg data (sensors by columns).
98 | % emb_dim = embedding dimensions to consider
99 | % tau = time lag to consider for embedding
100 | % k = number of neighbours to consider
101 | % Output parameters:
102 | % mi = Mutual Information Functional Connectivity matrix
103 |
104 | emb_dim=3;
105 | tau=2;
106 | k=4;
107 | tic;[mi]=fastfc_mi(x,emb_dim,tau,k);t_mi=toc;
108 |
109 | fprintf(' Function ''fastfc_mi'' is working properly.\n');
110 | fprintf(' FastFC calculation of Mutual Information index took: %.03f seconds.\n\n',t_mi);
111 |
112 | %% Testing Generalized Synchronization
113 | fprintf(' Starting Generalized Synchronization test:\n');
114 |
115 | % [S,H,M,L]=fastfc_gs(data,emb_dim,tau,k,w,states_eff_step)
116 | %
117 | % Input parameters:
118 | % data = eeg data (sensors by columns).
119 | % emb_dim = embedding dimension
120 | % tau = time lag for embedding
121 | % k = number of neighbours to consider
122 | % w = window correction for neighbour finding
123 | % states_eff_step = state-space down sampling to consider when calculating distances
124 | % Output parameters:
125 | % S, H, M and L = Functional Connectivity matrices for each index.
126 |
127 | emb_dim=3;
128 | tau=2;
129 | k=4;
130 | w=20;
131 | states_eff_step=1;
132 |
133 | tic;[S,H,M,L]=fastfc_gs(x,emb_dim,tau,k,w,states_eff_step);t_gs=toc;
134 |
135 | fprintf(' Function ''fastfc_gs'' is working properly.\n');
136 | fprintf(' FastFC calculation of Generalized Synchronization indices: S, H, M, and L took: %0.2f seconds.\n\n',t_gs);
137 |
138 | %% Testing Strength
139 | fprintf(' Starting Strength test:\n');
140 |
141 | A=randn(n_sensors);
142 | A(1:n_sensors+1:end)=0;
143 |
144 | % [S]=fastfc_strength_wu(A)
145 | %
146 | % Input parameters:
147 | % A = adjacency matrix of real values between 0 and 1, with zeroed principal diagonal elements.
148 | % Output parameters:
149 | % C = a row matrix where every value represents the Strength of each node.
150 |
151 | tic;[St]=fastfc_strength_wu(A);t_S=toc;
152 |
153 | fprintf(' Function ''fastfc_strength_wu'' is working properly.');
154 | fprintf(' FastFC calculation of Strength index took: %0.4f seconds.\n\n',t_S);
155 |
156 | %% Testing Clustering Coefficient
157 | fprintf(' Starting Clustering Coefficient test:\n');
158 |
159 | A=randn(n_sensors);
160 | A(1:n_sensors+1:end)=0;
161 |
162 | % [C]=fastfc_cluster_coef_wu(A)
163 | %
164 | % Input parameters:
165 | % A = adjacency matrix of nodes by nodes. Values between 0 and 1. Principal diagonal is zero.
166 | % Output parameters:
167 | % C= column matrix where every value represents the Clustering Coefficient of each node.
168 |
169 | tic;[C]=fastfc_cluster_coef_wu(A);t_C=toc;
170 |
171 | fprintf(' Function ''fastfc_cluster_coef_wu'' is working properly.\n');
172 | fprintf(' FastFC calculation of Clustering Coefficient index took: %0.4f seconds.\n\n',t_C);
173 |
174 | %% Testing Shortest Path Length
175 | fprintf(' Starting Shortest Path Lenght test:\n');
176 |
177 | A=randn(n_sensors);
178 | A(1:n_sensors+1:end)=0;
179 | W=(A.^-1);
180 |
181 | % [D,L]=fastfc_shortest_path_length_w(W)
182 | %
183 | % Input parameters:
184 | % W = directed or undirected weighted connection length matrix.Typically W is obtained by inverting each element in the Functional Connectivity matrix, transforming therefore between weights to length.
185 | % Output parameters:
186 | % D = distance matrix between nodes (shortest weighted path).
187 | % L = number of edges in each shortest weighted path.
188 |
189 | tic;[Dst,Ln]=fastfc_shortest_path_length_w(W);t_L=toc;
190 |
191 | fprintf(' Function ''fastfc_shortest_path_length_w'' is working properly.\n');
192 | fprintf(' FastFC calculation of Shortest Path Length index took: %0.4f seconds.\n\n',t_L);
193 |
194 | %% Testing Betweenness Centrality
195 | fprintf(' Starting Betweenness Centrality test:\n');
196 |
197 | A=randn(n_sensors);
198 | A(1:n_sensors+1:end)=0;
199 | W=(A.^-1);
200 |
201 | % [D,L,BC]=fastfc_betweenness_cent_w(W)
202 | %
203 | % Input parameters:
204 | % W = directed or undirected connection-length matrix.
205 | % Output parameters:
206 | % D = distance matrix between nodes (shortest weighted path).
207 | % L = number of edges in each shortest weighted path.
208 | % BC = node Betweenness Centrality for each node in the network.
209 |
210 | tic;[D,L,B]=fastfc_betweenness_cent_w(W);t_B=toc;
211 |
212 | fprintf(' Function ''fastfc_shortest_path_length_w'' is working properly.\n');
213 | fprintf(' FastFC calculation of Shortest Path Length index took: %0.4f seconds.\n\n',t_B);
214 |
215 | %% Final
216 | fprintf(' ............ Fast FC is working rock solid. Thanks! ..............\n\n')
217 | fprintf(' This file is part of Fast Functional Connectivity (FastFC) ---> http://juangpc.github.io/FastFC\n');
218 | fprintf(' Please consider helping by citing our work\n\n\n');
219 |
220 |
--------------------------------------------------------------------------------
/src/generalized_sync/fastfc_gs.c:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2014-2015 Juan Garcia-Prieto Cuesta
3 | //
4 | // This file is part of Fast Functional Connectivity (FastFC)
5 | //
6 | // FastFC is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // FastFC is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with FastFC. If not, see .
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 | #include
30 | #include
31 | #include
32 |
33 | struct neighbor{
34 | int index;
35 | float dist;
36 | };
37 |
38 | int comp(const void *a,const void *b)
39 | {
40 | return ((*(struct neighbor *)a).dist<(*(struct neighbor *)b).dist)?
41 | -1:
42 | ((*(struct neighbor *)a).dist>(*(struct neighbor *)b).dist);
43 | }
44 |
45 | void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
46 | {
47 |
48 | //call
49 | // shml(trial(by columns),emb_d,tau, k , w_emb , states_eff_step,
50 | // (0) (1) (2) (3) (4) (5)
51 |
52 | int state_eff_i,state_i,state_j,tau_i,n_states,n_states_eff,n_indexes,
53 | actual_state,k_in,index_i,sensor_i,sensor_j;
54 | float *mean_d_nn,*mean_d,*adj_s,*adj_h,*adj_m,*adj_l,
55 | dist_diff,dist_sum_1,dist_sum_2,cum_dist_sum_1,
56 | cum_sum_s,cum_sum_h,cum_sum_m,cum_sum_l,
57 | g_i,g_i_g_ik,mean_rank_dist,mean_cond_dist;
58 | double *data,*data_i,*out_s,*out_h,*out_m,*out_l;
59 | struct neighbor *emb_dist,*emb_dist_i,*emb_dist_ord,*emb_dist_ord_i,
60 | *knn,*knn_i,this_neighbor;
61 |
62 | const int n_samples=(int)mxGetM(prhs[0]);
63 | const int n_sensors=(int)mxGetN(prhs[0]);
64 | const int emb_d=(int)mxGetScalar(prhs[1]);
65 | const int tau=(int)mxGetScalar(prhs[2]);
66 | const int k=(int)mxGetScalar(prhs[3]);
67 | const int w_emb=(int)mxGetScalar(prhs[4]);
68 | const int states_eff_step=(int)mxGetScalar(prhs[5]);
69 | const int n_threads=omp_get_num_procs();
70 |
71 | n_states=n_samples-(tau*(emb_d-1));
72 | n_states_eff=n_states/states_eff_step;
73 | n_indexes=n_sensors*n_sensors;
74 | g_i=((float)n_states)/2;
75 | g_i_g_ik=g_i-(((float)k+1)/2);
76 |
77 | data=(double*)mxGetPr(prhs[0]);
78 |
79 | emb_dist=(struct neighbor*)mxMalloc(n_states_eff*n_states*n_sensors*sizeof(struct neighbor));
80 | emb_dist_ord=(struct neighbor*)mxMalloc(n_states_eff*n_states*n_sensors*sizeof(struct neighbor));
81 | mean_d=(float*)mxMalloc(n_states_eff*n_sensors*sizeof(float));
82 | mean_d_nn=(float*)mxMalloc(n_states_eff*n_sensors*sizeof(float));
83 | knn=(struct neighbor*)mxMalloc(n_states_eff*k*n_sensors*sizeof(struct neighbor));
84 |
85 | omp_set_num_threads(n_threads);
86 |
87 | for(sensor_i=0;sensor_iw_emb)
126 | {
127 | knn_i[k_in+state_eff_i*k].index=this_neighbor.index;
128 | knn_i[k_in+state_eff_i*k].dist=this_neighbor.dist;
129 | dist_sum_2+=this_neighbor.dist;
130 | k_in++;
131 | }
132 | state_i++;
133 | }
134 | mean_d_nn[state_eff_i+sensor_i*n_states_eff]=dist_sum_2/(float)k;
135 | }
136 | }
137 | }
138 |
139 | adj_s=(float*)mxMalloc(n_indexes*sizeof(float));
140 | adj_h=(float*)mxMalloc(n_indexes*sizeof(float));
141 | adj_m=(float*)mxMalloc(n_indexes*sizeof(float));
142 | adj_l=(float*)mxMalloc(n_indexes*sizeof(float));
143 |
144 | for(sensor_i=0;sensor_i.
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 | void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
35 | {
36 | int i,s_i,s_j,th_i;
37 | float *b,*x,*adj_plv,*pval_plv,*adj_pli,*adj_wpli,phi,sin_phi,plv_i;
38 | float sum_cos=0;
39 | float sum_sin=0;
40 | float sum_sin_sign=0;
41 | float sum_abs_sin=0;
42 |
43 | double *x_d,*b_d,*out_plv,*out_pli,*out_wpli,*out_pval;
44 | fftwf_complex *fft_b,**h,**a;
45 | fftwf_plan p_r2c_1,p_r2c_2,p_c2r,p_c2c;
46 |
47 | const int n_samples=(int)mxGetM(prhs[0]);
48 | const int n_sensors=(int)mxGetN(prhs[0]);
49 | const int init_sample=(int)mxGetScalar(prhs[1]);
50 | const int l_b=(int)mxGetN(prhs[2]);
51 | const int mode=(int)mxGetScalar(prhs[3]);
52 | const int n_threads=1;//omp_get_num_procs();
53 |
54 | const int n_indexes=n_sensors*n_sensors;
55 | const int n_samples_eff=n_samples-2*init_sample;
56 | const int l_p=n_samples+2*(l_b-1);
57 | const int is_even=(n_samples%2)?0:1;
58 | const int n_f=n_samples/2+((is_even)?0:1);
59 | const float factor_n_l_p=(float)1./l_p;
60 | const float factor_n_ns=(float)1./n_samples;
61 | const float factor_n_eff=(float)1./n_samples_eff;
62 |
63 | x_d=(double*)mxGetPr(prhs[0]);
64 | b_d=(double*)mxGetPr(prhs[2]);
65 |
66 | b=(float*)fftwf_malloc(l_p*sizeof(float));
67 | fft_b=(fftwf_complex*)fftwf_malloc(l_p*sizeof(fftwf_complex));
68 |
69 | x=(float*)mxMalloc(l_p*n_sensors*sizeof(float));
70 | h=(fftwf_complex**)mxMalloc(n_threads*sizeof(fftwf_complex*));
71 | a=(fftwf_complex**)mxMalloc(n_threads*sizeof(fftwf_complex*));
72 |
73 | for(th_i=0;th_i0.0)-(sin_phi<0.0);
212 | sum_abs_sin+=fabsf(sin_phi);
213 | }
214 | sum_cos*=factor_n_eff;
215 | sum_sin*=factor_n_eff;
216 |
217 | plv_i=sqrtf(sum_cos*sum_cos+sum_sin*sum_sin);
218 | adj_pli[s_j+(n_sensors*s_i)]=fabsf(sum_sin_sign/n_samples_eff);
219 | adj_wpli[s_j+(n_sensors*s_i)]=(fabsf(sum_sin)*n_samples_eff)/sum_abs_sin;
220 | adj_plv[s_j+(n_sensors*s_i)]=plv_i;
221 | pval_plv[s_j+(n_sensors*s_i)]=expf(
222 | sqrtf((float)(1+4*n_samples_eff)+
223 | (float)4.0*n_samples_eff*n_samples_eff*((float)1.0-plv_i*plv_i))
224 | -(1+2*n_samples_eff));
225 |
226 | adj_plv[s_i+(n_sensors*s_j)]=plv_i;
227 | adj_pli[s_i+(n_sensors*s_j)]=adj_pli[s_j+(n_sensors*s_i)];
228 | adj_wpli[s_i+(n_sensors*s_j)]=adj_wpli[s_j+(n_sensors*s_i)];
229 | pval_plv[s_i+(n_sensors*s_j)]=pval_plv[s_j+(n_sensors*s_i)];
230 |
231 | }
232 | }
233 | }
234 |
235 | mxFree(x);
236 |
237 | plhs[0]=mxCreateDoubleMatrix(n_sensors,n_sensors,mxREAL);
238 | plhs[1]=mxCreateDoubleMatrix(n_sensors,n_sensors,mxREAL);
239 | plhs[2]=mxCreateDoubleMatrix(n_sensors,n_sensors,mxREAL);
240 | plhs[3]=mxCreateDoubleMatrix(n_sensors,n_sensors,mxREAL);
241 |
242 |
243 | #pragma omp parallel sections private(i)
244 | {
245 | #pragma omp section
246 | {
247 | out_plv=(double*)mxGetPr(plhs[0]);
248 | for(i=0;i.
18 | //
19 | // -------------------------------------------------------
20 | // Please consider citing our work:
21 | //
22 | // Efficient computation of functional brain networks: towards real-time functional connectivity
23 | // Frontiers in Neuroinformatics (2017) García-Prieto Juan, Bajo Ricardo, Pereda Ernesto
24 | //
25 | // -------------------------------------------------------
26 | // Contact: Juan Garcia-Prieto juangpc (at) gmail.com
27 | // -------------------------------------------------------
28 | //
29 |
30 | /* Copyright 2009 Alexander Kraskov, Harald Stoegbauer, Peter Grassberger
31 | //-----------------------------------------------------------------------------------------
32 | // This program is free software: you can redistribute it and/or modify
33 | // it under the terms of the GNU General Public License as published by
34 | // the Free Software Foundation, either version 3 of the License, or
35 | // (at your option) any later version.
36 | //
37 | // This program is distributed in the hope that it will be useful,
38 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
39 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 | // GNU General Public License for more details.
41 | //
42 | // You should receive a copy of the GNU General Public License
43 | // along with this program. See also .
44 | //-----------------------------------------------------------------------------------------
45 | // Contacts:
46 | //
47 | // Harald Stoegbauer
48 | // Alexander Kraskov
49 | //-----------------------------------------------------------------------------------------
50 | // Please reference
51 | //
52 | // A. Kraskov, H. Stogbauer, and P. Grassberger,
53 | // Estimating mutual information.
54 | // Phys. Rev. E 69 (6) 066138, 2004
55 | //
56 | // in your published research.
57 | */
58 |
59 | void make_box1(double *x, int N, double scal, int bs,
60 | int *box, int *lis, int *mxi);
61 | /* make one-dimensional box
62 | input
63 | x - input sequence
64 | N - length of the input sequence
65 | scal - renormalization factor, scal=#boxes/(max(x)-min(x))
66 | bs - #boxes
67 | output
68 | box - each element of the array is ordinary number of the last point in the box
69 | lis - each element of the array is ordinary number of the previous points in the box or -1
70 | mxi - accumulative number of the points in the box
71 | */
72 | void make_box2(double **x, int dim, int N, int comp1, int comp2, int bs, int inveps,
73 | int **box, int *lis);
74 | /* uses comp1 and comp2 component for two-dimensional grid */
75 | /* make two-dimensional box !!! changing the order of the points
76 | input
77 | x - two-dimensional input sequence
78 | dim - dimension of x
79 | N - length of the input sequence
80 | comp1 - first component for two dimensional grid
81 | comp2 - second component for two dimensional grid
82 | bs - #boxes
83 | inveps - box size
84 | output
85 | box - each element of the array is ordinary number of the last point in the box
86 | lis - each element of the array is ordinary number of the previous points in the box or -1
87 | */
88 | void make_box2ind(double **x, int dim, int N, int comp1, int comp2, int bs, int inveps,
89 | int *ind, int **box, int *lis);
90 | /* make two-dimensional box !!! changing the order of the points, but saving the order in ind
91 | input
92 | x - dim-dimensional input sequence
93 | dim - dimension of input sequence
94 | N - length of the input sequence
95 | comp1 - first component for creating grid
96 | comp2 - first component for creating grid
97 | bs - #boxes
98 | inveps - box size
99 | output
100 | ind - index of original data
101 | box - each element of the array is ordinary number of the last point in the box
102 | lis - each element of the array is ordinary number of the previous points in the box or -1
103 | */
104 | int neiE1(double *x, int i, double scal, int bs, double eps, int *box, int *lis, int *mxi);
105 | /* searching for neighbors of point i in eps-neighborhood in one dimension
106 | input
107 | x - one-dimensional input sequence
108 | i - current point
109 | scal - renormalization factor, scal=#boxes/(max(x)-min(x))
110 | bs - #boxes
111 | eps - neighborhood
112 | box - each element of the array is ordinary number of the last point in the box
113 | lis - each element of the array is ordinary number of the previous points in the box or -1
114 | mxi - accumulative number of the points in the box
115 | output
116 | number of neighbors
117 | */
118 | int neiE(double **x, int i, int comp1, int comp2, int dim, int bs, double epsgrid, double eps, int **box, int *lis);
119 | /* searching for neighbors of point i in eps-neighborhood in dim dimension
120 | input
121 | x - dim-dimensional input sequence
122 | i - current point
123 | dim -dimension on input sequence
124 | comp1 -
125 | comp2 -
126 | bs - #boxes
127 | epsgrid - size of the grid
128 | eps - neighborhood
129 | box - each element of the array is ordinary number of the last point in the box
130 | lis - each element of the array is ordinary number of the previous points in the box or -1
131 | output
132 | number of neighbors
133 | */
134 | void neiEK(double **x, int i, int comp1, int comp2, int dim, int K,
135 | int bs, double epsgrid, double *eps, int **box, int *lis,
136 | int *nx);
137 | /* searching for neighbors of point i in eps-neighborhood in dim dimension for K
138 | input
139 | x - dim-dimensional input sequence
140 | i - current point
141 | dim -dimension on input sequence
142 | K - max number of neighbors
143 | comp1 -
144 | comp2 -
145 | bs - #boxes
146 | epsgrid - size of the grid
147 | eps - neighborhood
148 | box - each element of the array is ordinary number of the last point in the box
149 | lis - each element of the array is ordinary number of the previous points in the box or -1
150 | output
151 | nx - number of neighbors
152 | */
153 |
154 |
155 | void neiK(double **x, int dim, int comp1, int comp2, int i,
156 | int bs, double epsgrid, int K, int **box, int *lis,
157 | int *nn);
158 | /* searching for K neighbors of point i in dim dimension
159 | input
160 | x - dim-dimensional input sequence
161 | dim - dimension of x
162 | comp1 - first component for two dimensional grid
163 | comp2 - second component for two dimensional grid
164 | i - current point
165 | bs - #boxes
166 | epsgrid - size of the grid
167 | box - each element of the array is ordinary number of the last point in the box
168 | lis - each element of the array is ordinary number of the previous points in the box or -1
169 | output
170 | nn - indices of K neighbors
171 | */
172 |
173 | //void neiK(double **x, int i, int bs, double epsgrid, int K, int **box, int *lis,
174 | // int *nn);
175 | /* searching for K neighbours of point i in two dimension
176 | input
177 | x - 2-dimensional input sequence
178 | i - current point
179 | bs - #boxes
180 | epsgrid - size of the grid
181 | box - each element of the array is ordinary number of the last point in the box
182 | lis - each element of the array is ordinary number of the previous points in the box or -1
183 | output
184 | nn - indices of K neighbors
185 | */
186 | void mi2(double **x, int N, int K,
187 | double *psi,
188 | double *scal,
189 | double *mic, double *mir);
190 | void mi2c(double **x, int N, int K,
191 | double *psi,
192 | double *scal,
193 | double *mic);
194 | void mi2r(double **x, int N, int K,
195 | double *psi,
196 | double *scal,
197 | double *mir);
198 | void mi2r_(double **x, int N, int K,
199 | double *psi,
200 | double *scal,
201 | double *mir);
202 |
203 | void red(double **x, int dim, int N, int K,
204 | double *psi,
205 | double *scal,
206 | double *mic, double *mir);
207 | void redc(double **x, int dim, int N, int K,
208 | double *psi,
209 | double *scal,
210 | double *mic);
211 | void redr(double **x, int dim, int N, int K,
212 | double *psi,
213 | double *scal,
214 | double *mir);
215 | void redr_embed(double **x, int dim, int edim, int tau, int N, int K,
216 | double *psi,
217 | double *mir);
218 | void mi_xnyn(double **x, int dimx, int dimy, int N, int K,
219 | double *psi,
220 | double *scal,
221 | double *mic, double *mir);
222 | /*
223 | calculating of mutual information between vectors, only for one K
224 |
225 | input
226 | x - (dimx+dimy)-dimensional input
227 | dimx - dimension of vector x
228 | dimy - dimension of vector y
229 | N - length of vectors
230 | K - max number of neighbors
231 | psi - digamma function
232 | scal - scale for one dimensional box (BOX1/(max-min))
233 | output
234 | mic - cubic method
235 | mir - rectange method
236 | */
237 | void mic_xnyn(double **x, int dimx, int dimy, int N, int K,
238 | double *psi,
239 | double *scal,
240 | double *mic);
241 | void mir_xnyn(double **x, int dimx, int dimy, int N, int K,
242 | double *psi,
243 | double *scal,
244 | double *mir);
245 |
246 |
247 |
248 | void redK(double **x, int dim, int N, int K,
249 | double *psi,
250 | double *scal,
251 | double *mi_cr);
252 | /*
253 | calculating of redundancy
254 |
255 | input
256 | x - dim-dimensional input
257 | dim - dimension
258 | N - length of vectors
259 | K - max number of neighbors
260 | psi - digamma function
261 | scal - scale for one dimensional box (BOX1/(max-min))
262 | output
263 | mi_cr - MI using cubic and rectangle method for different K
264 | array contains the values of mutual information [cub_k1,rec_k1,cub_k2,rec_k2,...,cub_kK,rec_kK]
265 | */
266 |
267 | void mi2K(double **x, int N, int K,
268 | double *psi,
269 | double *scal,
270 | double *mi_cr);
271 | /*
272 | calculating of mutual information
273 |
274 | input
275 | x - two-dimensional input
276 | N - length of vectors
277 | K - max number of neighbors
278 | psi - digamma function
279 | scal - scale for one dimensional box (BOX1/(max-min))
280 | output
281 | mi_cr - MI using cubic and rectangle method for different K
282 | array contains the values of mutual information [cub_k1,rec_k1,cub_k2,rec_k2,...,cub_kK,rec_kK]
283 | */
284 |
285 | void mi_xnynK(double **x, int dimx, int dimy, int N, int K,
286 | double *psi,
287 | double *scal,
288 | double *mi_cr);
289 | void mi_xnynKembed(double **x, int dim, int N, int K,
290 | double **xx, double **yy,
291 | int **boxx, int *lisx, int *indx,
292 | int **boxy, int *lisy, int *indy,
293 | double *psi,
294 | double *mi_cr);
295 |
296 |
297 | void mi2h(double **x, int N, int K,
298 | double *psi,
299 | double *scal,
300 | double *mic, double *mir, double *hc, double *hr);
301 |
302 |
303 | void mi_embed(double **x, int dim, int N, int K, float *mi_cr,
304 | double *psi, double *phi, double minx, double maxx, double miny, double maxy);
305 |
306 |
307 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
341 |
--------------------------------------------------------------------------------
/src/filter/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
341 |
--------------------------------------------------------------------------------
/src/networks/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
341 |
--------------------------------------------------------------------------------
/src/phase_sync/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
341 |
--------------------------------------------------------------------------------
/src/generalized_sync/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
341 |
--------------------------------------------------------------------------------