コード例 #1
0
/**
 *
 * Create a supplier for a directory, including the results of all
 * of the SETMETHOD methods as values
 *
 * @return An appropriate supplier object.
 */
SupplierClass *DirectoryClass::supplier()
{
    // get the supplier for the base collection.
    Protected<SupplierClass> supplier = contents->supplier();

    // do we have a method table?  We need to include these also, which
    // requires running each of the methods to obtain the value.
    if (methodTable != OREF_NULL)
    {
        Protected<ArrayClass> indexes = new_array(methodTable->items());
        Protected<ArrayClass> values = new_array(methodTable->items());

        HashContents::TableIterator iterator = methodTable->iterator();

        for (; iterator.isAvailable(); iterator.next())
        {
            RexxString *name = (RexxString *)iterator.index();
            MethodClass *method = (MethodClass *)iterator.value();

            ProtectedObject v;
            // run the method, using the directory as the receiver
            method->run(ActivityManager::currentActivity, this, name, NULL, 0, v);

            indexes->append(name);
            values->append(v);
        }
        // append the method table part to the existing supplier
        supplier->append(values, indexes);
    }
    return supplier;
}
コード例 #2
0
/**
 * Create a supplier for the stem, returning the tail names as
 * the indexes and the values as the items.
 *
 * @return A supplier instance.
 */
