Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
excit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
argo
excit
Commits
4b54d0f5
Commit
4b54d0f5
authored
Jan 23, 2019
by
Nicolas Denoyelle
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'documentation' into tleaf
parents
1a956f14
a8e2470b
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
314 additions
and
52 deletions
+314
-52
src/Makefile.am
src/Makefile.am
+1
-1
src/composition.c
src/composition.c
+179
-0
src/composition.h
src/composition.h
+2
-2
src/excit.c
src/excit.c
+6
-6
src/excit.h
src/excit.h
+106
-26
src/tleaf.c
src/tleaf.c
+4
-1
tests/Makefile.am
tests/Makefile.am
+2
-2
tests/excit_composition.c
tests/excit_composition.c
+14
-14
No files found.
src/Makefile.am
View file @
4b54d0f5
...
...
@@ -2,6 +2,6 @@ AM_CFLAGS = -Wall -Werror -pedantic
lib_LTLIBRARIES
=
libexcit.la
libexcit_la_SOURCES
=
excit.c
slice
.c prod.c cons.c repeat.c hilbert2d.c range.c tleaf.c
libexcit_la_SOURCES
=
excit.c
composition
.c prod.c cons.c repeat.c hilbert2d.c range.c tleaf.c
include_HEADERS
=
excit.h
src/
slice
.c
→
src/
composition
.c
View file @
4b54d0f5
#include "dev/excit.h"
#include "
slice
.h"
#include "
composition
.h"
static
int
slice
_it_alloc
(
excit_t
data
)
static
int
composition
_it_alloc
(
excit_t
data
)
{
struct
slice_it_s
*
it
=
(
struct
slice
_it_s
*
)
data
->
data
;
struct
composition_it_s
*
it
=
(
struct
composition
_it_s
*
)
data
->
data
;
it
->
src
=
NULL
;
it
->
indexer
=
NULL
;
return
EXCIT_SUCCESS
;
}
static
void
slice
_it_free
(
excit_t
data
)
static
void
composition
_it_free
(
excit_t
data
)
{
struct
slice_it_s
*
it
=
(
struct
slice
_it_s
*
)
data
->
data
;
struct
composition_it_s
*
it
=
(
struct
composition
_it_s
*
)
data
->
data
;
excit_free
(
it
->
src
);
excit_free
(
it
->
indexer
);
}
static
int
slice
_it_copy
(
excit_t
dst
,
const
excit_t
src
)
static
int
composition
_it_copy
(
excit_t
dst
,
const
excit_t
src
)
{
const
struct
slice_it_s
*
it
=
(
const
struct
slice
_it_s
*
)
src
->
data
;
struct
slice_it_s
*
result
=
(
struct
slice
_it_s
*
)
dst
->
data
;
const
struct
composition_it_s
*
it
=
(
const
struct
composition
_it_s
*
)
src
->
data
;
struct
composition_it_s
*
result
=
(
struct
composition
_it_s
*
)
dst
->
data
;
result
->
src
=
excit_dup
(
it
->
src
);
if
(
!
result
->
src
)
...
...
@@ -34,9 +34,9 @@ static int slice_it_copy(excit_t dst, const excit_t src)
return
EXCIT_SUCCESS
;
}
static
int
slice
_it_next
(
excit_t
data
,
ssize_t
*
indexes
)
static
int
composition
_it_next
(
excit_t
data
,
ssize_t
*
indexes
)
{
struct
slice_it_s
*
it
=
(
struct
slice
_it_s
*
)
data
->
data
;
struct
composition_it_s
*
it
=
(
struct
composition
_it_s
*
)
data
->
data
;
ssize_t
n
;
int
err
=
excit_next
(
it
->
indexer
,
&
n
);
...
...
@@ -45,9 +45,9 @@ static int slice_it_next(excit_t data, ssize_t *indexes)
return
excit_nth
(
it
->
src
,
n
,
indexes
);
}
static
int
slice
_it_peek
(
const
excit_t
data
,
ssize_t
*
indexes
)
static
int
composition
_it_peek
(
const
excit_t
data
,
ssize_t
*
indexes
)
{
const
struct
slice_it_s
*
it
=
(
const
struct
slice
_it_s
*
)
data
->
data
;
const
struct
composition_it_s
*
it
=
(
const
struct
composition
_it_s
*
)
data
->
data
;
ssize_t
n
;
int
err
=
excit_peek
(
it
->
indexer
,
&
n
);
...
...
@@ -56,23 +56,23 @@ static int slice_it_peek(const excit_t data, ssize_t *indexes)
return
excit_nth
(
it
->
src
,
n
,
indexes
);
}
static
int
slice
_it_size
(
const
excit_t
data
,
ssize_t
*
size
)
static
int
composition
_it_size
(
const
excit_t
data
,
ssize_t
*
size
)
{
const
struct
slice_it_s
*
it
=
(
const
struct
slice
_it_s
*
)
data
->
data
;
const
struct
composition_it_s
*
it
=
(
const
struct
composition
_it_s
*
)
data
->
data
;
return
excit_size
(
it
->
indexer
,
size
);
}
static
int
slice
_it_rewind
(
excit_t
data
)
static
int
composition
_it_rewind
(
excit_t
data
)
{
struct
slice_it_s
*
it
=
(
struct
slice
_it_s
*
)
data
->
data
;
struct
composition_it_s
*
it
=
(
struct
composition
_it_s
*
)
data
->
data
;
return
excit_rewind
(
it
->
indexer
);
}
static
int
slice
_it_nth
(
const
excit_t
data
,
ssize_t
n
,
ssize_t
*
indexes
)
static
int
composition
_it_nth
(
const
excit_t
data
,
ssize_t
n
,
ssize_t
*
indexes
)
{
const
struct
slice_it_s
*
it
=
(
const
struct
slice
_it_s
*
)
data
->
data
;
const
struct
composition_it_s
*
it
=
(
const
struct
composition
_it_s
*
)
data
->
data
;
ssize_t
p
;
int
err
=
excit_nth
(
it
->
indexer
,
n
,
&
p
);
...
...
@@ -81,10 +81,10 @@ static int slice_it_nth(const excit_t data, ssize_t n, ssize_t *indexes)
return
excit_nth
(
it
->
src
,
p
,
indexes
);
}
static
int
slice
_it_rank
(
const
excit_t
data
,
const
ssize_t
*
indexes
,
static
int
composition
_it_rank
(
const
excit_t
data
,
const
ssize_t
*
indexes
,
ssize_t
*
n
)
{
const
struct
slice_it_s
*
it
=
(
const
struct
slice
_it_s
*
)
data
->
data
;
const
struct
composition_it_s
*
it
=
(
const
struct
composition
_it_s
*
)
data
->
data
;
ssize_t
inner_n
;
int
err
=
excit_rank
(
it
->
src
,
indexes
,
&
inner_n
);
...
...
@@ -93,16 +93,16 @@ static int slice_it_rank(const excit_t data, const ssize_t *indexes,
return
excit_rank
(
it
->
indexer
,
&
inner_n
,
n
);
}
static
int
slice
_it_pos
(
const
excit_t
data
,
ssize_t
*
n
)
static
int
composition
_it_pos
(
const
excit_t
data
,
ssize_t
*
n
)
{
const
struct
slice_it_s
*
it
=
(
const
struct
slice
_it_s
*
)
data
->
data
;
const
struct
composition_it_s
*
it
=
(
const
struct
composition
_it_s
*
)
data
->
data
;
return
excit_pos
(
it
->
indexer
,
n
);
}
static
int
slice
_it_split
(
const
excit_t
data
,
ssize_t
n
,
excit_t
*
results
)
static
int
composition
_it_split
(
const
excit_t
data
,
ssize_t
n
,
excit_t
*
results
)
{
const
struct
slice_it_s
*
it
=
(
const
struct
slice
_it_s
*
)
data
->
data
;
const
struct
composition_it_s
*
it
=
(
const
struct
composition
_it_s
*
)
data
->
data
;
int
err
=
excit_split
(
it
->
indexer
,
n
,
results
);
if
(
err
)
...
...
@@ -114,7 +114,7 @@ static int slice_it_split(const excit_t data, ssize_t n, excit_t *results)
excit_t
tmp2
;
tmp
=
results
[
i
];
results
[
i
]
=
excit_alloc
(
EXCIT_
SLICE
);
results
[
i
]
=
excit_alloc
(
EXCIT_
COMPOSITION
);
if
(
!
results
[
i
])
{
excit_free
(
tmp
);
err
=
-
EXCIT_ENOMEM
;
...
...
@@ -126,7 +126,7 @@ static int slice_it_split(const excit_t data, ssize_t n, excit_t *results)
err
=
-
EXCIT_ENOMEM
;
goto
error
;
}
err
=
excit_
slice
_init
(
results
[
i
],
tmp2
,
tmp
);
err
=
excit_
composition
_init
(
results
[
i
],
tmp2
,
tmp
);
if
(
err
)
{
excit_free
(
tmp
);
excit_free
(
tmp2
);
...
...
@@ -140,26 +140,26 @@ error:
return
err
;
}
struct
excit_func_table_s
excit_
slice
_func_table
=
{
slice
_it_alloc
,
slice
_it_free
,
slice
_it_copy
,
slice
_it_next
,
slice
_it_peek
,
slice
_it_size
,
slice
_it_rewind
,
slice
_it_split
,
slice
_it_nth
,
slice
_it_rank
,
slice
_it_pos
struct
excit_func_table_s
excit_
composition
_func_table
=
{
composition
_it_alloc
,
composition
_it_free
,
composition
_it_copy
,
composition
_it_next
,
composition
_it_peek
,
composition
_it_size
,
composition
_it_rewind
,
composition
_it_split
,
composition
_it_nth
,
composition
_it_rank
,
composition
_it_pos
};
int
excit_
slice
_init
(
excit_t
it
,
excit_t
src
,
excit_t
indexer
)
int
excit_
composition
_init
(
excit_t
it
,
excit_t
src
,
excit_t
indexer
)
{
if
(
!
it
||
it
->
type
!=
EXCIT_
SLICE
||
!
src
||
!
indexer
if
(
!
it
||
it
->
type
!=
EXCIT_
COMPOSITION
||
!
src
||
!
indexer
||
indexer
->
dimension
!=
1
)
return
-
EXCIT_EINVAL
;
struct
slice_it_s
*
slice_it
=
(
struct
slice
_it_s
*
)
it
->
data
;
struct
composition_it_s
*
composition_it
=
(
struct
composition
_it_s
*
)
it
->
data
;
ssize_t
size_src
;
ssize_t
size_indexer
;
int
err
=
excit_size
(
src
,
&
size_src
);
...
...
@@ -171,8 +171,8 @@ int excit_slice_init(excit_t it, excit_t src, excit_t indexer)
return
err
;
if
(
size_indexer
>
size_src
)
return
-
EXCIT_EDOM
;
slice
_it
->
src
=
src
;
slice
_it
->
indexer
=
indexer
;
composition
_it
->
src
=
src
;
composition
_it
->
indexer
=
indexer
;
it
->
dimension
=
src
->
dimension
;
return
EXCIT_SUCCESS
;
}
...
...
src/
slice
.h
→
src/
composition
.h
View file @
4b54d0f5
...
...
@@ -4,12 +4,12 @@
#include "excit.h"
#include "dev/excit.h"
struct
slice
_it_s
{
struct
composition
_it_s
{
excit_t
src
;
excit_t
indexer
;
};
extern
struct
excit_func_table_s
excit_
slice
_func_table
;
extern
struct
excit_func_table_s
excit_
composition
_func_table
;
#endif //EXCIT_SLICE_H
src/excit.c
View file @
4b54d0f5
#include <stdlib.h>
#include "excit.h"
#include "dev/excit.h"
#include "
slice
.h"
#include "
composition
.h"
#include "prod.h"
#include "cons.h"
#include "repeat.h"
...
...
@@ -19,7 +19,7 @@ const char *excit_type_name(enum excit_type_e type)
CASE
(
EXCIT_REPEAT
);
CASE
(
EXCIT_HILBERT2D
);
CASE
(
EXCIT_PRODUCT
);
CASE
(
EXCIT_
SLICE
);
CASE
(
EXCIT_
COMPOSITION
);
CASE
(
EXCIT_USER
);
CASE
(
EXCIT_TYPE_MAX
);
default:
...
...
@@ -115,8 +115,8 @@ excit_t excit_alloc(enum excit_type_e type)
case
EXCIT_PRODUCT
:
ALLOC_EXCIT
(
prod
);
break
;
case
EXCIT_
SLICE
:
ALLOC_EXCIT
(
slice
);
case
EXCIT_
COMPOSITION
:
ALLOC_EXCIT
(
composition
);
break
;
case
EXCIT_TLEAF
:
ALLOC_EXCIT
(
tleaf
);
...
...
@@ -270,12 +270,12 @@ int excit_split(const excit_t it, ssize_t n, excit_t *results)
if
(
!
tmp
)
goto
error2
;
tmp2
=
results
[
i
];
results
[
i
]
=
excit_alloc
(
EXCIT_
SLICE
);
results
[
i
]
=
excit_alloc
(
EXCIT_
COMPOSITION
);
if
(
!
results
[
i
])
{
excit_free
(
tmp2
);
goto
error2
;
}
err
=
excit_
slice
_init
(
results
[
i
],
tmp
,
tmp2
);
err
=
excit_
composition
_init
(
results
[
i
],
tmp
,
tmp2
);
if
(
err
)
{
excit_free
(
tmp2
);
goto
error2
;
...
...
src/excit.h
View file @
4b54d0f5
This diff is collapsed.
Click to expand it.
src/tleaf.c
View file @
4b54d0f5
...
...
@@ -184,7 +184,8 @@ int tleaf_it_rank(const excit_t it, const ssize_t *indexes, ssize_t *n)
acc
*=
data_it
->
arities
[
i
];
}
*
n
=
val
;
if
(
n
!=
NULL
)
*
n
=
val
;
return
EXCIT_SUCCESS
;
}
...
...
@@ -399,6 +400,8 @@ int tleaf_it_split(const excit_t it, const ssize_t depth,
if
(
data_it
->
arities
[
depth
]
%
n
!=
0
)
return
-
EXCIT_EINVAL
;
if
(
out
==
NULL
)
return
EXCIT_SUCCESS
;
int
err
;
excit_t
*
levels
,
*
levels_inverse
;
...
...
tests/Makefile.am
View file @
4b54d0f5
...
...
@@ -12,9 +12,9 @@ excit_repeat_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_repeat.c
excit_cons_SOURCES
=
$(LIBHSOURCES)
$(LIBCSOURCES)
excit_cons.c
excit_tleaf_SOURCES
=
$(LIBHSOURCES)
$(LIBCSOURCES)
excit_tleaf.c
excit_hilbert2d_SOURCES
=
$(LIBHSOURCES)
$(LIBCSOURCES)
excit_hilbert2d.c
excit_
slice_SOURCES
=
$(LIBHSOURCES)
$(LIBCSOURCES)
excit_slice
.c
excit_
composition_SOURCES
=
$(LIBHSOURCES)
$(LIBCSOURCES)
excit_composition
.c
UNIT_TESTS
=
excit_range excit_product excit_repeat excit_cons excit_hilbert2d excit_
slice
excit_tleaf
UNIT_TESTS
=
excit_range excit_product excit_repeat excit_cons excit_hilbert2d excit_
composition
excit_tleaf
# all tests
check_PROGRAMS
=
$(UNIT_TESTS)
...
...
tests/excit_
slice
.c
→
tests/excit_
composition
.c
View file @
4b54d0f5
...
...
@@ -15,16 +15,16 @@ excit_t create_test_range(ssize_t start, ssize_t stop, ssize_t step)
return
it
;
}
void
test_alloc_init_
slice
(
excit_t
source
,
excit_t
indexer
)
void
test_alloc_init_
composition
(
excit_t
source
,
excit_t
indexer
)
{
excit_t
it
;
ssize_t
dim
,
expected_dim
,
size
,
expected_size
;
it
=
excit_alloc_test
(
EXCIT_
SLICE
);
it
=
excit_alloc_test
(
EXCIT_
COMPOSITION
);
assert
(
excit_dimension
(
it
,
&
dim
)
==
ES
);
assert
(
dim
==
0
);
assert
(
excit_
slice
_init
(
it
,
excit_dup
(
source
),
excit_dup
(
indexer
))
==
assert
(
excit_
composition
_init
(
it
,
excit_dup
(
source
),
excit_dup
(
indexer
))
==
ES
);
assert
(
excit_dimension
(
it
,
&
dim
)
==
ES
);
assert
(
excit_dimension
(
source
,
&
expected_dim
)
==
ES
);
...
...
@@ -36,19 +36,19 @@ void test_alloc_init_slice(excit_t source, excit_t indexer)
excit_free
(
it
);
}
excit_t
create_test_
slice
(
excit_t
source
,
excit_t
indexer
)
excit_t
create_test_
composition
(
excit_t
source
,
excit_t
indexer
)
{
excit_t
it
;
it
=
excit_alloc_test
(
EXCIT_
SLICE
);
assert
(
excit_
slice
_init
(
it
,
excit_dup
(
source
),
excit_dup
(
indexer
))
==
it
=
excit_alloc_test
(
EXCIT_
COMPOSITION
);
assert
(
excit_
composition
_init
(
it
,
excit_dup
(
source
),
excit_dup
(
indexer
))
==
ES
);
return
it
;
}
void
test_next_
slice
(
excit_t
source
,
excit_t
indexer
)
void
test_next_
composition
(
excit_t
source
,
excit_t
indexer
)
{
excit_t
it
=
create_test_
slice
(
source
,
indexer
);
excit_t
it
=
create_test_
composition
(
source
,
indexer
);
excit_t
iit
=
excit_dup
(
indexer
);
...
...
@@ -73,16 +73,16 @@ void test_next_slice(excit_t source, excit_t indexer)
excit_free
(
iit
);
}
void
test_
slice
_iterator
(
excit_t
source
,
excit_t
indexer
)
void
test_
composition
_iterator
(
excit_t
source
,
excit_t
indexer
)
{
test_alloc_init_
slice
(
source
,
indexer
);
test_alloc_init_
composition
(
source
,
indexer
);
test_next_
slice
(
source
,
indexer
);
test_next_
composition
(
source
,
indexer
);
int
i
=
0
;
while
(
synthetic_tests
[
i
])
{
excit_t
it
=
create_test_
slice
(
source
,
indexer
);
excit_t
it
=
create_test_
composition
(
source
,
indexer
);
synthetic_tests
[
i
]
(
it
);
excit_free
(
it
);
...
...
@@ -96,13 +96,13 @@ int main(int argc, char *argv[])
source
=
create_test_range
(
-
15
,
14
,
2
);
indexer
=
create_test_range
(
4
,
12
,
3
);
test_
slice
_iterator
(
source
,
indexer
);
test_
composition
_iterator
(
source
,
indexer
);
source2
=
excit_alloc_test
(
EXCIT_PRODUCT
);
assert
(
excit_product_add
(
source2
,
create_test_range
(
-
15
,
14
,
2
))
==
ES
);
assert
(
excit_product_add
(
source2
,
create_test_range
(
4
,
12
,
3
))
==
ES
);
indexer2
=
create_test_range
(
4
,
35
,
2
);
test_
slice
_iterator
(
source2
,
indexer2
);
test_
composition
_iterator
(
source2
,
indexer2
);
excit_free
(
source
);
excit_free
(
source2
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment