您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ vget函数代码示例

51自学网 2021-06-03 09:39:25
  C++
这篇教程C++ vget函数代码示例写得很实用,希望能帮到您。

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

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

示例1: s5fs_lookup

/* * s5fs_lookup: * s5fs_lookup sets *result to the vnode in dir with the specified name. * param *base: the vnode object of the base directory * param *name: name string * param namelen: the length of the name * param **result: *result points to the vnode in dir with the specified name * return: 0 on success; negative number on a variety of errors */ints5fs_lookup(vnode_t *base, const char *name, size_t namelen, vnode_t **result){    dbg(DBG_S5FS, "{/n");        KASSERT(base != NULL);    KASSERT(name != NULL);    KASSERT(namelen <= S5_NAME_LEN-1);        kmutex_lock(&base->vn_mutex);        int inode_number = 0;    if ((inode_number = s5_find_dirent(base, name, namelen)) < 0)    {        kmutex_unlock(&base->vn_mutex);        return inode_number;    }    /* May block here */    /* No modification, no need to lock */    *result = vget(base->vn_fs, inode_number);        kmutex_unlock(&base->vn_mutex);        dbg(DBG_S5FS, "}/n");    return 0;}
开发者ID:lygood2008,项目名称:CodingSample,代码行数:35,


示例2: fileerror

voidfileerror(ino_t cwd, ino_t ino, const char *errmesg){	char pathbuf[MAXPATHLEN + 1];	struct uvnode *vp;	pwarn("%s ", errmesg);	pinode(ino);	printf("/n");	pwarn("PARENT=%lld/n", (long long)cwd);	getpathname(pathbuf, sizeof(pathbuf), cwd, ino);	if (ino < ULFS_ROOTINO || ino >= maxino) {		pfatal("NAME=%s/n", pathbuf);		return;	}	vp = vget(fs, ino);	if (vp == NULL)		pfatal("INO is NULL/n");	else {		if (ftypeok(VTOD(vp)))			pfatal("%s=%s/n",			    (lfs_dino_getmode(fs, VTOI(vp)->i_din) & LFS_IFMT) == LFS_IFDIR ?			    "DIR" : "FILE", pathbuf);		else			pfatal("NAME=%s/n", pathbuf);	}}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:27,


示例3: DPMHC_u_smplr

int DPMHC_u_smplr(struct str_DPMHC *ptr_DPMHC_data){    gsl_vector_int *vi_S = ptr_DPMHC_data->vi_S;    gsl_vector *v_w = ptr_DPMHC_data->v_w;    gsl_vector *v_u = ptr_DPMHC_data->v_u;    size_t i_T = vi_S->size;    int i,i_si;    double d_ui,d_w_si;    for(i=0;i<i_T;i++){        i_si = vget_int( vi_S, i);        d_w_si = vget( v_w, i_si);        dw:            d_ui = d_w_si * gsl_rng_uniform (rng);            if( d_ui == 0.0 ){            printf("/n/n ******** u_i = 0.0 /n");            goto dw;            }        vset( v_u, i, d_ui);    }    return 0;}
开发者ID:econmj,项目名称:firm_DPMHC,代码行数:26,


示例4: quantiles

VEC quantiles ( const VEC v, const VEC q){	assert(NULL!=q);	assert(NULL!=v);	VEC quant = create_vec(vlen(q));	assert(NULL!=quant);	VEC vcopy = copy_vec(v);	qsort (vcopy->x,vlen(vcopy),sizeof(double),CmpDouble);	for ( unsigned int i=0; i<vlen(q) ; i++){		assert(vget(q,i)>=0. && vget(q,i)<=1.);		vset(quant,i,quantile_fromsorted(vcopy,vget(q,i)));	}	free_vec(vcopy);	return quant;}
开发者ID:timmassingham,项目名称:SLR,代码行数:16,


示例5: msdosfs_sync_vnode

