ElfPSP_ParallelABC
Protein Structure Prediction using Parallel Artificial Bee Colony Optimization
int3d.h
Go to the documentation of this file.
1 #ifndef INT3D_H
2 #define INT3D_H
3 
6 #include <stdbool.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 
10 #ifndef INT3D_SOURCE_FILE
11  #define INT3D_INLINE inline
12 #else // If it's source file, declare extern inline
13  #define INT3D_INLINE extern inline
14 #endif
15 
17 typedef struct int3d_ {
18  int x;
19  int y;
20  int z;
21 } int3d;
22 
24 INT3D_INLINE
25 int3d int3d_make(int x, int y, int z){
26  int3d num;
27  num.x = x;
28  num.y = y;
29  num.z = z;
30  return num;
31 }
32 
34 INT3D_INLINE
36  int3d res;
37  res.x = a.x + b.x;
38  res.y = a.y + b.y;
39  res.z = a.z + b.z;
40  return res;
41 }
42 
44 INT3D_INLINE
46  int dx = abs(a.x - b.x);
47  int dy = abs(a.y - b.y);
48  int dz = abs(a.z - b.z);
49  int sum = dx + dy + dz;
50  return sum == 1 ? true : false;
51 }
52 
54 INT3D_INLINE
55 bool int3d_equal(int3d a, int3d b){
56  if(a.x != b.x || a.y != b.y || a.z != b.z)
57  return false;
58  return true;
59 }
60 
62 INT3D_INLINE
63 void int3d_print(int3d a, FILE *fp){
64  fprintf(fp, "%d,%d,%d", a.x, a.y, a.z);
65 }
66 
67 #endif // INT3D_H
68 
struct int3d_ int3d
Type for representing a tridimensional coordinate.
INT3D_INLINE int3d int3d_add(int3d a, int3d b)
Adds two int3d objects.
Definition: int3d.h:35
int y
Coordinate y.
Definition: int3d.h:19
INT3D_INLINE bool int3d_equal(int3d a, int3d b)
Verifies if a and b are equal.
Definition: int3d.h:55
int x
Coordinate x.
Definition: int3d.h:18
INT3D_INLINE int3d int3d_make(int x, int y, int z)
Creates an int3d.
Definition: int3d.h:25
INT3D_INLINE void int3d_print(int3d a, FILE *fp)
Prints the given int3d object, without placing a newline.
Definition: int3d.h:63
Type for representing a tridimensional coordinate.
Definition: int3d.h:17
int z
Coordinate z.
Definition: int3d.h:20
INT3D_INLINE bool int3d_isDist1(int3d a, int3d b)
Verifies if a and b are within a distance of exactly 1 from each other.
Definition: int3d.h:45