ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/BioCocoa/BioSwarm/trunk/internal.h
Revision: 350
Committed: Wed Aug 19 16:45:07 2015 UTC (4 years, 9 months ago) by schristley
File size: 2033 byte(s)
Log Message:
MPI timing
Line File contents
1 /*
2 internal.h
3
4 Copyright (C) 2010-2011 Scott Christley
5
6 Author: Scott Christley <schristley@mac.com>
7 Date: November 2010
8
9 This file is part of the BioSwarm Framework.
10
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Lesser General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
15
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Library General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public
22 License along with this library; if not, write to the Free
23 Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 Boston, MA 02111 USA.
25 */
26
27 #define CHECK_PARAM(P,N) if (!P) { printf("WARNING: Missing parameter: %s\n",N); }
28 #define CHECK_PARAMF(P,N,F) if (!P) { printf("ERROR: Missing parameter: %s\n",N); F = NO; }
29
30 #define RAND_NUM ((double)rand() / (double)RAND_MAX )
31
32 #define EPS 1e-7
33 #define DEPS 1e-12
34
35 extern double normal_dist_rand(double mean, double sd);
36 extern int determine_scale_double(double value);
37 extern int determine_scale_float(float value);
38 extern BOOL direction_round(int direction, int dim);
39
40 typedef struct _sort_helper
41 {
42 float fValue;
43 double dValue;
44 int idx;
45 } sort_helper;
46
47 static int float_cmp_sort_helper(const void *a, const void *b)
48 {
49 sort_helper *sa = (sort_helper *)a;
50 sort_helper *sb = (sort_helper *)b;
51
52 if (sa->fValue < sb->fValue) return -1;
53 if (sa->fValue > sb->fValue) return 1;
54 return 0;
55 }
56
57 static int double_cmp_sort_helper(const void *a, const void *b)
58 {
59 sort_helper *sa = (sort_helper *)a;
60 sort_helper *sb = (sort_helper *)b;
61
62 if (sa->dValue < sb->dValue) return -1;
63 if (sa->dValue > sb->dValue) return 1;
64 return 0;
65 }
66
67 // simple time profiling
68 #define TIME_PROFILE 1
69 extern void bc_record_time(const char *msg);