/* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * Evgeniy Alekseev wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return * ---------------------------------------------------------------------------- */ /** * @file stat_sort.c * Source code of mathmech library * @author Evgeniy Alekseev (arcanis) * @copyright Beerware * @bug No known bugs */ #include #include #include /** * @fn proc_matrix */ int proc_matrix (const system_info _system_info, const int *connect, int *num_mol_agl, int *agl, int *stat, int *stat_all) { int i, j, k, p, *bin; /* p weight / graph index * bin binary massive of labels */ /// Work blocks // definition and zeroing bin = (int *) malloc (_system_info.num_mol * sizeof (int)); if (bin == NULL) return 1; for (i=0; i<_system_info.num_mol; i++) { bin[i] = 1; stat[i] = 0; num_mol_agl[i] = 0; for (j=0; j<_system_info.num_mol; j++) agl[_system_info.num_mol*i+j] = 0; } ///
   select non-bonded molecules 
for (i=0; i<_system_info.num_mol; i++) { p = 0; for (j=0; j<_system_info.num_mol; j++) p += connect[i*_system_info.num_mol+j]; if (p == 0) { bin[i] = 0; stat[0]++; stat_all[0]++; } } ///
   unwraping of connectivity matrix 
p = 0; for (i=0; i<_system_info.num_mol; i++) if (bin[i] == 1) { agl[_system_info.num_mol*p+num_mol_agl[p]] = i; num_mol_agl[p]++; bin[i] = 0; for (j=0; j filling statistic array i = 0; while (num_mol_agl[i] > 0) { stat[num_mol_agl[i]-1]++; stat_all[num_mol_agl[i]-1]++; i++; } ///
   free memory 
free (bin); return 0; }