SupplierClass *StemClass::supplier()
{
    // essentially the same logic as allItems(), but both the item and the
    // tail value are accumulated.
    size_t count = 0;
    CompoundTableElement *variable = tails.first();
    while (variable != OREF_NULL)
    {
        // again, get the variable count
        if (variable->getVariableValue() != OREF_NULL)
        {
            count++;                     /* count this variable               */
        }
        variable = tails.next(variable);
    }

    // to create the supplier, we need 2 arrays
    ArrayClass *tailValues = new_array(count);
    ArrayClass *values = new_array(count);
    count = 1;                           // we fill in using 1-based indexes

    variable = tails.first();
    while (variable != OREF_NULL)
    {
        // now grab both the tail and value and put them in the respective arrays
        if (variable->getVariableValue() != OREF_NULL)
        {
            tailValues->put(variable->getName(), count);
            values->put(variable->getVariableValue(), count++);
        }
        variable = tails.next(variable);
    }
    // two arrays become one supplier
    return new_supplier(values, tailValues);
}
コード例 #3
0
ファイル: stress.c プロジェクト: Goettsch/game-editor
float*
circuitModel(vtx_data * graph, int nG)
{
    int i, j, e, rv, count;
    float *Dij = N_NEW(nG * (nG + 1) / 2, float);
    double **Gm;
    double **Gm_inv;

    Gm = new_array(nG, nG, 0.0);
    Gm_inv = new_array(nG, nG, 0.0);

    /* set non-diagonal entries */
    if (graph->ewgts) {
	for (i = 0; i < nG; i++) {
	    for (e = 1; e < graph[i].nedges; e++) {
		j = graph[i].edges[e];
		/* conductance is 1/resistance */
		Gm[i][j] = Gm[j][i] = -1.0 / graph[i].ewgts[e];	/* negate */
	    }
	}
    } else {
	for (i = 0; i < nG; i++) {
	    for (e = 1; e < graph[i].nedges; e++) {
		j = graph[i].edges[e];
		/* conductance is 1/resistance */
		Gm[i][j] = Gm[j][i] = -1.0;	/* ewgts are all 1 */
	    }
	}
    }

    rv = solveCircuit(nG, Gm, Gm_inv);

    if (rv) {
	float v;
	count = 0;
	for (i = 0; i < nG; i++) {
	    for (j = i; j < nG; j++) {
		if (i == j)
		    v = 0.0;
		else
		    v = (float) (Gm_inv[i][i] + Gm_inv[j][j] -
				 2.0 * Gm_inv[i][j]);
		Dij[count++] = v;
	    }
	}
    } else {
	free(Dij);
	Dij = NULL;
    }
    free_array(Gm);
    free_array(Gm_inv);
    return Dij;
}
コード例 #4
0
ファイル: test_array.c プロジェクト: xindongzhang/deepnet-dsp
void test_array_array()
{
  printf("test array array\n");
  Array* array0 = new_array(10);
  Array* array1 = new_array(10);
  Array* array2 = new_array(10);
  Array* array3 = new_array(10);
  Array* array  = new_array(10);
  array_push(array, array0, del_array);
  array_push(array, array1, del_array);
  array_push(array, array2, del_array);
  array_push(array, array3, del_array);
  array_print(array);
  del_array(array);
}
コード例 #5
0
ファイル: JSON.cpp プロジェクト: w3c/wot-arduino
JSON * JSON::parse_array(Lexer *lexer)
{
    JSON *array = new_array();
    unsigned int index = 0;
    
    if (lexer->end_of_array())
        return array;  // empty array
        
    for (;;)
    {
        JSON *item = parse_private(lexer);
    
        if (item)
            array->insert_array_item(index++, item);
        else
        {
            Serial.println(F("missing array item"));
            break;
        }
 
        Json_Token token = lexer->get_token();
        
        if (token == Array_stop_token)
            return array;
            
        if (token != Comma_token)
            break;
    }

    Serial.println(F("JSON syntax error in array"));
    return null;
}
コード例 #6
0
ファイル: array.c プロジェクト: peterlintang/apue
int split_array(array_t *orig, int ix, array_t **first, array_t **second)
{
	if (!orig || ix >= orig->count || ix < 0 
		|| !first || !second) return -1;	/* error */

	(*second) = new_array();
	if (!(*second)) return 0;

	(*second)->count = orig->count - ix;
	(*second)->items = malloc(sizeof(void *) * (*second)->count);
	if (!(*second)->items) {
		destroy_array(second, NULL);
		return 0;
	} else {
		memcpy(&(*second)->items, &orig->items[ix], 
			sizeof(void *) * (*second)->count);
	}

	(*first) = orig;
	(*first)->count = ix;
	(*first)->items = realloc(orig->items, sizeof(void *) * ix);
	if (!(*first)->items) {
		destroy_array(second, NULL);
		return 0;
	}

	return 1;
}
コード例 #7
0
ファイル: correlate.c プロジェクト: cdfassnacht/CodeCDF
float *wt_hanning(Fluxrec *flux, int npoints)
{
  int i;               /* Looping variable */
  float weight;        /* Weighting for any one point */
  float *hann=NULL;    /* Weighted curve */
  float *hptr;         /* Pointer to navigate hann */
  Fluxrec *fptr;       /* Pointer to navigate flux */

  /*
   * Allocate memory for weighted curve
   */

  if(!(hann = new_array(npoints,1))) {
    fprintf(stderr,"ERROR: wt_hann\n");
    return NULL;
  }

  /*
   * Loop through the Fluxrec array, applying the weighting
   */

  for(i=0,hptr=hann,fptr=flux; i<npoints; i++,hptr++,fptr++) {
    weight = 0.5 * (1 - cos(2*PI*i/npoints));
    *hptr = fptr->flux * weight;
  }

  return hann;

}
コード例 #8
0
ファイル: array.c プロジェクト: dancheah/CeeCode
void test1()
{
    array_t* a = new_array();

    for (int i = 0; i < 1024; i++) {
        append(a, i);
    }

    printf("Test Resize 1\n");
    for (int i = 1024; i < 2048; i++) {
        append(a, i);
    }
    print_array_info(a);

    printf("Test Resize 2\n");
    for (int i = 2048; i < 4096; i++) {
        append(a, i);
    }
    print_array_info(a);

    data_t* tmp = get(a, 0);
    print_data(tmp); 

    tmp = get(a, 4095);
    print_data(tmp); 
}
コード例 #9
0
ファイル: RexxCode.cpp プロジェクト: jlfaucher/executor
RexxArray *RexxCode::getSource()
/******************************************************************************/
/* Function:  Extract the source from a method from the source object as an   */
/*            array of strings.                                               */
/******************************************************************************/
{
  SourceLocation   location;           /* location information              */
  SourceLocation   end_location;       /* ending location                   */
  RexxInstruction *current;            /* current instruction               */

  if (this->start == OREF_NULL)        /* empty method?                     */
    return new_array((size_t)0);       /* just return an empty array        */
  location = start->getLocation();     /* get its location info             */
  current = this->start;               /* point to the beginning            */
                                       /* while not at the last one         */
  while (current->nextInstruction != OREF_NULL) {
    current = current->nextInstruction;/* step to the next one              */
  }

  end_location = current->getLocation(); /* get the end location              */
                                       /* copy over the ending position     */
  location.setEndLine(end_location.getEndLine());
  location.setEndOffset(end_location.getEndOffset());
                                       /* go extract the source array       */
  return this->source->extractSource(location);
}
コード例 #10
0
ファイル: calcu.c プロジェクト: Hilzu/HeatConduction
/*
 * Juho Gävert & Santeri Hiltunen
 Starting point of calculation. Searches for temperature balance in Array for
 maximum iterations of max_iters.
 */
