Hitmap 1.3
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
hit_cshape.h
Go to the documentation of this file.
1 
10 /*
11  * <license>
12  *
13  * Hitmap v1.2
14  *
15  * This software is provided to enhance knowledge and encourage progress in the scientific
16  * community. It should be used only for research and educational purposes. Any reproduction
17  * or use for commercial purpose, public redistribution, in source or binary forms, with or
18  * without modifications, is NOT ALLOWED without the previous authorization of the copyright
19  * holder. The origin of this software must not be misrepresented; you must not claim that you
20  * wrote the original software. If you use this software for any purpose (e.g. publication),
21  * a reference to the software package and the authors must be included.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND ANY
24  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
26  * THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * Copyright (c) 2007-2015, Trasgo Group, Universidad de Valladolid.
34  * All rights reserved.
35  *
36  * More information on http://trasgo.infor.uva.es/
37  *
38  * </license>
39 */
40 
41 #ifndef _HitCShape_
42 #define _HitCShape_
43 
44 #include "hit_shape.h"
45 
46 
48 #define HIT_CSHAPE_MATRIX 0
49 
50 #define HIT_CSHAPE_GRAPH 1
51 
56 
57 // @cond INTERNAL
59 #define HIT_CSR_SHAPE_INTERNAL_NULL_STATIC { {0,0}, NULL, NULL, {HIT_NAMELIST_NULL_STATIC,HIT_NAMELIST_NULL_STATIC} }
60 
61 // @note
62 // @author javfres: C++ do not support this kind of struct initialization.
63 // @author arturo: Solution, do the initialization in two assignments in the .c file. Done.
64 #ifdef __cplusplus
65 #else
66 #define HIT_CSR_SHAPE_NULL_STATIC { HIT_CSR_SHAPE, {.csr = HIT_CSR_SHAPE_INTERNAL_NULL_STATIC} }
67 #endif
68 // @endcond
69 
70 
71 /* 1. Hit CSR Sparse Shape generating functions */
80 HitShape hit_csrShape(int nvertices, int nedges);
81 
90 HitShape hit_csrShapeMatrix(int n, int m, int nz);
91 
98 
99 
100 
101 /* 2. Hit Sparse Shape access macros */
108 #define hit_cShapeCard(shape, dim) (hit_cShapeAccess(shape).cards[(dim)])
109 
110 
118 #define hit_cShapeNvertices(shape) (hit_cShapeCard(shape, 0))
119 
120 
126 #define hit_cShapeNZElems(shape) (hit_cShapeXadj((shape))[hit_cShapeNvertices(shape)])
127 
128 
136 #define hit_cShapeNedges(shape) hit_cShapeNZElems(shape)
137 
145 #define hit_cShapeXadj(shape) (hit_cShapeAccess(shape).xadj)
146 
154 #define hit_cShapeAdjncy(shape) (hit_cShapeAccess(shape).adjncy)
155 
162 #define hit_cShapeNameList(shape,dim) (hit_cShapeAccess((shape)).names[(dim)])
163 
171 int hit_cShapeElemExists(HitShape shape, int x, int y);
172 
173 
182 #define hit_cShapeFistColumn(s, row) (hit_cShapeXadj(s)[(row)])
183 
192 #define hit_cShapeLastColumn(s, row) (hit_cShapeXadj(s)[(row)+1])
193 
202 #define hit_cShapeNEdgesFromVertex(s, vertex) (hit_cShapeLastColumn(s, vertex) - hit_cShapeFistColumn(s, vertex))
203 
210 #define hit_cShapeNColsRow(s, row) hit_cShapeNEdgesFromVertex(s, row)
211 
220 #define hit_cShapeEdgeTarget(s,edge) (hit_cShapeAdjncy(s)[(edge)])
221 
222 
223 /* 3. Hit CSR Sparse Shape operations */
233 #define hit_cShapeVertexToGlobal(s,vertex) (hit_nameListIndex2Name(hit_cShapeNameList(s,0),vertex))
234 
235 
243 #define hit_cShapeVertexToLocal(s,vertex) (hit_nameListName2Index(hit_cShapeNameList(s,0),vertex))
244 
245 
253 #define hit_cShapeCoordToGlobal(s,dim,elem) (hit_nameListIndex2Name(hit_cShapeNameList((s),(dim)),(elem)))
254 
255 
263 #define hit_cShapeCoordToLocal(s,dim,elem) (hit_nameListName2Index(hit_cShapeNameList((s),(dim)),(elem)))
264 
265 
266 
267 
276 #define hit_cShapeHasVertex(s,v) (hit_cShapeVertexToLocal(s, v) != -1)
277 
287 HitShape hit_cShapeSelect(HitShape s, int nvertices, int * vertices);
288 
289 
300 HitShape hit_cShapeSelectRows(HitShape shape, int n, int * names);
301 
302 
311 HitShape hit_cShapeExpand(HitShape shape, HitShape original, int amount);
312 
322 HitShape hit_cShapeReorder(HitShape s, int * newNames);
323 
330 #define hit_cShapeAddVertex(shapeP, x) hit_cShapeAddEmptyRow_or_Vertex(shapeP, x, HIT_CSHAPE_GRAPH)
331 
338 void hit_cShapeAddEmptyRow_or_Vertex(HitShape * shape, int x, int mode);
339 
348 #define hit_cShapeAddEdge(shapep, x, y) hit_cShapeAddElem_or_Edge(shapep, x, y, HIT_CSHAPE_GRAPH)
349 
358 #define hit_cShapeAddEdge2(shape,x,y) {hit_cShapeAddEdge(shape,x,y); hit_cShapeAddEdge(shape,y,x);}
359 
369 
370 
371 
372 /* 4. Hit CSR Sparse Shape Iterators */
373 
381 #define hit_cShapeRowIterator(var,shape) \
382  for(var=0; var<hit_cShapeCard(shape, 0); var++)
383 
392 #define hit_cShapeVertexIterator(var,shape) hit_cShapeRowIterator(var,shape)
393 
403 #define hit_cShapeColumnIterator(var,shape,row) \
404  for(var=hit_cShapeFistColumn(shape,row); var<hit_cShapeLastColumn(shape,row); var++)
405 
406 
416 #define hit_cShapeEdgeIterator(var,shape,vertex) hit_cShapeColumnIterator(var,shape,vertex)
417 
418 
426 void hit_cShapeAddElem_or_Edge(HitShape * shape, int x, int y, int mode);
427 
428 
435 #define hit_cShapeAddElem(shapep, x, y) hit_cShapeAddElem_or_Edge(shapep, x, y, HIT_CSHAPE_MATRIX)
436 
437 
438 
439 /* END OF HEADER FILE _HitCShape_ */
440 #endif
HitShape hit_cShapeReorder(HitShape s, int *newNames)
HitShape hit_csrShapeMatrix(int n, int m, int nz)
Definition: hit_cshape.c:72
#define y(a, b, c)
void hit_cShapeCreateInvNames(HitShape *shape)
Definition: hit_cshape.c:318
HitShape hit_csrShape(int nvertices, int nedges)
Definition: hit_cshape.c:47
#define x
HitShape hit_cShapeExpand(HitShape shape, HitShape original, int amount)
Definition: hit_cshape.c:208
HitShape hit_cShapeSelect(HitShape s, int nvertices, int *vertices)
Definition: hit_cshape.c:109
HitShape shape
HitShape HIT_CSR_SHAPE_NULL
Definition: hit_shape.c:70
HitShape hit_cShapeSelectRows(HitShape shape, int n, int *names)
Definition: hit_cshape.c:542
#define s
void hit_cShapeFree(HitShape shape)
Definition: hit_cshape.c:99
#define m(a, b, c)
void hit_cShapeAddEmptyRow_or_Vertex(HitShape *shape, int x, int mode)
Definition: hit_cshape.c:349
int hit_cShapeElemExists(HitShape shape, int x, int y)
Definition: hit_cshape.c:416
void hit_cShapeAddElem_or_Edge(HitShape *shape, int x, int y, int mode)
Definition: hit_cshape.c:432