Esempio n. 1
0
CSLbool zerop(Lisp_Object a)
{
    switch ((int)a & TAG_BITS)
    {
    case TAG_FIXNUM:
        return (a == fixnum_of_int(0));
    case TAG_NUMBERS:
        /* #C(r i) must satisfy zerop is r and i both do */
        if (is_complex(a) && zerop(real_part(a)))
            return zerop(imag_part(a));
        else return NO;
    case TAG_SFLOAT:
        /*
         * The code here assumes that the the floating point number zero
         * is represented by a zero bit-pattern... see onep() for a more
         * cautious way of coding things.
         */
        return ((a & 0x7ffffff8) == 0); /* Strip sign bit as well as tags */
    case TAG_BOXFLOAT:
        return (float_of_number(a) == 0.0);
    default:
        return NO;
    }
}
Esempio n. 2
0
cons_t* proc_div(cons_t *p, environment_t *e)
{
  assert_length(p, 2);

  cons_t *a = car(p);
  cons_t *b = cadr(p);

  assert_number(a);
  assert_number(b);

  bool exact = (a->number.exact && b->number.exact);

  if ( zerop(b) )
    raise(runtime_exception(format(
      "Division by zero: %s", sprint(cons(symbol("/"), p)).c_str())));

  if ( type_of(a) == type_of(b) ) {
    if ( integerp(a) ) {
      // division yields integer?
      if ( gcd(a->number.integer, b->number.integer) == 0)
        return integer(a->number.integer / b->number.integer, exact);
      else
        return rational(make_rational(a) /= make_rational(b), exact);
    } else if ( realp(a) )
      return real(a->number.real / b->number.real);
    else if ( rationalp(a) )
      return rational(a->number.rational / b->number.rational, exact);
    else
      raise(runtime_exception(format("Cannot perform division on %s",
        indef_art(to_s(type_of(a))).c_str())));
  }

  bool anyrational = (rationalp(a) || rationalp(b));
  bool anyinteger = (integerp(a) || integerp(b));

  // int/rat or rat/int ==> turn into rational, and not an int
  if ( anyrational && anyinteger )
    return rational(make_rational(a) /= make_rational(b), exact, false);

  // proceed with real division
  return proc_divf(p, e);
}
Esempio n. 3
0
CSLbool onep(Lisp_Object a)
{
    switch ((int)a & TAG_BITS)
    {
    case TAG_FIXNUM:
        return (a == fixnum_of_int(1));
    case TAG_NUMBERS:
        /* #C(r i) must satisfy onep(r) and zerop(i) */
        if (is_complex(a) && onep(real_part(a)))
            return zerop(imag_part(a));
        else return NO;
    case TAG_SFLOAT:
    {   Float_union w;
        w.f = (float)1.0;
        return (a == (w.i & ~(int32_t)0xf) + TAG_SFLOAT);
    }
    case TAG_BOXFLOAT:
        return (float_of_number(a) == 1.0);
    default:
        return NO;
    }
}
Esempio n. 4
0
struct super_block *hpfs_read_super(struct super_block *s,
				    void *options, int silent)
{
	struct hpfs_boot_block *bootblock;
	struct hpfs_super_block *superblock;
	struct hpfs_spare_block *spareblock;
	struct hpfs_dirent *de;
	struct buffer_head *bh0, *bh1, *bh2;
	struct quad_buffer_head qbh;
	dnode_secno root_dno;
	dev_t dev;
	uid_t uid;
	gid_t gid;
	umode_t umask;
	int lowercase;
	int conv;
	int dubious;

	/*
	 * Get the mount options
	 */

	if (!parse_opts(options, &uid, &gid, &umask, &lowercase, &conv)) {
		printk("HPFS: syntax error in mount options.  Not mounted.\n");
		s->s_dev = 0;
		return 0;
	}

	/*
	 * Fill in the super block struct
	 */

	lock_super(s);
	dev = s->s_dev;
	set_blocksize(dev, 512);

	/*
	 * fetch sectors 0, 16, 17
	 */

	bootblock = map_sector(dev, 0, &bh0);
	if (!bootblock)
		goto bail;

	superblock = map_sector(dev, 16, &bh1);
	if (!superblock)
		goto bail0;

	spareblock = map_sector(dev, 17, &bh2);
	if (!spareblock)
		goto bail1;

	/*
	 * Check that this fs looks enough like a known one that we can find
	 * and read the root directory.
	 */

	if (bootblock->magic != 0xaa55
	    || superblock->magic != SB_MAGIC
	    || spareblock->magic != SP_MAGIC
	    || bootblock->sig_28h != 0x28
	    || memcmp(&bootblock->sig_hpfs, "HPFS    ", 8)
	    || little_ushort(bootblock->bytes_per_sector) != 512) {
		printk("HPFS: hpfs_read_super: Not HPFS\n");
		goto bail2;
	}

	/*
	 * Check for inconsistencies -- possibly wrong guesses here, possibly
	 * filesystem problems.
	 */

	dubious = 0;

	dubious |= check_warn(spareblock->dirty != 0,
		       "`Improperly stopped'", "flag is set", "run CHKDSK");
	dubious |= check_warn(spareblock->n_spares_used != 0,
			      "Spare blocks", "may be in use", "run CHKDSK");

	/*
	 * Above errors mean we could get wrong answers if we proceed,
	 * so don't
	 */

	if (dubious)
		goto bail2;

	dubious |= check_warn((spareblock->n_dnode_spares !=
			       spareblock->n_dnode_spares_free),
			      "Spare dnodes", "may be in use", "run CHKDSK");
	dubious |= check_warn(superblock->zero1 != 0,
			      "#1", "unknown word nonzero", "investigate");
	dubious |= check_warn(superblock->zero3 != 0,
			      "#3", "unknown word nonzero", "investigate");
	dubious |= check_warn(superblock->zero4 != 0,
			      "#4", "unknown word nonzero", "investigate");
	dubious |= check_warn(!zerop(superblock->zero5,
				     sizeof superblock->zero5),
			      "#5", "unknown word nonzero", "investigate");
	dubious |= check_warn(!zerop(superblock->zero6,
				     sizeof superblock->zero6),
			      "#6", "unknown word nonzero", "investigate");

	if (dubious)
		printk("HPFS: Proceeding, but operation may be unreliable\n");

	/*
	 * set fs read only
	 */

	s->s_flags |= MS_RDONLY;

	/*
	 * fill in standard stuff
	 */

	s->s_magic = HPFS_SUPER_MAGIC;
	s->s_blocksize = 512;
	s->s_blocksize_bits = 9;
	s->s_op = (struct super_operations *) &hpfs_sops;

	/*
	 * fill in hpfs stuff
	 */

	s->s_hpfs_root = dir_ino(superblock->root);
	s->s_hpfs_fs_size = superblock->n_sectors;
	s->s_hpfs_dirband_size = superblock->n_dir_band / 4;
	s->s_hpfs_dmap = superblock->dir_band_bitmap;
	s->s_hpfs_bitmaps = superblock->bitmaps;
	s->s_hpfs_uid = uid;
	s->s_hpfs_gid = gid;
	s->s_hpfs_mode = 0777 & ~umask;
	s->s_hpfs_n_free = -1;
	s->s_hpfs_n_free_dnodes = -1;
	s->s_hpfs_lowercase = lowercase;
	s->s_hpfs_conv = conv;

	/*
	 * done with the low blocks
	 */

	brelse(bh2);
	brelse(bh1);
	brelse(bh0);

	/*
	 * all set.  try it out.
	 */

	s->s_mounted = iget(s, s->s_hpfs_root);
	unlock_super(s);

	if (!s->s_mounted) {
		printk("HPFS: hpfs_read_super: inode get failed\n");
		s->s_dev = 0;
		return 0;
	}

	/*
	 * find the root directory's . pointer & finish filling in the inode
	 */

	root_dno = fnode_dno(dev, s->s_hpfs_root);
	if (root_dno)
		de = map_dirent(s->s_mounted, root_dno, "\001\001", 2, &qbh);
	if (!root_dno || !de) {
		printk("HPFS: "
		       "hpfs_read_super: root dir isn't in the root dir\n");
		s->s_dev = 0;
		return 0;
	}

	s->s_mounted->i_atime = local_to_gmt(de->read_date);
	s->s_mounted->i_mtime = local_to_gmt(de->write_date);
	s->s_mounted->i_ctime = local_to_gmt(de->creation_date);

	brelse4(&qbh);
	return s;

 bail2:
	brelse(bh2);
 bail1:
	brelse(bh1);
 bail0:
	brelse(bh0);
 bail:
	s->s_dev = 0;
	unlock_super(s);
	return 0;
}
Esempio n. 5
0
static CSLbool numeqic(Lisp_Object a, Lisp_Object b)
{
    if (!zerop(imag_part(b))) return NO;
    else return numeq2(a, real_part(b));
}
Esempio n. 6
0
int CRps::SetSkipFlag()
{
	//3-->全skip
	//1-->部分skip

	D3DXVECTOR3 zerop( 0.0f, 0.0f, 0.0f );

	ZeroMemory( m_skipflag, sizeof( int ) * SKEL_MAX );


	int skno;
	if( (m_pelem + 0 * SKEL_MAX + SKEL_TORSO)->confidence != 1.0f){
		//|| ((m_pelem + 0 * SKEL_MAX + SKEL_TORSO)->pos == zerop) ){

		for( skno = 0; skno < SKEL_MAX; skno++ ){
			m_skipflag[skno] = 3;
		}
		return 0;
	}

	if( ((m_pelem + 0 * SKEL_MAX + SKEL_NECK)->confidence != 1.0f) || 
		((m_pelem + 0 * SKEL_MAX + SKEL_NECK)->pos == zerop) ){
		m_skipflag[SKEL_NECK] = 3;
		m_skipflag[SKEL_HEAD] = 3;
		m_skipflag[SKEL_LEFT_SHOULDER] = 3;
		m_skipflag[SKEL_LEFT_ELBOW] = 3;
		m_skipflag[SKEL_LEFT_HAND] = 3;
		m_skipflag[SKEL_RIGHT_SHOULDER] = 3;
		m_skipflag[SKEL_RIGHT_ELBOW] = 3;
		m_skipflag[SKEL_RIGHT_HAND] = 3;
	}

	if( ((m_pelem + 0 * SKEL_MAX + SKEL_HEAD)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_HEAD)->pos == zerop) ){
		m_skipflag[SKEL_HEAD] = 3;
	}

	if( ((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_HIP)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_HIP)->pos == zerop) ){
		m_skipflag[SKEL_TORSO] |= 1;//!!!!!!!
		m_skipflag[SKEL_LEFT_HIP] = 3;
		m_skipflag[SKEL_LEFT_KNEE] = 3;
		m_skipflag[SKEL_LEFT_FOOT] = 3;
	}
	if( ((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_HIP)->confidence != 1.0f) || 
		((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_HIP)->pos == zerop) ){
		m_skipflag[SKEL_TORSO] |= 1;//!!!!!!!
		m_skipflag[SKEL_RIGHT_HIP] = 3;
		m_skipflag[SKEL_RIGHT_KNEE] = 3;
		m_skipflag[SKEL_RIGHT_FOOT] = 3;
	}

	if( ((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_KNEE)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_KNEE)->pos == zerop) ){
		m_skipflag[SKEL_LEFT_KNEE] = 3;
		m_skipflag[SKEL_LEFT_FOOT] = 3;
	}
	if( ((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_KNEE)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_KNEE)->pos == zerop) ){
		m_skipflag[SKEL_RIGHT_KNEE] = 3;
		m_skipflag[SKEL_RIGHT_FOOT] = 3;
	}

	if( ((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_FOOT)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_FOOT)->pos == zerop) ){
		m_skipflag[SKEL_LEFT_FOOT] = 3;
	}
	if( ((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_FOOT)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_FOOT)->pos == zerop) ){
		m_skipflag[SKEL_RIGHT_FOOT] = 3;
	}


	if( ((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_SHOULDER)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_SHOULDER)->pos == zerop) ){
		//m_skipflag[SKEL_NECK] |= 1;//!!!!!!!!!!!!!!
		m_skipflag[SKEL_NECK] = 3;
		m_skipflag[SKEL_HEAD] = 3;
		m_skipflag[SKEL_LEFT_SHOULDER] = 3;
		m_skipflag[SKEL_LEFT_ELBOW] = 3;
		m_skipflag[SKEL_LEFT_HAND] = 3;
	}
	if( ((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_SHOULDER)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_SHOULDER)->pos == zerop) ){
		//m_skipflag[SKEL_NECK] |= 1;//!!!!!!!!!!!!!!
		m_skipflag[SKEL_NECK] = 3;
		m_skipflag[SKEL_HEAD] = 3;
		m_skipflag[SKEL_RIGHT_SHOULDER] = 3;
		m_skipflag[SKEL_RIGHT_ELBOW] = 3;
		m_skipflag[SKEL_RIGHT_HAND] = 3;
	}

	if( ((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_ELBOW)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_ELBOW)->pos == zerop) ){
		m_skipflag[SKEL_LEFT_ELBOW] = 3;
		m_skipflag[SKEL_LEFT_HAND] = 3;
	}
	if( ((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_ELBOW)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_ELBOW)->pos == zerop) ){
		m_skipflag[SKEL_RIGHT_ELBOW] = 3;
		m_skipflag[SKEL_RIGHT_HAND] = 3;
	}

	if( ((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_HAND)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_LEFT_HAND)->pos == zerop) ){
		m_skipflag[SKEL_LEFT_HAND] = 3;
	}
	if( ((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_HAND)->confidence != 1.0f) ||
		((m_pelem + 0 * SKEL_MAX + SKEL_RIGHT_HAND)->pos == zerop) ){
		m_skipflag[SKEL_RIGHT_HAND] = 3;
	}


	return 0;
}