Rearrange the file tree.
[u/mdw/catacomb] / math / mp-misc.c
1 /* -*-c-*-
2 *
3 * Miscellaneous multiprecision support functions
4 *
5 * (c) 1999 Straylight/Edgeware
6 */
7
8 /*----- Licensing notice --------------------------------------------------*
9 *
10 * This file is part of Catacomb.
11 *
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
16 *
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
21 *
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 * MA 02111-1307, USA.
26 */
27
28 /*----- Header files ------------------------------------------------------*/
29
30 #include "mp.h"
31
32 /*----- Basic manipulation ------------------------------------------------*/
33
34 /* --- @mp_shrink@ --- *
35 *
36 * Arguments: @mp *m@ = pointer to a multiprecision integer
37 *
38 * Returns: ---
39 *
40 * Use: Reduces the recorded length of an integer. This doesn't
41 * reduce the amount of memory used, although it can improve
42 * performance a bit. To reduce memory, use @mp_minimize@
43 * instead. This can't change the value of an integer, and is
44 * therefore safe to use even when there are multiple
45 * references.
46 */
47
48 void mp_shrink(mp *m) { MP_SHRINK(m); }
49
50 /* --- @mp_minimize@ --- *
51 *
52 * Arguments: @mp *m@ = pointer to a multiprecision integer
53 *
54 * Returns: ---
55 *
56 * Use: Reduces the amount of memory an integer uses. It's best to
57 * do this to numbers which aren't going to change in the
58 * future.
59 */
60
61 void mp_minimize(mp *m)
62 {
63 MP_SHRINK(m);
64 MP_RESIZE(m, MP_LEN(m));
65 }
66
67 /*----- Bit scanning ------------------------------------------------------*/
68
69 /* --- @mp_scan@ --- *
70 *
71 * Arguments: @mpscan *sc@ = pointer to bitscanner block
72 * @const mp *m@ = pointer to a multiprecision integer
73 *
74 * Returns: ---
75 *
76 * Use: Initializes a bitscanner on a multiprecision integer.
77 */
78
79 void mp_scan(mpscan *sc, const mp *m) { MP_SCAN(sc, m); }
80
81 /* --- @mp_scan@ --- *
82 *
83 * Arguments: @mpscan *sc@ = pointer to bitscanner block
84 * @const mp *m@ = pointer to a multiprecision integer
85 *
86 * Returns: ---
87 *
88 * Use: Initializes a reverse bitscanner on a multiprecision
89 * integer.
90 */
91
92 void mp_rscan(mpscan *sc, const mp *m) { MP_RSCAN(sc, m); }
93
94 /*----- That's all, folks -------------------------------------------------*/