NAMD
Classes | Macros | Typedefs | Functions
LincsSolver.C File Reference
#include <cstdlib>
#include <cerrno>
#include <cstdio>
#include <cstring>
#include "LincsSolver.h"
#include <cmath>

Go to the source code of this file.

Classes

struct  sparseMatrix
 
struct  atomData
 
struct  constraintTuple
 

Macros

#define BUFFSIZE   1024
 

Typedefs

typedef struct atomData atomData
 
typedef struct constraintTuple constraintTuple
 

Functions

static void * Malloc (size_t size)
 
static void * Realloc (void *src, size_t size)
 
static void * Calloc (size_t size, size_t elem)
 
static int intPairCmp (const void *a1, const void *a2)
 
static int intCmp (const void *a1, const void *a2)
 
static void swapInt (int *v, int a, int b)
 
static void swapBigReal (BigReal *v, int a, int b)
 
static void swapVector3 (BigReal *v, int a, int b)
 

Macro Definition Documentation

◆ BUFFSIZE

#define BUFFSIZE   1024

Definition at line 12 of file LincsSolver.C.

Typedef Documentation

◆ atomData

typedef struct atomData atomData

◆ constraintTuple

Function Documentation

◆ Calloc()

static void* Calloc ( size_t  size,
size_t  elem 
)
static

Definition at line 61 of file LincsSolver.C.

References NAMD_die().

62 {
63  void* ptr = calloc(size, elem);
64  if(errno != 0)
65  {
66  perror("calloc error");
67  NAMD_die("calloc error");
68  }
69  return ptr;
70 }
void NAMD_die(const char *err_msg)
Definition: common.C:147

◆ intCmp()

static int intCmp ( const void *  a1,
const void *  a2 
)
static

Definition at line 172 of file LincsSolver.C.

173 {
174  int* a = (int*)a1;
175  int* b = (int*)a2;
176  if(*a < *b)
177  return -1;
178  else if(*a > *b)
179  return 1;
180  else
181  return 0;
182 }

◆ intPairCmp()

static int intPairCmp ( const void *  a1,
const void *  a2 
)
static

Definition at line 155 of file LincsSolver.C.

References constraintTuple::i, and constraintTuple::j.

156 {
159  if(a->i < b->i)
160  return -1;
161  else if(a->i > b->i)
162  return 1;
163  else
164  {
165  if(a->j < b->j)
166  return -1;
167  else
168  return 1;
169  }
170 }

◆ Malloc()

static void* Malloc ( size_t  size)
static

Definition at line 37 of file LincsSolver.C.

References NAMD_die().

Referenced by Realloc(), and LincsSolver::solve().

38 {
39  void* ptr = malloc(size);
40  if(errno != 0)
41  {
42  perror("malloc error");
43  NAMD_die("malloc error");
44  }
45  return ptr;
46 }
void NAMD_die(const char *err_msg)
Definition: common.C:147

◆ Realloc()

static void* Realloc ( void *  src,
size_t  size 
)
static

Definition at line 48 of file LincsSolver.C.

References Malloc(), and NAMD_die().

49 {
50  if(src == NULL)
51  return Malloc(size);
52  void* ptr = realloc(src, size);
53  if(errno != 0)
54  {
55  perror("realloc error");
56  NAMD_die("realloc error");
57  }
58  return ptr;
59 }
void NAMD_die(const char *err_msg)
Definition: common.C:147
static void * Malloc(size_t size)
Definition: LincsSolver.C:37

◆ swapBigReal()

static void swapBigReal ( BigReal v,
int  a,
int  b 
)
static

Definition at line 202 of file LincsSolver.C.

203 {
204  BigReal tmp = v[a];
205  v[a] = v[b];
206  v[b] = tmp;
207 }
double BigReal
Definition: common.h:123

◆ swapInt()

static void swapInt ( int *  v,
int  a,
int  b 
)
static

Definition at line 195 of file LincsSolver.C.

196 {
197  int tmp = v[a];
198  v[a] = v[b];
199  v[b] = tmp;
200 }

◆ swapVector3()

static void swapVector3 ( BigReal v,
int  a,
int  b 
)
static

Definition at line 209 of file LincsSolver.C.

210 {
211  BigReal tmp;
212  for(int i = 0; i < 3; ++i)
213  {
214  tmp = v[3*a+i];
215  v[3*a+i] = v[3*b+i];
216  v[3*b+i] = tmp;
217  }
218 }
double BigReal
Definition: common.h:123