source: icGREP/icgrep-devel/cudd-2.5.1/mtr/mtr.h @ 5815

Last change on this file since 5815 was 4597, checked in by nmedfort, 4 years ago

Upload of the CUDD library.

File size: 6.9 KB
Line 
1/**CHeaderFile*****************************************************************
2
3  FileName    [mtr.h]
4
5  PackageName [mtr]
6
7  Synopsis    [Multiway-branch tree manipulation]
8
9  Description [This package provides two layers of functions. Functions
10  of the lower level manipulate multiway-branch trees, implemented
11  according to the classical scheme whereby each node points to its
12  first child and its previous and next siblings. These functions are
13  collected in mtrBasic.c.<p>
14  Functions of the upper layer deal with group trees, that is the trees
15  used by group sifting to represent the grouping of variables. These
16  functions are collected in mtrGroup.c.]
17
18  SeeAlso     [The CUDD package documentation; specifically on group
19  sifting.]
20
21  Author      [Fabio Somenzi]
22
23  Copyright   [Copyright (c) 1995-2012, Regents of the University of Colorado
24
25  All rights reserved.
26
27  Redistribution and use in source and binary forms, with or without
28  modification, are permitted provided that the following conditions
29  are met:
30
31  Redistributions of source code must retain the above copyright
32  notice, this list of conditions and the following disclaimer.
33
34  Redistributions in binary form must reproduce the above copyright
35  notice, this list of conditions and the following disclaimer in the
36  documentation and/or other materials provided with the distribution.
37
38  Neither the name of the University of Colorado nor the names of its
39  contributors may be used to endorse or promote products derived from
40  this software without specific prior written permission.
41
42  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
45  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
46  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
47  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
48  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
50  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
52  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
53  POSSIBILITY OF SUCH DAMAGE.]
54
55  Revision    [$Id: mtr.h,v 1.17 2012/02/05 01:06:19 fabio Exp $]
56
57******************************************************************************/
58
59#ifndef __MTR
60#define __MTR
61
62/*---------------------------------------------------------------------------*/
63/* Nested includes                                                           */
64/*---------------------------------------------------------------------------*/
65
66#ifdef __cplusplus
67extern "C" {
68#endif
69
70/*---------------------------------------------------------------------------*/
71/* Constant declarations                                                     */
72/*---------------------------------------------------------------------------*/
73
74#ifndef SIZEOF_VOID_P
75#define SIZEOF_VOID_P 4
76#endif
77#ifndef SIZEOF_INT
78#define SIZEOF_INT 4
79#endif
80
81#if defined(__GNUC__)
82#define MTR_INLINE __inline__
83# if (__GNUC__ >2 || __GNUC_MINOR__ >=7)
84#   define MTR_UNUSED __attribute__ ((unused))
85# else
86#   define MTR_UNUSED
87# endif
88#else
89#define MTR_INLINE
90#define MTR_UNUSED
91#endif
92
93/* Flag definitions */
94#define MTR_DEFAULT     0x00000000
95#define MTR_TERMINAL    0x00000001
96#define MTR_SOFT        0x00000002
97#define MTR_FIXED       0x00000004
98#define MTR_NEWNODE     0x00000008
99
100/* MTR_MAXHIGH is defined in such a way that on 32-bit and 64-bit
101** machines one can cast a value to (int) without generating a negative
102** number.
103*/
104#if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
105#define MTR_MAXHIGH     (((MtrHalfWord) ~0) >> 1)
106#else
107#define MTR_MAXHIGH     ((MtrHalfWord) ~0)
108#endif
109
110
111/*---------------------------------------------------------------------------*/
112/* Stucture declarations                                                     */
113/*---------------------------------------------------------------------------*/
114
115
116/*---------------------------------------------------------------------------*/
117/* Type declarations                                                         */
118/*---------------------------------------------------------------------------*/
119
120#if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
121typedef unsigned int   MtrHalfWord;
122#else
123typedef unsigned short MtrHalfWord;
124#endif
125
126typedef struct MtrNode {
127    MtrHalfWord flags;
128    MtrHalfWord low;
129    MtrHalfWord size;
130    MtrHalfWord index;
131    struct MtrNode *parent;
132    struct MtrNode *child;
133    struct MtrNode *elder;
134    struct MtrNode *younger;
135} MtrNode;
136
137
138/*---------------------------------------------------------------------------*/
139/* Variable declarations                                                     */
140/*---------------------------------------------------------------------------*/
141
142
143/*---------------------------------------------------------------------------*/
144/* Macro declarations                                                        */
145/*---------------------------------------------------------------------------*/
146
147/* Flag manipulation macros */
148#define MTR_SET(node, flag)     (node->flags |= (flag))
149#define MTR_RESET(node, flag)   (node->flags &= ~ (flag))
150#define MTR_TEST(node, flag)    (node->flags & (flag))
151
152
153/**AutomaticStart*************************************************************/
154
155/*---------------------------------------------------------------------------*/
156/* Function prototypes                                                       */
157/*---------------------------------------------------------------------------*/
158
159extern MtrNode * Mtr_AllocNode (void);
160extern void Mtr_DeallocNode (MtrNode *node);
161extern MtrNode * Mtr_InitTree (void);
162extern void Mtr_FreeTree (MtrNode *node);
163extern MtrNode * Mtr_CopyTree (MtrNode *node, int expansion);
164extern void Mtr_MakeFirstChild (MtrNode *parent, MtrNode *child);
165extern void Mtr_MakeLastChild (MtrNode *parent, MtrNode *child);
166extern MtrNode * Mtr_CreateFirstChild (MtrNode *parent);
167extern MtrNode * Mtr_CreateLastChild (MtrNode *parent);
168extern void Mtr_MakeNextSibling (MtrNode *first, MtrNode *second);
169extern void Mtr_PrintTree (MtrNode *node);
170extern MtrNode * Mtr_InitGroupTree (int lower, int size);
171extern MtrNode * Mtr_MakeGroup (MtrNode *root, unsigned int low, unsigned int high, unsigned int flags);
172extern MtrNode * Mtr_DissolveGroup (MtrNode *group);
173extern MtrNode * Mtr_FindGroup (MtrNode *root, unsigned int low, unsigned int high);
174extern int Mtr_SwapGroups (MtrNode *first, MtrNode *second);
175extern void Mtr_ReorderGroups(MtrNode *treenode, int *permutation);
176 
177extern void Mtr_PrintGroups (MtrNode *root, int silent);
178  extern int Mtr_PrintGroupedOrder(MtrNode * root, int *invperm, FILE *fp);
179extern MtrNode * Mtr_ReadGroups (FILE *fp, int nleaves);
180
181/**AutomaticEnd***************************************************************/
182
183#ifdef __cplusplus
184}
185#endif
186
187#endif /* __MTR */
Note: See TracBrowser for help on using the repository browser.