int Eqv (Object x1, Object x2) { register int t1, t2; if (EQ(x1, x2)) return 1; t1 = TYPE(x1); t2 = TYPE(x2); if (Numeric (t1) && Numeric (t2)) { /* r4rs 6.2 states that (eqv? 1 1.0) ==> #f */ if((t1 == T_Flonum && t2 != T_Flonum) || (t1 != T_Flonum && t2 == T_Flonum)) return 0; return Generic_Equal (x1, x2); } if (t1 != t2) return 0; switch (t1) { case T_String: return STRING(x1)->size == 0 && STRING(x2)->size == 0; case T_Vector: return VECTOR(x1)->size == 0 && VECTOR(x2)->size == 0; case T_Primitive: return strcmp (PRIM(x1)->name, PRIM(x2)->name) == 0; default: if (t1 < 0 || t1 >= Num_Types) Panic ("bad type in eqv"); if (Types[t1].eqv == NOFUNC) return 0; return (Types[t1].eqv)(x1, x2); } /*NOTREACHED*/ }
static GC _bottomShadowGC(XmLabelWidget _label) { XGCValues gcValues; XtGCMask mask; XFontStruct *fs; mask = GCForeground | GCBackground; gcValues.foreground = PRIM(_label).bottom_shadow_color; gcValues.background = PRIM(_label).foreground; if ((PRIM(_label).bottom_shadow_pixmap != None) && (PRIM(_label).bottom_shadow_pixmap != XmUNSPECIFIED_PIXMAP)) { mask |= GCFillStyle | GCTile; gcValues.fill_style = FillTiled; gcValues.tile = PRIM(_label).bottom_shadow_pixmap; } _XmFontListGetDefaultFont(LABEL(_label).font, &fs); if (fs != 0) { mask |= GCFont; gcValues.font = fs->fid; } return XtGetGC ((Widget)_label, mask, &gcValues); }
void init_env(struct lisp0_state*state){ setenv(state,5,"macro", PRIM(MACRO)); setenv(state,6,"lambda", PRIM(LAMBDA)); setenv(state,5,"label", PRIM(LABEL)); setenv(state,4,"cons", PRIM(CONS)); setenv(state,3,"cdr", PRIM(CDR)); setenv(state,3,"car", PRIM(CAR)); setenv(state,4,"cond", PRIM(COND)); setenv(state,2,"eq", PRIM(EQ)); setenv(state,4,"atom", PRIM(ATOM)); setenv(state,5,"quote", PRIM(QUOTE)); }
void main() { int M[MAXIMO][MAXIMO],T[MAXIMO][MAXIMO]; int suma, marcas[MAXIMO],padres[MAXIMO],minimo [MAXIMO]; int nv,i; int PRIM (int M[][MAXIMO], int N,int minimo[],int padres[],int marcas[]); int lea_grafo (int grafo[][MAXIMO]); void listar_g (int g[][MAXIMO], int nv); void listar_r (int a[],int nv); nv = lea_grafo (M); listar_g (M ,nv); SALTO; getch(); suma = PRIM (M,nv,minimo,padres,marcas); printf ("\n suma=%d\n",suma); SALTO; listar_r (minimo,nv); SALTO; SALTO; listar_r (padres,nv); SALTO; listar_r (marcas,nv); SALTO; getch(); }
LakeVal *apply(LakeCtx *ctx, LakeVal *fnVal, LakeList *args) { LakeVal *result = NULL; if (lake_is_type(TYPE_PRIM, fnVal)) { LakePrimitive *prim = PRIM(fnVal); int arity = prim->arity; if (arity == ARITY_VARARGS || LIST_N(args) == arity) { result = prim->fn(ctx, args); } else { ERR("%s expects %d params but got %zu", prim->name, arity, LIST_N(args)); result = NULL; } } else if (lake_is_type(TYPE_FN, fnVal)) { LakeFn *fn = FN(fnVal); /* Check # of params */ size_t nparams = LIST_N(fn->params); if (!fn->varargs && LIST_N(args) != nparams) { ERR("expected %zu params but got %zu", nparams, LIST_N(args)); return NULL; } else if (fn->varargs && LIST_N(args) < nparams) { ERR("expected at least %zu params but got %zu", nparams, LIST_N(args)); return NULL; } Env *env = env_make(fn->closure); /* bind each (param,arg) pair in env */ size_t i; for (i = 0; i < nparams; ++i) { env_define(env, SYM(LIST_VAL(fn->params, i)), LIST_VAL(args, i)); } /* bind varargs */ if (fn->varargs) { LakeList *remainingArgs = list_make_with_capacity(LIST_N(args) - nparams); for (; i < LIST_N(args); ++i) { list_append(remainingArgs, LIST_VAL(args, i)); } env_define(env, fn->varargs, VAL(remainingArgs)); } /* evaluate body */ result = eval_exprs1(ctx, env, fn->body); } else { ERR("not a function: %s", lake_repr(fnVal)); } return result; }
int main() { int i; CreateMatrix(); printf("The number of vertices is %d\n\n",NrOfVertices); printf("The adjacency matrix is:\n"); PrintMatrix(); char FirstVertex; //the vertex from where the minimum spanning tree begins printf("\nInput the vertex from which you want to start the Minimum Spanning Tree\n"); scanf("%c",&FirstVertex); //printf("%c\n",FirstVertex); int position; //to obtain the position of the FirstVertex from the vector they are stored for(i=0;i<NrOfVertices;i++) if(FirstVertex==vertices[i]) {position=i; break;} PRIM(position); return 0; }
OP_ERROR SOP_PointsFromVoxels::cookMySop(OP_Context &context) { bool cull, store; fpreal now, value; int rx, ry, rz; unsigned primnum; GA_Offset ptOff; GA_ROAttributeRef input_attr_gah; GA_RWAttributeRef attr_gah; GA_ROHandleS input_attr_h; GA_RWHandleF attr_h; const GU_Detail *input_geo; const GEO_Primitive *prim; const GEO_PrimVolume *vol; UT_String attr_name; UT_Vector3 pos; UT_VoxelArrayIteratorF vit; now = context.getTime(); if (lockInputs(context) >= UT_ERROR_ABORT) { return error(); } // Get the primitive number. primnum = PRIM(now); // Check for culling. cull = CULL(now); store = STORE(now); // Clear out the detail since we only want our new points. gdp->clearAndDestroy(); // Get the input geometry as read only. GU_DetailHandleAutoReadLock gdl(inputGeoHandle(0)); input_geo = gdl.getGdp(); // Primitive number is valid. if (primnum < input_geo->getNumPrimitives()) { // Get the primitive we need. prim = input_geo->primitives()(primnum); // The primitive is a volume primitive. if (prim->getTypeId().get() == GEO_PRIMVOLUME) { // Get the actual PrimVolume. vol = (const GEO_PrimVolume *)prim; // Get a voxel read handle from the primitive. UT_VoxelArrayReadHandleF vox(vol->getVoxelHandle()); // Attach the voxel iterator to the handle. vit.setHandle(vox); if (store) { // Try to find a 'name' attribute. input_attr_gah = input_geo->findPrimitiveAttribute("name"); if (input_attr_gah.isValid()) { // Get this primitive's name. input_attr_h.bind(input_attr_gah.getAttribute()); attr_name = input_attr_h.get(primnum); } // No name, so just use 'value'. else { attr_name = "value"; } // Add a float point attribute to store the values. attr_gah = gdp->addFloatTuple(GA_ATTRIB_POINT, attr_name, 1); // Attach an attribute handle. attr_h.bind(attr_gah.getAttribute()); } // Culling empty voxels. if (cull) { // Iterate over all the voxels. for (vit.rewind(); !vit.atEnd(); vit.advance()) { // The voxel value. value = vit.getValue(); // Skip voxels with a value of 0. if (value == 0) { continue; } // Convert the voxel index to a position. vol->indexToPos(vit.x(), vit.y(), vit.z(), pos); // Create a point and set it to the position of the // voxel. ptOff = gdp->appendPointOffset(); gdp->setPos3(ptOff, pos); // Store the value if necessary. if (store) { attr_h.set(ptOff, value); } } } else { // Get the resolution of the volume. vol->getRes(rx, ry, rz); // Add points for each voxel. ptOff = gdp->appendPointBlock(rx * ry * rz); // Iterate over all the voxels. for (vit.rewind(); !vit.atEnd(); vit.advance()) { // Convert the voxel index to a position. vol->indexToPos(vit.x(), vit.y(), vit.z(), pos); // Set the position for the current offset. gdp->setPos3(ptOff, pos); // Get and store the value if necessary. if (store) { value = vit.getValue(); attr_h.set(ptOff, value); } // Increment the offset since the block of points we // created is guaranteed to be contiguous. ptOff++; } } } // Primitive isn't a volume primitive. else { addError(SOP_MESSAGE, "Not a volume primitive."); } } // Picked a primitive number that is out of range. else { addWarning(SOP_MESSAGE, "Invalid source index. Index out of range."); } unlockInputs(); return error(); }