main () { int x,y, poziom, pion; printf("\nWYKRES FUNKCJI:\n\n "); for (x=0; x<szer; x=x+1) for (y=0; y<wys; y=y+1) rysuj(x, y, ' '); pion = interpoluj(0, dol_x, gora_x, szer); for(y=0; y<wys; y=y+1) rysuj(pion, y, '|'); poziom = interpoluj(0, dol_y, gora_y, wys); for(x=0; x<szer; x=x+1) rysuj(x, poziom, '-'); rysuj(pion, poziom, '+'); for (x=0; x<szer; x=x+1) rysuj(x, f_b(x), '*'); for (y=wys-1; y>=0; y=y-1) { for (x=0; x<szer; x=x+1) printf("%c", rysunek[x][y]); printf("\n "); } printf("\n\n"); }
QString get_info_from_file(const char* path_file, const char* name_info, const char* color) { QString s_msg = "<table border=0 width=100%>"; s_msg += QString("<tr bgcolor=\"lightGray\"><th>%1</th><tr>").arg(name_info); QString msg; QFile f_b(path_file); if(f_b.exists()) { if ( f_b.open( IO_ReadOnly ) ) { QTextStream stream( &f_b ); while ( !stream.atEnd() ) { QString line = stream.readLine(); if(line.isEmpty()) continue; line.replace("<","<"); QString s1 = QString("<tr bgcolor=\"#EEF6FF\"><td><font color=\"%1\">").arg(color); int i = line.find("="); if(i == -1) i = line.find(":"); if(i!=-1) { QString s2 = "</font><font color=\"#0F990F\">"; line.insert(i+1,s2); msg += s1+line+"</font></td></tr>"; } else msg += s1 + line + "</font></td></tr>"; } f_b.close(); } else msg +=QString("<tr bgcolor=\"#EEF6FF\"><td><font color=\"red\">%1 : %2</font></td>").arg(QObject::tr("can't open file")).arg(path_file); } else { msg +=QString("<tr bgcolor=\"#EEF6FF\"><td><font color=\"red\">%1</font></td>").arg(QObject::tr("Not found")); } s_msg += msg; s_msg += "</table>"; return s_msg; }
int main() { setbuf(stdout, NULL); for (long l = 256; l <= 16384; l *= 2) { // for (long n = 256; n <= 16384; n *= 2) { for (long idx = 0; idx < 13; idx ++) { long n = 256*(1L << idx/2); if (idx & 1) n += n/2; SetSeed((ZZ(l) << 64) + ZZ(n)); ZZX a, b, c; a.SetLength(n); for (long i = 0; i < n; i++) RandomBits(a[i], l); a.normalize(); b.SetLength(n); for (long i = 0; i < n; i++) RandomBits(b[i], l); b.normalize(); double t; mul(c, a, b); long iter = 1; do { t = GetTime(); for (long i = 0; i < iter; i++) mul(c, a, b); t = GetTime() - t; iter *= 2; } while (t < 3); iter /= 2; t = GetTime(); for (long i = 0; i < iter; i++) mul(c, a, b); t = GetTime()-t; double NTLTime = t; FlintZZX f_a(a), f_b(b), f_c(c); fmpz_poly_mul(f_c.value, f_a.value, f_b.value); t = GetTime(); for (long i = 0; i < iter; i++) fmpz_poly_mul(f_c.value, f_a.value, f_b.value); t = GetTime()-t; double FlintTime = t; printf("%8.2f", FlintTime/NTLTime); } printf("\n"); } }
main () { int x,y, poziom, pion, wyb; printf("\nMENU:\n\n "); printf("Wybierz wykres do narysowania:\n"); printf("1. y=x^3/27-2x^2/9+x/3+2\n"); printf("2. y=ln(x+1)\n"); printf("3. y=x^2\n"); scanf("%d", &wyb); for (x=0; x<szer; x=x+1) for (y=0; y<wys; y=y+1) rysuj(x, y, ' '); pion = interpoluj(0, dol_x, gora_x, szer); for(y=0; y<wys; y=y+1) rysuj(pion, y, '|'); poziom = interpoluj(0, dol_y, gora_y, wys); for(x=0; x<szer; x=x+1) rysuj(x, poziom, '-'); rysuj(pion, poziom, '+'); for (x=0; x<szer; x=x+1) rysuj(x, f_b(x), '*'); for (y=wys-1; y>=0; y=y-1) { for (x=0; x<szer; x=x+1) printf("%c", rysunek[x][y]); printf("\n "); printf("\n\n"); } }
int main (int arg, char *argv[]) { GModule *module_self, *module_a, *module_b; gchar *dir; gchar *plugin_a, *plugin_b; SimpleFunc f_a, f_b, f_self; GModuleFunc gmod_f; if (!g_module_supported ()) return 0; dir = g_get_current_dir (); plugin_a = g_strconcat (dir, G_DIR_SEPARATOR_S "libmoduletestplugin_a", NULL); plugin_b = g_strconcat (dir, G_DIR_SEPARATOR_S "libmoduletestplugin_b", NULL); g_free (dir); /* module handles */ module_self = g_module_open (NULL, G_MODULE_BIND_LAZY); if (!module_self) g_error ("error: %s", g_module_error ()); if (!g_module_symbol (module_self, "g_module_close", (gpointer *) &f_self)) g_error ("error: %s", g_module_error ()); module_a = g_module_open (plugin_a, G_MODULE_BIND_LAZY); if (!module_a) g_error ("error: %s", g_module_error ()); module_b = g_module_open (plugin_b, G_MODULE_BIND_LAZY); if (!module_b) g_error ("error: %s", g_module_error ()); /* get plugin state vars */ if (!g_module_symbol (module_a, "gplugin_a_state", (gpointer *) &gplugin_a_state)) g_error ("error: %s", g_module_error ()); if (!g_module_symbol (module_b, "gplugin_b_state", (gpointer *) &gplugin_b_state)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, "check-init"); /* get plugin specific symbols and call them */ if (!g_module_symbol (module_a, "gplugin_a_func", (gpointer *) &f_a)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); if (!g_module_symbol (module_b, "gplugin_b_func", (gpointer *) &f_b)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); f_a (); test_states (NULL, "Hello world", NULL); f_b (); test_states (NULL, NULL, "Hello world"); /* get and call globally clashing functions */ if (!g_module_symbol (module_self, "g_clash_func", (gpointer *) &f_self)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); if (!g_module_symbol (module_a, "g_clash_func", (gpointer *) &f_a)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); if (!g_module_symbol (module_b, "g_clash_func", (gpointer *) &f_b)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); f_self (); test_states ("global clash", NULL, NULL); f_a (); test_states (NULL, "global clash", NULL); f_b (); test_states (NULL, NULL, "global clash"); /* get and call clashing plugin functions */ if (!g_module_symbol (module_a, "gplugin_clash_func", (gpointer *) &f_a)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); if (!g_module_symbol (module_b, "gplugin_clash_func", (gpointer *) &f_b)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); plugin_clash_func = f_a; plugin_clash_func (); test_states (NULL, "plugin clash", NULL); plugin_clash_func = f_b; plugin_clash_func (); test_states (NULL, NULL, "plugin clash"); /* call gmodule function from A */ if (!g_module_symbol (module_a, "gplugin_a_module_func", (gpointer *) &gmod_f)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); gmod_f (module_b); test_states (NULL, NULL, "BOOH"); gmod_f (module_a); test_states (NULL, "BOOH", NULL); /* unload plugins */ if (!g_module_close (module_a)) g_error ("error: %s", g_module_error ()); if (!g_module_close (module_b)) g_error ("error: %s", g_module_error ()); return 0; }
int main (int arg, char *argv[]) { GModule *module_self, *module_a, *module_b; gchar *string; gchar *plugin_a, *plugin_b; SimpleFunc f_a, f_b, f_self; GModuleFunc gmod_f; string = g_get_current_dir (); g_print ("testgmodule (%s):\n", string); #if (G_MODULE_IMPL == G_MODULE_IMPL_WIN32) plugin_a = g_strconcat (string, "\\libgplugin_a.dll", NULL); plugin_b = g_strconcat (string, "\\libgplugin_b.dll", NULL); #elif (G_MODULE_IMPL == G_MODULE_IMPL_DLD) plugin_a = g_strconcat (string, "/.libs/", "libgplugin_a.sl", NULL); plugin_b = g_strconcat (string, "/.libs/", "libgplugin_b.sl", NULL); #else /* neither DLD nor WIN32 */ plugin_a = g_strconcat (string, "/.libs/", "libgplugin_a.so", NULL); plugin_b = g_strconcat (string, "/.libs/", "libgplugin_b.so", NULL); #endif g_free (string); /* module handles */ g_print ("get main module handle\n"); module_self = g_module_open (NULL, G_MODULE_BIND_LAZY); if (!module_self) { g_print ("error: %s\n", g_module_error ()); return 1; } g_print ("check that not yet bound symbols in shared libraries of main module are retrievable:\n"); string = "g_module_close"; g_print ("retrive symbol `%s' from \"%s\":\n", string, g_basename (g_module_name (module_self))); if (!g_module_symbol (module_self, string, (gpointer) &f_self)) { g_print ("error: %s\n", g_module_error ()); return 1; } g_print ("retrived symbol `%s' as %p\n", string, f_self); g_print ("load plugin from \"%s\"\n", plugin_a); module_a = g_module_open (plugin_a, G_MODULE_BIND_LAZY); if (!module_a) { g_print ("error: %s\n", g_module_error ()); return 1; } g_print ("load plugin from \"%s\"\n", plugin_b); module_b = g_module_open (plugin_b, G_MODULE_BIND_LAZY); if (!module_b) { g_print ("error: %s\n", g_module_error ()); return 1; } /* get plugin specific symbols and call them */ string = "gplugin_a_func"; g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_a))); if (!g_module_symbol (module_a, string, (gpointer) &f_a)) { g_print ("error: %s\n", g_module_error ()); return 1; } string = "gplugin_b_func"; g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_b))); if (!g_module_symbol (module_b, string, (gpointer) &f_b)) { g_print ("error: %s\n", g_module_error ()); return 1; } g_print ("call plugin function(%p) A: ", f_a); f_a (); g_print ("call plugin function(%p) B: ", f_b); f_b (); /* get and call globally clashing functions */ string = "g_clash_func"; g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_self))); if (!g_module_symbol (module_self, string, (gpointer) &f_self)) { g_print ("error: %s\n", g_module_error ()); return 1; } g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_a))); if (!g_module_symbol (module_a, string, (gpointer) &f_a)) { g_print ("error: %s\n", g_module_error ()); return 1; } g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_b))); if (!g_module_symbol (module_b, string, (gpointer) &f_b)) { g_print ("error: %s\n", g_module_error ()); return 1; } g_print ("call plugin function(%p) self: ", f_self); f_self (); g_print ("call plugin function(%p) A: ", f_a); f_a (); g_print ("call plugin function(%p) B: ", f_b); f_b (); /* get and call clashing plugin functions */ string = "gplugin_clash_func"; g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_self))); if (!g_module_symbol (module_self, string, (gpointer) &f_self)) f_self = NULL; g_print ("retrived function `%s' from self: %p\n", string, f_self); g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_a))); if (!g_module_symbol (module_a, string, (gpointer) &f_a)) { g_print ("error: %s\n", g_module_error ()); return 1; } g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_b))); if (!g_module_symbol (module_b, string, (gpointer) &f_b)) { g_print ("error: %s\n", g_module_error ()); return 1; } g_print ("call plugin function(%p) A: ", f_a); plugin_clash_func = f_a; plugin_clash_func (); g_print ("call plugin function(%p) B: ", f_b); plugin_clash_func = f_b; plugin_clash_func (); /* call gmodule function form A */ string = "gplugin_a_module_func"; g_print ("retrive symbol `%s' from \"%s\"\n", string, g_basename (g_module_name (module_a))); if (!g_module_symbol (module_a, string, (gpointer) &gmod_f)) { g_print ("error: %s\n", g_module_error ()); return 1; } g_print ("call plugin A's module function(%p):\n{\n", gmod_f); gmod_f (module_b); g_print ("}\n"); /* unload plugins */ g_print ("unload plugin A:\n"); if (!g_module_close (module_a)) g_print ("error: %s\n", g_module_error ()); g_print ("unload plugin B:\n"); if (!g_module_close (module_b)) g_print ("error: %s\n", g_module_error ()); #if 0 g_log_set_fatal_mask ("GModule", G_LOG_FATAL_MASK|G_LOG_LEVEL_WARNING); g_module_symbol (0, 0, 0); g_warning("jahooo"); g_on_error_query (".libs/testgmodule"); #endif return 0; }
int main (int argc, char **argv) { GModule *module_self, *module_a, *module_b; gchar *plugin_a, *plugin_b; SimpleFunc f_a, f_b, f_self; GModuleFunc gmod_f; g_test_init (&argc, &argv, NULL); if (!g_module_supported ()) g_error ("dynamic modules not supported"); plugin_a = g_test_build_filename (G_TEST_BUILT, "libmoduletestplugin_a", NULL); plugin_b = g_test_build_filename (G_TEST_BUILT, "libmoduletestplugin_b", NULL); /* module handles */ module_self = g_module_open (NULL, G_MODULE_BIND_LAZY); if (!module_self) g_error ("error: %s", g_module_error ()); if (!g_module_symbol (module_self, "g_module_close", (gpointer *) &f_self)) g_error ("error: %s", g_module_error ()); module_a = g_module_open (plugin_a, G_MODULE_BIND_LAZY); if (!module_a) g_error ("error: %s", g_module_error ()); module_b = g_module_open (plugin_b, G_MODULE_BIND_LAZY); if (!module_b) g_error ("error: %s", g_module_error ()); /* get plugin state vars */ if (!g_module_symbol (module_a, "gplugin_a_state", (gpointer *) &gplugin_a_state)) g_error ("error: %s", g_module_error ()); if (!g_module_symbol (module_b, "gplugin_b_state", (gpointer *) &gplugin_b_state)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, "check-init"); /* get plugin specific symbols and call them */ if (!g_module_symbol (module_a, "gplugin_a_func", (gpointer *) &f_a)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); if (!g_module_symbol (module_b, "gplugin_b_func", (gpointer *) &f_b)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); f_a (); test_states (NULL, "Hello world", NULL); f_b (); test_states (NULL, NULL, "Hello world"); /* get and call globally clashing functions */ if (!g_module_symbol (module_self, "g_clash_func", (gpointer *) &f_self)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); if (!g_module_symbol (module_a, "g_clash_func", (gpointer *) &f_a)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); if (!g_module_symbol (module_b, "g_clash_func", (gpointer *) &f_b)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); f_self (); test_states ("global clash", NULL, NULL); f_a (); test_states (NULL, "global clash", NULL); f_b (); test_states (NULL, NULL, "global clash"); /* get and call clashing plugin functions */ if (!g_module_symbol (module_a, "gplugin_clash_func", (gpointer *) &f_a)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); if (!g_module_symbol (module_b, "gplugin_clash_func", (gpointer *) &f_b)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); plugin_clash_func = f_a; plugin_clash_func (); test_states (NULL, "plugin clash", NULL); plugin_clash_func = f_b; plugin_clash_func (); test_states (NULL, NULL, "plugin clash"); /* call gmodule function from A */ if (!g_module_symbol (module_a, "gplugin_a_module_func", (gpointer *) &gmod_f)) g_error ("error: %s", g_module_error ()); test_states (NULL, NULL, NULL); gmod_f (module_b); test_states (NULL, NULL, "BOOH"); gmod_f (module_a); test_states (NULL, "BOOH", NULL); /* unload plugins */ if (!g_module_close (module_a)) g_error ("error: %s", g_module_error ()); if (!g_module_close (module_b)) g_error ("error: %s", g_module_error ()); g_free (plugin_a); g_free (plugin_b); g_module_close (module_self); return 0; }
int main() { setbuf(stdout, NULL); SetSeed(ZZ(0)); for (long l = 256; l <= 16384; l *= 2) { // for (long n = 256; n <= 16384; n *= 2) { for (long idx = 0; idx < 13; idx ++) { long n = 256*(1L << idx/2); if (idx & 1) n += n/2; SetSeed((ZZ(l) << 64) + ZZ(n)); ZZ p; RandomLen(p, l); if (!IsOdd(p)) p++; ZZ_p::init(p); ZZ_pX a, b, c, f; random(a, n); random(b, n); random(f, n); SetCoeff(f, n); ZZ_pXModulus F(f); ZZ_pXMultiplier B(b, F); double t; MulMod(c, a, B, F); long iter = 1; do { t = GetTime(); for (long i = 0; i < iter; i++) MulMod(c, a, B, F); t = GetTime() - t; iter *= 2; } while (t < 3); iter /= 2; t = GetTime(); for (long i = 0; i < iter; i++) MulMod(c, a, B, F); t = GetTime()-t; double NTLTime = t; FlintZZ_pX f_a(a), f_b(b), f_c, f_f(f), f_finv; fmpz_mod_poly_reverse(f_finv.value, f_f.value, f_f.value->length); fmpz_mod_poly_inv_series_newton(f_finv.value, f_finv.value, f_f.value->length); fmpz_mod_poly_mulmod_preinv(f_c.value, f_a.value, f_b.value, f_f.value, f_finv.value); t = GetTime(); for (long i = 0; i < iter; i++) fmpz_mod_poly_mulmod_preinv(f_c.value, f_a.value, f_b.value, f_f.value, f_finv.value); t = GetTime()-t; double FlintTime = t; printf("%8.2f", FlintTime/NTLTime); } printf("\n"); } }