当前位置: 首页>>代码示例>>C++>>正文


C++ SIZ函数代码示例

本文整理汇总了C++中SIZ函数的典型用法代码示例。如果您正苦于以下问题:C++ SIZ函数的具体用法?C++ SIZ怎么用?C++ SIZ使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SIZ函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mpn_trace_file

void
mpn_trace_file (const char *filename, mp_srcptr ptr, mp_size_t size)
{
  FILE   *fp;
  mpz_t  z;

  fp = fopen (filename, "w");
  if (fp == NULL)
    {
      perror ("fopen");
      abort();
    }

  MPN_NORMALIZE (ptr, size);
  PTR(z) = (mp_ptr) ptr;
  SIZ(z) = (int) size;

  mpz_out_str (fp, mp_trace_base, z);
  fprintf (fp, "\n");

  if (ferror (fp) || fclose (fp) != 0)
    {
      printf ("error writing %s\n", filename);
      abort();
    }
}
开发者ID:KrisChaplin,项目名称:LRT2x4_v1.0.2.06_GPL_source,代码行数:26,代码来源:trace.c

示例2: mpz_realloc2

void
mpz_realloc2 (mpz_ptr m, mp_bitcnt_t bits)
{
  mp_size_t new_alloc;

  bits -= (bits != 0);		/* Round down, except if 0 */
  new_alloc = 1 + bits / GMP_NUMB_BITS;

  if (sizeof (unsigned long) > sizeof (int)) /* param vs _mp_size field */
    {
      if (UNLIKELY (new_alloc > INT_MAX))
	{
	  fprintf (stderr, "gmp: overflow in mpz type\n");
	  abort ();
	}
    }

  PTR(m) = __GMP_REALLOCATE_FUNC_LIMBS (PTR(m), ALLOC(m), new_alloc);
  ALLOC(m) = new_alloc;

  /* Don't create an invalid number; if the current value doesn't fit after
     reallocation, clear it to 0.  */
  if (ABSIZ(m) > new_alloc)
    SIZ(m) = 0;
}
开发者ID:119,项目名称:aircam-openwrt,代码行数:25,代码来源:realloc2.c

示例3: mpf_get_ui

unsigned long
mpf_get_ui (mpf_srcptr f)
{
  mp_size_t size;
  mp_exp_t exp;
  mp_srcptr fp;
  mp_limb_t fl;

  exp = EXP (f);
  size = SIZ (f);
  fp = PTR (f);

  fl = 0;
  if (exp > 0)
    {
      /* there are some limbs above the radix point */

      size = ABS (size);
      if (size >= exp)
        fl = fp[size-exp];

#if BITS_PER_ULONG > GMP_NUMB_BITS
      if (exp > 1 && size+1 >= exp)
        fl += (fp[size-exp+1] << GMP_NUMB_BITS);
#endif
    }

  return (unsigned long) fl;
}
开发者ID:bsmr-common-lisp,项目名称:xcl,代码行数:29,代码来源:get_ui.c

示例4: mpq_set_z

void
mpq_set_z (mpq_ptr dest, mpz_srcptr src)
{
  mp_size_t num_size;
  mp_size_t abs_num_size;
  mp_ptr dp;

  num_size = SIZ (src);
  abs_num_size = ABS (num_size);
  dp = MPZ_NEWALLOC (NUM(dest), abs_num_size);
  SIZ(NUM(dest)) = num_size;
  MPN_COPY (dp, PTR(src), abs_num_size);

  PTR(DEN(dest))[0] = 1;
  SIZ(DEN(dest)) = 1;
}
开发者ID:AlexeiSheplyakov,项目名称:gmp.pkg,代码行数:16,代码来源:set_z.c

示例5: mpf_get_d_2exp

double
mpf_get_d_2exp (mpir_si *exp2, mpf_srcptr src)
{
  mp_size_t size, abs_size;
  mp_srcptr ptr;
  int cnt;
  mpir_si exp;

  size = SIZ(src);
  if (UNLIKELY (size == 0))
    {
      *exp2 = 0;
      return 0.0;
    }

  ptr = PTR(src);
  abs_size = ABS (size);
  count_leading_zeros (cnt, ptr[abs_size - 1]);
  cnt -= GMP_NAIL_BITS;

  exp = EXP(src) * GMP_NUMB_BITS - cnt;
  *exp2 = exp;

  return mpn_get_d (ptr, abs_size, size,
                    (long) - (abs_size * GMP_NUMB_BITS - cnt));
}
开发者ID:HRF92,项目名称:mpir,代码行数:26,代码来源:get_d_2exp.c

示例6: mpf_div_ui

