示例#1
0
文件: add.c 项目: smurakami/AI-2012
void main()
{
  NET  Net;
  int ct = 0;
  

  InitializeRandoms();

  GenerateNetwork(&Net);

  RandomWeights(&Net);

  InitializeApplication(&Net);


  do {
    TrainNet(&Net, 10);
    if (ct % 10 == 0) {
	fprintf(f, "Epoch = %d\n",ct);
	EvaluateNet(&Net);
       }
    ct++;
   } while (ct<MAXCT);

  fprintf(f, "\n");
  fprintf(f, "Finial Epoch:\n");
  EvaluateNet(&Net);
   
  FinalizeApplication(&Net);
}
示例#2
0
文件: BPN.C 项目: dunghand/msrds
void main()
{
  NET  Net;
  BOOL Stop;
  REAL MinTestError;

  InitializeRandoms();
  GenerateNetwork(&Net);
  RandomWeights(&Net);
  InitializeApplication(&Net);

  Stop = FALSE;
  MinTestError = MAX_REAL;
  do {
    TrainNet(&Net, 10);
    TestNet(&Net);
    if (TestError < MinTestError) {
      fprintf(f, " - saving Weights ...");
      MinTestError = TestError;
      SaveWeights(&Net);
    }
    else if (TestError > 1.2 * MinTestError) {
      fprintf(f, " - stopping Training and restoring Weights ...");
      Stop = TRUE;
      RestoreWeights(&Net);
    }
  } while (NOT Stop);

  TestNet(&Net);
  EvaluateNet(&Net);
   
  FinalizeApplication(&Net);
}
示例#3
0
文件: Main.c 项目: ee230/trunks
static void MainThread(void) {
	unsigned int BluetoothStackID;
	int Result;
	BTPS_Initialization_t BTPS_Initialization;
	HCI_DriverInformation_t HCI_DriverInformation;

	/* Configure the UART Parameters.                                    */
	HCI_DRIVER_SET_COMM_INFORMATION(&HCI_DriverInformation, 1, 115200, cpUART);
	HCI_DriverInformation.DriverInformation.COMMDriverInformation.InitializationDelay =
			100;

	/* Set up the application callbacks.                                 */
	BTPS_Initialization.GetTickCountCallback = GetTickCallback;
	BTPS_Initialization.MessageOutputCallback = DisplayCallback;

	/* Initialize the application.                                       */
	if ((Result = InitializeApplication(&HCI_DriverInformation,
			&BTPS_Initialization)) > 0) {
		/* Save the Bluetooth Stack ID.                                   */
		BluetoothStackID = (unsigned int) Result;

		/* Go ahead an enable HCILL Mode.                                 */
		HCILL_Init();
		HCILL_Configure(BluetoothStackID, HCILL_MODE_INACTIVITY_TIMEOUT,
				HCILL_MODE_RETRANSMIT_TIMEOUT, TRUE);

		/* Call the main application state machine.                       */
		while (1) {
			ApplicationMain();
		}
	}
}
示例#4
0
JNIEXPORT jboolean JNICALL JAVA_FUNC(initSequence)
  (JNIEnv *env, jobject obj, jint j_width, jint j_height, jstring j_strPath,
		  jstring j_model, jstring j_brand, jstring j_board, jstring j_version, jstring j_tz)
{
    if( !LoadApplication ){
        if(InitializeApplication()) return 0;
    }
    return PROC_FUNC(initSequence)( env, obj, j_width, j_height, j_strPath, j_model, j_brand, j_board, j_version, j_tz );
    return 0;
}
示例#5
0
JNIEXPORT jint JNICALL JAVA_FUNC(getGLVersion)
  (JNIEnv * env, jobject obj)
{
	jint ret = 0;
	if(!LoadApplication) {
        if(InitializeApplication()) return -1;
	}
	char buf[256];
	if(PROC_FUNC(getGLVersion)) ret = PROC_FUNC(getGLVersion)( env, obj );
	return ret;
}
示例#6
0
文件: SOM.C 项目: dunghand/msrds
void main()
{
  NET Net;

  InitializeRandoms();
  GenerateNetwork(&Net);
  RandomWeights(&Net);
  InitializeApplication(&Net);
  TrainNet(&Net);
  WriteNet(&Net);
  FinalizeApplication(&Net);
}
	void RunApplication( IGameApp& app, const wchar_t* className )
	{
		HINSTANCE hInst = GetModuleHandle(0);

		// Register class
		WNDCLASSEX wcex;
		wcex.cbSize = sizeof(WNDCLASSEX);
		wcex.style = CS_HREDRAW | CS_VREDRAW;
		wcex.lpfnWndProc = WndProc;
		wcex.cbClsExtra = 0;
		wcex.cbWndExtra = 0;
		wcex.hInstance = hInst;
		wcex.hIcon = LoadIcon(hInst, IDI_APPLICATION);
		wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
		wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
		wcex.lpszMenuName = nullptr;
		wcex.lpszClassName = className;
		wcex.hIconSm = LoadIcon(hInst, IDI_APPLICATION);
		ASSERT(0 != RegisterClassEx(&wcex), "Unable to register a window");

		// Create window
		RECT rc = { 0, 0, (LONG)g_DisplayWidth, (LONG)g_DisplayHeight };
		AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);

		g_hWnd = CreateWindow(className, className, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
			rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInst, nullptr);

		ASSERT(g_hWnd != 0);

		InitializeApplication(app);

		ShowWindow( g_hWnd, SW_SHOWDEFAULT );

		do
		{
			MSG msg = {};
			while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			if (msg.message == WM_QUIT)
				break;
		}
		while (UpdateApplication(app));	// Returns false to quit loop

		Graphics::Terminate();
		TerminateApplication(app);
		Graphics::Shutdown();
	}
