Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hqr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
solverstack
hqr
Commits
231eae15
Commit
231eae15
authored
8 years ago
by
BOUCHERIE Raphael
Browse files
Options
Downloads
Patches
Plain Diff
added print_tree function
parent
86923d9a
No related branches found
No related tags found
1 merge request
!5
Print tree
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/libhqr.h
+2
-1
2 additions, 1 deletion
include/libhqr.h
src/treewalk.c
+36
-6
36 additions, 6 deletions
src/treewalk.c
testings/testing_treedraw.c
+1
-20
1 addition, 20 deletions
testings/testing_treedraw.c
with
39 additions
and
27 deletions
include/libhqr.h
+
2
−
1
View file @
231eae15
...
@@ -191,13 +191,14 @@ int libhqr_hqr_init( libhqr_tree_t *qrtree,
...
@@ -191,13 +191,14 @@ int libhqr_hqr_init( libhqr_tree_t *qrtree,
void
libhqr_hqr_finalize
(
libhqr_tree_t
*
qrtree
);
void
libhqr_hqr_finalize
(
libhqr_tree_t
*
qrtree
);
/*
/*
* function for tree
walk
* function for
drawing the
tree
*/
*/
void
libhqr_treewalk
(
const
libhqr_tree_t
*
qrtree
,
int
k
,
int
*
tiles
,
FILE
*
file
);
void
libhqr_treewalk
(
const
libhqr_tree_t
*
qrtree
,
int
k
,
int
*
tiles
,
FILE
*
file
);
void
draw_rectangle
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
);
void
draw_rectangle
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
);
void
draw_horizontal_line
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
);
void
draw_horizontal_line
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
);
void
draw_vertical_line
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
);
void
draw_vertical_line
(
int
k
,
int
p
,
int
m
,
int
*
tiles
,
FILE
*
file
);
void
libhqr_print_tree
(
const
libhqr_tree_t
*
qrtree
,
libhqr_tiledesc_t
*
matrix
);
/*
/*
* Debugging functions
* Debugging functions
...
...
This diff is collapsed.
Click to expand it.
src/treewalk.c
+
36
−
6
View file @
231eae15
...
@@ -13,11 +13,14 @@
...
@@ -13,11 +13,14 @@
* @date 2017-03-21
* @date 2017-03-21
*
*
*/
*/
#include
"libhqr.h"
#include
"libhqr.h"
#include
"libdraw.h"
#include
"libdraw.h"
#include
"queue.h"
#include
"queue.h"
#include
<stdio.h>
#include
<stdio.h>
#include
<assert.h>
#include
<assert.h>
#include
<stdlib.h>
#include
<string.h>
/*
/*
* Common prameters to the 2 following functions:
* Common prameters to the 2 following functions:
...
@@ -99,10 +102,10 @@ void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *file)
...
@@ -99,10 +102,10 @@ void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *file)
(
qrtree
->
prevpiv
(
qrtree
,
k
,
p
,
p
)
!=
qrtree
->
mt
)
)
(
qrtree
->
prevpiv
(
qrtree
,
k
,
p
,
p
)
!=
qrtree
->
mt
)
)
{
{
libhqr_queue_tile_push
(
&
tt
,
p
);
libhqr_queue_tile_push
(
&
tt
,
p
);
printf
(
"PUSH TT: %d
\n
"
,
p
);
/*
printf("PUSH TT: %d\n", p);
*/
}
}
libhqr_queue_tile_push
(
&
ts
,
p
);
libhqr_queue_tile_push
(
&
ts
,
p
);
printf
(
"PUSH TS: %d
\n
"
,
p
);
/*
printf("PUSH TS: %d\n", p);
*/
p
=
qrtree
->
prevpiv
(
qrtree
,
k
,
pivot
,
p
);
p
=
qrtree
->
prevpiv
(
qrtree
,
k
,
pivot
,
p
);
assert
(
p
!=
-
1
);
assert
(
p
!=
-
1
);
}
}
...
@@ -112,12 +115,12 @@ void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *file)
...
@@ -112,12 +115,12 @@ void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *file)
/* Unstack all element killed by TS, or by TT and already discovered */
/* Unstack all element killed by TS, or by TT and already discovered */
while
(
tsid
!=
-
1
&&
tsid
!=
ttid
)
{
while
(
tsid
!=
-
1
&&
tsid
!=
ttid
)
{
printf
(
"TS=%d, TT=%d
\n
"
,
tsid
,
ttid
);
/*
printf( "TS=%d, TT=%d\n", tsid, ttid );
*/
tsid
=
libhqr_queue_tile_pop
(
&
ts
);
tsid
=
libhqr_queue_tile_pop
(
&
ts
);
printf
(
"POP TS: %d
\n
"
,
tsid
);
/*
printf("POP TS: %d\n", tsid);
*/
printf
(
"Call function on (%d, %d)
\n
"
,
/*
printf("Call function on (%d, %d)\n",
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
tsid
);
qrtree->currpiv(qrtree, k, tsid), tsid );
*/
draw_horizontal_line
(
k
,
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
tsid
,
tiles
,
file
);
draw_horizontal_line
(
k
,
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
tsid
,
tiles
,
file
);
draw_vertical_line
(
k
,
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
tsid
,
tiles
,
file
);
draw_vertical_line
(
k
,
qrtree
->
currpiv
(
qrtree
,
k
,
tsid
),
tsid
,
tiles
,
file
);
tsid
=
libhqr_queue_tile_head
(
&
ts
);
tsid
=
libhqr_queue_tile_head
(
&
ts
);
...
@@ -128,3 +131,30 @@ void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *file)
...
@@ -128,3 +131,30 @@ void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *file)
assert
(
ts
==
NULL
);
assert
(
ts
==
NULL
);
assert
(
tt
==
NULL
);
assert
(
tt
==
NULL
);
}
}
/****************************************************
* LIBHQR_PRINT_TREE
***************************************************/
void
libhqr_print_tree
(
const
libhqr_tree_t
*
qrtree
,
libhqr_tiledesc_t
*
matrix
){
int
maxMN
,
minMN
,
k
,
i
;
int
*
tiles
;
FILE
*
file
;
maxMN
=
libhqr_imax
(
matrix
->
mt
,
matrix
->
nt
);
minMN
=
libhqr_imin
(
matrix
->
mt
,
matrix
->
nt
);
tiles
=
(
int
*
)
malloc
(
maxMN
*
sizeof
(
int
));
memset
(
tiles
,
0
,
maxMN
*
sizeof
(
int
)
);
file
=
fopen
(
"tree.svg"
,
"w+"
);
libhqr_writeheader
(
file
);
for
(
k
=
0
;
k
<
minMN
;
k
++
){
/* Drawing the lines */
libhqr_treewalk
(
qrtree
,
k
,
tiles
,
file
);
/* Drawing the rectangles */
for
(
i
=
k
+
1
;
i
<
maxMN
;
i
++
){
draw_rectangle
(
k
,
qrtree
->
currpiv
(
qrtree
,
k
,
i
),
i
,
tiles
,
file
);
}
}
libhqr_writeend
(
file
);
fclose
(
file
);
free
(
tiles
);
}
This diff is collapsed.
Click to expand it.
testings/testing_treedraw.c
+
1
−
20
View file @
231eae15
...
@@ -26,31 +26,12 @@ main(int argc, char ** argv)
...
@@ -26,31 +26,12 @@ main(int argc, char ** argv)
{
{
libhqr_tree_t
qrtree
;
libhqr_tree_t
qrtree
;
libhqr_tiledesc_t
matrix
;
libhqr_tiledesc_t
matrix
;
int
maxMN
,
k
,
i
;
int
*
tiles
;
matrix
.
nodes
=
1
;
matrix
.
nodes
=
1
;
matrix
.
p
=
1
;
matrix
.
p
=
1
;
matrix
.
mt
=
16
;
matrix
.
mt
=
16
;
matrix
.
nt
=
4
;
matrix
.
nt
=
4
;
libhqr_hqr_init
(
&
qrtree
,
LIBHQR_QR
,
&
matrix
,
LIBHQR_BINARY_TREE
,
LIBHQR_FLAT_TREE
,
1
,
2
,
0
,
0
);
libhqr_hqr_init
(
&
qrtree
,
LIBHQR_QR
,
&
matrix
,
LIBHQR_BINARY_TREE
,
LIBHQR_FLAT_TREE
,
1
,
2
,
0
,
0
);
maxMN
=
libhqr_imax
(
matrix
.
mt
,
matrix
.
nt
);
libhqr_print_tree
(
&
qrtree
,
&
matrix
);
tiles
=
(
int
*
)
malloc
(
maxMN
*
sizeof
(
int
));
for
(
int
i
=
0
;
i
<
maxMN
;
i
++
){
tiles
[
i
]
=
0
;
}
FILE
*
tree
=
fopen
(
"tree.svg"
,
"w+"
);
libhqr_writeheader
(
tree
);
for
(
k
=
0
;
k
<
3
;
k
++
){
/* Drawing the lines */
libhqr_treewalk
(
&
qrtree
,
k
,
tiles
,
tree
);
/* Drawing the rectangles */
for
(
i
=
k
+
1
;
i
<
maxMN
;
i
++
){
draw_rectangle
(
k
,
qrtree
.
currpiv
(
&
qrtree
,
k
,
i
),
i
,
tiles
,
tree
);
}
}
libhqr_writeend
(
tree
);
libhqr_hqr_finalize
(
&
qrtree
);
libhqr_hqr_finalize
(
&
qrtree
);
free
(
tiles
);
fclose
(
tree
);
return
1
;
return
1
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment