added structure to all functions of library

This commit is contained in:
arcan1s
2014-01-28 03:11:30 +04:00
parent 38eb392e32
commit d88f3b317f
44 changed files with 945 additions and 819 deletions

View File

@ -4,29 +4,15 @@
#include <stdlib.h>
#include <mathmech/stat_sort.h>
#include <mathmech/var_types.h>
/**
* @fn proc_matrix
*/
int proc_matrix (const int num_mol, const int *connect, int *num_mol_agl, int *agl,
int *stat, int *stat_all)
/**
* @brief function that processes connectivity matrix
* @code
* proc_matrix (number_of_molecules, connect_matrix, num_of_molecules_in_agglomerates,
* agglomerates, statistic, summary_statistic);
* @endcode
*
* @param num_mol number of molecules
* @param connect connectivity graph for all molecules
* @param num_mol_agl massive of number of molecules in agglomerates
* @param agl massive of agglomerates
* @param stat massive of statistic
* @param stat_all massive of summary statistic
*
* @return 1 - memory error
* @return 0 - exit without errors
*/
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;
@ -37,24 +23,24 @@ int proc_matrix (const int num_mol, const int *connect, int *num_mol_agl, int *a
/// <b>Work blocks</b>
// definition and zeroing
bin = (int *) malloc (num_mol * sizeof (int));
bin = (int *) malloc (_system_info.num_mol * sizeof (int));
if (bin == NULL)
return 1;
for (i=0; i<num_mol; i++)
for (i=0; i<_system_info.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;
for (j=0; j<_system_info.num_mol; j++)
agl[_system_info.num_mol*i+j] = 0;
}
/// <pre> select non-bonded molecules </pre>
for (i=0; i<num_mol; i++)
for (i=0; i<_system_info.num_mol; i++)
{
p = 0;
for (j=0; j<num_mol; j++)
p += connect[i*num_mol+j];
for (j=0; j<_system_info.num_mol; j++)
p += connect[i*_system_info.num_mol+j];
if (p == 0)
{
bin[i] = 0;
@ -65,18 +51,18 @@ int proc_matrix (const int num_mol, const int *connect, int *num_mol_agl, int *a
/// <pre> unwraping of connectivity matrix </pre>
p = 0;
for (i=0; i<num_mol; i++)
for (i=0; i<_system_info.num_mol; i++)
if (bin[i] == 1)
{
agl[num_mol*p+num_mol_agl[p]] = i;
agl[_system_info.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))
for (k=0; k<_system_info.num_mol; k++)
if ((connect[agl[_system_info.num_mol*p+j]*_system_info.num_mol+k] == 1) && (bin[k] == 1))
{
agl[num_mol*p+num_mol_agl[p]] = k;
agl[_system_info.num_mol*p+num_mol_agl[p]] = k;
num_mol_agl[p]++;
bin[k] = 0;
}
@ -97,4 +83,4 @@ int proc_matrix (const int num_mol, const int *connect, int *num_mol_agl, int *a
free (bin);
return 0;
}
}