double calculate_heatconduct(Array* arr, unsigned int max_iters)
{

  if (max_iters == 0 || arr->width < 3 || arr->height < 3)
    return -1;

  Array* temp_arr = new_array(arr->width, arr->height);
  copy_array(arr, temp_arr);

  double prev_mean = -1;
  for (unsigned int i = 0; i < max_iters; ++i) {
    double new_mean = calculate_iteration(arr, temp_arr);

    swap_ptrs((void**) &arr, (void**) &temp_arr);

    if (conf.verbose) {
      printf("Iter: %d Mean: %.15f\n", i + 1, new_mean);
      if (conf.verbose > 1) {
        print_arr(arr);
      }
    }

    if (fabs(new_mean - prev_mean) < 0.0000000000001) {
      printf("Found balance after %d iterations.\n", i);
      del_array(temp_arr);
      return new_mean;
    }

    prev_mean = new_mean;
  }
  del_array(temp_arr);
  printf("Didn't find balance after %d iterations.\n", max_iters);
  return prev_mean;
}
コード例 #11
0
ファイル: transpose.hpp プロジェクト: OnlySang/pythran
            types::ndarray<T,N> _transpose(types::ndarray<T,N> const & a, long const l[N])
            {
                auto shape = a.shape;
                types::array<long, N> shp;
                for(unsigned long i=0; i<N; ++i)
                    shp[i] = shape[l[i]];

                types::ndarray<T,N> new_array(shp, __builtin__::None);

                types::array<long, N> new_strides;
                new_strides[N-1] = 1;
                std::transform(new_strides.rbegin(), new_strides.rend() -1, shp.rbegin(), new_strides.rbegin() + 1, std::multiplies<long>());

                types::array<long, N> old_strides;
                old_strides[N-1] = 1;
                std::transform(old_strides.rbegin(), old_strides.rend() -1, shape.rbegin(), old_strides.rbegin() + 1, std::multiplies<long>());

                auto iter = a.buffer,
                     iter_end = a.buffer + a.size();
                for(long i=0; iter!=iter_end; ++iter, ++i) {
                    long offset = 0;
                    for(unsigned long s=0; s<N; s++)
                        offset += ((i/old_strides[l[s]]) % shape[l[s]])*new_strides[s];
                    new_array.buffer[offset] = *iter;
                }

                return new_array;
            }
