File: AdBaseFunctions.c

package info (click to toggle)
adun.app 0.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 6,824 kB
  • ctags: 713
  • sloc: objc: 49,683; ansic: 4,680; sh: 523; python: 79; makefile: 67; cpp: 33
file content (23 lines) | stat: -rw-r--r-- 428 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <Base/AdBaseFunctions.h>

inline double AdCalculateKineticEnergy(DoubleMatrix* velocities, double* masses)
{
	register int i, j;
	double *vhold;
	double **matrix;
	double en, enhold;
	
	matrix = velocities->matrix;
	for(en =0, i=0; i<velocities->no_rows; i++)
	{	
		vhold = matrix[i];
		for(enhold = 0,j=0; j< 3; j++)
			enhold += *(vhold + j)* *(vhold + j);

		en += enhold*masses[i];
	}
	en = en*0.5;

	return en;
}