~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/gmp/mpz/powm_ui.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2007-04-09 11:51:51 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070409115151-ql8cr0kalzx1jmla
Tags: 0.9i-20070324-2
Upload to unstable. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* mpz_powm_ui(res,base,exp,mod) -- Set RES to (base**exp) mod MOD.
2
2
 
3
 
Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2002 Free Software
 
3
Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2005 Free Software
4
4
Foundation, Inc.
5
5
 
6
6
This file is part of the GNU MP Library.
17
17
 
18
18
You should have received a copy of the GNU Lesser General Public License
19
19
along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
20
 
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21
 
MA 02111-1307, USA. */
 
20
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
21
MA 02110-1301, USA. */
22
22
 
23
23
 
24
24
#include "gmp.h"
31
31
reduce (mp_ptr tp, mp_srcptr ap, mp_size_t an, mp_srcptr mp, mp_size_t mn)
32
32
{
33
33
  mp_ptr qp;
34
 
  TMP_DECL (marker);
 
34
  TMP_DECL;
35
35
 
36
 
  TMP_MARK (marker);
 
36
  TMP_MARK;
37
37
  qp = TMP_ALLOC_LIMBS (an - mn + 1);
38
38
 
39
39
  mpn_tdiv_qr (qp, tp, 0L, ap, an, mp, mn);
40
40
 
41
 
  TMP_FREE (marker);
 
41
  TMP_FREE;
42
42
}
43
43
 
44
44
void
49
49
  int m_zero_cnt;
50
50
  int c;
51
51
  mp_limb_t e;
52
 
  TMP_DECL (marker);
 
52
  TMP_DECL;
53
53
 
54
54
  mp = PTR(m);
55
55
  mn = ABSIZ(m);
65
65
      return;
66
66
    }
67
67
 
68
 
  TMP_MARK (marker);
 
68
  TMP_MARK;
69
69
 
70
70
  /* Normalize m (i.e. make its most significant bit set) as required by
71
71
     division functions below.  */
96
96
  if (bn == 0)
97
97
    {
98
98
      SIZ(r) = 0;
99
 
      TMP_FREE (marker);
 
99
      TMP_FREE;
100
100
      return;
101
101
    }
102
102
 
193
193
  SIZ (r) = xn;
194
194
  MPN_COPY (PTR(r), xp, xn);
195
195
 
196
 
  TMP_FREE (marker);
 
196
  TMP_FREE;
197
197
}