コード例 #12
0
bool ConfigFile::remove_rom_id_1(std::string package, std::string rom_id) {
    const Json::Value syncacross =
            m_root[CONF_PACKAGES][package][CONF_SYNC_ACROSS];

    if (syncacross.isNull() || !syncacross.isArray()) {
        return false;
    }

    bool removed = false;

    // jsoncpp has no built-in way of removing items from an array
    Json::Value new_array(Json::arrayValue);
    for (unsigned int i = 0; i < syncacross.size(); i++) {
        std::string value = syncacross[i].asString();
        if (rom_id == value) {
            removed = true;
            continue;
        }
        new_array.append(value);
    }

    if (new_array.size() == 0) {
        m_root[CONF_PACKAGES].removeMember(package);
        removed = true;
    } else {
        m_root[CONF_PACKAGES][package][CONF_SYNC_ACROSS] = new_array;
    }

    if (removed) {
        write_config();
    }

    return removed;
}
コード例 #13
0
ファイル: cmap.cpp プロジェクト: Chenguang-Zhu/ICE-C5
array * __select (std::map<int, std::set<int> * > const & map, int (*callback) (int, int)) {

	// Select
	std::list<int> result;
	for (std::map<int, std::set<int> * >::const_iterator it1 = map.begin(); it1 != map.end(); it1++) {
		for (std::set<int>::const_iterator it2 = it1->second->begin(); it2 != it1->second->end(); it2++) {

			if (callback (it1->first, *it2)) {
				result.push_back (*it2);
			}

		}
	} 

	// Convert to array
	array * a = new_array (result.size ());
	int i=0;
	for (std::list<int>::const_iterator it = result.begin(); it != result.end(); it++) {

		a->entries[i] = *it;
		i++;

	}

	return a;

}
コード例 #14
0
//=============================================================================
void Parse::do_anewarray() {
  bool will_link;
  ciKlass* klass = iter().get_klass(will_link);

  // Uncommon Trap when class that array contains is not loaded
  // we need the loaded class for the rest of graph; do not
  // initialize the container class (see Java spec)!!!
  assert(will_link, "anewarray: typeflow responsibility");

  ciObjArrayKlass* array_klass = ciObjArrayKlass::make(klass);
  // Check that array_klass object is loaded
  if (!array_klass->is_loaded()) {
    // Generate uncommon_trap for unloaded array_class
    uncommon_trap(Deoptimization::Reason_unloaded,
                  Deoptimization::Action_reinterpret,
                  array_klass);
    return;
  }

  kill_dead_locals();

  const TypeKlassPtr* array_klass_type = TypeKlassPtr::make(array_klass);
  Node* count_val = pop();
  Node* obj = new_array(makecon(array_klass_type), count_val, 1);
  push(obj);
}
コード例 #15
0
ファイル: main.c プロジェクト: Hilzu/HeatConduction
int main(int argc, char** argv)
{
  set_defaults();

  parse_options(argc, argv);

  if (conf.help_flag) {
    print_help();
    exit(0);
  }

  check_conf();

  unsigned int arr_width = conf.width * conf.multiplier;
  unsigned int arr_height = conf.height * conf.multiplier;
  
  printf("Creating array size of %ux%u.\n", arr_width, arr_height);
  Array* arr = new_array(arr_width, arr_height);

  printf("Initializing with side temps of %f, %f, %f, %f.\n",
          conf.top_temp, conf.right_temp, conf.bottom_temp, conf.left_temp);
  initialize_array(arr, conf.top_temp, conf.right_temp, conf.bottom_temp, conf.left_temp);

  printf("Searching for temp balance with max iterations of %d.\n", conf.max_iters);
  double mean_temp = calculate_heatconduct(arr, conf.max_iters);

  printf("Mean temperature: %f\n", mean_temp);

  return 0;
}
コード例 #16
0
ファイル: circuit.c プロジェクト: david-redick/lwmapgen
void circuit()
{
     int r, c;
     int do_cut;
     int radius;
     int centerx, centery;


     clear_invert_map();

     grid = (char **) new_grid(map.num_row, map.num_col, sizeof(char));
     count = (int *) new_array(map.num_row, sizeof(int));

     radius = (map.sec_width > map.sec_height ? map.sec_width : map.sec_height)/4.0;
     radius = (radius == 0 ? 1 : radius );

     line_size = (map.sec_width > map.sec_height ? map.sec_width : map.sec_height)/4.0;
     line_size = (line_size == 0 ? 1 : line_size);

     for( r = 0; r < map.num_row; r++ )
     {
          count[r] = 0;
          for( c = 0; c < map.num_col; c++ )
          {
               if( (r == 0 || r == map.num_row-1)
               && (c == 0 || c == map.num_col/2 || c == map.num_col-1) )
                    do_cut = 1;
               else
                    do_cut = rand()%4;

               if( do_cut != 1 )
               {
                    grid[r][c] = 0;
                    continue;
               }

               section_center(&centerx, &centery, r, c);
               circlefill(map.map, centerx, centery, radius, 255);

               grid[r][c] = 1;
               count[r]++;
          }
     }


     connect_rows();
     connect_front();
     connect_back();
     connect_mid();

     delete_grid((void **)grid, map.num_row);
     delete_array(count);

     /* redraw outline */
     /* TODO: once in a while if cuts off the edge.. */
     rect(map.map, 0, 0, map.width-1, map.height-1, 0);

return;
}
コード例 #17
0
ファイル: fit_1_to_3.c プロジェクト: cdfassnacht/CodeCDF
int plot_fit_curve(float *a, int ncoeff, float tmin, float tmax)
{
  int i,j;            /* Looping variables */
  int nstep=500;      /* Number of steps used to compute curve */
  float xtmp,ytmp;    /* Values of x,y used in constructing the curve */
  float *polyx=NULL;  /* Polynomial in x */

  cpgsci(2);
  cpgslw(5);

  /*
   * Allocate memory for container for polynomial values
   */

  if(!(polyx = new_array(ncoeff,1))) {
    fprintf(stderr,"ERROR: plot_fit_curve\n");
    return 1;
  }

  /*
   * Loop through range of x values in step sizes determined by nstep.
   * At each value of x, compute the value of y by first calling poly
   *  to compute the values of the various powers of x at that step, and
   *  then multiplying by the coefficients contained in a.
   */

  for(i=0; i<nstep; i++) {

    /*
     * Compute the values of x and y at this step
     */

    xtmp = tmin + i*(tmax - tmin)/(1.0 * nstep);
    sinpoly(xtmp,polyx-1,ncoeff);
    ytmp = 0;
    for(j=0; j<ncoeff; j++)
      ytmp += a[j] * polyx[j];

    /*
     * Now connect this point to the previous one with a cpgdraw call
     */

    if(i == 0)
      cpgmove(xtmp,ytmp);
    else
      cpgdraw(xtmp,ytmp);
  }

  /*
   * Clean up and exit
   */

  cpgslw(1);
  cpgsci(1);
  polyx = del_array(polyx);

  return 0;
}
コード例 #18
0
ファイル: correlate.c プロジェクト: cdfassnacht/CodeCDF
float *zero_pad(Fluxrec *flux, int npoints)
{
  int i;             /* Looping variable */
  float *zpad=NULL;  /* Padded light curve */
  float *zptr;       /* Pointer to navigate zpad */
  Fluxrec *fptr;     /* Pointer to navigate flux */

  /*
   * Allocate memory for the padded array
   */

  if(!(zpad = new_array(npoints,ZEROFAC))) {
    fprintf(stderr,"ERROR: zero_pad.\n");
    return NULL;
  }

#if 0
  /*
   * Put the data from flux in the middle of the padded
   *  array container.  Note that new_array initializes the
   *  members of the array to zero, so there is no need to set the
   *  first and last (npoints/2) points to zero in this function.
   */

  for(i=0,fptr=flux,zptr=zpad+(npoints/2); i<npoints; i++,fptr++,zptr++) 
    *zptr = fptr->flux;
#endif
  /*
   * Put the data into the first npoints members in the array and put
   *  zeros in the last npoints members.  Note that since new_array
   *  sets all members of the new array to 0.0, all we have to do
   *  here is put the members of flux into the first npoints members
   *  of zpad.
   */

  for(i=0,fptr=flux,zptr=zpad; i<npoints; i++,fptr++,zptr++)
    *zptr = fptr->flux;

#if 0
  /*
   * Convert the padded array into Numerical Recipes' "wrap-around"
   *  order -- that is with points (npoints/2) to (npoints - 1) in
   *  positions 0 to (npoints/2 - 1) and points 0 to (npoints/2 - 1)
   *  in positionis (3*npoints/2) to (2*npoints - 1).  The middle
   *  npoints/2 points will be 0.0, since new_array sets all members
   *  of the new array to 0.0.  Thus we will have a zero-padded array.
   */

  for(i=0; i<npoints/2; i++)
    zpad[i + 3*npoints/2] = flux[i].flux;

  for(i=npoints/2; i<npoints; i++)
    zpad[i-npoints/2] = flux[i].flux;
#endif

  return zpad;
}
コード例 #19
0
ファイル: cmap.cpp プロジェクト: Chenguang-Zhu/ICE-C5
struct array * cmap_get_keys (struct cmap const * map) {

