File: cln_11.html

package info (click to toggle)
cln 0.98-7.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 12,188 kB
  • ctags: 15,282
  • sloc: cpp: 71,545; ansic: 12,015; asm: 8,431; sh: 3,159; makefile: 886; lisp: 64
file content (298 lines) | stat: -rw-r--r-- 8,125 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.51
     from cln.texi on 2 Febuary 1998 -->

<TITLE>CLN, a Class Library for Numbers - 11  Using the library</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_10.html">previous</A>, <A HREF="cln_12.html">next</A>, <A HREF="cln_13.html">last</A> section, <A HREF="cln_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC61" HREF="cln_toc.html#TOC61">11  Using the library</A></H1>

<P>
For the following discussion, we will assume that you have installed
the CLN source in <CODE>$CLN_DIR</CODE> and built it in <CODE>$CLN_TARGETDIR</CODE>.
For example, for me it's <CODE>CLN_DIR="$HOME/cln"</CODE> and
<CODE>CLN_TARGETDIR="$HOME/cln/linuxelf"</CODE>. You might define these as
environment variables, or directly substitute the appropriate values.

</P>



<H2><A NAME="SEC62" HREF="cln_toc.html#TOC62">11.1  Compiler options</A></H2>

<P>
Until you have installed CLN in a public place, the following options are
needed:

</P>
<P>
When you compile CLN application code, add the flags

<PRE>
   -I$CLN_DIR/include -I$CLN_TARGETDIR/include
</PRE>

<P>
to the C++ compiler's command line (<CODE>make</CODE> variable CFLAGS or CXXFLAGS).
When you link CLN application code to form an executable, add the flags

<PRE>
   $CLN_TARGETDIR/src/libcln.a
</PRE>

<P>
to the C/C++ compiler's command line (<CODE>make</CODE> variable LIBS).

</P>
<P>
If you did a <CODE>make install</CODE>, the include files are installed in a
public directory (normally <CODE>/usr/local/include</CODE>), hence you don't
need special flags for compiling. The library has been installed to a
public directory as well (normally <CODE>/usr/local/lib</CODE>), hence when
linking a CLN application it is sufficient to give the flag <CODE>-lcln</CODE>.

</P>



<H2><A NAME="SEC63" HREF="cln_toc.html#TOC63">11.2  Include files</A></H2>

<P>
Here is a summary of the include files and their contents.

</P>
<DL COMPACT>

<DT><CODE>&#60;cl_object.h&#62;</CODE>
<DD>
General definitions, reference counting, garbage collection.
<DT><CODE>&#60;cl_number.h&#62;</CODE>
<DD>
The ordinary number classes.
<DT><CODE>&#60;cl_real.h&#62;</CODE>
<DD>
Functions for class cl_R, the real numbers.
<DT><CODE>&#60;cl_float.h&#62;</CODE>
<DD>
Functions for class cl_F, the floats.
<DT><CODE>&#60;cl_sfloat.h&#62;</CODE>
<DD>
Functions for class cl_SF, the short-floats.
<DT><CODE>&#60;cl_ffloat.h&#62;</CODE>
<DD>
Functions for class cl_FF, the single-floats.
<DT><CODE>&#60;cl_dfloat.h&#62;</CODE>
<DD>
Functions for class cl_DF, the double-floats.
<DT><CODE>&#60;cl_lfloat.h&#62;</CODE>
<DD>
Functions for class cl_LF, the long-floats.
<DT><CODE>&#60;cl_rational.h&#62;</CODE>
<DD>
Functions for class cl_RA, the rational numbers.
<DT><CODE>&#60;cl_integer.h&#62;</CODE>
<DD>
Functions for class cl_I, the integers.
<DT><CODE>&#60;cl_complex.h&#62;</CODE>
<DD>
Functions for class cl_N, the complex numbers.
<DT><CODE>&#60;cl_random.h&#62;</CODE>
<DD>
Random number generators.
<DT><CODE>&#60;cl_malloc.h&#62;</CODE>
<DD>
<CODE>cl_malloc_hook</CODE>, <CODE>cl_free_hook</CODE>.
<DT><CODE>&#60;cl_abort.h&#62;</CODE>
<DD>
<CODE>cl_abort</CODE>.
<DT><CODE>&#60;cl_io.h&#62;</CODE>
<DD>
Input/Output.
<DT><CODE>&#60;cl_input.h&#62;</CODE>
<DD>
Flags for customizing input operations.
<DT><CODE>&#60;cl_output.h&#62;</CODE>
<DD>
Flags for customizing output operations.
<DT><CODE>&#60;cl_condition.h&#62;</CODE>
<DD>
Conditions/exceptions.
<DT><CODE>&#60;cl_string.h&#62;</CODE>
<DD>
Strings.
<DT><CODE>&#60;cl_symbol.h&#62;</CODE>
<DD>
Symbols.
<DT><CODE>&#60;cl_proplist.h&#62;</CODE>
<DD>
Property lists.
<DT><CODE>&#60;cl_ring.h&#62;</CODE>
<DD>
General rings.
<DT><CODE>&#60;cl_numtheory.h&#62;</CODE>
<DD>
Number threory functions.
<DT><CODE>&#60;cl_modinteger.h&#62;</CODE>
<DD>
Modular integers.
<DT><CODE>&#60;cl_V.h&#62;</CODE>
<DD>
Vectors.
<DT><CODE>&#60;cl_GV.h&#62;</CODE>
<DD>
General vectors.
<DT><CODE>&#60;cl_GV_integer.h&#62;</CODE>
<DD>
General vectors over cl_I.
<DT><CODE>&#60;cl_GV_rational.h&#62;</CODE>
<DD>
General vectors over cl_RA.
<DT><CODE>&#60;cl_GV_real.h&#62;</CODE>
<DD>
General vectors over cl_R.
<DT><CODE>&#60;cl_GV_complex.h&#62;</CODE>
<DD>
General vectors over cl_N.
<DT><CODE>&#60;cl_GV_modinteger.h&#62;</CODE>
<DD>
General vectors of modular integers.
<DT><CODE>&#60;cl_SV.h&#62;</CODE>
<DD>
Simple vectors.
<DT><CODE>&#60;cl_SV_integer.h&#62;</CODE>
<DD>
Simple vectors over cl_I.
<DT><CODE>&#60;cl_SV_rational.h&#62;</CODE>
<DD>
Simple vectors over cl_RA.
<DT><CODE>&#60;cl_SV_real.h&#62;</CODE>
<DD>
Simple vectors over cl_R.
<DT><CODE>&#60;cl_SV_complex.h&#62;</CODE>
<DD>
Simple vectors over cl_N.
<DT><CODE>&#60;cl_SV_ringelt.h&#62;</CODE>
<DD>
Simple vectors of general ring elements.
<DT><CODE>&#60;cl_univpoly.h&#62;</CODE>
<DD>
Univariate polynomials.
<DT><CODE>&#60;cl_univpoly_integer.h&#62;</CODE>
<DD>
Univariate polynomials over the integers.
<DT><CODE>&#60;cl_univpoly_rational.h&#62;</CODE>
<DD>
Univariate polynomials over the rational numbers.
<DT><CODE>&#60;cl_univpoly_real.h&#62;</CODE>
<DD>
Univariate polynomials over the real numbers.
<DT><CODE>&#60;cl_univpoly_complex.h&#62;</CODE>
<DD>
Univariate polynomials over the complex numbers.
<DT><CODE>&#60;cl_univpoly_modint.h&#62;</CODE>
<DD>
Univariate polynomials over modular integer rings.
<DT><CODE>&#60;cl_timing.h&#62;</CODE>
<DD>
Timing facilities.
<DT><CODE>&#60;cln.h&#62;</CODE>
<DD>
Includes all of the above.
</DL>



