int main(int argc, char **argv) { int ret=0; struct cmd_t *pcmd = NULL; int idx = 0; printf("sid: %d pgid: %d pid: %d ppid: %d \n", getsid(0), getpgid(0), getpid(), getppid()); if(argc >= 2) { if( strcmp(argv[1], "-h") == 0 ) wftool_usage(); else if( strcmp(argv[1], "help") == 0 ) print_usage(argv[2]); else{ for(idx=0; idx<ARRAY_NUM(cmd_list); idx++){ if(strcmp(argv[1], cmd_list[idx].cmd) == 0){ pcmd = &cmd_list[idx]; } } } if(pcmd) pcmd->cmd_call(argc, argv); else wftool_usage(); } else{ wftool_usage(); } return ret; }
void * AllocNode( nodearray * list ) /*****************************************/ { if( ARRAY_NUM(list->num) > list->arraymax ) { AllocNewArray( list ); } list->num++; return FindNode( list, list->num ); }
void * AllocNodeIdx( nodearray *list, unsigned index ) /***********************************************************/ { if( list->num < index ) { list->num = index; while( ARRAY_NUM(index - 1) > list->arraymax ) { AllocNewArray( list ); } } return FindNode( list, index ); }
void * FindNode( nodearray *list, unsigned index ) /*******************************************************/ { index--; // index is base 1 //#ifdef _INT_DEBUG if ( index > list->num ) { LnkMsg( ERR+MSG_INVALID_INDEX_IN_RELOC, "d", index+1 ); //printf("objnode.FindNode(): index %d exceeds max index %d\n", index+1, list->num ); return( NULL ); } //#endif return list->array[ARRAY_NUM(index)] + ELEMENT_NUM(index) * list->elsize; }
void IterateNodelist( nodearray *list, void (*fn)(void *, void *), void *cookie ) /***********************************************************************/ { int index; int limit; if( list->num == 0 ) return; limit = ARRAY_NUM( list->num ); for( index = 0; index < limit; index++ ) { IterateNodeArray( list->array[index], fn, list->elsize, NODE_ARRAY_SIZE, cookie ); } IterateNodeArray( list->array[limit], fn, list->elsize, ELEMENT_NUM(list->num), cookie ); }
void wftool_usage() { int idx = 0; fprintf(stderr, "wftool usage: \n" "\twftool [cmd] [option] [...] \n" "cmd list: \n" " help \n" ); for(idx=0; idx<ARRAY_NUM(cmd_list); idx++){ fprintf(stderr, " %s \n", cmd_list[idx].cmd); } fprintf(stderr, "note:\"wftool help <cmd>\" for help on a specific cmd \n"); }
static void * IterateFindValue( nodearray *list, void *target, bool (*fn)(void *, void *) ) /***************************************************************/ { unsigned index; void * retval; unsigned limit; if( list->num == 0 ) return NULL; limit = ARRAY_NUM( list->num ); for( index = 0; index < limit; index++ ) { retval = ListFindValue( list->array[index], NODE_ARRAY_SIZE, list->elsize, target, fn); if( retval ) return retval; } return ListFindValue( list->array[limit], ELEMENT_NUM(list->num), list->elsize, target, fn ); }
int main() { NN::MathInit(); typedef NN::Iris CONTENT; const char* fpath = "iris.nn"; int mid_layer = 4; NN::Network::InitParam init_param[] = { { {CONTENT::DataSize, mid_layer}, NN::Network::LogisticLayer }, { {mid_layer, CONTENT::LabelSize}, NN::Network::SoftMaxLayer }, }; int layer_num = ARRAY_NUM(init_param); const int batch_size = 5; const int train_count = 10; NN::Network net_train(layer_num, init_param, batch_size); net_train.load(fpath); NN::Network net_test(layer_num, init_param, 1); CONTENT::Content trainData, testData; CONTENT::LoadTrainData(trainData); CONTENT::LoadTestData(testData); int count = 50; while (--count) { DWORD tick = GetTickCount(); std::cout << "start.." << std::endl; NN::Train(net_train, trainData, batch_size, train_count); std::cout << "tick = " << (GetTickCount() - tick) << std::endl; net_train.save(fpath); net_test.load(fpath); NN::Test(net_test, testData); } getchar(); return 0; }
rtems_status_code bdbuf_test_end() { rtems_status_code sc; unsigned int i; for (i = 0; i < ARRAY_NUM(g_test_ctx.test_task); i++) { if (g_test_ctx.test_task[i] != OBJECTS_ID_NONE) { sc = rtems_semaphore_obtain(g_test_ctx.test_end_main, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (sc != RTEMS_SUCCESSFUL) { printk("Failed to get a thread stopped\n"); } g_test_ctx.test_task[i] = OBJECTS_ID_NONE; } } return RTEMS_SUCCESSFUL; }
void print_usage(char *cmd) { struct cmd_t *pcmd = NULL; int idx = 0; if(cmd == NULL) wftool_usage(); else{ for(idx=0; idx<ARRAY_NUM(cmd_list); idx++){ if(strcmp(cmd, cmd_list[idx].cmd) == 0){ pcmd = &cmd_list[idx]; } } } if(pcmd) pcmd->usage_call(); else wftool_usage(); exit(0); }
void run_bdbuf_tests() { rtems_disk_device *disk; rtems_status_code sc; dev_t dev = -1; dev_t test_dev; unsigned int i; rtems_device_major_number major; rtems_driver_address_table testdisk = { test_disk_initialize, RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES }; /* Create a message queue to get events from disk driver. */ sc = rtems_message_queue_create(TEST_TASK_RX_MQUEUE_NAME, TEST_TASK_RX_MQUEUE_COUNT, sizeof(bdbuf_test_msg), RTEMS_DEFAULT_ATTRIBUTES, &g_test_ctx.test_qid); if (sc != RTEMS_SUCCESSFUL) { printk("Failed to create message queue for test task: %u\n", sc); return; } /* Register a disk device that is used in tests */ sc = rtems_io_register_driver(0, &testdisk, &major); if (sc != RTEMS_SUCCESSFUL) { printk("Failed to register TEST DEVICE: %d\n", sc); return; } test_dev = -1; while ((disk = rtems_disk_next(dev)) != NULL) { printk("DEV: %s [%lu]\n", disk->name, disk->size); dev = disk->dev; if (strcmp(disk->name, TEST_DISK_NAME) == 0) test_dev = dev; rtems_disk_release(disk); } if (test_dev == (dev_t)-1) { printf("Failed to find %s disk\n", TEST_DISK_NAME); return; } test_dd = rtems_disk_obtain(test_dev); if (test_dd == NULL) { printf("Failed to obtain %s disk\n", TEST_DISK_NAME); return; } /* * On initialization test disk device driver registers * its RX message queue, so we just need to locate it. */ sc = rtems_message_queue_ident(TEST_DRV_RX_MQUEUE_NAME, RTEMS_SEARCH_ALL_NODES, &g_test_ctx.test_drv_qid); if (sc != RTEMS_SUCCESSFUL) { printf("Failed to find Test Driver Queue: %u\n", sc); return; } for (i = 0; i < ARRAY_NUM(g_test_ctx.test_sync_main); i++) { sc = rtems_semaphore_create(rtems_build_name('T', 'S', 'M', '0' + i), 0, TEST_SEM_ATTRIBS, 0, &g_test_ctx.test_sync_main[i]); if (sc != RTEMS_SUCCESSFUL) { printk("Failed to create sync sem for test task: %u\n", sc); return; } } for (i = 0; i < ARRAY_NUM(g_test_ctx.test_sync); i++) { sc = rtems_semaphore_create(rtems_build_name('T', 'S', 'T', '0' + i), 0, TEST_SEM_ATTRIBS, 0, &g_test_ctx.test_sync[i]); if (sc != RTEMS_SUCCESSFUL) { printk("Failed to create sync sem for test task #%d: %u\n", i + 1, sc); return; } } sc = rtems_semaphore_create(rtems_build_name('T', 'S', 'M', 'E'), 0, TEST_SEM_ATTRIBS, 0, &g_test_ctx.test_end_main); if (sc != RTEMS_SUCCESSFUL) { printk("Failed to create end sync sem for test task: %u\n", sc); return; } for (i = 0; i < ARRAY_NUM(g_test_ctx.test_task); i++) g_test_ctx.test_task[i] = OBJECTS_ID_NONE; for (i = 0; i < sizeof(bdbuf_tests) / sizeof(bdbuf_tests[0]); i++) { bdbuf_tests[i].main(); } }
// サイズ変更イベント void AnimationForm::resizeEvent(QResizeEvent *event) { // QSize add_w = QSize(add.width(), 0) ; if ( m_oldWinSize.width() < 0 || m_oldWinSize.height() < 0 ) { m_oldWinSize = event->size() ; return ; } QSize add = event->size() - m_oldWinSize ; QSize add_h = QSize(0, add.height()) ; QSize add_w = QSize(add.width(), 0) ; QPoint add_w_p = QPoint(add.width(), 0) ; m_oldWinSize = event->size() ; ui->treeView->resize(ui->treeView->size()+add_h); ui->scrollArea_anime->resize(ui->scrollArea_anime->size()+add); m_pSplitter->resize(m_pSplitter->size()+add); ui->label_frame->resize(ui->label_frame->size()+add_w) ; ui->horizontalScrollBar_frame->resize(ui->horizontalScrollBar_frame->size()+add_w); setSplitterPos(m_pSetting->getAnmWindowTreeWidth(), m_pSetting->getAnmWindowTreeWidthIndex()); ui->comboBox_image_no->move(ui->comboBox_image_no->pos() + add_w_p); ui->groupBox->move(ui->groupBox->pos() + add_w_p); ui->pushButton_backward->move(ui->pushButton_backward->pos() + add_w_p) ; ui->pushButton_forward->move(ui->pushButton_forward->pos() + add_w_p) ; ui->spinBox_nowSequence->move(ui->spinBox_nowSequence->pos() + add_w_p) ; ui->label_fps->move(ui->label_fps->pos() + add_w_p) ; ui->spinBox_fps->move(ui->spinBox_fps->pos() + add_w_p) ; ui->label_frame->setScrollBarSize() ; QWidget *tmp[] = { ui->label_x, ui->label_y, ui->label_z, ui->label_uv, ui->label_uv_left, ui->label_uv_right, ui->label_uv_top, ui->label_uv_bottom, ui->label_image, ui->label_loop, ui->label_color, ui->label_r, ui->label_g, ui->label_b, ui->label_a, ui->doubleSpinBox_pos_x, ui->doubleSpinBox_pos_y, ui->doubleSpinBox_pos_z, ui->doubleSpinBox_rot_x, ui->doubleSpinBox_rot_y, ui->doubleSpinBox_rot_z, ui->doubleSpinBox_uv_left, ui->doubleSpinBox_uv_right, ui->doubleSpinBox_uv_top, ui->doubleSpinBox_uv_bottom, ui->doubleSpinBox_center_x, ui->doubleSpinBox_center_y, ui->spinBox_loop, ui->spinBox_r, ui->spinBox_g, ui->spinBox_b, ui->spinBox_a, ui->doubleSpinBox_scale_x, ui->doubleSpinBox_scale_y, ui->checkBox_uv_anime, ui->line_0, ui->line_1, ui->checkBox_center, ui->checkBox_frame, ui->checkBox_grid, ui->toolButton_picker, ui->checkBox_linear_filter, ui->spinBox_frame_end, ui->pushButton_del_path } ; for ( int i = 0 ; i < ARRAY_NUM(tmp) ; i ++ ) { tmp[i]->move(tmp[i]->pos() + QPoint(add.width(), 0)); } }
void * FindNode( nodearray *list, unsigned index ) /*******************************************************/ { index--; // index is base 1 return list->array[ARRAY_NUM(index)] + ELEMENT_NUM(index) * list->elsize; }
struct digest_ctx * auth_create_byid(int private_id) { return digest_create_byid(private_id, profile, ARRAY_NUM(profile)); }
struct digest_ctx * auth_create(int transform_id) { return digest_create(transform_id, profile, ARRAY_NUM(profile)); }
int main(void) { FILE *fp; char map[13][25]; // マップの大きさは考慮しない char buf[28]; int i=0; int j=0; int loop=0; NODE s={0,0,0}; NODE e={0,0,0}; LIST open; LIST close; open.index=0; close.index=0; if ( fopen_s(&fp,"map.txt","r") != 0 ) { return 1; } while( fgets(buf,sizeof(buf),fp) != NULL ){ for(j=0;j<26;j++){ map[i][j] = buf[j]; } i++; } fclose(fp); for(i=0;i<ARRAY_NUM(map);i++) { for(j=0;j<26;j++) { if(map[i][j] == 'S'){ s.i=i; s.j=j; open.node[open.index++] = &s; } if(map[i][j] == 'G'){ e.i=i; e.j=j; } } } while (1) { NODE *n = NULL; for(i=0;i<open.index;i++) { if ( open.node[i] != NULL ) { int cost = g(&s,open.node[i]); if ( n == NULL || n->cost > cost ) { // ノードの中で一番最小のコストを得る n = open.node[i]; open.node[i] = NULL; } } } // openからリストがなくなったので終了する if ( n == NULL ) { printf("no goal...\n"); break; } // もしGなら終了する if ( map[n->i][n->j] == 'G' ) { printf("ok goal!!!\n"); n = n->parent; while(n->parent!=NULL) { map[n->i][n->j] = '$'; n = n->parent; } break; } close.node[close.index++] = n; // 上のノードを検索 if ( n->i >= 1 && map[n->i-1][n->j] == ' ' || map[n->i-1][n->j] == 'G' ) { search_node(&open,&close,&s,&e,n,create_node(n->i-1,n->j,n->cost+1)); } // 下のノードを検索 if ( n->i <= 11 && map[n->i+1][n->j] == ' ' || map[n->i+1][n->j] == 'G' ) { search_node(&open,&close,&s,&e,n,create_node(n->i+1,n->j,n->cost+1)); } // 右のノードを検索 if ( n->j <= 24 && map[n->i][n->j+1] == ' ' || map[n->i][n->j+1] == 'G' ) { search_node(&open,&close,&s,&e,n,create_node(n->i,n->j+1,n->cost+1)); } // 左のノードを検索 if ( n->j >= 1 && map[n->i][n->j-1] == ' ' || map[n->i][n->j-1] == 'G' ) { search_node(&open,&close,&s,&e,n,create_node(n->i,n->j-1,n->cost+1)); } if ( loop++ > 1000 ) { printf("loop error...\n"); break; } } for(i=0;i<ARRAY_NUM(map);i++) { for(j=0;j<26;j++) { printf("%c",map[i][j]); } printf("\n"); } return 0; }