parQHV
Compute HyperVolumes using threads
 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 "Extending
8  * quick hypervolume. Luís M. S. Russo, Alexandre P. Francisco:
9  * J. Heuristics 22(3): 245-271 (2016)".
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 #define _SVID_SOURCE
28 #include <math.h>
29 #include <string.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #undef _SVID_SOURCE
33 #include "point.h"
34 #include "macros.h"
35 
36 /*** global variables *************************************/
37 
38 /*** file scope macro definitions *************************/
39 
40 /*** file scope type declarations *************************/
41 
42 /*** file scope variables *********************************/
43 
44 point cZero = {{ B(0, D) }};
45 point cOne = {{ B(1, D) }};
46 
47 /*** file scope functions declarations ********************/
48 
49 /*** public functions declarations ************************/
50 
51 /*** file scope functions *********************************/
52 
53 /* ------------------------------------------------------ */
54 
55 /*** public functions *************************************/
56 
57 void parsePoint(char* S, point* p, double max)
58 {
59  char* tok;
60  int i;
61 
62  tok = strtok(S, " \n");
63 
64  i = 0;
65  while(i < D)
66  {
67  sscanf(tok, "%le", &p->x[i]);
68  p->x[i] = p->x[i] / max;
69  tok = strtok(NULL, " \n");
70  i++;
71  }
72 }
73 
75 {
76  int i;
77 
78  i = 0;
79  while(i < D)
80  {
81  p->x[i] = (double)random()/(double)RAND_MAX;
82  i++;
83  }
84 }
85 
point cZero
Definition: point.c:44
#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:74
void parsePoint(char *S, point *p, double max)
Definition: point.c:57
Point is an array of coordinates, in a struct for simple and fast copy.
Definition: pointStruct.h:47
point cOne
Definition: point.c:45