intmsdosfs_sync_vnode(struct vnode *vp, void *arg){    struct msdosfs_sync_arg *msa = arg;    int error;    struct denode *dep;    dep = VTODE(vp);    if (vp->v_type == VNON ||            ((dep->de_flag & (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0             && LIST_EMPTY(&vp->v_dirtyblkhd)) ||            msa->waitfor == MNT_LAZY) {        return (0);    }    if (vget(vp, LK_EXCLUSIVE | LK_NOWAIT, msa->p))        return (0);    if ((error = VOP_FSYNC(vp, msa->cred, msa->waitfor, msa->p)) != 0)        msa->allerror = error;    VOP_UNLOCK(vp, 0, msa->p);    vrele(vp);    return (0);}
开发者ID:7shi,项目名称:openbsd-loongson-vc,代码行数:25,


示例6: argmax

int argmax(gsl_vector *v){    int argmax = 0;    double max = vget(v, 0);    int i;    for (i = 1; i < v->size; i++)    {        double val = vget(v, i);        if (val > max)        {            argmax = i;            max    = val;        }    }    return(argmax);}
开发者ID:cran,项目名称:topicmodels,代码行数:16,


示例7: vfs_mount

int vfs_mount(struct vnode *node, int fsnum, u32 dev, u32 flags){    ASSERT(V_ISDIR(node->v_flags));    ASSERT(fstypes[fsnum].vfs_ops);    ASSERT(node->v_count == 1);    struct vfs *new_vfs = create_empty_vfs(fsnum);    struct vnode *new_root = create_empty_vnode(new_vfs);    new_vfs->vfs_flags = flags;    new_vfs->vfs_dev = dev;    new_vfs->v_root = new_root;    new_root->v_name[0] = '/';    new_root->v_flags = V_DIR;    int ret = fstypes[fsnum].vfs_ops->vfs_mount(new_vfs);    if (!ret)    {        btree_insert(node->v_vfs->vfs_mounts, (void*) node->v_inode, new_vfs);        vget(new_root);    }    return ret;}
开发者ID:helgefmi,项目名称:termos,代码行数:26,


示例8: calculate_refcounts

static voidcalculate_refcounts(int *counts, vnode_t *vnode){        int ret;        counts[vnode->vn_vno]++;        dbg(DBG_S5FS, "calculate_refcounts: Incrementing count of inode %d to"            " %d/n", vnode->vn_vno, counts[vnode->vn_vno]);        /*         * We only consider the children of this directory if this is the         * first time we have seen it.  Otherwise, we would recurse forever.         */        if (counts[vnode->vn_vno] == 1 && S_ISDIR(vnode->vn_mode)) {                int offset = 0;                struct dirent d;                vnode_t *child;                while (0 < (ret = s5fs_readdir(vnode, offset, &d))) {                        /*                         * We don't count '.', because we don't increment the                         * refcount for this (an empty directory only has a                         * link count of 1).                         */                        if (0 != strcmp(d.d_name, ".")) {                                child = vget(vnode->vn_fs, d.d_ino);                                calculate_refcounts(counts, child);                                vput(child);                        }                        offset += ret;                }                KASSERT(ret == 0);        }}
开发者ID:lygood2007,项目名称:Weenix,代码行数:34,


示例9: vprint

void vprint(const gsl_vector * v){    int i;    for (i = 0; i < v->size; i++)	Rprintf("%5.5f ", vget(v, i));    Rprintf("/n/n");}
开发者ID:cran,项目名称:topicmodels,代码行数:7,


示例10: nwfs_sync

/* ARGSUSED */static intnwfs_sync(struct mount *mp, int waitfor){	struct vnode *vp;	int error, allerror = 0;	/*	 * Force stale buffer cache information to be flushed.	 */loop:	for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist);	     vp != NULL;	     vp = TAILQ_NEXT(vp, v_nmntvnodes)) {		/*		 * If the vnode that we are about to sync is no longer		 * associated with this mount point, start over.		 */		if (vp->v_mount != mp)			goto loop;		if (vn_islocked(vp) || RB_EMPTY(&vp->v_rbdirty_tree) ||		    (waitfor & MNT_LAZY))			continue;		if (vget(vp, LK_EXCLUSIVE))			goto loop;		/* XXX vp may not be retained */		error = VOP_FSYNC(vp, waitfor, 0);		if (error)			allerror = error;		vput(vp);	}	return (allerror);}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:32,


示例11: lda_m_step