void
mpf_div_ui (mpf_ptr r, mpf_srcptr u, unsigned long int v)
{
  mp_srcptr up;
  mp_ptr rp, tp, rtp;
  mp_size_t usize;
  mp_size_t rsize, tsize;
  mp_size_t sign_quotient;
  mp_size_t prec;
  mp_limb_t q_limb;
  mp_exp_t rexp;
  TMP_DECL;

#if BITS_PER_ULONG > GMP_NUMB_BITS  /* avoid warnings about shift amount */
  if (v > GMP_NUMB_MAX)
    {
      mpf_t vf;
      mp_limb_t vl[2];
      SIZ(vf) = 2;
      EXP(vf) = 2;
      PTR(vf) = vl;
      vl[0] = v & GMP_NUMB_MASK;
      vl[1] = v >> GMP_NUMB_BITS;
      mpf_div (r, u, vf);
      return;
    }
开发者ID:119,项目名称:aircam-openwrt,代码行数:26,代码来源:div_ui.c

示例7: mpz_tstbit

int
mpz_tstbit (mpz_srcptr u, unsigned long bit_index)
{
  mp_srcptr      u_ptr      = PTR(u);
  mp_size_t      size       = SIZ(u);
  unsigned       abs_size   = ABS(size);
  unsigned long  limb_index = bit_index / GMP_NUMB_BITS;
  mp_srcptr      p          = u_ptr + limb_index;
  mp_limb_t      limb;

  if (limb_index >= abs_size)
    return (size < 0);

  limb = *p;
  if (size < 0)
    {
      limb = -limb;     /* twos complement */

      while (p != u_ptr)
        {
          p--;
          if (*p != 0)
            {
              limb--;   /* make it a ones complement instead */
              break;
            }
        }
    }

  return (limb >> (bit_index % GMP_NUMB_BITS)) & 1;
}
开发者ID:RodneyBates,项目名称:M3Devel,代码行数:31,代码来源:tstbit.c

示例8: WeaponCheat

VOID WeaponCheat ( PLAYERp pp, char *cheat_string )
{
    PLAYERp p;
    short pnum;
    unsigned int i;
    USERp u;
    TRAVERSE_CONNECT ( pnum )
    {
        p = &Player[pnum];
        u = User[p->PlayerSprite];
        
        // ALL WEAPONS
        if ( !SW_SHAREWARE )
        {
            p->WpnFlags = 0xFFFFFFFF;
        }
        
        else
        {
            p->WpnFlags = 0x0000207F;    // Disallows high weapon cheat in shareware
        }
        
        for ( i = 0; i < SIZ ( p->WpnAmmo ); i++ )
        {
            p->WpnAmmo[i] = DamageData[i].max_ammo;
        }
        
        PlayerUpdateWeapon ( p, u->WeaponNum );
    }
}
开发者ID:jmarshall23,项目名称:PolymerNGPublic,代码行数:30,代码来源:cheats.cpp

示例9: set_z

/*
 * Set f to z, choosing the smallest precision for f
 * so that z = f*(2^BPML)*zs*2^(RetVal)
 */
static int
set_z (mpfr_ptr f, mpz_srcptr z, mp_size_t *zs)
{
  mp_limb_t *p;
  mp_size_t s;
  int c;
  mpfr_prec_t pf;

  MPFR_ASSERTD (mpz_sgn (z) != 0);

  /* Remove useless ending 0 */
  for (p = PTR (z), s = *zs = ABS (SIZ (z)) ; *p == 0; p++, s--)
    MPFR_ASSERTD (s >= 0);

  /* Get working precision */
  count_leading_zeros (c, p[s-1]);
  pf = s * GMP_NUMB_BITS - c;
  if (pf < MPFR_PREC_MIN)
    pf = MPFR_PREC_MIN;
  mpfr_init2 (f, pf);

  /* Copy Mantissa */
  if (MPFR_LIKELY (c))
    mpn_lshift (MPFR_MANT (f), p, s, c);
  else
    MPN_COPY (MPFR_MANT (f), p, s);

  MPFR_SET_SIGN (f, mpz_sgn (z));
  MPFR_SET_EXP (f, 0);

  return -c;
}
开发者ID:texlive,项目名称:texlive-source,代码行数:36,代码来源:set_q.c

示例10: mpz_fake_bits

/* Create a fake mpz consisting of just a single 1 bit, with totbits being
   the total number of bits, inclusive of that 1 bit.  */
void
mpz_fake_bits (mpz_ptr z, unsigned long totbits)
{
  static mp_limb_t  n;
  unsigned long     zero_bits, zero_limbs;

  zero_bits = totbits - 1;
  zero_limbs = zero_bits / GMP_NUMB_BITS;
  zero_bits %= GMP_NUMB_BITS;

  SIZ(z) = zero_limbs + 1;
  PTR(z) = (&n) - (SIZ(z) - 1);
  n = CNST_LIMB(1) << zero_bits;

  ASSERT_ALWAYS (mpz_sizeinbase (z, 2) == totbits);
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:18,代码来源:t-sizeinbase.c

示例11: mpq_init

void
mpq_init (mpq_t x)
{
  ALLOC(NUM(x)) = 1;
  PTR(NUM(x)) = __GMP_ALLOCATE_FUNC_LIMBS (1);
  SIZ(NUM(x)) = 0;
  ALLOC(DEN(x)) = 1;
  PTR(DEN(x)) = __GMP_ALLOCATE_FUNC_LIMBS (1);
  PTR(DEN(x))[0] = 1;
  SIZ(DEN(x)) = 1;

#ifdef __CHECKER__
  /* let the low limb look initialized, for the benefit of mpz_get_ui etc */
  PTR(NUM(x))[0] = 0;
#endif
}
开发者ID:AaronNGray,项目名称:texlive-libs,代码行数:16,代码来源:init.c

示例12: mpz_fib2_ui

void
mpz_fib2_ui (mpz_ptr fn, mpz_ptr fnsub1, mpir_ui n)
{
  mp_ptr     fp, f1p;
  mp_size_t  size;

  size = MPN_FIB2_SIZE (n);
  MPZ_REALLOC (fn,     size);
  MPZ_REALLOC (fnsub1, size);
  fp = PTR (fn);
  f1p = PTR (fnsub1);

  size = mpn_fib2_ui (fp, f1p, n);

  SIZ(fn)     = size - (n == 0);
  SIZ(fnsub1) = size - (f1p[size-1] == 0);
}
开发者ID:BrianGladman,项目名称:mpir,代码行数:17,代码来源:fib2_ui.c

示例13: mpres_print

/* this function is useful in debug mode to print residues */
static void
mpres_print (mpres_t x, char* name, mpmod_t n)
{
  mp_size_t m, xn;
  mpres_t t;
  mpres_init(t, n);
  mpz_set_ui(t, 1);
  mpres_mul (t, x, t, n);

  xn = SIZ(t);
  m = ABSIZ(t);
  MPN_NORMALIZE(PTR(t), m);
  SIZ(t) = xn >= 0 ? m : -m;
  gmp_printf ("%s=%Zd\n", name, t);
  SIZ(t) = xn;
  mpres_clear (t, n);
}
开发者ID:CplusHua,项目名称:yafu-setup-package,代码行数:18,代码来源:ellparam_batch.c

示例14: mpz_limbs_finish

void
mpz_limbs_finish (mpz_ptr x, mp_size_t n)
{
  assert (n >= 0);
  MPN_NORMALIZE (PTR(x), n);

  SIZ (x) = n;
}
开发者ID:Distrotech,项目名称:nettle,代码行数:8,代码来源:gmp-glue.c

示例15: mpz_tdiv_r_2exp

void
mpz_tdiv_r_2exp (mpz_ptr res, mpz_srcptr in, mp_bitcnt_t cnt)
{
  mp_size_t in_size = ABSIZ (in);
  mp_size_t res_size;
  mp_size_t limb_cnt = cnt / GMP_NUMB_BITS;
  mp_srcptr in_ptr = PTR (in);

  if (in_size > limb_cnt)
    {
      /* The input operand is (probably) greater than 2**CNT.  */
      mp_limb_t x;

      x = in_ptr[limb_cnt] & (((mp_limb_t) 1 << cnt % GMP_NUMB_BITS) - 1);
      if (x != 0)
	{
	  res_size = limb_cnt + 1;
	  MPZ_REALLOC (res, res_size);

	  PTR (res)[limb_cnt] = x;
	}
      else
	{
	  res_size = limb_cnt;
	  MPN_NORMALIZE (in_ptr, res_size);

	  MPZ_REALLOC (res, res_size);

	  limb_cnt = res_size;
	}
    }
  else
    {
      /* The input operand is smaller than 2**CNT.  We perform a no-op,
	 apart from that we might need to copy IN to RES.  */
      res_size = in_size;
      MPZ_REALLOC (res, res_size);

      limb_cnt = res_size;
    }

  if (res != in)
    MPN_COPY (PTR (res), PTR (in), limb_cnt);
  SIZ (res) = SIZ (in) >= 0 ? res_size : -res_size;
}
开发者ID:AlexeiSheplyakov,项目名称:gmp.pkg,代码行数:45,代码来源:tdiv_r_2exp.c


注:本文中的SIZ函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。