Skip to content

Commit 389ff11

Browse files
committed
0.5.0:
New function: reconstruction of directed acyclic graph from prior information of edge significance. For details, see library function netr_one_greedy, doc.pdf, or UPDATES in any interface.
1 parent ca1b679 commit 389ff11

14 files changed

Lines changed: 1249 additions & 9 deletions

File tree

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ URL_LIB_REL="$(URL_LIB)/releases"
1414
URL_BIN_REL="$(URL_BIN)/releases"
1515
URL_R_REL="$(URL_R)/releases"
1616
VERSION1=0
17-
VERSION2=4
18-
VERSION3=1
17+
VERSION2=5
18+
VERSION3=0
1919
LICENSE=AGPL-3
2020
LICENSE_FULL="GNU Affero General Public License, Version 3"
2121
LICENSE_URL="https://www.gnu.org/licenses/agpl-3.0"
@@ -152,13 +152,12 @@ Makefile.flags:
152152
ldflags="$$ldflags -lgfortran"; \
153153
echo "Testing local GSL" ; \
154154
if [ -n "$(DIR_SRC_GSL)" ] ; then \
155-
( dd=$$(pwd) && cd "$(DIR_SRC_GSL)" && ./configure && $(MAKE) && cd "$$dd" &> /dev/null ) || exit 1; \
156155
echo "Testing -Wl,--whole-archive" ; \
157156
ldflags2="$(DIR_SRC_GSL)/.libs/libgsl.a $(DIR_SRC_GSL)/cblas/.libs/libgslcblas.a"; \
157+
$(LD) $$ldflags "-Wl,--whole-archive $$ldflags2 -Wl,--no-whole-archive" --shared -o $(TMP_FILE) &> /dev/null && \
158+
ldflags2="-Wl,--whole-archive $$ldflags2 -Wl,--no-whole-archive"; \
158159
$(LD) $$ldflags $$ldflags2 --shared -o $(TMP_FILE) &> /dev/null || \
159-
( ldflags="-Wl,--whole-archive $$ldflags2 -Wl,--no-whole-archive" ; \
160-
$(LD) $$ldflags $$ldflags2 --shared -o $(TMP_FILE) &> /dev/null || \
161-
( echo "Can't link to local GSL with right flag." ; exit 1; ) ) ; \
160+
( echo "Can't link to embedded GSL with right flag." ; exit 1; ); \
162161
cflags="-I $(DIR_SRC_GSL) $$cflags" ; \
163162
ldflags="$$ldflags $$ldflags2" ; \
164163
else \

UPDATES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
0.5.0:
2+
New function: reconstruction of directed acyclic graph from prior information of edge significance. For details, see library function netr_one_greedy, doc.pdf, or UPDATES in any interface.
13
0.4.1:
24
Extreme situation behavior:
35
Added error checking for few samples (<4).

base/data_struct.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Copyright 2016, 2017 Lingfei Wang
2+
*
3+
* This file is part of Findr.
4+
*
5+
* Findr is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* Findr is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with Findr. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
/* This lib contains definitions of data structures
19+
*/
20+
21+
#ifndef _HEADER_LIB_DATA_STRUCT_H_
22+
#define _HEADER_LIB_DATA_STRUCT_H_
23+
#include "config.h"
24+
#include "data_struct_ll.h"
25+
#include "data_struct_heap.h"
26+
27+
#endif