<H2><A NAME="SEC64" HREF="cln_toc.html#TOC64">11.3  An Example</A></H2>

<P>
(This section still needs to be written.)

</P>



<H2><A NAME="SEC65" HREF="cln_toc.html#TOC65">11.4  Debugging support</A></H2>

<P>
When debugging a CLN application with GNU <CODE>gdb</CODE>, two facilities are
available from the library:

</P>

<UL>
<LI>The library does type checks, range checks, consistency checks at

many places. When one of these fails, the function <CODE>cl_abort()</CODE> is
called. Its default implementation is to perform an <CODE>exit(1)</CODE>, so
you won't have a core dump. But for debugging, it is best to set a
breakpoint at this function:

<PRE>
(gdb) break cl_abort
</PRE>

When this breakpoint is hit, look at the stack's backtrace:

<PRE>
(gdb) where
</PRE>

<LI>The debugger's normal <CODE>print</CODE> command doesn't know about

CLN's types and therefore prints mostly useless hexadecimal addresses.
CLN offers a function <CODE>cl_print</CODE>, callable from the debugger,
for printing number objects. In order to get this function, you have
to define the macro <SAMP>`CL_DEBUG'</SAMP> and then include all the header files
for which you want <CODE>cl_print</CODE> debugging support. For example:

<PRE>
#define CL_DEBUG
#include &#60;cl_string.h&#62;
</PRE>

Now, if you have in your program a variable <CODE>cl_string s</CODE>, and
inspect it under <CODE>gdb</CODE>, the output may look like this:

<PRE>
(gdb) print s
$7 = {&#60;cl_gcpointer&#62; = { = {pointer = 0x8055b60, heappointer = 0x8055b60,
  word = 134568800}}, }
(gdb) call cl_print(s)
(cl_string) ""
$8 = 134568800
</PRE>

Note that the output of <CODE>cl_print</CODE> goes to the program's error output,
not to gdb's standard output.

Note, however, that the above facility does not work with all CLN types,
only with number objects and similar. Therefore CLN offers a member function
<CODE>debug_print()</CODE> on all CLN types. The same macro <SAMP>`CL_DEBUG'</SAMP>
is needed for this member function to be implemented. Under <CODE>gdb</CODE>,
you call it like this:

<PRE>
(gdb) print s
$7 = {&#60;cl_gcpointer&#62; = { = {pointer = 0x8055b60, heappointer = 0x8055b60,
  word = 134568800}}, }
(gdb) call s.debug_print()
(cl_string) ""
(gdb) define cprint
&#62;call ($1).debug_print()
&#62;end
(gdb) cprint s
(cl_string) ""
</PRE>

Unfortunately, this feature does not seem to work under all circumstances.
</UL>

<P><HR><P>
Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_10.html">previous</A>, <A HREF="cln_12.html">next</A>, <A HREF="cln_13.html">last</A> section, <A HREF="cln_toc.html">table of contents</A>.
</BODY>
</HTML>