static el_t *elsNew(size_t len) { size_t i; bor_real_t x, y; el_t *ns; ns = BOR_ALLOC_ARR(el_t, arr_len); for (i = 0; i < len; i++){ x = borRand(&r, -15., 15.); y = borRand(&r, -20., 20.); borVec2Set(&ns[i].v, x, y); borNNElInit(linear, &ns[i].linear, (const bor_vec_t *)&ns[i].v); borNNElInit(gug, &ns[i].gug, (const bor_vec_t *)&ns[i].v); borNNElInit(vp, &ns[i].vp, (const bor_vec_t *)&ns[i].v); borNNAdd(linear, &ns[i].linear); borNNAdd(gug, &ns[i].gug); borNNAdd(vp, &ns[i].vp); } return ns; }
static void _nnAddRm(uint8_t type, bor_nn_params_t *params) { bor_rand_mt_t *rand; bor_nn_t *nn; static bor_list_t els_list; static int els_len = ADD_ELS_LEN; static el_t els[ADD_ELS_LEN]; int i, j; rand = borRandMTNewAuto(); params->type = type; nn = borNNNew(params); borListInit(&els_list); for (i = 0; i < els_len; i++){ borVec2Set(&els[i].w, borRandMT(rand, -3, 3), borRandMT(rand, -3, 3)); borNNElInit(nn, &els[i].el, (const bor_vec_t *)&els[i].w); borListAppend(&els_list, &els[i].list); } for (i = 0; i < ADD_ELS_LEN; i++){ //fprintf(stdout, "%02d:\n", i); borNNAdd(nn, &els[i].el); //borNNDump(vp, stdout); } for (i = 0; i < ADD_ELS_LEN; i += 3){ borNNRemove(nn, &els[i].el); borListDel(&els[i].list); } for (i = 0; i < ADD_NUM_TESTS; i++){ for (j = 1; j <= ADD_NUM_NNS; j++){ test2(rand, nn, &els_list, j); } } borNNDel(nn); borRandMTDel(rand); }