refactoring

This commit is contained in:
arcan1s
2013-07-22 15:42:42 +04:00
parent 51d31d0a2f
commit 694751ce09
46 changed files with 1140 additions and 225760 deletions
Executable
BIN
View File
Binary file not shown.
+9 -2
View File
@@ -162,7 +162,14 @@ void main()
for (i=0; i<n; i++) for (i=0; i<n; i++)
p[i] = 0; p[i] = 0;
iso(); iso();
for (i=0; i<n; i++)
for (j=0; j<n; j++)
printf ("%lf\n", a[i][j]);
printf ("\n");
for (i=0; i<n; i++)
for (j=0; j<n; j++)
printf ("%lf\n", b[i][j]);
for (i=0; i<n; i++) for (i=0; i<n; i++)
printf ("%i\t", p[i]); printf ("%i\t", p[i]);
@@ -176,5 +183,5 @@ void main()
else else
printf ("\nGraphs aren't isomorthic.\n"); printf ("\nGraphs aren't isomorthic.\n");
getch(); // getch();
} }
+8
View File
@@ -0,0 +1,8 @@
3
0 1 0
1 0 1
0 1 0
0 0 1
0 0 1
1 1 0
+152
View File
@@ -0,0 +1,152 @@
/* Library for check isomorphic graph
*
* Usage:
* iso_check (number_of_vertex, graph)
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "nrutil.h"
int equat (const int num_mol_agl, float *c, const int rang, float *sol)
{
int i, j, k, imax;
float max, res;
for (i=0; i<num_mol_agl; i++)
if (i == rang)
c[i*num_mol_agl+num_mol_agl] = 1;
else
c[i*num_mol_agl+num_mol_agl] = 0;
for (i=0; i<num_mol_agl; i++)
{
imax = 0;
max = c[imax*num_mol_agl+i];
for (j=i; j<num_mol_agl; j++)
if (fabs (c[j*num_mol_agl+i]) > max)
{
max = fabs (c[j*num_mol_agl+i]);
imax = j;
}
for (j=0; j<=num_mol_agl; j++)
{
res = c[i*num_mol_agl+j];
c[i*num_mol_agl+j] = c[imax*num_mol_agl+j];
c[imax*num_mol_agl+j] = res;
}
for (j=0; j<num_mol_agl; j++)
if (j != i)
{
res = c[j*num_mol_agl+i] / c[i*num_mol_agl+i];
for(k=i; k<=num_mol_agl; k++)
c[j*num_mol_agl+k] = c[j*num_mol_agl+k] - (res * c[i*num_mol_agl+k]);
}
}
for (i=0; i<num_mol_agl; i++)
sol[i] = c[i*num_mol_agl+num_mol_agl] / c[i*num_mol_agl+i];
return 0;
}
int three_vertex (const int *matrix)
{
int i, j;
int test_mtx[2][9] = {{0, 1, 0, 1, 0, 1, 0, 1, 0}, {0, 1, 1, 1, 0, 1, 1, 1, 0}};
for (i=0; i<2; i++)
return 0;
}
int iso (const int N, const int *mtx, const int *ref_mtx)
{
int i, j, k, *indx;
float *a, *b, *d, dmax, det, eps, **nr_mtx, *x;
// initialization of variables
a = (float *) malloc (N * N * sizeof (float));
d = (float *) malloc (N * sizeof (float));
nr_mtx = matrix (1, N, 1, N);
indx = ivector (1, N);
x = vector (1, N);
// copy matrix
for (i=0; i<N; i++)
for (j=0; j<N; j++)
a[i*N+j] = mtx[i*N+j];
// create d-matrix
for (i=0; i<N; i++)
{
d[i] = 0;
for (j=0; j<N; j++)
if (j != i)
d[i] += a[i*N+j];
}
dmax = d[0];
for (i=0; i<N; i++)
if (d[i] > dmax)
dmax = d[i];
for (i=0; i<N; i++)
{
// to nr object
for (j=1; j<=N; j++)
for (k=1; k<=N; k++)
nr_mtx[j][k] = a[(j-1)*N+(k-1)];
ludcmp (nr_mtx, N, indx, &det);
for(j=1; j<=N; j++) det *= nr_mtx[j][j];
// define SLE
eps = sqrt (pow ((d + d[i]), 2) + 2 / n * (det + 2 + 2 / n)) - (d + d[i]);
for (j=0; j<N; j++)
for (k=0; k<N; k++)
if ((j == k) && (j == i))
a[j*N+k] = a[j*N+k] + eps;
else
a[j*N+k] = a[j*N+k];
// solution of SLE
for (j=1; j<=N; j++)
{
if (j == i)
x[j] = 1;
else
x[j] = 0;
for (k=1; k<=N; k++)
nr_mtx[j][k] = a[(j-1)*N+(k-1)];
ludcmp (nr_mtx, N, indx, &det);
lubksb (nr_mtx, N, indx, x);
}
}
free_vector (i);
free_ivector (indx);
free_matrix (nr_mtx);
return 0;
}
int iso_check (const int num_mol_agl, const int *matrix)
{
int i, j, type;
type = 0;
switch (num_mol_agl)
{
case 2:
type = 1;
break;
case 3:
type = three_vertex (matrix);
}
return type;
}
+113
View File
@@ -0,0 +1,113 @@
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "nrutil.h"
#define TINY 1.0e-20
// #define N 2
void ludcmp (float **a, int n, int *indx, float *d)
{
int i, imax, j, k;
float big, dum, sum, temp;
float *vv;
vv = vector (1,n);
*d = 1.0;
for (i=1; i<=n; i++)
{
big = 0.0;
for (j=1; j<=n; j++)
if ((temp = fabs(a[i][j])) > big) big = temp;
if (big == 0.0) nrerror("Singular matrix in routine ludcmp");
vv[i] = 1.0 / big;
}
for (j=1; j<=n; j++)
{
for (i=1; i<j; i++)
{
sum = a[i][j];
for (k=1; k<i; k++) sum -= a[i][k] * a[k][j];
a[i][j] = sum;
}
big = 0.0;
for (i=j; i<=n; i++)
{
sum = a[i][j];
for (k=1; k<j; k++)
sum -= a[i][k] * a[k][j];
a[i][j] = sum;
if ((dum = vv[i] * fabs(sum)) >= big)
{
big = dum;
imax = i;
}
}
if (j != imax)
{
for (k=1; k<=n; k++)
{
dum = a[imax][k];
a[imax][k] = a[j][k];
a[j][k] = dum;
}
*d = -(*d);
vv[imax] = vv[j];
}
indx[j] = imax;
if (a[j][j] == 0.0) a[j][j] = TINY;
if (j != n)
{
dum = 1.0 / a[j][j];
for (i=j+1; i<=n; i++) a[i][j] *= dum;
}
}
free_vector (vv, 1, n);
}
void lubksb (float **a, int n, int *indx, float b[])
{
int i, ii=0, ip, j;
float sum;
for (i=1; i<=n; i++)
{
ip = indx[i];
sum = b[ip];
b[ip] = b[i];
if (ii)
for (j=ii; j<=i-1; j++) sum -= a[i][j] * b[j];
else if (sum) ii = i;
b[i] = sum;
}
for (i=n; i>=1; i--)
{
sum = b[i];
for (j=i+1; j<=n; j++) sum -= a[i][j] * b[j];
b[i] = sum / a[i][i];
}
}
// int main ()
// {
// float **a, d;
// int i, j, *indx;
//
// float a_array[N][N] = {
// { 1.0, 2.0 },
// { 3.0, 4.0 }
// };
// a = matrix (1, N, 1, N);
// for (i=1; i<N+1; i++)
// for (j=1; j<N+1; j++)
// a[i][j] = a_array[i-1][j-1];
// indx = ivector (1, N);
// ludcmp (a, N, indx, &d);
// for(j=1; j<=N; j++) d *= a[j][j];
// printf ("%lf\n", d);
//
// return 0;
// }
+614
View File
@@ -0,0 +1,614 @@
#if defined(__STDC__) || defined(ANSI) || defined(NRANSI) /* ANSI */
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#define NR_END 1
#define FREE_ARG char*
void nrerror(char error_text[])
/* Numerical Recipes standard error handler */
{
fprintf(stderr,"Numerical Recipes run-time error...\n");
fprintf(stderr,"%s\n",error_text);
fprintf(stderr,"...now exiting to system...\n");
exit(1);
}
float *vector(long nl, long nh)
/* allocate a float vector with subscript range v[nl..nh] */
{
float *v;
v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
if (!v) nrerror("allocation failure in vector()");
return v-nl+NR_END;
}
int *ivector(long nl, long nh)
/* allocate an int vector with subscript range v[nl..nh] */
{
int *v;
v=(int *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(int)));
if (!v) nrerror("allocation failure in ivector()");
return v-nl+NR_END;
}
unsigned char *cvector(long nl, long nh)
/* allocate an unsigned char vector with subscript range v[nl..nh] */
{
unsigned char *v;
v=(unsigned char *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
if (!v) nrerror("allocation failure in cvector()");
return v-nl+NR_END;
}
unsigned long *lvector(long nl, long nh)
/* allocate an unsigned long vector with subscript range v[nl..nh] */
{
unsigned long *v;
v=(unsigned long *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(long)));
if (!v) nrerror("allocation failure in lvector()");
return v-nl+NR_END;
}
double *dvector(long nl, long nh)
/* allocate a double vector with subscript range v[nl..nh] */
{
double *v;
v=(double *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(double)));
if (!v) nrerror("allocation failure in dvector()");
return v-nl+NR_END;
}
float **matrix(long nrl, long nrh, long ncl, long nch)
/* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
float **m;
/* allocate pointers to rows */
m=(float **) malloc((size_t)((nrow+NR_END)*sizeof(float*)));
if (!m) nrerror("allocation failure 1 in matrix()");
m += NR_END;
m -= nrl;
/* allocate rows and set pointers to them */
m[nrl]=(float *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float)));
if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
m[nrl] += NR_END;
m[nrl] -= ncl;
for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
/* return pointer to array of pointers to rows */
return m;
}
double **dmatrix(long nrl, long nrh, long ncl, long nch)
/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
double **m;
/* allocate pointers to rows */
m=(double **) malloc((size_t)((nrow+NR_END)*sizeof(double*)));
if (!m) nrerror("allocation failure 1 in matrix()");
m += NR_END;
m -= nrl;
/* allocate rows and set pointers to them */
m[nrl]=(double *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double)));
if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
m[nrl] += NR_END;
m[nrl] -= ncl;
for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
/* return pointer to array of pointers to rows */
return m;
}
int **imatrix(long nrl, long nrh, long ncl, long nch)
/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
int **m;
/* allocate pointers to rows */
m=(int **) malloc((size_t)((nrow+NR_END)*sizeof(int*)));
if (!m) nrerror("allocation failure 1 in matrix()");
m += NR_END;
m -= nrl;
/* allocate rows and set pointers to them */
m[nrl]=(int *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(int)));
if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
m[nrl] += NR_END;
m[nrl] -= ncl;
for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
/* return pointer to array of pointers to rows */
return m;
}
float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch,
long newrl, long newcl)
/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
{
long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
float **m;
/* allocate array of pointers to rows */
m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
if (!m) nrerror("allocation failure in submatrix()");
m += NR_END;
m -= newrl;
/* set pointers to rows */
for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol;
/* return pointer to array of pointers to rows */
return m;
}
float **convert_matrix(float *a, long nrl, long nrh, long ncl, long nch)
/* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
and ncol=nch-ncl+1. The routine should be called with the address
&a[0][0] as the first argument. */
{
long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
float **m;
/* allocate pointers to rows */
m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
if (!m) nrerror("allocation failure in convert_matrix()");
m += NR_END;
m -= nrl;
/* set pointers to rows */
m[nrl]=a-ncl;
for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol;
/* return pointer to array of pointers to rows */
return m;
}
float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh)
/* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
{
long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
float ***t;
/* allocate pointers to pointers to rows */
t=(float ***) malloc((size_t)((nrow+NR_END)*sizeof(float**)));
if (!t) nrerror("allocation failure 1 in f3tensor()");
t += NR_END;
t -= nrl;
/* allocate pointers to rows and set pointers to them */
t[nrl]=(float **) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float*)));
if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
t[nrl] += NR_END;
t[nrl] -= ncl;
/* allocate rows and set pointers to them */
t[nrl][ncl]=(float *) malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(float)));
if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
t[nrl][ncl] += NR_END;
t[nrl][ncl] -= ndl;
for(j=ncl+1;j<=nch;j++) t[nrl][j]=t[nrl][j-1]+ndep;
for(i=nrl+1;i<=nrh;i++) {
t[i]=t[i-1]+ncol;
t[i][ncl]=t[i-1][ncl]+ncol*ndep;
for(j=ncl+1;j<=nch;j++) t[i][j]=t[i][j-1]+ndep;
}
/* return pointer to array of pointers to rows */
return t;
}
void free_vector(float *v, long nl, long nh)
/* free a float vector allocated with vector() */
{
free((FREE_ARG) (v+nl-NR_END));
}
void free_ivector(int *v, long nl, long nh)
/* free an int vector allocated with ivector() */
{
free((FREE_ARG) (v+nl-NR_END));
}
void free_cvector(unsigned char *v, long nl, long nh)
/* free an unsigned char vector allocated with cvector() */
{
free((FREE_ARG) (v+nl-NR_END));
}
void free_lvector(unsigned long *v, long nl, long nh)
/* free an unsigned long vector allocated with lvector() */
{
free((FREE_ARG) (v+nl-NR_END));
}
void free_dvector(double *v, long nl, long nh)
/* free a double vector allocated with dvector() */
{
free((FREE_ARG) (v+nl-NR_END));
}
void free_matrix(float **m, long nrl, long nrh, long ncl, long nch)
/* free a float matrix allocated by matrix() */
{
free((FREE_ARG) (m[nrl]+ncl-NR_END));
free((FREE_ARG) (m+nrl-NR_END));
}
void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch)
/* free a double matrix allocated by dmatrix() */
{
free((FREE_ARG) (m[nrl]+ncl-NR_END));
free((FREE_ARG) (m+nrl-NR_END));
}
void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch)
/* free an int matrix allocated by imatrix() */
{
free((FREE_ARG) (m[nrl]+ncl-NR_END));
free((FREE_ARG) (m+nrl-NR_END));
}
void free_submatrix(float **b, long nrl, long nrh, long ncl, long nch)
/* free a submatrix allocated by submatrix() */
{
free((FREE_ARG) (b+nrl-NR_END));
}
void free_convert_matrix(float **b, long nrl, long nrh, long ncl, long nch)
/* free a matrix allocated by convert_matrix() */
{
free((FREE_ARG) (b+nrl-NR_END));
}
void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch,
long ndl, long ndh)
/* free a float f3tensor allocated by f3tensor() */
{
free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
free((FREE_ARG) (t[nrl]+ncl-NR_END));
free((FREE_ARG) (t+nrl-NR_END));
}
#else /* ANSI */
/* traditional - K&R */
#include <stdio.h>
#define NR_END 1
#define FREE_ARG char*
void nrerror(error_text)
char error_text[];
/* Numerical Recipes standard error handler */
{
void exit();
fprintf(stderr,"Numerical Recipes run-time error...\n");
fprintf(stderr,"%s\n",error_text);
fprintf(stderr,"...now exiting to system...\n");
exit(1);
}
float *vector(nl,nh)
long nh,nl;
/* allocate a float vector with subscript range v[nl..nh] */
{
float *v;
v=(float *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(float)));
if (!v) nrerror("allocation failure in vector()");
return v-nl+NR_END;
}
int *ivector(nl,nh)
long nh,nl;
/* allocate an int vector with subscript range v[nl..nh] */
{
int *v;
v=(int *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(int)));
if (!v) nrerror("allocation failure in ivector()");
return v-nl+NR_END;
}
unsigned char *cvector(nl,nh)
long nh,nl;
/* allocate an unsigned char vector with subscript range v[nl..nh] */
{
unsigned char *v;
v=(unsigned char *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
if (!v) nrerror("allocation failure in cvector()");
return v-nl+NR_END;
}
unsigned long *lvector(nl,nh)
long nh,nl;
/* allocate an unsigned long vector with subscript range v[nl..nh] */
{
unsigned long *v;
v=(unsigned long *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(long)));
if (!v) nrerror("allocation failure in lvector()");
return v-nl+NR_END;
}
double *dvector(nl,nh)
long nh,nl;
/* allocate a double vector with subscript range v[nl..nh] */
{
double *v;
v=(double *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(double)));
if (!v) nrerror("allocation failure in dvector()");
return v-nl+NR_END;
}
float **matrix(nrl,nrh,ncl,nch)
long nch,ncl,nrh,nrl;
/* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
float **m;
/* allocate pointers to rows */
m=(float **) malloc((unsigned int)((nrow+NR_END)*sizeof(float*)));
if (!m) nrerror("allocation failure 1 in matrix()");
m += NR_END;
m -= nrl;
/* allocate rows and set pointers to them */
m[nrl]=(float *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float)));
if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
m[nrl] += NR_END;
m[nrl] -= ncl;
for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
/* return pointer to array of pointers to rows */
return m;
}
double **dmatrix(nrl,nrh,ncl,nch)
long nch,ncl,nrh,nrl;
/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
double **m;
/* allocate pointers to rows */
m=(double **) malloc((unsigned int)((nrow+NR_END)*sizeof(double*)));
if (!m) nrerror("allocation failure 1 in matrix()");
m += NR_END;
m -= nrl;
/* allocate rows and set pointers to them */
m[nrl]=(double *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(double)));
if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
m[nrl] += NR_END;
m[nrl] -= ncl;
for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
/* return pointer to array of pointers to rows */
return m;
}
int **imatrix(nrl,nrh,ncl,nch)
long nch,ncl,nrh,nrl;
/* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
{
long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
int **m;
/* allocate pointers to rows */
m=(int **) malloc((unsigned int)((nrow+NR_END)*sizeof(int*)));
if (!m) nrerror("allocation failure 1 in matrix()");
m += NR_END;
m -= nrl;
/* allocate rows and set pointers to them */
m[nrl]=(int *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(int)));
if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
m[nrl] += NR_END;
m[nrl] -= ncl;
for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
/* return pointer to array of pointers to rows */
return m;
}
float **submatrix(a,oldrl,oldrh,oldcl,oldch,newrl,newcl)
float **a;
long newcl,newrl,oldch,oldcl,oldrh,oldrl;
/* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
{
long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
float **m;
/* allocate array of pointers to rows */
m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
if (!m) nrerror("allocation failure in submatrix()");
m += NR_END;
m -= newrl;
/* set pointers to rows */
for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol;
/* return pointer to array of pointers to rows */
return m;
}
float **convert_matrix(a,nrl,nrh,ncl,nch)
float *a;
long nch,ncl,nrh,nrl;
/* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
and ncol=nch-ncl+1. The routine should be called with the address
&a[0][0] as the first argument. */
{
long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
float **m;
/* allocate pointers to rows */
m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
if (!m) nrerror("allocation failure in convert_matrix()");
m += NR_END;
m -= nrl;
/* set pointers to rows */
m[nrl]=a-ncl;
for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol;
/* return pointer to array of pointers to rows */
return m;
}
float ***f3tensor(nrl,nrh,ncl,nch,ndl,ndh)
long nch,ncl,ndh,ndl,nrh,nrl;
/* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
{
long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
float ***t;
/* allocate pointers to pointers to rows */
t=(float ***) malloc((unsigned int)((nrow+NR_END)*sizeof(float**)));
if (!t) nrerror("allocation failure 1 in f3tensor()");
t += NR_END;
t -= nrl;
/* allocate pointers to rows and set pointers to them */
t[nrl]=(float **) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float*)));
if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
t[nrl] += NR_END;
t[nrl] -= ncl;
/* allocate rows and set pointers to them */
t[nrl][ncl]=(float *) malloc((unsigned int)((nrow*ncol*ndep+NR_END)*sizeof(float)));
if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
t[nrl][ncl] += NR_END;
t[nrl][ncl] -= ndl;
for(j=ncl+1;j<=nch;j++) t[nrl][j]=t[nrl][j-1]+ndep;
for(i=nrl+1;i<=nrh;i++) {
t[i]=t[i-1]+ncol;
t[i][ncl]=t[i-1][ncl]+ncol*ndep;
for(j=ncl+1;j<=nch;j++) t[i][j]=t[i][j-1]+ndep;
}
/* return pointer to array of pointers to rows */
return t;
}
void free_vector(v,nl,nh)
float *v;
long nh,nl;
/* free a float vector allocated with vector() */
{
free((FREE_ARG) (v+nl-NR_END));
}
void free_ivector(v,nl,nh)
int *v;
long nh,nl;
/* free an int vector allocated with ivector() */
{
free((FREE_ARG) (v+nl-NR_END));
}
void free_cvector(v,nl,nh)
long nh,nl;
unsigned char *v;
/* free an unsigned char vector allocated with cvector() */
{
free((FREE_ARG) (v+nl-NR_END));
}
void free_lvector(v,nl,nh)
long nh,nl;
unsigned long *v;
/* free an unsigned long vector allocated with lvector() */
{
free((FREE_ARG) (v+nl-NR_END));
}
void free_dvector(v,nl,nh)
double *v;
long nh,nl;
/* free a double vector allocated with dvector() */
{
free((FREE_ARG) (v+nl-NR_END));
}
void free_matrix(m,nrl,nrh,ncl,nch)
float **m;
long nch,ncl,nrh,nrl;
/* free a float matrix allocated by matrix() */
{
free((FREE_ARG) (m[nrl]+ncl-NR_END));
free((FREE_ARG) (m+nrl-NR_END));
}
void free_dmatrix(m,nrl,nrh,ncl,nch)
double **m;
long nch,ncl,nrh,nrl;
/* free a double matrix allocated by dmatrix() */
{
free((FREE_ARG) (m[nrl]+ncl-NR_END));
free((FREE_ARG) (m+nrl-NR_END));
}
void free_imatrix(m,nrl,nrh,ncl,nch)
int **m;
long nch,ncl,nrh,nrl;
/* free an int matrix allocated by imatrix() */
{
free((FREE_ARG) (m[nrl]+ncl-NR_END));
free((FREE_ARG) (m+nrl-NR_END));
}
void free_submatrix(b,nrl,nrh,ncl,nch)
float **b;
long nch,ncl,nrh,nrl;
/* free a submatrix allocated by submatrix() */
{
free((FREE_ARG) (b+nrl-NR_END));
}
void free_convert_matrix(b,nrl,nrh,ncl,nch)
float **b;
long nch,ncl,nrh,nrl;
/* free a matrix allocated by convert_matrix() */
{
free((FREE_ARG) (b+nrl-NR_END));
}
void free_f3tensor(t,nrl,nrh,ncl,nch,ndl,ndh)
float ***t;
long nch,ncl,ndh,ndl,nrh,nrl;
/* free a float f3tensor allocated by f3tensor() */
{
free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
free((FREE_ARG) (t[nrl]+ncl-NR_END));
free((FREE_ARG) (t+nrl-NR_END));
}
#endif /* ANSI */
+101
View File
@@ -0,0 +1,101 @@
#ifndef _NR_UTILS_H_
#define _NR_UTILS_H_
static float sqrarg;
#define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg)
static double dsqrarg;
#define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg)
static double dmaxarg1,dmaxarg2;
#define DMAX(a,b) (dmaxarg1=(a),dmaxarg2=(b),(dmaxarg1) > (dmaxarg2) ?\
(dmaxarg1) : (dmaxarg2))
static double dminarg1,dminarg2;
#define DMIN(a,b) (dminarg1=(a),dminarg2=(b),(dminarg1) < (dminarg2) ?\
(dminarg1) : (dminarg2))
static float maxarg1,maxarg2;
#define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?\
(maxarg1) : (maxarg2))
static float minarg1,minarg2;
#define FMIN(a,b) (minarg1=(a),minarg2=(b),(minarg1) < (minarg2) ?\
(minarg1) : (minarg2))
static long lmaxarg1,lmaxarg2;
#define LMAX(a,b) (lmaxarg1=(a),lmaxarg2=(b),(lmaxarg1) > (lmaxarg2) ?\
(lmaxarg1) : (lmaxarg2))
static long lminarg1,lminarg2;
#define LMIN(a,b) (lminarg1=(a),lminarg2=(b),(lminarg1) < (lminarg2) ?\
(lminarg1) : (lminarg2))
static int imaxarg1,imaxarg2;
#define IMAX(a,b) (imaxarg1=(a),imaxarg2=(b),(imaxarg1) > (imaxarg2) ?\
(imaxarg1) : (imaxarg2))
static int iminarg1,iminarg2;
#define IMIN(a,b) (iminarg1=(a),iminarg2=(b),(iminarg1) < (iminarg2) ?\
(iminarg1) : (iminarg2))
#define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
#if defined(__STDC__) || defined(ANSI) || defined(NRANSI) /* ANSI */
void nrerror(char error_text[]);
float *vector(long nl, long nh);
int *ivector(long nl, long nh);
unsigned char *cvector(long nl, long nh);
unsigned long *lvector(long nl, long nh);
double *dvector(long nl, long nh);
float **matrix(long nrl, long nrh, long ncl, long nch);
double **dmatrix(long nrl, long nrh, long ncl, long nch);
int **imatrix(long nrl, long nrh, long ncl, long nch);
float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch,
long newrl, long newcl);
float **convert_matrix(float *a, long nrl, long nrh, long ncl, long nch);
float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
void free_vector(float *v, long nl, long nh);
void free_ivector(int *v, long nl, long nh);
void free_cvector(unsigned char *v, long nl, long nh);
void free_lvector(unsigned long *v, long nl, long nh);
void free_dvector(double *v, long nl, long nh);
void free_matrix(float **m, long nrl, long nrh, long ncl, long nch);
void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch);
void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch);
void free_submatrix(float **b, long nrl, long nrh, long ncl, long nch);
void free_convert_matrix(float **b, long nrl, long nrh, long ncl, long nch);
void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch,
long ndl, long ndh);
#else /* ANSI */
/* traditional - K&R */
void nrerror();
float *vector();
float **matrix();
float **submatrix();
float **convert_matrix();
float ***f3tensor();
double *dvector();
double **dmatrix();
int *ivector();
int **imatrix();
unsigned char *cvector();
unsigned long *lvector();
void free_vector();
void free_dvector();
void free_ivector();
void free_cvector();
void free_lvector();
void free_matrix();
void free_submatrix();
void free_convert_matrix();
void free_dmatrix();
void free_imatrix();
void free_f3tensor();
#endif /* ANSI */
#endif /* _NR_UTILS_H_ */
-20
View File
@@ -1,20 +0,0 @@
PROJECT=STATGEN
CC=gcc
CFLAGS=-c -Wall -fPIC
LDFLAGS=-lm
SOURCES=main.c coords.c int2str.c stat_print.c stat_select.c stat_sort.c summary_stat.c
OBJECTS=$(SOURCES:.c=.o)
EXECUTABLE=statgen
$(PROJECT): $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
.c.o:
$(CC) $(CFLAGS) $< -o $@
clean:
rm -f *.o
-279
View File
@@ -1,279 +0,0 @@
/* Library for reading coordinates from input file
*
* Usage:
* reading_coords (filename, type_interaction, labels, cell,
* &number_of_molecules, &number_of_atoms, true_label_molecule, label_molecule,
* type_atoms, coords)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int reading_coords (char *filename, int type_inter, const int *label_atom,
const float *cell, int *num_mol, int *num_atoms,
int *true_label_mol, int *label_mol,
int *type_atoms, float *coords)
/* filename - name of file with coordinates
* type_inter - type interaction (number of molecules for interaction)
* label_atom - types of atom for interaction
* cell - cell dimension
* num_mol - number of molecules for writing coordinates
* num_atoms - number of atoms for writing coordinates
* true_label_mol - massive of true numbers of molecule for atoms
* label_mol - massive of numbers of molecule for atoms
* type_atoms - massive of atom types for atoms
* coords - massive of coordinates
*/
{
char file_string[256];
int atoms, i, j, tr_num_atoms, ref_mol, x, y;
float not_tr_coords[750000], ref[3];
FILE *inp;
/* file_string - temp string variable
* atoms - total number of atoms in system
* tr_num_atoms - number of translated atoms for writing coordinates (m.b. 8*num_atoms)
* ref_mol - number of molecule for reference
* not_tr_coords - not translated coordinates
* ref - coordinates of reference molecule
* inp - file with input data
*/
*num_atoms = 0;
*num_mol = 0;
// Reading file
inp = fopen (filename, "r");
if (inp == NULL)
return 1;
ref_mol = -1;
fscanf (inp, "%i", &atoms);
for (i=0; i<atoms; i++)
{
fgets (file_string, 256, inp);
for (j=0; j<type_inter; j++)
if (atoi (&file_string[47]) == label_atom[j])
{
not_tr_coords[3**num_atoms+0] = atof (&file_string[10]);
not_tr_coords[3**num_atoms+1] = atof (&file_string[23]);
not_tr_coords[3**num_atoms+2] = atof (&file_string[35]);
if (ref_mol != atoi (&file_string[53]))
{
ref_mol = atoi (&file_string[53]);
true_label_mol[*num_mol] = ref_mol;
*num_mol = *num_mol + 1;
}
label_mol[*num_atoms] = *num_mol - 1;
type_atoms[*num_atoms] = j;
*num_atoms = *num_atoms + 1;
}
}
fclose (inp);
// Translation
tr_num_atoms = *num_atoms;
for (i=0; i<*num_atoms; i++)
for (j=0; j<3; j++)
coords[3*i+j] = not_tr_coords[3*i+j];
// Assign initial value to reference coordinates
ref_mol = label_mol[0];
for (i=0; i<3; i++)
ref[i] = coords[i];
for (i=0; i<*num_atoms; i++)
{
if (label_mol[i] != ref_mol)
{
ref_mol = label_mol[i];
for (j=0; j<3; j++)
ref[j] = not_tr_coords[3*i+j];
}
for (x=0; x<3; x++)
{
if (ref[x] >= 0.0)
// if xyz >= 0.0 A
{
for (j=0; j<3; j++)
if (j == x)
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] - cell[j];
else
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
else
// if xyz < 0.0 A
{
for (j=0; j<3; j++)
if (j == x)
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] + cell[j];
else
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
}
for (x=0; x<3; x++)
{
for (y=x+1; y<3; y++)
{
if ((ref[x] >= 0.0) && (ref[y] >= 0.0))
// if xyz and xyz >= 0.0 A
{
for (j=0; j<3; j++)
if ((j == x) || (j == y))
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] - cell[j];
else
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
if ((ref[x] < 0.0) && (ref[y] < 0.0))
// if xyz and xyz < 0.0 A
{
for (j=0; j<3; j++)
if ((j == x) || (j == y))
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] + cell[j];
else
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
}
for (y=0; y<3; y++)
if ((ref[x] < 0.0) && (ref[y] >= 0.0))
// if xyz OR xyz >= 0.0
{
for (j=0; j<3; j++)
{
if (j == x)
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] + cell[j];
if (j == y)
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] - cell[j];
if ((j != x) && (j != y))
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j];
}
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
}
if ((ref[0] >= 0.0) && (ref[1] >= 0.0) && (ref[2] >= 0.0))
// if x and y and z >= 0.0 A
{
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] - cell[2];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
if ((ref[0] >= 0.0) && (ref[1] >= 0.0) && (ref[2] < 0.0))
// if x and y >= 0.0 A and z < 0.0 A
{
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] + cell[2];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
if ((ref[0] >= 0.0) && (ref[1] < 0.0) && (ref[2] >= 0.0))
// if x and z >= 0.0 A and y < 0.0 A
{
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] - cell[2];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
if ((ref[0] < 0.0) && (ref[1] >= 0.0) && (ref[2] >= 0.0))
// if y and z >= 0.0 A and x < 0.0 A
{
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] - cell[2];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
if ((ref[0] < 0.0) && (ref[1] < 0.0) && (ref[2] >= 0.0))
// if x and y < 0.0 A and z >= 0.0 A
{
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] - cell[2];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
if ((ref[0] < 0.0) && (ref[1] >= 0.0) && (ref[2] < 0.0))
// if x and z < 0.0 A and y >= 0.0 A
{
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] + cell[2];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
if ((ref[0] >= 0.0) && (ref[1] < 0.0) && (ref[2] < 0.0))
// if x >= 0.0 A and y and z < 0.0 A
{
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] + cell[2];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
if ((ref[0] < 0.0) && (ref[1] < 0.0) && (ref[2] < 0.0))
// if x and y and z < 0.0 A
{
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] + cell[2];
label_mol[tr_num_atoms] = label_mol[i];
type_atoms[tr_num_atoms] = type_atoms[i];
tr_num_atoms++;
}
}
return 0;
}
-26
View File
@@ -1,26 +0,0 @@
/* Library for converting integer to string
* Usage
* char = conv (number, position)
*/
#include <stdio.h>
#include <stdlib.h>
char conv (int fnumb, int dig_pos)
/* fnumb - integer
* dig_pos - position
*/
{
int d, h, o;
char const digit[] = "0123456789";
h = fnumb / 100;
d = (fnumb % 100) / 10;
o = fnumb % 10;
if (dig_pos == 1) return digit[o];
if (dig_pos == 2) return digit[d];
if (dig_pos == 3) return digit[h];
else return digit[0];
}
-362
View File
@@ -1,362 +0,0 @@
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// prototypes
char conv (int, int);
int create_matrix (int, int, const int *, const int *, const float *, int,
const float *, int *);
int printing_agl (char *, char *, const int *, int, const int *, const int *,
const int *, const int *, int *);
int proc_matrix (int, const int *, int *, int *, int *, int *);
int reading_coords (char *, int, const int *, const float *, int *, int *,
int *, int *, int *, float *);
int summary_statistic (char *, int, int, const int *, const int *);
int error_checking (const float *cell, int from, const char *input,
int num_of_inter, const char *output, int to, int type_inter)
{
if ((type_inter == 0) || (type_inter > 4))
return 11;
if ((cell[0] == 0.0) || (cell[1] == 0.0) || (cell[2] == 0.0))
return 12;
if ((to == -1) || (from == -1))
return 13;
if (num_of_inter == 0)
return 14;
if (input[0] == '#')
return 15;
if (output[0] == '#')
return 16;
return 0;
}
int printing_head (const char *output, int log, int quiet, const char *input,
int from, int to, const float *cell, int type_inter,
const int *label_atom, int num_of_inter, const float *crit)
{
int i;
FILE *f_out;
f_out = fopen (output, "w");
fprintf (f_out, "statgen ::: V.1.0.0 ::: 2013-07-17\n\n");
fprintf (f_out, "CONFIGURATION\n");
fprintf (f_out, "LOG=%i\nQUIET=%i\n", log, quiet);
fprintf (f_out, "MASK=%s\nFIRST=%i\nLAST=%i\n", input, from, to);
fprintf (f_out, "CELL=%.4f,%.4f,%.4f\n", cell[0], cell[1], cell[2]);
fprintf (f_out, "ATOMS=%i", label_atom[0]);
for (i=1; i<type_inter; i++)
fprintf (f_out, ",%i", label_atom[i]);
fprintf (f_out, "\n");
for (i=0; i<num_of_inter; i++)
{
fprintf (f_out, "INTERACTION=");
fprintf (f_out, "0-0:%4.2f,0-1:%4.2f,1-1:%4.2f,", crit[16*i+0], crit[16*i+1],
crit[16*i+5]);
fprintf (f_out, "0-2:%4.2f,1-2:%4.2f,2-2:%4.2f,", crit[16*i+2], crit[16*i+6],
crit[16*i+10]);
fprintf (f_out, "0-3:%4.2f,1-3:%4.2f,2-3:%4.2f,3-3:%4.2f\n", crit[16*i+3],
crit[16*i+7], crit[16*i+11], crit[16*i+15]);
}
fprintf (f_out, "END\n\n");
fclose (f_out);
return 0;
}
int set_defaults (float *cell, int *from, char *input, int *log, int *num_of_inter,
char *output, int *to, int *type_agl, int *type_inter, int *quiet)
{
int i;
for (i=0; i<3; i++)
cell[i] = 0.0;
*from = -1;
input[0] = '#';
*log = 0;
*num_of_inter = 0;
output[0] = '#';
*to = -1;
type_agl[0] = 0;
type_agl[1] = 0;
*type_inter = 0;
*quiet = 0;
return 0;
}
int main (int argc, char *argv[])
{
char filename[256], tmp_str[256];
int error, i, index, j, k, label[2];
float label_fl;
FILE *f_inp;
char input[256], logfile[256], output[256];
float cell[3], *coords, *crit;
int *agl, *connect, from, *label_atom, *label_mol, log, num_atoms, num_mol,
*num_mol_agl, num_of_inter, *stat, *stat_all, step, to, *true_label_mol,
type_agl[2], *type_atoms, type_inter, quiet;
/* input - mask of input files
* logfile - log file name
* output - output file name
*
* cell - cell dimension
* coords - massive of coordinates
* crit - massive of criteria
*
* agl - massive of aglomerates
* connect - connectivity graph for all molecules
* from - start point
* label_atom - types of atom for interaction
* label_mol - massive of numbers of molecule for atoms
* log - status of log-mode
* num_atoms - number of atoms for writing coordinates
* num_mol - number of molecules for writing coordinates
* num_mol_agl - massive of numbers of molecule in aglomerates
* num_of_inter - number of different interactions
* stat - massive of statistics
* stat_all - massive of summary statistics
* step - $(to - from + 1)
* to - finish point
* true_label_mol - massive of true numbers of molecule for atoms
* type_agl - massive of numbers of aglomerate types
* type_atoms - massive of atom types for atoms
* type_inter - type interaction (number of molecules for interaction)
* quiet - status of quiet-mode
*/
set_defaults (cell, &from, input, &log, &num_of_inter, output, &to, type_agl,
&type_inter, &quiet);
// reading number of interactions
for (i=1; i<argc; i++)
if ((argv[i][0] == '-') && (argv[i][1] == 'r'))
num_of_inter++;
if (num_of_inter > 0)
{
crit = (float *) malloc ( 16 * num_of_inter * sizeof (float));
for (i=0; i<16*num_of_inter; i++)
crit[i] = 0.0;
num_of_inter = 0;
}
// reading arguments
for (i=1; i<argc; i++)
{
if ((argv[i][0] == '-') && (argv[i][1] == 'h'))
{
printf (" statgen\n");
printf ("Program for analyze molecular dynamic trajectories\n");
printf ("Version : 1.0.0 License : GPL\n");
printf (" Alekseev Evgeniy aka arcanis\n");
printf (" E-mail : esalexeev@gmail.com\n\n");
printf ("Usage:\n");
printf ("statgen -i INPUT -s FIRST,LAST -c X,Y,Z -a ... -r ... -o OUTPUT [ -l LOGFILE ] [ -q ] [ -h ]\n\n");
printf ("Parametrs:\n");
printf (" -i - mask of input files\n");
printf (" -s - trajectory steps (integer)\n");
printf (" -c - cell size (float), A\n");
printf (" -a - atom types (integer). Format: 'ATOM1' or 'ATOM1,ATOM2' or etc\n");
printf (" -r - criteria (float), A. Format: '0-0:2.4,0-1:3.0' means 0-0-interaction\n");
printf (" (<2.4 A) and 0-1 (<3.0) are needed. This flag can be used multiple times\n");
printf (" -o - output file name\n");
printf (" -l - log enable\n");
printf (" -q - quiet enable\n");
printf (" -h - show this help and exit\n");
return 0;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'i'))
// mask of input files
{
strcpy (input, argv[i+1]);
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 's'))
// steps
{
sscanf (argv[i+1], "%i,%i", &from, &to);
if (from > to)
{
to += from;
from = to - from;
to -= from;
}
step = to - from + 1;
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'c'))
// cell size
{
sscanf (argv[i+1], "%f,%f,%f", &cell[0], &cell[1], &cell[2]);
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'a'))
// atom types
{
type_inter = 1;
for (j=0; j<strlen(argv[i+1]); j++)
if (argv[i+1][j] == ',')
type_inter++;
label_atom = (int *) malloc (type_inter * sizeof (int));
switch (type_inter)
{
case 1:
sscanf (argv[i+1], "%i", &label_atom[0]);
break;
case 2:
sscanf (argv[i+1], "%i,%i", &label_atom[0], &label_atom[1]);
break;
case 3:
sscanf (argv[i+1], "%i,%i,%i", &label_atom[0], &label_atom[1], &label_atom[2]);
break;
case 4:
sscanf (argv[i+1], "%i,%i,%i,%i", &label_atom[0], &label_atom[1], &label_atom[2], &label_atom[3]);
break;
}
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'r'))
// criteria
{
index = 0;
sscanf (&argv[i+1][index], "%i-%i:%f%s", &label[0], &label[1], &label_fl, tmp_str);
crit[16*num_of_inter+4*label[0]+label[1]] = label_fl;
crit[16*num_of_inter+4*label[1]+label[0]] = label_fl;
for (j=index; j<strlen(argv[i+1]); j++)
if (argv[i+1][j] == ',')
{
index = j+1;
sscanf (&argv[i+1][index], "%i-%i:%f%s", &label[0], &label[1], &label_fl, tmp_str);
crit[16*num_of_inter+4*label[0]+label[1]] = label_fl;
crit[16*num_of_inter+4*label[1]+label[0]] = label_fl;
}
num_of_inter++;
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'o'))
// output file
{
strcpy (output, argv[i+1]);
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'l'))
// log mode
{
log = 1;
strcpy (logfile, argv[i+1]);
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'q'))
// quiet mode
{
quiet = 1;
}
}
// error checking
error = error_checking (cell, from, input, num_of_inter, output, to, type_inter);
if (error > 1)
{
printf ("Something wrong (error code: %i)!\nSee 'statgen -h' for more details\n", error);
return 1;
}
// processing
// initial variables
k = strlen (input);
strcpy (filename, input);
filename[k] = '.';
filename[k+1] = conv (from, 3);
filename[k+2] = conv (from, 2);
filename[k+3] = conv (from, 1);
filename[k+4] = '\0';
f_inp = fopen (filename, "r");
if (f_inp == NULL)
return 1;
fscanf (f_inp, "%i", &num_atoms);
fclose (f_inp);
coords = (float *) malloc (3 * 8 * num_atoms * sizeof (float));
label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
true_label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
type_atoms = (int *) malloc (8 * num_atoms * sizeof (int));
// head
printing_head (output, log, quiet, input, from, to, cell, type_inter, label_atom,
num_of_inter, crit);
// main cycle
for (i=from; i<to+1; i++)
{
// reading coordinates
filename[k+1] = conv (i, 3);
filename[k+2] = conv (i, 2);
filename[k+3] = conv (i, 1);
filename[k+4] = '\0';
error = reading_coords (filename, type_inter, label_atom, cell, &num_mol,
&num_atoms, true_label_mol, label_mol, type_atoms, coords);
// initializate variables
if (i == from)
{
agl = (int *) malloc (num_mol * num_mol * sizeof (int));
connect = (int *) malloc (num_mol * num_mol * sizeof (int));
num_mol_agl = (int *) malloc (num_mol * sizeof (int));
stat = (int *) malloc (num_mol * sizeof (int));
stat_all = (int *) malloc (num_mol * sizeof (int));
}
for (j=0; j<num_mol; j++)
{
num_mol_agl[j] = j;
printf ("%i - %i\n", j, num_mol_agl[j]);
}
// analyze
error = 1;
error = create_matrix (num_mol, num_atoms, label_mol, type_atoms, coords,
num_of_inter, crit, connect);
if (error == 0)
{
error = 1;
error = proc_matrix (num_mol, connect, num_mol_agl, agl, stat, stat_all);
if (error == 0)
printing_agl (filename, output, connect, num_mol, true_label_mol,
num_mol_agl, agl, stat, type_agl);
}
}
num_mol_agl[num_mol-1] = num_mol;
printf ("%i - %i\n", num_mol-1, num_mol_agl[num_mol]);
// tail
summary_statistic (output, step, num_mol, type_agl, stat_all);
printf ("%i - %i\n", num_mol-1, num_mol_agl[num_mol]);
// free memory
free (agl);
free (connect);
free (coords);
free (crit);
free (label_mol);
// memory crash here
free(num_mol_agl);
// free (stat);
// free (stat_all);
free (true_label_mol);
free (type_atoms);
return 0;
}
-3376
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-3241
View File
File diff suppressed because it is too large Load Diff
-107
View File
@@ -1,107 +0,0 @@
/* Library for printing aglomerates
*
* Usage:
* printing_agl (input_file, output_file, number_of_molecules,
* true_label_molecules, num_of_molecules_in_aglomerates, aglomerates,
* statistic, type_of_aglomerate)
*/
#include <stdio.h>
#include <stdlib.h>
int printing_agl (char *input, char *output, const int *connect, int num_mol,
const int *true_label_mol, const int *num_mol_agl,
const int *agl, const int *stat, int *type_agl)
/* input - name of file with coordinates
* output - name of output file
* connect - connectivity graph for all molecules
* num_mol - number of molecules
* true_label_mol - massive of true numbers of molecule for atoms
* num_mol_agl - massive of numbers of molecule in aglomerates
* agl - massive of aglomerates
* stat - massive of statistics
* type_agl - massive of numbers of aglomerate types
*/
{
int i, iso, j, k, p, type, *label_matrix, **matrix;
FILE *f_out;
/* iso - isomorphic graph in database
* type - number of cycle in aglomerates
* label_matrix - massive of indexes of molecule
* matrix - connectivity graph
* f_out - output file
*/
f_out = fopen (output, "a");
// head
fprintf (f_out, "FILE=%s\nSTATISTIC:\n| n | N |\n-----------------\n", input);
for (i=0; i<num_mol; i++)
if (stat[i] != 0)
fprintf (f_out, " %7i %7i \n", i+1, stat[i]);
fprintf (f_out, "-----------------\n");
// body
for (i=0; i<num_mol; i++)
if (num_mol_agl[i] > 0)
{
// creating connectivity graph
matrix = (int **) malloc (num_mol_agl[i] * sizeof (int *));
for (j=0; j<num_mol_agl[i]; j++)
{
matrix[j] = (int *) malloc (num_mol_agl[i] * sizeof (int));
for (k=0; k<num_mol_agl[i]; k++)
matrix[j][k] = 0;
}
label_matrix = (int *) malloc (num_mol * sizeof (int));
for (j=0; j<num_mol_agl[i]; j++)
label_matrix[agl[num_mol*i+j]] = j;
for (j=0; j<num_mol_agl[i]; j++)
for (k=j+1; k<num_mol_agl[i]; k++)
if (connect[num_mol*agl[num_mol*i+j]+agl[num_mol*i+k]] == 1)
{
matrix[label_matrix[agl[num_mol*i+j]]][label_matrix[agl[num_mol*i+k]]] = 1;
matrix[label_matrix[agl[num_mol*i+k]]][label_matrix[agl[num_mol*i+j]]] = 1;
}
// TODO: analyze of topology
iso = 0;
p = 0;
for (j=0; j<num_mol_agl[i]; j++)
for (k=0; k<num_mol_agl[i]; k++)
p += matrix[j][k];
if (p == (2*num_mol_agl[i]-2))
{
type = 0;
type_agl[0]++;
}
else
{
type = (p - (2*num_mol_agl[i]-2)) / 2;
type_agl[1]++;
}
// printing class of aglomerate
fprintf (f_out, "AGL=%i=%i=%i\n", num_mol_agl[i], type, iso);
for (j=0; j<num_mol_agl[i]; j++)
{
fprintf (f_out, "%7i=", true_label_mol[agl[num_mol*i+j]]);
for (k=0; k<num_mol_agl[i]; k++)
{
if (matrix[j][k] == 1)
fprintf (f_out, "%i,", true_label_mol[agl[num_mol*i+k]]);
}
fprintf (f_out, "\n");
}
// free memory
for (j=0; j<num_mol_agl[i]; j++)
free (matrix[j]);
free (matrix);
free (label_matrix);
}
fprintf (f_out, "---------------------------------------------------\n");
fclose (f_out);
return 0;
}
-104
View File
@@ -1,104 +0,0 @@
/* Library for creating connectivity matrix
*
* Usage:
* create_matrix (number_of_molecules, number_of_atoms, label_molecule,
* type_atoms, coords, number_of_interactions, criteria, connect_matrix)
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int create_matrix (int num_mol, int num_atoms, const int *label_mol,
const int *type_atoms, const float *coords, int num_of_inter,
const float *crit, int *connect)
/* num_mol - number of molecules
* num_atoms - number of atoms
* label_mol - massive of numbers of molecule for atoms
* type_atoms - massive of atom types for atoms
* coords - massive of coordinates
* num_of_inter - number of different interactions
* crit - massive of criteria
* connect - connectivity graph for all molecules
*/
{
float r;
int cur_num_inter, i, j, k, l, num_inter, ***label_inter;
/* r - radius
* cur_num_inter - current number of true interactions
* num_inter - needed number of true interactions
* label_inter - temporary massive of true interactions
*/
label_inter = (int ***) malloc (num_mol * sizeof (int **));
for (i=0; i<num_mol; i++)
{
label_inter[i] = (int **) malloc (num_mol * sizeof (int *));
for (j=0; j<num_mol; j++)
{
label_inter[i][j] = (int *) malloc (16 * sizeof (int));
for (k=0; k<16; k++)
label_inter[i][j][k] = 0;
}
}
// creating initial connectivity matrix
for (i=0; i<num_atoms*8; i++)
for (j=i+1; j<num_atoms*8; j++)
// if atoms from different molecules
if (label_mol[i] != label_mol[j])
{
r = sqrt (pow ((coords[3*i+0]-coords[3*j+0]), 2) +
pow ((coords[3*i+1]-coords[3*j+1]), 2) +
pow ((coords[3*i+2]-coords[3*j+2]), 2));
for (k=0; k<num_of_inter; k++)
if (crit[16*k+4*type_atoms[i]+type_atoms[j]] != 0.0)
if (r < crit[16*k+4*type_atoms[i]+type_atoms[j]])
{
label_inter[label_mol[i]][label_mol[j]][4*type_atoms[i]+type_atoms[j]] = 1;
label_inter[label_mol[i]][label_mol[j]][4*type_atoms[j]+type_atoms[i]] = 1;
label_inter[label_mol[j]][label_mol[i]][4*type_atoms[i]+type_atoms[j]] = 1;
label_inter[label_mol[j]][label_mol[i]][4*type_atoms[j]+type_atoms[i]] = 1;
}
}
for (i=0; i<num_mol; i++)
for (j=0; j<num_mol; j++)
connect[i*num_mol+j] = 0;
// processing of initial connectivity matrix
for (k=0; k<num_of_inter; k++)
{
// determination of the number of interactions
num_inter = 0;
for (l=0; l<16; l++)
if (crit[16*k+l] != 0.0)
num_inter++;
for (i=0; i<num_mol; i++)
for (j=i+1; j<num_mol; j++)
{
cur_num_inter = 0;
for (l=0; l<16; l++)
cur_num_inter += label_inter[i][j][l];
if (cur_num_inter == num_inter)
{
connect[i*num_mol+j] = 1;
connect[j*num_mol+i] = 1;
}
}
}
// free memory
for (i=0; i<num_mol; i++)
{
for (j=0; j<num_mol; j++)
free (label_inter[i][j]);
free (label_inter[i]);
}
free (label_inter);
return 0;
}
-83
View File
@@ -1,83 +0,0 @@
/* Library for processing connectivity matrix
*
* Usage:
* proc_matrix (number_of_molecules, connect_matrix,
* num_of_molecules_in_aglomerates, aglomerates, statistic, summary_statistic)
*/
#include <stdio.h>
#include <stdlib.h>
int proc_matrix (int num_mol, const int *connect, int *num_mol_agl, int *agl,
int *stat, int *stat_all)
/* num_mol - number of molecules
* connect - connectivity graph for all molecules
* num_mol_agl - massive of numbers of molecule in aglomerates
* agl - massive of aglomerates
* stat - massive of statistics
* stat_all - massive of summary statistics
*/
{
int i, j, k, p, *bin;
/* p - weight / graph index
* bin - binary massive of labels
*/
// definition and zeroing
bin = (int *) malloc (num_mol * sizeof (int));
for (i=0; i<num_mol; i++)
{
bin[i] = 1;
stat[i] = 0;
num_mol_agl[i] = 0;
for (j=0; j<num_mol; j++)
agl[num_mol*i+j] = 0;
}
// select non-bonded molecules
for (i=0; i<num_mol; i++)
{
p = 0;
for (j=0; j<num_mol; j++)
p += connect[i*num_mol+j];
if (p == 0)
{
bin[i] = 0;
stat[0]++;
stat_all[0]++;
}
}
// unwraping of connectivity matrix
p = 0;
for (i=0; i<num_mol; i++)
if (bin[i] == 1)
{
agl[num_mol*p+num_mol_agl[p]] = i;
num_mol_agl[p]++;
bin[i] = 0;
for (j=0; j<num_mol_agl[p]; j++)
for (k=0; k<num_mol; k++)
if ((connect[agl[num_mol*p+j]*num_mol+k] == 1) && (bin[k] == 1))
{
agl[num_mol*p+num_mol_agl[p]] = k;
num_mol_agl[p]++;
bin[k] = 0;
}
p++;
}
// filling statistic array
for (i=0; i<num_mol; i++)
{
stat[num_mol_agl[i]-1]++;
stat_all[num_mol_agl[i]-1]++;
}
free (bin);
return 0;
}
BIN
View File
Binary file not shown.
-64
View File
@@ -1,64 +0,0 @@
/* Library for summary statistic
* Usage:
* summary_statistic (filename, number_of_step, number_of_molecules,
* type_of_aglomerate, summary_statistic)
*/
#include <stdio.h>
#include <stdlib.h>
int summary_statistic (char *filename, int step, int num_mol, const int *type_agl, const int *stat_all)
/* filename - name of output file
* step - number of steps
* num_mol - number of molecules
* type_agl - massive of numbers of aglomerate types
* stat_all - massive of summary statistics
*/
{
float conc, p, pn, type[2], x, y;
int i, index;
FILE *f_out;
/* conc - concentrate of aglomerates
* p - probability of aglomerates
* pn - weight probability of aglomerates
* f_out - output file
*/
index = 0;
for (i=0; i<num_mol; i++)
if (stat_all[i] != 0)
index = i;
// head
f_out = fopen (filename, "a");
fprintf (f_out, "SUMMARY STATISTIC:\n");
fprintf (f_out, "| n | N | C | p | pn |\n------------------------------------------------\n");
for (i=0; i<index+1; i++)
{
// calculating concentrates
x = stat_all[i];
y = step;
conc = x / y;
// calculating probabilityes
x = (i + 1) * stat_all[i];
y = step * num_mol;
p = x / y;
pn = (i + 1) * p;
fprintf (f_out, " %7i %7i %9.2f %9.5f %10.5f\n", i+1, stat_all[i], conc, p, pn);
}
// types of aglomerates
x = type_agl[0] + type_agl[1];
type[0] = type_agl[0];
type[1] = type_agl[1];
fprintf (f_out, "------------------------------------------------\n");
fprintf (f_out, "LINEAR=%.5f\nCYCLE=%.5f\n", type[0]/x, type[1]/x);
fclose (f_out);
return 0;
}
+28 -18
View File
@@ -1,23 +1,33 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required (VERSION 2.8)
project(statgen) cmake_policy(SET CMP0011 NEW)
cmake_policy(SET CMP0003 OLD)
set(MY_CXX_FLAGS "-Wall") # set project name
set(CMAKE_CXX_FLAGS "-O0 ${MY_CXX_FLAGS}") set (PROJECT statgen)
set(CMAKE_SHARED_LINKER_FLAGS "-lm") # set additional cmake file
include (${PROJECT}.cmake)
set(SOURCE_EXE main.c)
set(SOURCE_LIB add_main.c
coords.c
graph.c
int2char.c
messages.c
stat_print.c
stat_select.c
stat_sort.c
summary_stat.c)
add_library(stat SHARED ${SOURCE_LIB}) # additional options
add_executable(statgen ${SOURCE_EXE}) OPTION (WITH_DEBUG_MODE "Build with debug mode" ON)
OPTION (ADD_INCLUDE "Add include files" ON)
target_link_libraries(statgen stat) # set libraries
set (LIBRARIES)
foreach (LIBRARY ${LIBRARIES})
find_library ("${LIBRARY}_FOUND" ${LIBRARY})
message (STATUS "Check the ${LIBRARY} is installed: " ${${LIBRARY}_FOUND})
if ("${${LIBRARY}_FOUND}" STREQUAL "${LIBRARY}_FOUND-NOTFOUND")
message (STATUS "Adding library sources")
add_subdirectory (../${LIBRARY} lib/${LIBRARY})
endif ()
endforeach ()
# additional targets
set (TARGETS "")
set (HEADERS "")
message (STATUS "SOURCES: ${SOURCES}")
add_subdirectory (src)
+23
View File
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 2.8)
project(statgen)
set(MY_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS "-O0 ${MY_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "-lm")
set(SOURCE_EXE main.c)
set(SOURCE_LIB add_main.c
coords.c
graph.c
int2char.c
messages.c
stat_print.c
stat_select.c
stat_sort.c
summary_stat.c)
add_library(stat SHARED ${SOURCE_LIB})
add_executable(statgen ${SOURCE_EXE})
target_link_libraries(statgen stat)
-3376
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-3241
View File
File diff suppressed because it is too large Load Diff
+61
View File
@@ -0,0 +1,61 @@
set ("${PROJECT}_VERSION_MAJOR" 1)
set ("${PROJECT}_VERSION_MINOR" 0)
set ("${PROJECT}_VERSION_PATCH" 1)
set ("${PROJECT}_VERSION" ${${PROJECT}_VERSION_MAJOR}.${${PROJECT}_VERSION_MINOR}.${${PROJECT}_VERSION_PATCH})
message (STATUS ${${PROJECT}_VERSION})
## set files
# main files
set (MAIN_SOURCES main)
# not public srcs
set (PRIVATE_CLASSES)
# headers only files
SET (HEADERS_ONLY)
# public srcs
set (PUBLIC_CLASSES add_main
coords
graph
int2char
messages
stat_print
stat_select
stat_sort
summary_stat)
# public headers
set (PUBLIC_HEADERS)
# shared libraries
if (CMAKE_COMPILER_IS_GNUCXX)
set (ADDITIONAL_LIB m)
else ()
set (ADDITIONAL_LIB)
endif()
set (SOURCES)
# append list
foreach (class ${PRIVATE_CLASSES})
LIST (APPEND SOURCES ${class}.c)
LIST (APPEND HEADERS ${class}.h)
endforeach ()
foreach (class ${HEADERS_ONLY})
LIST (APPEND HEADERS ${class}.h)
endforeach ()
foreach (class ${PUBLIC_CLASSES})
LIST (APPEND SOURCES ${class}.c)
LIST (APPEND HEADERS ../include/${PROJECT}/${class}.h)
LIST (APPEND PUBLIC_HEADERS ../include/${PROJECT}/${class}.h)
endforeach ()
# link libraries and compile
add_executable (${PROJECT} ${MAIN_SOURCES} ${SOURCES})
target_link_libraries (${PROJECT} ${ADDITIONAL_LIB})
# install properties
INSTALL (TARGETS ${PROJECT}
DESTINATION bin)
if (ADD_INCLUDE)
INSTALL (FILES ${PUBLIC_HEADERS}
DESTINATION include/${PROJECT})
endif ()
+8 -8
View File
@@ -4,14 +4,14 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include "add_main.h" // #include "add_main.h"
#include "coords.h" // #include "coords.h"
#include "int2char.h" // #include "int2char.h"
#include "messages.h" // #include "messages.h"
#include "stat_print.h" // #include "stat_print.h"
#include "stat_select.h" // #include "stat_select.h"
#include "stat_sort.h" // #include "stat_sort.h"
#include "summary_stat.h" // #include "summary_stat.h"
int main (int argc, char *argv[]) int main (int argc, char *argv[])
@@ -9,7 +9,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "graph.h" // #include "graph.h"
int printing_agl (const char *input, const char *output, const int *connect, int printing_agl (const char *input, const char *output, const int *connect,
+22
View File
@@ -0,0 +1,22 @@
# set directories
set ("${PROJECT}_BINARY_DIR" bin)
set ("${PROJECT}_SOURCE_DIR" src:include)
set ("${PROJECT}_LIB_DIR" lib)
set (CMAKE_INCLUDE_PATH ${${PROJECT}_SOURCE_DIR})
set (CMAKE_LIBRARY_PATH ${${PROJECT}_LIB_DIR})
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/${${PROJECT}_BINARY_DIR})
set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_BUILD_TYPE Debug)
if ( WITH_DEBUG_MODE )
ADD_DEFINITIONS ( -DDEBUG_MODE=1 )
endif ()
if ( CMAKE_COMPILER_IS_GNUCXX )
set (ADD_CXX_FLAGS "-Wall -v")
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
else ()
message ("not yet")
endif ()