base/data_struct_heap.c

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
/* Copyright 2016, 2017 Lingfei Wang
2+
*
3+
* This file is part of Findr.
4+
*
5+
* Findr is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* Findr is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with Findr. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
#include "config.h"
19+
#include <string.h>
20+
#include "logger.h"
21+
#include "macros.h"
22+
#include "data_struct_heap.h"
23+
24+
int data_heap_init(struct data_heap* h,size_t nmax)
25+
{
26+
h->nmax=nmax;
27+
h->n=0;
28+
MALLOCSIZE(h->d,nmax);
29+
return !h->d;
30+
}
31+
32+
void data_heap_free(struct data_heap* h)
33+
{
34+
h->nmax=0;
35+
if(h->d)
36+
free(h->d);
37+
h->d=0;
38+
}
39+
40+
void data_heap_empty(struct data_heap* h)
41+
{
42+
h->n=0;
43+
}
44+
45+
int data_heap_push(struct data_heap* h, HTYPE d)
46+
{
47+
size_t c,p;
48+
49+
if(h->nmax==h->n)
50+
{
51+
LOG(10,"Heap push failed: heap full.")
52+
return 1;
53+
}
54+
h->d[h->n]=d;
55+
c=h->n++;
56+
while(c)
57+
{
58+
p=(c-1)/2;
59+
if(d>h->d[p])
60+
return 0;
61+
h->d[c]=h->d[p];
62+
h->d[p]=d;
63+
c=p;
64+
}
65+
return 0;
66+
}
67+
68+
HTYPE data_heap_pop(struct data_heap* h)
69+
{
70+
size_t p,c2,cm,pn;
71+
HTYPE v,ret;
72+
73+
assert(h->n);
74+
ret=h->d[0];
75+
h->d[0]=h->d[--(h->n)];
76+
if(!h->n)
77+
return ret;
78+
p=0;
79+
pn=h->n/2;
80+
while(p+1<pn)
81+
{
82+
cm=2*p+1;
83+
c2=cm+1;
84+
if(h->d[c2]<h->d[cm])
85+
cm=c2;
86+
if(h->d[p]<h->d[cm])
87+
return ret;
88+
v=h->d[p];
89+
h->d[p]=h->d[cm];
90+
h->d[cm]=v;
91+
p=cm;
92+
}
93+
if(p+1==pn)
94+
{
95+
cm=2*p+1;
96+
c2=cm+1;
97+
if((c2<h->n)&&(h->d[c2]<h->d[cm]))
98+
cm=c2;
99+
if(h->d[p]<h->d[cm])
100+
return ret;
101+
v=h->d[p];
102+
h->d[p]=h->d[cm];
103+
h->d[cm]=v;
104+
}
105+
return ret;
106+
}
107+
108+
int data_heapdec_push(struct data_heapdec* h, HTYPE d)
109+
{
110+
size_t c,p;
111+
112+
if(h->nmax==h->n)
113+
{
114+
LOG(10,"Heap push failed: heap full.")
115+
return 1;
116+
}
117+
h->d[h->n]=d;
118+
c=h->n++;
119+
while(c)
120+
{
121+
p=(c-1)/2;
122+
if(d<h->d[p])
123+
return 0;
124+
h->d[c]=h->d[p];
125+
h->d[p]=d;
126+
c=p;
127+
}
128+
return 0;
129+
}
130+
131+
HTYPE data_heapdec_pop(struct data_heapdec* h)
132+
{
133+
size_t p,c2,cm,pn;
134+
HTYPE v,ret;
135+
136+
assert(h->n);
137+
ret=h->d[0];
138+
h->d[0]=h->d[--(h->n)];
139+
if(!h->n)
140+
return ret;
141+
p=0;
142+
pn=h->n/2;
143+
while(p+1<pn)
144+
{
145+
cm=2*p+1;
146+
c2=cm+1;
147+
if(h->d[c2]>h->d[cm])
148+
cm=c2;
149+
if(h->d[p]>h->d[cm])
150+
return ret;
151+
v=h->d[p];
152+
h->d[p]=h->d[cm];
153+
h->d[cm]=v;
154+
p=cm;
155+
}
156+
if(p+1==pn)
157+
{
158+
cm=2*p+1;
159+
c2=cm+1;
160+
if((c2<h->n)&&(h->d[c2]>h->d[cm]))
161+
cm=c2;
162+
if(h->d[p]>h->d[cm])
163+
return ret;
164+
v=h->d[p];
165+
h->d[p]=h->d[cm];
166+
h->d[cm]=v;
167+
}
168+
return ret;
169+
}
170+
171+
172+

base/data_struct_heap.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/* Copyright 2016, 2017 Lingfei Wang
2+
*
3+
* This file is part of Findr.
4+
*
5+
* Findr is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* Findr is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with Findr. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
/* This lib contains definition of heap data structure
19+
*/
20+
21+
#ifndef _HEADER_LIB_DATA_STRUCT_HEAP_H_
22+
#define _HEADER_LIB_DATA_STRUCT_HEAP_H_
23+
#include "config.h"
24+
#include <stdlib.h>
25+
#include <assert.h>
26+
27+
#ifdef __cplusplus
28+
extern "C"
29+
{
30+
#endif
31+
32+
33+
#define HTYPE size_t
34+
35+
//Incremental heap
36+
struct data_heap
37+
{
38+
size_t nmax;
39+
size_t n;
40+
HTYPE* restrict d;
41+
};
42+
43+
int data_heap_init(struct data_heap* h,size_t nmax);
44+
void data_heap_free(struct data_heap* h);
45+
void data_heap_empty(struct data_heap* h);
46+
int data_heap_push(struct data_heap* h, HTYPE d);
47+
HTYPE data_heap_pop(struct data_heap* h);
48+
// int data_heap_popto(struct data_heap* h, HTYPE* d);
49+
static inline HTYPE data_heap_get(const struct data_heap* h,size_t n);
50+
static inline HTYPE data_heap_top(const struct data_heap* h);
51+
52+
//Decremental heap
53+
#define data_heapdec data_heap
54+
#define data_heapdec_init data_heap_init
55+
#define data_heapdec_free data_heap_free
56+
#define data_heapdec_empty data_heap_empty
57+
int data_heapdec_push(struct data_heapdec* h, HTYPE d);
58+
HTYPE data_heapdec_pop(struct data_heapdec* h);
59+
#define data_heapdec_get data_heap_get
60+
#define data_heapdec_top data_heap_top
61+
62+
63+
static inline HTYPE data_heap_get(const struct data_heap* h,size_t n)
64+
{
65+
assert(h->n>n);
66+
return h->d[n];
67+
}
68+
69+
static inline HTYPE data_heap_top(const struct data_heap* h)
70+
{
71+
return data_heap_get(h,0);
72+
}
73+
74+
#ifdef __cplusplus
75+
}
76+
#endif
77+
#endif