	if (map == NULL || map->left2right_map.size () == 0) {
		return new_array (0);
	}

	array * a = new_array (map->left2right_map.size ());
	int i=0;
	for (std::map<int, std::set<int> * >::const_iterator it = map->left2right_map.begin(); it != map->left2right_map.end(); it++) {

		a->entries[i] = it->first;
		i += 1;

	}

	return a;
	
}
コード例 #20
0
ファイル: array.c プロジェクト: CyberLeo/zetamuck
stk_array *
new_array_dictionary(void)
{
    stk_array *new2;

    new2 = new_array();
    new2->type = ARRAY_DICTIONARY;
    return new2;
}
コード例 #21
0
ファイル: _clip_vnewarray.c プロジェクト: amery/clip-angelo
CLIP_DLLEXPORT void
_clip_vnewarray(ClipMachine * ClipMachineMemory, int n, long *vect)
{
   ClipVar *sp = ClipMachineMemory->fp->ClipVar_sp_of_ClipFrame;

   new_array(sp, n, vect);
   ++(ClipMachineMemory->fp->ClipVar_sp_of_ClipFrame);
   CLIP_CHECK_STACK;
}
コード例 #22
0
void Parse::do_newarray(BasicType elem_type) {
  kill_dead_locals();

  Node*   count_val = pop();
  const TypeKlassPtr* array_klass = TypeKlassPtr::make(ciTypeArrayKlass::make(elem_type));
  Node*   obj = new_array(makecon(array_klass), count_val, 1);
  // Push resultant oop onto stack
  push(obj);
}
コード例 #23
0
ファイル: rset.c プロジェクト: JoeDog/fido
RSET
new_rset()
{
  RSET this;

  this = xcalloc(RSETSIZE, 1);
  this->group = new_array();
  return this;
}
コード例 #24
0
ファイル: render.c プロジェクト: suzuren/ejoy2d
struct render * 
render_init(struct render_init_args *args, void * buffer, int sz) {
	struct block B;
	block_init(&B, buffer, sz);
	struct render * R = (struct render *)block_slice(&B, sizeof(struct render));
	memset(R, 0, sizeof(*R));
	log_init(&R->log, stderr);
	new_array(&B, &R->buffer, args->max_buffer, sizeof(struct buffer));
	new_array(&B, &R->attrib, args->max_layout, sizeof(struct attrib));
	new_array(&B, &R->target, args->max_target, sizeof(struct target));
	new_array(&B, &R->texture, args->max_texture, sizeof(struct texture));
	new_array(&B, &R->shader, args->max_shader, sizeof(struct shader));

	glGetIntegerv(GL_FRAMEBUFFER_BINDING, &R->default_framebuffer);

	CHECK_GL_ERROR

	return R;
}
コード例 #25
0
ファイル: program.c プロジェクト: jamorton/libgp
// Create a program with a random length N and a sequence of N randomly
// initialized statements
void gp_program_init(GpWorld * world, GpProgram * program)
{
	uint i;
	program->evaluated = 0;
	program->num_stmts = urand(world->conf.min_program_length,
							   world->conf.max_program_length + 1);
	program->stmts = new_array(GpStatement, program->num_stmts);
	for (i = 0; i < program->num_stmts; i++)
		program->stmts[i] = gp_statement_random(world);
}
コード例 #26
0
ファイル: cf_append.c プロジェクト: edhodapp/cf
CF append1(CF a, int t)
{
  CFP result = new_cf_append(2);
  if (result == 0) return 0;

  result->cf[0] = a;
  result->cf[1] = new_array(t);
  result->next = next_append;
  return (CF) result;
}
コード例 #27
0
ファイル: cmap.cpp プロジェクト: Chenguang-Zhu/ICE-C5
array * cmap_rget(cmap * map, int y) {
	
	std::map<int, std::set<int> *>::iterator it1 = map->right2left_map.find(y);
	if(it1 != map->right2left_map.end() && it1->second != NULL && it1->second->size() > 0) {

		array * a = new_array(it1->second->size());
		unsigned int i = 0;
		for(std::set<int>::iterator it2 = it1->second->begin(); it2 != it1->second->end(); it2++, i++) {
			a->entries[i] = *it2;
		}

		return a;

	} else {

		return new_array (0);

	}

}
コード例 #28
0
ファイル: PackageManager.cpp プロジェクト: jlfaucher/executor
/**
 * Return the information that needs to be saved in the saved
 * image.
 *
 * @return An array of the items added to the saved image.
 */