示例#8
0
int main( void )
{
	OSErr	err;
	
	err	= InitializeApplication();
	if ( err != noErr )	goto Bail;
	
	SendCommandProcessEvent( kHICommandNew );							//	Send a kHICommandNew to ourselves to create a default new window
	
	RunApplicationEventLoop();

Bail:	
	if ( g.mainNib != NULL )	DisposeNibReference( g.mainNib );
	if ( g.mainBundle != NULL )	CFRelease( g.mainBundle );
	return( noErr );
}
示例#9
0
文件: ADALINE.C 项目: dunghand/msrds
void main()
{
  NET  Net;
  REAL Error;
  BOOL Stop;
  INT  n,m;

  InitializeRandoms();
  GenerateNetwork(&Net);
  RandomWeights(&Net);
  InitializeApplication(&Net);
   
  do {
    Error = 0;
    Stop = TRUE;
    for (n=0; n<NUM_DATA; n++) {
      SimulateNet(&Net, Input[n], Output[n], FALSE, FALSE);
      Error = MAX(Error, Net.Error);
      Stop = Stop AND (Net.Error < Net.Epsilon);
    }
    Error = MAX(Error, Net.Epsilon);
    printf("Training %0.0f%% completed ...\n", (Net.Epsilon / Error) * 100);
    if (NOT Stop) {
      for (m=0; m<10*NUM_DATA; m++) {
        n = RandomEqualINT(0, NUM_DATA-1);      
        SimulateNet(&Net, Input[n], Output[n], TRUE, FALSE);
      }
    }
  } while (NOT Stop);
   
  for (n=0; n<NUM_DATA; n++) {
    SimulateNet(&Net, Input[n], Output[n], FALSE, TRUE);
  }
   
  FinalizeApplication(&Net);
}
示例#10
0
int PASCAL WinMain(
    HINSTANCE hinst,
    HINSTANCE hinstPrev,
    LPSTR lpCmdLine,
    int nCmdShow)
{
    MSG msg;
    int RemoveCursor = TRUE;

    ghinst = hinst;


    // if command line option exist

    if (lpCmdLine[0]) {
	LPSTR cmdArg;
	if ( cmdArg = strstr ( lpCmdLine, "-a"))     //automation switch
	    AutoRun = TRUE;
	if ( cmdArg = strstr ( lpCmdLine, "-m"))     //cursor stays
	    RemoveCursor = FALSE;
    }

    /*
     * If this is the first instance of the app. register window classes
     */

    if (hinstPrev == NULL)
        if (!InitializeApplication())
            return 0;

    /*
     * Create the frame and do other initialization
     */

    if (!InitializeInstance(nCmdShow))
        return 0;


    if (RemoveCursor)
	ShowCursor(0);

    /*
     * Enter main message loop
     */

    while (GetMessage(&msg, NULL, 0, 0)) {

	if (AutoRun) {
	    AutoTest();
	    break;
	}

        /*
         * If a keyboard message is for the MDI, let the MDI client
         * take care of it.  Otherwise, check to see if it's a normal
         * accelerator key (like F3 = find next).  Otherwise, just handle
         * the message as usual.
         */
        if (!TranslateMDISysAccel(ghwndMDIClient, &msg) &&
                !TranslateAccelerator(ghwndFrame, ghaccel, &msg)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    if (AutoRun)
	PostQuitMessage(0);


    return 0;
}
示例#11
0
int test(char** argv)
{
	int argc = 1;
	static APPLICATION application = {0};
	
	static APPLICATION_LABELS labels =
	{
		"English",
		{"OK", "Apply", "Cancel", "Normal", "Reverse", "Edit Selection", "Window",
			"Close Window", "Dock Left", "Dock Right", "Full Screen", "Reference Image Window",
			"Move Top Left", "Hot Key", "Loading...", "Saving..."},
		{"pixel", "Length", "Angle", "_BG", "Loop", "Preview", "Interval", "minute", "Detail", "Target",
			"Clip Board", "Name", "Type", "Resolution", "Center", "Straight", "Grow", "Mode", "Red", "Green", "Blue",
			"Cyan", "Magenta", "Yellow", "Key Plate", "Add", "Delete"},
		{"File", "New", "Open", "Open as Layer", "Save", "Save as", "Close", "Quit", "Edit", "Undo", "Redo",
			"Copy", "Copy Visible", "Cut", "Paste", "Clipboard", "Transform", "Projection", "Canvas",
			"Change Resolution", "Change Canvas Size", "Flip Canvas Horizontally", "Flip Canvas Vertically",
			"Switch _BG Color", "Change 2nd _BG Color", "Change ICC Profile", "Layer", "_New Layer(Color)",
			"_New Layer(Vector)", "_New Layer Set", "_New 3D Modeling Layer", "_New Adjustment Lyaer", "_Copy Layer",
			"_Delete Layer", "Fill with _FG Color", "Fill with Pattern", "Rasterize Layer", "Merge Down",
			"_Flatten Image", "_Visible to Layer", "Visible Copy", "Select", "None", "Invert", "All", "Grow",
			"Shrink", "View", "Zoom", "Zoom _In", "Zoom _Out", "Actual Size", "Reverse Horizontally", "Rotate",
			"Reset Roatate", "Display Filters", "Nothing", "Gray Scale", "Gray Scale (YIQ)", "Filters", "Blur",
			"Motion Blur", "Gaussian Blur", "Brightness & Contrast", "Hue & Saturation", "Levels", "Tone Curve",
			"Luminosity to Opacity", "Color to Alpha", "Colorize with Under Layer", "Gradation Map",
			"Map with Detect Max Black Value", "Transparency as White", "Fill with Vector", "Render", "Cloud",
			"Fractal", "Trace Pixels", "Plug-in", "Script", "Help", "Version"
		},
		{"New", "New Canvas", "Width", "Height", "2nd BG Color", "Adopt ICC Profile?", "Preset", "Add Preset",
			"Swap Height and Width"},
		{"Tool Box", "Initialize", "New Brush", "Smooth", "Quality", "Rate", "Gaussian", "Average", "Magnification",
			"Brush Size", "Scale", "Flow", "Pressure", "Extend Range", "Blur", "OutLine Hardness",
			"Color Extends", "Start Distance of Drag and Move", "Anti Alias", "Change Text Color", "Horizonal",
			"Vertical", "Style", "Normal", "Bold", "Italic", "Oblique", "Balloon", "Balloon Has Edge", "Line Color",
			"Fill Color", "Line Width", "Change Line Width", "Manually Set", "Aspect Ratio", "Centering Horizontally",
			"Centering Vertically", "Adjust Range to Text", "Number of Edge,", "Edge Size", "Edge Size Random",
			"Edge Distance Random", "Number of Children", "Start Child Size", "End Child Size", "Reverse",
			"Reverse Horizontally", "Reverse Vertically", "Blend Mode", "Hue", "Saturation", "Brightness", "Contrast",
			"Distance", "Rotate Start", "Rotate Speed", "Random Rotate", "Rotate to Brush Direction", "Size Range",
			"Rotate Range", "Random Size", "Clockwise", "Counter Clockwise", "Both Direction", "Minimum Degree",
			"Minumum Distance", "Minimum Pressure", "Enter", "Out", "Enter & Out", "Mix", "Reverse FG BG",
			"Devide Stroke", "Delete Stroke", "Target", "Stroke", "Prior Angle", "Control Point", "Free", "Scale",
			"Free Shape", "Rotate", "Preference", "Name", "Copy Brush", "Change Brush", "Delete Brush", "Texture",
			"Strength", "No Texture", "Add Color", "Delete Color", "Load Pallete", "Add Pallete", "Write Pallete",
			"Clear Pallete", "Pick Mode", "Single Pixel", "Average Color", "Open Path", "Close Path", "Update",
			"Frequency", "Cloud Color", "Persistence", "Random Seed", "Use Random", "Update Immediately",
			"Number of Octaves", "Linear", "Cosine", "Cubic", "Colorize", "Start Editting 3D Model",
			"Finish Editting 3D Model", "Scatter", "Scatter Size", "Scatter Range", "Random Size Scatter",
			"Random Flow Scatter", "Bevel", "Round", "Mitter", "Normal Brush",
			{"Pencil", "Hard Pen", "Air Brush", "Old Air Brush", "Water Color Brush", "Picker Brush", "Eraser", "Bucket",
				"Pattern Fill", "Blur Tool", "Smudge", "Mix Brush", "Gradation", "Text Tool", "Stamp Tool",
				"Image Brush", "Image Blend\nBrush", "Picker Image Brush", "Script Brush", "Custom Brush", "PLUG_IN"},
			{"Detection Target", "Detect from ... ", "Pixels Color", "Pixel Color + Alpha",
				"Alpha", "Active Layer", "Under Layer", "Canvas", "Threshold", "Detection Area", "Normal", "Large"},
			{"Select/Release", "Move Control Point", "Change Pressure", "Delete Control Point",
				"Move Stroke", "Copy & Move Stroke", "Joint Stroke"},
			{"Circle", "Eclipse", "Triangle", "Square", "Rhombus", "Hexagon", "Star", "Pattern", "Image"}
		},
		{"Layer", "Layer", "Vector", "Layer Set", "Text", "Adjustment", "3D Modeling", "Add Layer", "Add Vector Layer",
			"Add Layer Set", "Add 3D Modeling Layer", "Add Adjustment Layer", "Rename Layer", "Reorder Layer",
			"Opacity to Selection Area", "Opacity Add Selection Area", "Pasted Layer", "Under Layer",
			"Mixed Under Layer", "Blend Mode", "Opacity", "Masking with Under Layer", "Lock Opacity",
			{"Normal", "Add", "Multiply", "Screen", "Overlay", "Lighten", "Darken", "Dodge", "Burn",
				"Hard Light", "Soft Light", "Difference", "Exclusion", "Hue", "Saturation", "Color",
				"Luminosity", "Binalize"}},
		{"Random (Straight)", "Bidirection"},
		{"Compress", "Quality", "Write Opacity Data", "Write ICC Profile Data", "Save before close the image?",
			"There are some images with unsaved changes.", "There is Backup File.\nRecover it?"},
		{"Navigtion"},
		{"Preference", "Base Settings", "Auto Save", "Theme", "Default",
			"There is a conflict to set a hot key.", "Language", "Backup File Directory",
			"Show Preview Window on Taskbar", "Draw with Touch", "Scale Change and Move Canvas with Change",
			"Set Back Ground Color"},
		{"Execute Back Up..."}
	};

	static FRACTAL_LABEL fractal_labels =
	{
		"Triangle", "Transform", "Variations", "Colors", "Random",
		"Weight", "Symmetry", "Linear", "Sinusoidal", "Spherical",
		"Swirl", "Shorseshoe", "Polar", "Handkerchief", "Heart", "Disc",
		"Spiral", "Hyperbolic", "Diamond", "Ex", "Julia", "Bent", "Waves",
		"Fish Eye", "Pop Corn", "Preserve Weights", "Update", "Update Immediately",
		"Adjust", "Rendering", "Gamma", "Brightness", "Vibrancy", "Camera", "Zoom",
		"Option", "Oversample", "Filter Radius", "Forced Symmetry", "Type",
		"Order", "None", "Bilateral", "Rotational", "Dihedral", "Mutation",
		"Directions", "Controls", "Speed", "Trend", "Auto Zoom", "Add", "Delete",
		"Flip Horizontal", "Flip Vertical", "Flip Horizontal All",
		"Flip Vertical All", "Use Random", "Rest", "Create ID"
	};

	void *tbb = NULL;

#if defined(CHECK_MEMORY_POOL) && CHECK_MEMORY_POOL != 0
	_CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF);
#endif

#if defined(USE_3D_LAYER) && USE_3D_LAYER != 0
	application.flags |= APPLICATION_HAS_3D_LAYER;
	tbb = TbbObjectNew();
#endif

#ifdef _DEBUG
	atexit(AtExit);
#endif

	{
		gchar *raw_path;

		application.labels = &labels;
		application.fractal_labels = &fractal_labels;

#if GTK_MAJOR_VERSION <= 2
		gtk_set_locale();
#endif
		gtk_init(&argc, &argv);

#if defined(USE_3D_LAYER) && USE_3D_LAYER != 0
		gtk_gl_init(&argc, &argv);
#endif

		raw_path = g_locale_to_utf8(argv[0], -1, NULL, NULL, NULL);
		application.current_path = g_path_get_dirname(raw_path);

		InitializeApplication(&application, INITIALIZE_FILE_NAME);
		g_free(raw_path);
	}

	/*
	{
		cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 500, 500);
		cairo_t *cairo_p = cairo_create(surface);

		cairo_scale(cairo_p, 1, 2);
		cairo_arc(cairo_p, 100, 100, 50, 0, 2*G_PI);
		cairo_fill(cairo_p);

		cairo_surface_write_to_png(surface, "test.png");

		cairo_destroy(cairo_p);
	}
	*/

	if(argc > 1)
	{
		//gchar *file_path = g_locale_to_utf8(argv[1], -1, NULL, NULL, NULL);

		//OpenFile(file_path, &application);

		//g_free(file_path);

#ifdef _PROFILING
		return 0;
#endif
	}

	gtk_main();

#if defined(USE_3D_LAYER) && USE_3D_LAYER != 0
	DeleteTbbObject(tbb);
#endif

	return 0;
}
示例#12
0
文件: cwri.c 项目: xtforever/xtcw
/******************************************************************************
*   MAIN function
******************************************************************************/
int main ( int argc, char **argv )
{
    trace_main = TRACE_MAIN;

    XtAppContext app;
    m_init();
    XtSetLanguageProc (NULL, NULL, NULL);
    XawInitializeWidgetSet();

    /*  --  Intialize Toolkit creating the application shell
     */
    Widget appShell = XtOpenApplication (&app, APP_NAME,
             /* resources: can be set from argv */
             options, XtNumber(options),
	     &argc, argv,
	     fallback_resources,
	     sessionShellWidgetClass,
	     NULL, 0
	   );
    load_icon(XtDisplay(appShell));
    //    load_icon_default();

    /*  --  Enable Editres support
     */
    XtAddEventHandler(appShell, (EventMask) 0, True, _XEditResCheckMessages, NULL);

    XtAddCallback( appShell, XtNdieCallback, quit_cb, NULL );

    /*  --  not parsed options are removed by XtOpenApplication
            the only entry left should be the program name
    */
    if (argc != 1) { m_destruct(); syntax(); exit(1); }
    TopLevel = appShell;


    /*  --  Register all application specific
            callbacks and widget classes
    */
    RegisterApplication ( appShell );

    /*  --  Register all Athena and Public
            widget classes, CBs, ACTs
    */
    XpRegisterAll ( app );

    /*  --  Create widget tree below toplevel shell
            using Xrm database
    */
    WcWidgetCreation ( appShell );


    /*  -- Get application resources and widget ptrs
     */
    XtGetApplicationResources(	appShell, (XtPointer)&CWRI,
				CWRI_CONFIG_RES,
				XtNumber(CWRI_CONFIG_RES),
				(ArgList)0, 0 );

    InitializeApplication(appShell);

    /*  --  Realize the widget tree and enter
            the main application loop  */
    XtRealizeWidget ( appShell );
    /*  --  Set Icon for Window */
    set_app_icon(appShell);

    grab_window_quit( appShell );

    XtAppMainLoop ( app ); /* use XtAppSetExitFlag */
    XtDestroyWidget(appShell);
    m_destruct();

    return EXIT_SUCCESS;
}
示例#13
0
文件: video.c 项目: xtforever/xtcw
/******************************************************************************
*   MAIN function
******************************************************************************/
int main ( int argc, char **argv )
{
    trace_main = TRACE_MAIN;

    XtAppContext app;
    signal(SIGPIPE, SIG_IGN); /* ignore broken pipe on write */
    m_init();
    trace_level = trace_main;

    XtSetLanguageProc (NULL, NULL, NULL);
    XawInitializeWidgetSet();
    /*  -- Intialize Toolkit creating the application shell
     */
    Widget appShell = XtOpenApplication (&app, APP_NAME,
	     options, XtNumber(options),  /* resources: can be set from argv */
	     &argc, argv,
	     fallback_resources,
	     sessionShellWidgetClass,
	     NULL, 0
	   );

    /* enable Editres support */
    XtAddEventHandler(appShell, (EventMask) 0, True, _XEditResCheckMessages, NULL);

    XtAddCallback( appShell, XtNdieCallback, quit_gui, NULL );

    /* not parsed options are removed by XtOpenApplication
       the only entry left should be the program name
    */
    if (argc != 1) { m_destruct(); syntax(); exit(1); }

    TopLevel = appShell;


    /*  -- Register all application specific callbacks and widget classes
     */
    RegisterApplication ( appShell );

    /*  -- Register all Athena and Public widget classes, CBs, ACTs
     */
    XpRegisterAll ( app );

    /*  -- Create widget tree below toplevel shell using Xrm database
     */
    WcWidgetCreation ( appShell );

    /* get application resources and widget ptr */
    XtGetApplicationResources(	appShell, (XtPointer)&CONFIG,
				basicSettingRes,
				XtNumber(basicSettingRes),
				(ArgList)0, 0 );


    InitializeApplication(appShell);

    /*  -- Realize the widget tree and enter the main application loop
     */
    XtRealizeWidget ( appShell );
    grab_window_quit( appShell );


    XtAppMainLoop ( app ); /* use XtAppSetExitFlag */
    XtDestroyWidget(appShell);

    v_free(CONFIG.vset);
    m_destruct();

    return EXIT_SUCCESS;
}