QHV
Compute HyperVolumes sequentially
 All Data Structures Files Functions Variables Macros
point.c
1 /*
2  *
3  * Copyright (c) Year(s), 2013, Luis M. S. Russo and Alexandre
4  * P. Francisco / KDBIO / INESC-ID, <qhv@kdbio.inesc-id.pt>
5  *
6  * Any published media that is related with to use of the distributed
7  * software, or derived software, must contain a reference to "Quick
8  * HyperVolume, Luís M. S. Russo, Alexandre P. Francisco IEEE Trans.
9  * Evolutionary Computation 18(4): 481-502(2014)".
10  *
11  * Permission to use, copy, modify, and/or distribute this software for
12  * any purpose with or without fee is hereby granted, provided that the
13  * above copyright notice and this permission notice appear in all
14  * copies.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
17  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
19  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
20  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
21  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23  * PERFORMANCE OF THIS SOFTWARE.
24  *
25  */
26 
27 
28 #define _SVID_SOURCE
29 #include <math.h>
30 #include <string.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #undef _SVID_SOURCE
34 #include "point.h"
35 #include "macros.h"
36 
37 /*** global variables *************************************/
38 
39 /*** file scope macro definitions *************************/
40 
41 /*** file scope type declarations *************************/
42 
43 /*** file scope variables *********************************/
44 
45 point cZero = {{ B(0, D) }};
46 point cOne = {{ B(1, D) }};
47 
48 /*** file scope functions declarations ********************/
49 
50 /*** public functions declarations ************************/
51 
52 /*** file scope functions *********************************/
53 
54 /* ------------------------------------------------------ */
55 
56 /*** public functions *************************************/
57 
58 void parsePoint(char* S, point* p, double max)
59 {
60  char* tok;
61  int i;
62 
63  tok = strtok(S, " \n");
64 
65  i = 0;
66  while(i < D)
67  {
68  sscanf(tok, "%le", &p->x[i]);
69  p->x[i] = p->x[i] / max;
70  tok = strtok(NULL, " \n");
71  i++;
72  }
73 }
74 
76 {
77  int i;
78 
79  i = 0;
80  while(i < D)
81  {
82  p->x[i] = (double)random()/(double)RAND_MAX;
83  i++;
84  }
85 }
86 
point cZero
Definition: point.c:45
#define D
D is the number of dimensions.
Definition: pointStruct.h:43
Simple point interface. Contains simple point manipulation functions.
void randomPoint(point *p)
Definition: point.c:75
void parsePoint(char *S, point *p, double max)
Definition: point.c:58
Point is an array of coordinates, in a struct for simple and fast copy.
Definition: pointStruct.h:47
point cOne
Definition: point.c:46