double lda_m_step(lda* model, lda_suff_stats* ss) {    int k, w;    double lhood = 0;    for (k = 0; k < model->ntopics; k++)    {        gsl_vector ss_k = gsl_matrix_column(ss->topics_ss, k).vector;        gsl_vector log_p = gsl_matrix_column(model->topics, k).vector;        if (LDA_USE_VAR_BAYES == 0)        {            gsl_blas_dcopy(&ss_k, &log_p);            normalize(&log_p);            vct_log(&log_p);        }        else        {            double digsum = sum(&ss_k)+model->nterms*LDA_TOPIC_DIR_PARAM;            digsum = gsl_sf_psi(digsum);            double param_sum = 0;            for (w = 0; w < model->nterms; w++)            {                double param = vget(&ss_k, w) + LDA_TOPIC_DIR_PARAM;                param_sum += param;                double elogprob = gsl_sf_psi(param) - digsum;                vset(&log_p, w, elogprob);                lhood += (LDA_TOPIC_DIR_PARAM - param) * elogprob + gsl_sf_lngamma(param);            }            lhood -= gsl_sf_lngamma(param_sum);        }    }    return(lhood);}
开发者ID:RichardeJiang,项目名称:dtm,代码行数:31,


示例12: ptyfs_used_get

struct vnode *ptyfs_used_get(ptyfstype type, int pty, struct mount *mp, int flags){	struct ptyfs_hashhead *ppp;	struct ptyfsnode *pp;	struct vnode *vp;loop:	mutex_enter(&ptyfs_used_slock);	ppp = &ptyfs_used_tbl[PTYHASH(type, pty, ptyfs_used_mask)];	LIST_FOREACH(pp, ppp, ptyfs_hash) {		vp = PTYFSTOV(pp);		if (pty == pp->ptyfs_pty && pp->ptyfs_type == type &&		    vp->v_mount == mp) {		    	if (flags == 0) {				mutex_exit(&ptyfs_used_slock);			} else {				mutex_enter(vp->v_interlock);				mutex_exit(&ptyfs_used_slock);				if (vget(vp, flags))					goto loop;			}			return vp;		}	}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:25,


示例13: vop_compat_nresolve

/* * vop_compat_resolve { struct nchandle *a_nch, struct vnode *dvp } * XXX STOPGAP FUNCTION * * XXX OLD API ROUTINE!  WHEN ALL VFSs HAVE BEEN CLEANED UP THIS PROCEDURE * WILL BE REMOVED.  This procedure exists for all VFSs which have not * yet implemented VOP_NRESOLVE().  It converts VOP_NRESOLVE() into a  * vop_old_lookup() and does appropriate translations. * * Resolve a ncp for VFSs which do not support the VOP.  Eventually all * VFSs will support this VOP and this routine can be removed, since * VOP_NRESOLVE() is far less complex then the older LOOKUP/CACHEDLOOKUP * API. * * A locked ncp is passed in to be resolved.  The NCP is resolved by * figuring out the vnode (if any) and calling cache_setvp() to attach the * vnode to the entry.  If the entry represents a non-existant node then * cache_setvp() is called with a NULL vnode to resolve the entry into a * negative cache entry.  No vnode locks are retained and the * ncp is left locked on return. * * The ncp will NEVER represent "", "." or "..", or contain any slashes. * * There is a potential directory and vnode interlock.   The lock order * requirement is: namecache, governing directory, resolved vnode. */intvop_compat_nresolve(struct vop_nresolve_args *ap){	int error;	struct vnode *dvp;	struct vnode *vp;	struct nchandle *nch;	struct namecache *ncp;	struct componentname cnp;	nch = ap->a_nch;	/* locked namecache node */	ncp = nch->ncp;	dvp = ap->a_dvp;	/*	 * UFS currently stores all sorts of side effects, including a loop	 * variable, in the directory inode.  That needs to be fixed and the	 * other VFS's audited before we can switch to LK_SHARED.	 */	if ((error = vget(dvp, LK_EXCLUSIVE)) != 0) {		kprintf("[diagnostic] vop_compat_resolve: EAGAIN on ncp %p %s/n",			ncp, ncp->nc_name);		return(EAGAIN);	}	bzero(&cnp, sizeof(cnp));	cnp.cn_nameiop = NAMEI_LOOKUP;	cnp.cn_flags = 0;	cnp.cn_nameptr = ncp->nc_name;	cnp.cn_namelen = ncp->nc_nlen;	cnp.cn_cred = ap->a_cred;	cnp.cn_td = curthread; /* XXX */	/*	 * vop_old_lookup() always returns vp locked.  dvp may or may not be	 * left locked depending on CNP_PDIRUNLOCK.	 */	error = vop_old_lookup(ap->a_head.a_ops, dvp, &vp, &cnp);	if (error == 0)		vn_unlock(vp);	if ((cnp.cn_flags & CNP_PDIRUNLOCK) == 0)		vn_unlock(dvp);	if ((ncp->nc_flag & NCF_UNRESOLVED) == 0) {		/* was resolved by another process while we were unlocked */		if (error == 0)			vrele(vp);	} else if (error == 0) {		KKASSERT(vp != NULL);		cache_setvp(nch, vp);		vrele(vp);	} else if (error == ENOENT) {		KKASSERT(vp == NULL);		if (cnp.cn_flags & CNP_ISWHITEOUT)			ncp->nc_flag |= NCF_WHITEOUT;		cache_setvp(nch, NULL);	}	vrele(dvp);	return (error);}
开发者ID:madhavsuresh,项目名称:DragonFlyBSD,代码行数:85,


示例14: s5_remove_dirent

/* * Locate the directory entry in the given inode with the given name, * and delete it. If there is no entry with the given name, return * -ENOENT. * * In order to ensure that the directory entries are contiguous in the * directory file, you will need to move the last directory entry into * the remove dirent's place. * * When this function returns, the inode refcount on the removed file * should be decremented. * * It would be a nice extension to free blocks from the end of the * directory file which are no longer needed. * * Don't forget to dirty appropriate blocks! * * You probably want to use vget(), vput(), s5_read_file(), * s5_write_file(), and s5_dirty_inode(). */ints5_remove_dirent(vnode_t *vnode, const char *name, size_t namelen){    dbg_print("s5_remove_dirent: Removing Dirent");    int inode = s5_find_dirent(vnode,name,namelen);    if(inode == -ENOENT)    {        dbg_print("s5_remove_dirent: ERROR, Directory not found");        return -ENOENT;    }    else    {        vnode_t* vnode_to_remove = vget(vnode->vn_fs,inode);        s5_inode_t* inode_to_remove = VNODE_TO_S5INODE(vnode_to_remove);        inode_to_remove->s5_linkcount--;        vput(vnode_to_remove);        /* Need to get the offset of where the dirent is */        int total_count = 0;        int dir_index = 0;        /* Loop through the inode blocks until the dirent is found. */        s5_dirent_t traverse_dir;        while (s5_read_file(vnode, dir_index * sizeof(s5_dirent_t), (char *) &traverse_dir, sizeof(s5_dirent_t)) > 0)        {            /* Once found, return. */            if (name_match(traverse_dir.s5d_name, name, namelen))            {                dir_index = total_count;            }            total_count++;        }        total_count--;        if(dir_index != total_count)        {            /* swap dir with last */            char* last_buffer = kmalloc(sizeof(s5_dirent_t));            s5_dirent_t* dirent = (s5_dirent_t*)last_buffer;            int read = s5_read_file(vnode,vnode->vn_len - sizeof(s5_dirent_t),last_buffer,sizeof(s5_dirent_t));            KASSERT(read == sizeof(s5_dirent_t));            int write = s5_write_file(vnode, dir_index * sizeof(s5_dirent_t), last_buffer, sizeof(s5_dirent_t));            KASSERT(write == sizeof(s5_dirent_t));        }        s5_inode_t* inode = VNODE_TO_S5INODE(vnode);        vnode->vn_len -= sizeof(s5_dirent_t);        inode->s5_size -= sizeof(s5_dirent_t);        s5_dirty_inode(VNODE_TO_S5FS(vnode),inode);        return 0;    }        /* NOT_YET_IMPLEMENTED("S5FS: s5_remove_dirent");        * return -1;        */}
开发者ID:jonwchu,项目名称:OS-VirtualFileSystem,代码行数:79,


示例15: fdesc_allocvp

intfdesc_allocvp(fdntype ftype, int ix, struct mount *mp, struct vnode **vpp){	struct fdhashhead *fc;	struct fdescnode *fd;	int error = 0;	fc = FD_NHASH(ix);loop:	LIST_FOREACH(fd, fc, fd_hash) {		if (fd->fd_ix == ix && fd->fd_vnode->v_mount == mp) {			if (vget(fd->fd_vnode, LK_EXCLUSIVE|LK_SLEEPFAIL))				goto loop;			*vpp = fd->fd_vnode;			return (error);		}	}	/*	 * otherwise lock the array while we call getnewvnode	 * since that can block.	 */	if (fdcache_lock & FDL_LOCKED) {		fdcache_lock |= FDL_WANT;		tsleep((caddr_t) &fdcache_lock, 0, "fdalvp", 0);		goto loop;	}	fdcache_lock |= FDL_LOCKED;	/*	 * Do the MALLOC before the getnewvnode since doing so afterward	 * might cause a bogus v_data pointer to get dereferenced	 * elsewhere if MALLOC should block.	 */	fd = kmalloc(sizeof(struct fdescnode), M_TEMP, M_WAITOK);	error = getnewvnode(VT_FDESC, mp, vpp, 0, 0);	if (error) {		kfree(fd, M_TEMP);		goto out;	}	(*vpp)->v_data = fd;	fd->fd_vnode = *vpp;	fd->fd_type = ftype;	fd->fd_fd = -1;	fd->fd_ix = ix;	LIST_INSERT_HEAD(fc, fd, fd_hash);	vx_unlock(*vpp);out:	fdcache_lock &= ~FDL_LOCKED;	if (fdcache_lock & FDL_WANT) {		fdcache_lock &= ~FDL_WANT;		wakeup((caddr_t) &fdcache_lock);	}	return (error);}
开发者ID:Gwenio,项目名称:DragonFlyBSD,代码行数:59,


示例16: puffs_vnop_remove

/* * XXX: can't use callremove now because can't catch setbacks with * it due to lack of a pnode argument. */static intpuffs_vnop_remove(struct vop_nremove_args *ap){    PUFFS_MSG_VARS(vn, remove);    struct vnode *dvp = ap->a_dvp;    struct vnode *vp;    struct puffs_node *dpn = VPTOPP(dvp);    struct puffs_node *pn;    struct nchandle *nch = ap->a_nch;    struct namecache *ncp = nch->ncp;    struct ucred *cred = ap->a_cred;    struct mount *mp = dvp->v_mount;    struct puffs_mount *pmp = MPTOPUFFSMP(mp);    int error;    if (!EXISTSOP(pmp, REMOVE))        return EOPNOTSUPP;    error = vget(dvp, LK_EXCLUSIVE);    if (error != 0) {        DPRINTF(("puffs_vnop_remove: EAGAIN on parent vnode %p %s/n",                 dvp, ncp->nc_name));        return EAGAIN;    }    error = cache_vget(nch, cred, LK_EXCLUSIVE, &vp);    if (error != 0) {        DPRINTF(("puffs_vnop_remove: cache_vget error: %p %s/n",                 dvp, ncp->nc_name));        return EAGAIN;    }    if (vp->v_type == VDIR) {        error = EISDIR;        goto out;    }    pn = VPTOPP(vp);    PUFFS_MSG_ALLOC(vn, remove);    remove_msg->pvnr_cookie_targ = VPTOPNC(vp);    puffs_makecn(&remove_msg->pvnr_cn, &remove_msg->pvnr_cn_cred,                 ncp, cred);    puffs_msg_setinfo(park_remove, PUFFSOP_VN,                      PUFFS_VN_REMOVE, VPTOPNC(dvp));    puffs_msg_enqueue(pmp, park_remove);    error = puffs_msg_wait2(pmp, park_remove, dpn, pn);    PUFFS_MSG_RELEASE(remove);    error = checkerr(pmp, error, __func__);out:    vput(dvp);    vn_unlock(vp);    if (error == 0)        cache_unlink(nch);    vrele(vp);    return error;}
开发者ID:wan721,项目名称:DragonFlyBSD,代码行数:63,


示例17: vfprint

void vfprint(const gsl_vector * v, FILE * f){    int i;    for (i = 0; i < v->size; i++)	fprintf(f, "%5.5f ", vget(v, i));    fprintf(f, "/n");    fflush(f);}
开发者ID:cran,项目名称:topicmodels,代码行数:8,


示例18: normalize

void normalize(gsl_vector* v){    int size = v->size;    double sum_v = sum(v);    int i;    for (i = 0; i < size; i++)        vset(v, i, vget(v,i)/sum_v);}
开发者ID:cran,项目名称:topicmodels,代码行数:8,


示例19: into2int

object_t *vget_check (object_t * vo, object_t * io){  int i = into2int (io);  vector_t *v = OVAL (vo);  if (i < 0 || i >= (int) v->len)    THROW (out_of_bounds, UPREF (io));  return UPREF (vget (vo, i));}
开发者ID:qyqx,项目名称:wisp,代码行数:8,


示例20: center

void center(gsl_vector* v){    int size = v->size;    double mean = sum(v)/size;    int i;    for (i = 0; i < size; i++)        vset(v, i, vget(v,i)-mean);}
开发者ID:cran,项目名称:topicmodels,代码行数:8,


示例21: DPMHC_mu_smplr

int DPMHC_mu_smplr(struct str_DPMHC *ptr_DPMHC_data){    int i,j;    int i_n = ptr_DPMHC_data->v_y->size;    int i_K = ptr_DPMHC_data->i_K;    int i_nj;    double d_muj,d_s2j,d_yhatj;    double d_xij,d_tauj;    double d_m0 = ptr_DPMHC_data->d_m0;    double d_s2m = ptr_DPMHC_data->d_s2m;   gsl_vector *v_y = ptr_DPMHC_data->v_y;   gsl_vector_int *vi_S = ptr_DPMHC_data->vi_S;   gsl_vector_int *vi_n = ptr_DPMHC_data->vi_n;   gsl_matrix *m_theta = ptr_DPMHC_data->m_DPtheta; //  printf("/ni_K = %d/n",i_K);   for(j=0;j<i_K;j++){        d_yhatj = 0.;        i_nj = 0;        for(i=0;i<i_n;i++){            if( vget_int(vi_S,i) == j ){                d_yhatj += vget(v_y,i);                i_nj++;            }        }        if (vget_int(vi_n,j) != i_nj){            fprintf(stderr,"Error in  DPMN_theta_polya_smplr(): vi_n[%d] does not equal i_nj/n", j);            exit(1);        }        d_xij = mget(m_theta,j,1);        d_tauj = mget(m_theta,j,2);        d_yhatj /= (d_xij * d_xij / d_tauj);        d_s2j = 1./( 1./d_s2m + i_nj/ (d_xij * d_xij / d_tauj) );        d_muj = d_s2j * ( d_m0/d_s2m + d_yhatj );        d_muj = d_muj + gsl_ran_gaussian_ziggurat(rng, sqrt(d_s2j));        mset(m_theta,j,0, d_muj);       // printf("%d: eta = %g lambda^2 = %g/n",j, mget(m_theta,j,0), mget(m_theta,j,1) );     }    return 0;}
开发者ID:econmj,项目名称:firm_DPMHC,代码行数:57,


示例22: puffs_vnop_mknod

static intpuffs_vnop_mknod(struct vop_nmknod_args *ap){    PUFFS_MSG_VARS(vn, mknod);    struct vnode *dvp = ap->a_dvp;    struct vattr *vap = ap->a_vap;    struct puffs_node *dpn = VPTOPP(dvp);    struct nchandle *nch = ap->a_nch;    struct namecache *ncp = nch->ncp;    struct ucred *cred = ap->a_cred;    struct mount *mp = dvp->v_mount;    struct puffs_mount *pmp = MPTOPUFFSMP(mp);    int error;    if (!EXISTSOP(pmp, MKNOD))        return EOPNOTSUPP;    DPRINTF(("puffs_mknod: dvp %p, name: %s/n",             dvp, ncp->nc_name));    if (vap->va_type != VFIFO)        return EINVAL;    if ((error = vget(dvp, LK_EXCLUSIVE)) != 0) {        DPRINTF(("puffs_vnop_mknod: EAGAIN on ncp %p %s/n",                 ncp, ncp->nc_name));        return EAGAIN;    }    PUFFS_MSG_ALLOC(vn, mknod);    puffs_makecn(&mknod_msg->pvnr_cn, &mknod_msg->pvnr_cn_cred,                 ncp, cred);    mknod_msg->pvnr_va = *ap->a_vap;    puffs_msg_setinfo(park_mknod, PUFFSOP_VN,                      PUFFS_VN_MKNOD, VPTOPNC(dvp));    PUFFS_MSG_ENQUEUEWAIT2(pmp, park_mknod, dvp->v_data, NULL, error);    error = checkerr(pmp, error, __func__);    if (error)        goto out;    error = puffs_newnode(mp, dvp, ap->a_vpp,                          mknod_msg->pvnr_newnode, vap->va_type);    if (error)        puffs_abortbutton(pmp, PUFFS_ABORT_MKNOD, dpn->pn_cookie,                          mknod_msg->pvnr_newnode, ncp, cred);out:    vput(dvp);    if (!error) {        cache_setunresolved(nch);        cache_setvp(nch, *ap->a_vpp);    }    PUFFS_MSG_RELEASE(mknod);    return error;}
开发者ID:wan721,项目名称:DragonFlyBSD,代码行数:57,


示例23: s5fs_mount

/* * Read fs->fs_dev and set fs_op, fs_root, and fs_i. * * Point fs->fs_i to an s5fs_t*, and initialize it.  Be sure to * verify the superblock (using s5_check_super()).  Use vget() to get * the root vnode for fs_root. * * Return 0 on success, negative on failure. */ints5fs_mount(struct fs *fs){        int num;        blockdev_t *dev;        s5fs_t *s5;        pframe_t *vp;        KASSERT(fs);        if (sscanf(fs->fs_dev, "disk%d", &num) != 1) {                return -EINVAL;        }        if (!(dev = blockdev_lookup(MKDEVID(1, num)))) {                return -EINVAL;        }        /* allocate and initialize an s5fs_t: */        s5 = (s5fs_t *)kmalloc(sizeof(s5fs_t));        if (!s5)                return -ENOMEM;        /*     init s5f_disk: */        s5->s5f_bdev  = dev;        /*     init s5f_super: */        pframe_get(S5FS_TO_VMOBJ(s5), S5_SUPER_BLOCK, &vp);        KASSERT(vp);        s5->s5f_super = (s5_super_t *)(vp->pf_addr);        if (s5_check_super(s5->s5f_super)) {                /* corrupt */                kfree(s5);                return -EINVAL;        }        pframe_pin(vp);        /*     init s5f_mutex: */        kmutex_init(&s5->s5f_mutex);        /*     init s5f_fs: */        s5->s5f_fs = fs;        /* Init the members of fs that we (the fs-implementation) are         * responsible for initializing: */        fs->fs_i = s5;        fs->fs_op = &s5fs_fsops;        fs->fs_root = vget(fs, s5->s5f_super->s5s_root_inode);        return 0;}
开发者ID:ChenyangBai,项目名称:Kernel01,代码行数:66,


示例24: gsl_vector_alloc

double c_ctr::doc_inference(const c_document* doc, const gsl_vector* theta_v,                             const gsl_matrix* log_beta, gsl_matrix* phi,                            gsl_vector* gamma, gsl_matrix* word_ss,                             bool update_word_ss) {  double pseudo_count = 1.0;  double likelihood = 0;  gsl_vector* log_theta_v = gsl_vector_alloc(theta_v->size);  gsl_vector_memcpy(log_theta_v, theta_v);  vct_log(log_theta_v);  int n, k, w;  double x;  for (n = 0; n < doc->m_length; n ++) {    w = doc->m_words[n];     for (k = 0; k < m_num_factors; k ++)      mset(phi, n, k, vget(theta_v, k) * mget(m_beta, k, w));    gsl_vector_view row =  gsl_matrix_row(phi, n);    vnormalize(&row.vector);    for (k = 0; k < m_num_factors; k ++) {      x = mget(phi, n, k);      if (x > 0)         likelihood += x*(vget(log_theta_v, k) + mget(log_beta, k, w) - log(x));    }  }  if (pseudo_count > 0) {    likelihood += pseudo_count * vsum(log_theta_v);  }  gsl_vector_set_all(gamma, pseudo_count); // smoothing with small pseudo counts  for (n = 0; n < doc->m_length; n ++) {    for (k = 0; k < m_num_factors; k ++) {      x = doc->m_counts[n] * mget(phi, n, k);      vinc(gamma, k, x);            if (update_word_ss) minc(word_ss, k, doc->m_words[n], x);    }  }  gsl_vector_free(log_theta_v);  return likelihood;}
开发者ID:anukat2015,项目名称:ctr,代码行数:44,



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


C++ vgettext函数代码示例
C++ vgacon_text_force函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。