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

« back to all changes in this revision

Viewing changes to src/gmp/mpz/lucnum2_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_lucnum2_ui -- calculate Lucas numbers.
2
2
 
3
 
Copyright 2001 Free Software Foundation, Inc.
 
3
Copyright 2001, 2003, 2005 Free Software Foundation, Inc.
4
4
 
5
5
This file is part of the GNU MP Library.
6
6
 
16
16
 
17
17
You should have received a copy of the GNU Lesser General Public License
18
18
along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
19
 
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20
 
MA 02111-1307, USA. */
 
19
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
20
MA 02110-1301, USA. */
21
21
 
22
22
#include <stdio.h>
23
23
#include "gmp.h"
30
30
  mp_ptr     lp, l1p, f1p;
31
31
  mp_size_t  size;
32
32
  mp_limb_t  c;
33
 
  TMP_DECL (marker);
 
33
  TMP_DECL;
34
34
 
35
35
  ASSERT (ln != lnsub1);
36
36
 
51
51
      return;
52
52
    }
53
53
 
54
 
  TMP_MARK (marker);
 
54
  TMP_MARK;
55
55
  size = MPN_FIB2_SIZE (n);
56
56
  f1p = TMP_ALLOC_LIMBS (size);
57
57
 
63
63
  size = mpn_fib2_ui (l1p, f1p, n);
64
64
 
65
65
  /* L[n] = F[n] + 2F[n-1] */
 
66
#if HAVE_NATIVE_mpn_addlsh1_n
 
67
  c = mpn_addlsh1_n (lp, l1p, f1p, size);
 
68
#else
66
69
  c = mpn_lshift (lp, f1p, size, 1);
67
70
  c += mpn_add_n (lp, lp, l1p, size);
 
71
#endif
68
72
  lp[size] = c;
69
73
  SIZ(ln) = size + (c != 0);
70
74
 
75
79
  l1p[size] = c;
76
80
  SIZ(lnsub1) = size + (c != 0);
77
81
 
78
 
  TMP_FREE (marker);
 
82
  TMP_FREE;
79
83
}