base/data_struct_ll.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* Copyright 2016, 2017 Lingfei Wang
2+
*
3+
* This file is part of Findr.
4+
*
5+
* Findr is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* Findr is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with Findr. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
#include "config.h"
19+
#include <string.h>
20+
#include "macros.h"
21+
#include "data_struct_ll.h"
22+
23+
int data_ll_init(struct data_ll* ll,size_t nmax)
24+
{
25+
assert(ll);
26+
ll->nmax=nmax;
27+
ll->n=0;
28+
MALLOCSIZE(ll->d,2*nmax);
29+
if(!ll->d)
30+
{
31+
LOG(1,"Not enough memory.")
32+
return 1;
33+
}
34+
memset(ll->d,-1,2*nmax*sizeof(*ll->d));
35+
return 0;
36+
}
37+
38+
void data_ll_free(struct data_ll* ll)
39+
{
40+
assert(ll);
41+
if(ll->d)
42+
{
43+
free(ll->d);
44+
ll->d=0;
45+
}
46+
ll->nmax=0;
47+
}
48+
49+
void data_ll_empty(struct data_ll* ll)
50+
{
51+
assert(ll);
52+
ll->n=0;
53+
memset(ll->d,-1,2*ll->nmax*sizeof(*ll->d));
54+
}
55+
56+
57+

0 commit comments

Comments
 (0)