tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
data.h
Go to the documentation of this file.
1 /* =============================================================================
2  *
3  * data.h
4  *
5  * =============================================================================
6  *
7  * Copyright (C) Stanford University, 2006. All Rights Reserved.
8  * Author: Chi Cao Minh
9  *
10  * =============================================================================
11  *
12  * For the license of bayes/sort.h and bayes/sort.c, please see the header
13  * of the files.
14  *
15  * ------------------------------------------------------------------------
16  *
17  * For the license of kmeans, please see kmeans/LICENSE.kmeans
18  *
19  * ------------------------------------------------------------------------
20  *
21  * For the license of ssca2, please see ssca2/COPYRIGHT
22  *
23  * ------------------------------------------------------------------------
24  *
25  * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
26  * header of the files.
27  *
28  * ------------------------------------------------------------------------
29  *
30  * For the license of lib/rbtree.h and lib/rbtree.c, please see
31  * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
32  *
33  * ------------------------------------------------------------------------
34  *
35  * Unless otherwise noted, the following license applies to STAMP files:
36  *
37  * Copyright (c) 2007, Stanford University
38  * All rights reserved.
39  *
40  * Redistribution and use in source and binary forms, with or without
41  * modification, are permitted provided that the following conditions are
42  * met:
43  *
44  * * Redistributions of source code must retain the above copyright
45  * notice, this list of conditions and the following disclaimer.
46  *
47  * * Redistributions in binary form must reproduce the above copyright
48  * notice, this list of conditions and the following disclaimer in
49  * the documentation and/or other materials provided with the
50  * distribution.
51  *
52  * * Neither the name of Stanford University nor the names of its
53  * contributors may be used to endorse or promote products derived
54  * from this software without specific prior written permission.
55  *
56  * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
57  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
60  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
61  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
62  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
63  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
64  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
66  * THE POSSIBILITY OF SUCH DAMAGE.
67  *
68  * =============================================================================
69  */
70 
71 
72 #ifndef DATA_H
73 #define DATA_H 1
74 
75 
76 #include "bitmap.h"
77 #include "net.h"
78 #include "random.h"
79 
80 typedef struct data {
81  long numVar;
82  long numRecord;
83  char* records; /* concatenation of all records */
85 } data_t;
86 
87 
88 /* =============================================================================
89  * data_alloc
90  * =============================================================================
91  */
92 data_t*
93 data_alloc (long numVar, long numCase, random_t* randomPtr);
94 
95 
96 /* =============================================================================
97  * data_free
98  * =============================================================================
99  */
100 void
101 data_free (data_t* dataPtr);
102 
103 
104 /* =============================================================================
105  * data_generate
106  * -- Binary variables of random PDFs
107  * -- If seed is <0, do not reseed
108  * -- Returns random network
109  * =============================================================================
110  */
111 net_t*
112 data_generate (data_t* dataPtr, long seed, long maxNumParent, long percentParent);
113 
114 
115 /* =============================================================================
116  * data_getRecord
117  * -- Returns NULL if invalid index
118  * =============================================================================
119  */
120 char*
121 data_getRecord (data_t* dataPtr, long index);
122 
123 
124 /* =============================================================================
125  * data_copy
126  * -- Returns FALSE on failure
127  * =============================================================================
128  */
129 bool_t
130 data_copy (data_t* dstPtr, data_t* srcPtr);
131 
132 
133 /* =============================================================================
134  * data_sort
135  * -- In place
136  * =============================================================================
137  */
138 void
139 data_sort (data_t* dataPtr,
140  long start,
141  long num,
142  long offset);
143 
144 
145 /* =============================================================================
146  * data_findSplit
147  * -- Call data_sort first with proper start, num, offset
148  * -- Returns number of zeros in offset column
149  * =============================================================================
150  */
151 long
152 data_findSplit (data_t* dataPtr, long start, long num, long offset);
153 
154 
155 #endif /* DATA_H */
156 
157 
158 /* =============================================================================
159  *
160  * End of data.h
161  *
162  * =============================================================================
163  */
char * records
Definition: data.h:83
static void * start(jsw_avltrav_t *trav, jsw_avltree_t *tree, long dir)
Definition: avltree.c:681
long numRecord
Definition: data.h:82
data_t * data_alloc(long numVar, long numCase, random_t *randomPtr)
Definition: data.c:94
char * data_getRecord(data_t *dataPtr, long index)
Definition: data.c:296
struct data data_t
int bool_t
Definition: portable_defns.h:32
static int seed
Definition: mesh.cpp:40
net_t * data_generate(data_t *dataPtr, long seed, long maxNumParent, long percentParent)
Definition: data.c:136
bool_t data_copy(data_t *dstPtr, data_t *srcPtr)
Definition: data.c:312
Definition: net.c:96
void data_sort(data_t *dataPtr, long start, long num, long offset)
Definition: data.c:361
Definition: random.h:86
long data_findSplit(data_t *dataPtr, long start, long num, long offset)
Definition: data.c:388
random_t * randomPtr
Definition: data.h:84
void data_free(data_t *dataPtr)
Definition: data.c:121
Definition: data.h:80
long numVar
Definition: data.h:81