ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/smi23d/src/mengine/column.c
Revision: 3
Committed: Mon Jun 9 21:38:26 2008 UTC (11 years, 4 months ago) by tjod
File size: 1199 byte(s)
Log Message:
test

Line File contents
1 #define EXTERN extern
2
3
4 #include "pcwin.h"
5 #include "pcmod.h"
6
7 #include "energies.h"
8 #include "derivs.h"
9
10 void column(int, int *, int *,int *,int *,int *,int *, int *);
11
12 void column(int nvar, int *h_init, int *h_stop,int *h_index,
13 int *c_init,int *c_stop,int *c_index, int *c_value)
14 {
15 int i,j,k,m;
16
17 for (i=0; i < nvar; i++)
18 {
19 c_init[i] = 0;
20 c_stop[i] = 0;
21 }
22 // count number of elements in each column
23 for (i=0; i < nvar; i++)
24 {
25 for (j=h_init[i]; j < h_stop[i]; j++)
26 {
27 k = h_index[j];
28 c_stop[k]++;
29 }
30 }
31 // set each beginning marker past the last element for its column
32 c_init[0] = c_stop[0] + 1;
33 for (i=1; i <nvar; i++)
34 {
35 c_init[i] = c_init[i-1] + c_stop[i];
36 }
37 // set column index scanning rows in reverse order
38 for (i = nvar-1; i >= 0; i--)
39 {
40 for (j=h_init[i]; j < h_stop[i]; j++)
41 {
42 k = h_index[j];
43 m = c_init[k]-1;
44 c_init[k] = m;
45 c_index[m] = i;
46 c_value[m] = j;
47 }
48 }
49 for(i=0; i < nvar; i++)
50 {
51 c_stop[i] = c_init[i] + c_stop[i]-1;
52 }
53 }
54
55