RexxArray *PackageManager::getImageData()
{

    RexxArray *imageArray = new_array(IMAGE_ARRAY_SIZE);
    imageArray->put(packages, IMAGE_PACKAGES);
    imageArray->put(packageRoutines, IMAGE_PACKAGE_ROUTINES);
    imageArray->put(registeredRoutines, IMAGE_REGISTERED_ROUTINES);
    imageArray->put(loadedRequires, IMAGE_REQUIRES);

    return imageArray;
}
コード例 #29
0
ファイル: array.c プロジェクト: dancheah/CeeCode
void run_experiment(ull testsize)
{
    array_t* a = new_array();

    for (ull i = 0; i < testsize; i++) {
        append(a, i);        
    }

    //print_array_info(a); 

    destroy_array(a);
}
コード例 #30
0
ファイル: main_test.c プロジェクト: jbclements/rai
int main(int argc, char **argv) {
    nb_arg = argc-1;
    arg    = argv+1;

    /* Alloc buffers */
    float **state = malloc(sizeof(*state) * 2);
    state[0] = new_array(PROC(size_state), 0);
    state[1] = new_array(PROC(size_state), 0);

    _ **in    = malloc(sizeof(*in) * PROC(size_in));
    for (int i = 0; i < PROC(size_in); i++)
        in[i]  = new_array(NB_SAMP, in_default(i));

    _ *param = new_array(PROC(size_param), 0);
    for (int i = 0; i < PROC(size_param); i++)
        param[i] = in_default(i);

    _ **out   = malloc(sizeof(*out) * PROC(size_out));
    for (int i = 0; i < PROC(size_out); i++)
        out[i] = new_array(NB_SAMP, 0);

    _ *store = new_array(PROC(size_store), 0);

    /* Run once */
    PROC(loop)((void*)state, (void*)in, (void*)param, (void*)out, (void*)store, NB_SAMP);
    for (int i = 0; i < NB_SAMP; i++) {
        for (int o = 0; o < PROC(size_out); o++) {
            printf("%+0.4f ", out[o][i]);
        }
        printf("\n");
    }

    return 0;
}