int loadandcall(char* libname) { int rc = 0; MQTTAsync_nameValue* (*func_address)(void) = NULL; #if defined(WIN32) || defined(WIN64) HMODULE APILibrary = LoadLibrary(libname); if (APILibrary == NULL) printf("Error loading library %s, error code %d\n", libname, GetLastError()); else { func_address = (func_type)GetProcAddress(APILibrary, "MQTTAsync_getVersionInfo"); if (func_address == NULL) func_address = (func_type)GetProcAddress(APILibrary, "MQTTClient_getVersionInfo"); if (func_address) rc = printVersionInfo((*func_address)()); FreeLibrary(APILibrary); } #else void* APILibrary = dlopen(libname, RTLD_LAZY); /* Open the Library in question */ char* ErrorOutput = dlerror(); /* Check it opened properly */ if (ErrorOutput != NULL) printf("Error loading library %s, error %s\n", libname, ErrorOutput); else { *(void **) (&func_address) = dlsym(APILibrary, "MQTTAsync_getVersionInfo"); if (func_address == NULL) func_address = dlsym(APILibrary, "MQTTClient_getVersionInfo"); if (func_address) rc = printVersionInfo((*func_address)()); dlclose(APILibrary); } #endif return rc; }
/* * Parse command line arguments for fppmm binary */ int parseArguments(int argc, char **argv) { char *s = NULL; int c; while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"mapname", required_argument, 0, 'm'}, {"overlaymode", required_argument, 0, 'o'}, {"filename", required_argument, 0, 'f'}, {"testmode", required_argument, 0, 't'}, {"displayvers", no_argument, 0, 'V'}, {"channel", required_argument, 0, 'c'}, {"setvalue", required_argument, 0, 's'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "m:o:f:t:c:s:hV", long_options, &option_index); if (c == -1) break; switch (c) { case 'V': printVersionInfo(); exit(0); case 'm': blockName = strdup(optarg); break; case 'o': if (!strcmp(optarg, "off")) isActive = 0; else if (!strcmp(optarg, "on")) isActive = 1; else if (!strcmp(optarg, "transparent")) isActive = 2; else if (!strcmp(optarg, "transparentrgb")) isActive = 3; break; case 'f': inputFilename = strdup(optarg); break; case 't': testMode = strdup(optarg); break; case 'c': channels = strdup(optarg); break; case 's': channelData = strtol(optarg, NULL, 10); break; case 'h': usage(argv[0]); exit(EXIT_SUCCESS); default: usage(argv[0]); exit(EXIT_FAILURE); } } }
/** * main * This example uses the asynchronous API to * - detect removal or additon of devices * - get the product ID information from added devices * Devices may or may not be connected when this example is launched * Devices may be add/removed (pugged/unplugged) while this example is running. */ int main(int argc, char* argv[]) { int numIds; int deviceIds[FREESPACE_MAXIMUM_DEVICE_COUNT]; int rc; // Flag to indicate that the application should quit // Set by the control signal handler int quit = 0; printVersionInfo(argv[0]); addControlHandler(&quit); // Initialize the freespace library rc = freespace_init(); if (rc != FREESPACE_SUCCESS) { printf("Initialization error. rc=%d\n", rc); return 1; } // Set the callback to catch the initial devices. printf("Detecting the Freespace devices already connected...\n"); freespace_setDeviceHotplugCallback(hotplugCallback, NULL); freespace_perform(); printf("Waiting for Freespace devices to be inserted...\n"); printf("Type Ctrl-C to exit\n"); while (!quit) { // Easy event loop - just poll freespace_perform periodically // rather than waiting on select or WaitForMultipleObjects Sleep(100); // Callbacks are called from within the perform call. freespace_perform(); } printf("Exiting\n"); printf("Cleaning up all devices...\n"); rc = freespace_getDeviceList(deviceIds, FREESPACE_MAXIMUM_DEVICE_COUNT, &numIds); if (rc == FREESPACE_SUCCESS) { int i; for (i = 0; i < numIds; i++) { freespace_closeDevice(deviceIds[i]); } } else { printf("Error getting device list.\n"); } freespace_exit(); return 0; }
void processCommandLine ( int argc, const char* argv[] ) { /* local function variables */ unsigned int i = 0; bool inV = false; bool inH = false; bool inF = false; bool inB = false; bool unknown = false; bool inTooLong = false; char* tooLongOrigin = NULL; /* ---------------------------- */ /* scan all commandline parameters */ for(i = 1; i < argc; i++) { /* local variables */ char* current = NULL; /* --------------------- */ /* set current */ current = (char*)argv[i]; if(inF == true) { inF = false; /* nothing to process ? */ if(i >= argc) continue; /* check if too long */ if(strlen(current) >= 1024) { inTooLong = true; tooLongOrigin = "header file name"; break; } strncpy(header_file, current, 1024); } else if(inB == true) { inB = false; /* nothing to process ? */ if(i >= argc) continue; /* check if too long */ if(strlen(current) >= 1024) { inTooLong = true; tooLongOrigin = "blob name"; break; } strncpy(blob_name, current, 1024); } else if(current[0] == '-') { if((current[1] == 'v' && current[2] == 0) || strcmp(¤t[2], "version") == 0) { inV = true; break; } else if((current[1] == 'h' && current[2] == 0) || strcmp(¤t[2], "help") == 0) { inH = true; break; } else if((current[1] == 'f' && current[2] == 0) || strcmp(¤t[2], "file") == 0) { inF = true; } else if((current[1] == 'b' && current[2] == 0) || strcmp(¤t[2], "blobname") == 0) { inB = true; } else { unknown = true; break; } } else { /* set binary file */ binary_file = (char*)current; } } if(unknown == true) { printHeader(); printUnknown(); exit(EXIT_FAILURE); } else if(inTooLong == true) { printHeader(); printTooLong(tooLongOrigin); exit(EXIT_FAILURE); } else if(inV == true) { printHeader(); printVersionInfo(); exit(0); } else if(inH == true) { printHeader(); printUsage(argv[0]); printCommands(); exit(0); } if(binary_file == NULL) { printHeader(); printNoBinaryFile(); exit(EXIT_FAILURE); } if(blob_name[0] == 0) { /* copy default value */ strncpy(blob_name, DEFAULT_BLOB_NAME, 1024); } if(header_file[0] == 0) { /* copy default value */ strncpy(header_file, binary_file, 1024); strncat(header_file, "_", 1024); strncat(header_file, blob_name, 1024); strncat(header_file, ".h", 1024); } }
void versionInfoFunc(int value) { displaySubMenu(subMenuGenericUpdateFunc); printVersionInfo(); }
/** * main * This example uses the synchronous API to * - find a device * - open the device found * - configure the device to output motion * - read motion messages sent by the device * This example assume the device is already connected. */ int main(int argc, char* argv[]) { struct freespace_message message; FreespaceDeviceId device; int numIds; // The number of device ID found int rc; // Return code //struct MultiAxisSensor pointer; //struct MultiAxisSensor angVel; // Flag to indicate that the application should quit // Set by the control signal handler int quit = 0; printVersionInfo(argv[0]); addControlHandler(&quit); // Initialize the freespace library rc = freespace_init(); if (rc != FREESPACE_SUCCESS) { printf("Initialization error. rc=%d\n", rc); return 1; } printf("Scanning for Freespace devices...\n"); // Get the ID of the first device in the list of availble devices rc = freespace_getDeviceList(&device, 1, &numIds); if (numIds == 0) { printf("Didn't find any devices.\n"); return 1; } printf("Found a device. Trying to open it...\n"); // Prepare to communicate with the device found above rc = freespace_openDevice(device); if (rc != FREESPACE_SUCCESS) { printf("Error opening device: %d\n", rc); return 1; } // Display the device information. printDeviceInfo(device); // Make sure any old messages are cleared out of the system rc = freespace_flush(device); if (rc != FREESPACE_SUCCESS) { printf("Error flushing device: %d\n", rc); return 1; } // Cleanup when done and configure the device to output mouse packets printf("Sending message to enable mouse data.\n"); memset(&message, 0, sizeof(message)); // Init message fields to 0 message.messageType = FREESPACE_MESSAGE_DATAMODECONTROLV2REQUEST; message.dataModeControlV2Request.packetSelect = 1; // Mouse packet message.dataModeControlV2Request.mode = 0; // Set full motion rc = freespace_sendMessage(device, &message); if (rc != FREESPACE_SUCCESS) { printf("Could not send message: %d.\n", rc); } // Close communications with the device printf("Cleaning up...\n"); freespace_closeDevice(device); // Cleanup the library freespace_exit(); return 0; }
int main(int argc, char *argv[]) { initSettings(argc, argv); initMediaDetails(); if (DirectoryExists("/home/fpp")) loadSettings("/home/fpp/media/settings"); else loadSettings("/home/pi/media/settings"); wiringPiSetupGpio(); // would prefer wiringPiSetupSys(); // Parse our arguments first, override any defaults parseArguments(argc, argv); if (loggingToFile()) logVersionInfo(); printVersionInfo(); // Start functioning if (getDaemonize()) CreateDaemon(); scheduler = new Scheduler(); playlist = new Playlist(); sequence = new Sequence(); channelTester = new ChannelTester(); #ifndef NOROOT struct sched_param param; param.sched_priority = 99; if (sched_setscheduler(0, SCHED_FIFO, ¶m) != 0) { perror("sched_setscheduler"); exit(EXIT_FAILURE); } #endif MainLoop(); if (getFPPmode() != BRIDGE_MODE) { CleanupMediaOutput(); } if (getFPPmode() & PLAYER_MODE) { if (getFPPmode() == MASTER_MODE) ShutdownSync(); CloseChannelDataMemoryMap(); CloseEffects(); } CloseChannelOutputs(); delete channelTester; delete scheduler; delete playlist; delete sequence; return 0; }
/** * main * This example uses the synchronous API to * - find a device * - open the device found * - send a message * - look for a response * This example assumes that the device is already connected. */ int main(int argc, char* argv[]) { FreespaceDeviceId device; // Keep track of the device you are talking to struct freespace_message send; // A place to create messages to send to the device struct freespace_message receive; // A place to put a message received from the device int numIds; // Keep track of how many devices are available int rc; // Return Code int retryCount = 0; // How many times tried so far to get a response // Flag to indicate that the application should quit // Set by the control signal handler int quit = 0; printVersionInfo(argv[0]); addControlHandler(&quit); // Initialize the freespace library rc = freespace_init(); if (rc != FREESPACE_SUCCESS) { printf("Initialization error. rc=%d\n", rc); return 1; } printf("Scanning for Freespace devices...\n"); // Get the ID of the first device in the list of availble devices rc = freespace_getDeviceList(&device, 1, &numIds); if (numIds == 0) { printf("Didn't find any devices.\n"); return 1; } printf("Found a device. Trying to open it...\n"); // Prepare to communicate with the device found above rc = freespace_openDevice(device); if (rc != FREESPACE_SUCCESS) { printf("Error opening device: %d\n", rc); return 1; } // Display the device information. printDeviceInfo(device); // Make sure any old messages are cleared out of the system rc = freespace_flush(device); if (rc != FREESPACE_SUCCESS) { printf("Error flushing device: %d\n", rc); return 1; } printf("Requesting battery level messages.\n"); memset(&send, 0, sizeof(send)); // Start with a clean message struct // Populate the message fields. Two options are shown below. Uncomment one desired // and comment out the one not desired. //send.messageType = FREESPACE_MESSAGE_BATTERYLEVELREQUEST; // To send a battery level request send.messageType = FREESPACE_MESSAGE_PRODUCTIDREQUEST; // To send a product ID request while (!quit) { if (retryCount < RETRY_COUNT_LIMIT) { retryCount++; // Send the message constructed above. rc = freespace_sendMessage(device, &send); if (rc != FREESPACE_SUCCESS) { printf("Could not send message: %d.\n", rc); } // Read the response message. rc = freespace_readMessage(device, &receive, 100); if (rc == FREESPACE_SUCCESS) { // Print the received message freespace_printMessage(stdout, &receive); retryCount = 0; } else if (rc == FREESPACE_ERROR_TIMEOUT) { printf("<timeout> Try moving the Freespace device to wake it up.\n"); } else if (rc == FREESPACE_ERROR_INTERRUPTED) { printf("<interrupted>\n"); } else { printf("Error reading: %d. Quitting...\n", rc); break; } } else { printf("Did not receive response after %d trials\n", RETRY_COUNT_LIMIT); quit = 1; } SLEEP; } printf("Cleaning up...\n"); freespace_closeDevice(device); freespace_exit(); return 0; }
/* ----------------------------------------------------------------- */ int gensymm_main(int argc, char *argv[]) { int a,i,j,k,l,x,y,z,w,numOfVars,numOfGenerators,infoLevel; vector v; char fileName[127],outFileName[127]; FILE *out; setbuf(stdout,0); infoLevel=standardInfoLevel; for (i=1; i<argc-1; i++) { if (strncmp(argv[i],"--",2)==0) { if (strncmp(argv[i],"--qui",5)==0) { infoLevel=-1; } } } if (infoLevel>-1) { printVersionInfo(); } /* We require that all 1's come last in the tuple (x,y,z,w). */ strcpy(fileName,argv[argc-1]); x=atoi(argv[argc-5]); y=atoi(argv[argc-4]); z=atoi(argv[argc-3]); w=atoi(argv[argc-2]); /* Sigh. I did not code the stuff below correctly. Damn. To fix it, I need to bring the numbers >1 in (x,y,z,w) into opposite order. */ if (w>1) { /* Switch order of x,y,z,w. */ a=w; w=x; x=a; a=z; z=y; y=a; } else { if (z>1) { /* Switch order of x,y,z. */ a=z; z=x; x=a; } else { /* Switch order of x,y. */ a=y; y=x; x=a; } } /* Now we are back in business. */ strcpy(outFileName,fileName); strcat(outFileName,".sym"); if (!(out = fopen(outFileName,"w"))) { printf("Error opening generator file for output."); exit (0); } /* Write dimensions. */ numOfGenerators=4; if (z>1) numOfGenerators=numOfGenerators+2; if (w>1) numOfGenerators=numOfGenerators+2; if (x==y) numOfGenerators++; if (x==z) numOfGenerators++; if (x==w) numOfGenerators++; if (y==z) numOfGenerators++; if (y==w) numOfGenerators++; if ((z>1) && (z==w)) numOfGenerators++; numOfVars = x*y*z*w; fprintf(out,"%d %d\n",numOfGenerators,numOfVars); v = (vector)malloc(sizeof(int)*(numOfVars)); /* Permuting first component. */ for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { if (i==x-1) { v[i*(y*z*w)+j*(z*w)+k*w+l]=0*(y*z*w)+j*(z*w)+k*w+l+1; } else{ v[i*(y*z*w)+j*(z*w)+k*w+l]=(i+1)*(y*z*w)+j*(z*w)+k*w+l+1; } } } } } printPermutationToFile(out, v, numOfVars); for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { if (i==0) v[i*(y*z*w)+j*(z*w)+k*w+l]=1*(y*z*w)+j*(z*w)+k*w+l+1; if (i==1) v[i*(y*z*w)+j*(z*w)+k*w+l]=0*(y*z*w)+j*(z*w)+k*w+l+1; if (i>1) v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+k*w+l+1; } } } } printPermutationToFile(out, v, numOfVars); /* Permuting second component. */ for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { if (j==y-1) { v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+0*(z*w)+k*w+l+1; } else{ v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+(j+1)*(z*w)+k*w+l+1; } } } } } printPermutationToFile(out, v, numOfVars); for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { if (j==0) v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+1*(z*w)+k*w+l+1; if (j==1) v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+0*(z*w)+k*w+l+1; if (j>1) v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+k*w+l+1; } } } } printPermutationToFile(out, v, numOfVars); /* Permuting third component. */ if (z>1) { for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { if (k==z-1) { v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+0*w+l+1; } else{ v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+(k+1)*w+l+1; } } } } } printPermutationToFile(out, v, numOfVars); for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { if (k==0) v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+1*w+l+1; if (k==1) v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+0*w+l+1; if (k>1) v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+k*w+l+1; } } } } printPermutationToFile(out, v, numOfVars); } /* Permuting fourth component. */ if (w>1) { for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { if (l==w-1) { v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+k*w+0+1; } else{ v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+k*w+(l+1)+1; } } } } } printPermutationToFile(out, v, numOfVars); for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { if (l==0) v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+k*w+1+1; if (l==1) v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+k*w+0+1; if (l>1) v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+k*w+l+1; } } } } printPermutationToFile(out, v, numOfVars); } /* We are left with defining mirror symmetries. */ if (x==y) { for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { v[i*(y*z*w)+j*(z*w)+k*w+l]=j*(y*z*w)+i*(z*w)+k*w+l+1; } } } } printPermutationToFile(out, v, numOfVars); } if (x==z) { for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { v[i*(y*z*w)+j*(z*w)+k*w+l]=k*(y*z*w)+j*(z*w)+i*w+l+1; } } } } printPermutationToFile(out, v, numOfVars); } if (x==w) { for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { v[i*(y*z*w)+j*(z*w)+k*w+l]=l*(y*z*w)+j*(z*w)+k*w+i+1; } } } } printPermutationToFile(out, v, numOfVars); } if (y==z) { for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+k*(z*w)+j*w+l+1; } } } } printPermutationToFile(out, v, numOfVars); } if (y==w) { for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+l*(z*w)+k*w+j+1; } } } } printPermutationToFile(out, v, numOfVars); } if ((z>1) && (z==w)) { for (i=0; i<x; i++) { for (j=0; j<y; j++) { for (k=0; k<z; k++) { for (l=0; l<w; l++) { v[i*(y*z*w)+j*(z*w)+k*w+l]=i*(y*z*w)+j*(z*w)+l*w+k+1; } } } } printPermutationToFile(out, v, numOfVars); } return(0); }
void initNetwork(signed char *ssid, SlSecParams_t *keyParams) { memset(g_ConnectionSSID, 0, sizeof(g_ConnectionSSID)); memset(g_ConnectionBSSID, 0, sizeof(g_ConnectionBSSID)); short status = sl_Start(0, 0, 0); if (status >= 0) { printVersionInfo(); // disable scan unsigned char configOpt = SL_SCAN_POLICY(0); sl_WlanPolicySet(SL_POLICY_SCAN, configOpt, NULL, 0); // set tx power to maximum unsigned char txPower = 0; sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (unsigned char *)&txPower); // set power policy to normal sl_WlanPolicySet(SL_POLICY_PM, SL_NORMAL_POLICY, NULL, 0); // remove all rx filters _WlanRxFilterOperationCommandBuff_t rxFilterIdMask; memset(rxFilterIdMask.FilterIdMask, 0xFF, 8); sl_WlanRxFilterSet(SL_REMOVE_RX_FILTER, (unsigned char *)&rxFilterIdMask, sizeof(_WlanRxFilterOperationCommandBuff_t)); status = sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 0, 0, 0, 0), NULL, 0); } if (status < 0) { sl_Stop(SL_STOP_TIMEOUT); ERR_PRINT(status); LOOP_FOREVER(); } if (status < 0) { sl_Stop(SL_STOP_TIMEOUT); ERR_PRINT(status); LOOP_FOREVER(); } sl_WlanDisconnect(); status = sl_WlanSetMode(ROLE_STA); if (status < 0) { sl_Stop(SL_STOP_TIMEOUT); ERR_PRINT(status); LOOP_FOREVER(); } UART_PRINT("\r\n"); UART_PRINT("[QuickStart] Network init\r\n"); status = sl_WlanConnect(ssid, strlen((char *)ssid), NULL, keyParams, NULL); if (status < 0) { sl_Stop(SL_STOP_TIMEOUT); ERR_PRINT(status); LOOP_FOREVER(); } while (!IS_IP_ACQUIRED(g_Status)) { #ifndef SL_PLATFORM_MULTI_THREADED _SlNonOsMainLoopTask(); #else osi_Sleep(100); #endif } sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID); }
/* ----------------------------------------------------------------- */ int output_main(int argc, char *argv[]) { int i,j,x,y,z,numOfVars,numOfRows,numOfFixPoints,numOfLabels,infoLevel, degree,lowdegree,highdegree,coord,sizeOfLayer,val; char *s; char fileName[127],outFileName[127],domFileName[127],symFileName[127], varFileName[127],groFileName[127],costFileName[127]; char **labels; vector v,w,fixpoints; listVector *A, *B, *C, *basis, *domBasis, *tmp, *tmpV, *symmGroup, *weights; FILE *in; infoLevel=standardInfoLevel; for (i=1;i<argc-1;i++) { if (strncmp(argv[i],"--",2)==0) { if (strncmp(argv[i],"--qui",5)==0) { infoLevel=-1; } } } if (infoLevel>-1) { printVersionInfo(); } for (i=1; i<argc; i++) { if (strncmp(argv[i],"--pos",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); basis=extractPositivePartsOfVectors(basis,numOfVars); strcpy(outFileName,fileName); strcat(outFileName,".pos"); printListVectorToFile(outFileName,basis,numOfVars); } if (strncmp(argv[i],"--rep",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(symFileName,fileName); strcat(symFileName,".sym.full"); symmGroup=readListVector(&numOfVars,symFileName); if (symmGroup==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(symFileName,fileName); strcat(symFileName,".sym"); symmGroup=readListVector(&numOfVars,symFileName); tmpV=symmGroup; while (tmpV) { int i; v=tmpV->first; for (i=0; i<numOfVars; i++) v[i]=v[i]-1; tmpV->first=v; tmpV=tmpV->rest; } symmGroup=generateSymmetryGroup(symmGroup,numOfVars); strcat(symFileName,".full"); printListVectorToFile(symFileName, symmGroup, numOfVars); } basis=extractSymmetryRepresentatives(basis,symmGroup,numOfVars); strcpy(outFileName,fileName); strcat(outFileName,".rep"); printListVectorToFile(outFileName,basis,numOfVars); printf("%d representatives found.\n",lengthListVector(basis)); } if (strncmp(argv[i],"--dom",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(domFileName,argv[argc-2]); domBasis=readListVector(&numOfVars,domFileName); basis=extractNonDominatedVectors(basis,domBasis,numOfVars); strcpy(outFileName,fileName); strcat(outFileName,".nondom"); printListVectorToFile(outFileName,basis,numOfVars); printf("%d non-dominated vectors found.\n", lengthListVector(basis)); } if (strncmp(argv[i],"--max",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(symFileName,fileName); strcat(symFileName,".sym.full"); symmGroup=readListVector(&numOfVars,symFileName); if (symmGroup==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(symFileName,fileName); strcat(symFileName,".sym"); symmGroup=readListVector(&numOfVars,symFileName); tmpV=symmGroup; while (tmpV) { int i; v=tmpV->first; for (i=0; i<numOfVars; i++) v[i]=v[i]-1; tmpV->first=v; tmpV=tmpV->rest; } symmGroup=generateSymmetryGroup(symmGroup,numOfVars); strcat(symFileName,".full"); printListVectorToFile(symFileName, symmGroup, numOfVars); } basis=extractMaximalNonDominatedVectors(basis,symmGroup,numOfVars); strcpy(outFileName,fileName); strcat(outFileName,".maxnondom"); printListVectorToFile(outFileName,basis,numOfVars); printf("%d maximal non-dominated vectors found.\n", lengthListVector(basis)); } if (strncmp(argv[i],"--exp",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(symFileName,fileName); strcat(symFileName,".sym.full"); symmGroup=readListVector(&numOfVars,symFileName); if (symmGroup==0) { strcpy(symFileName,fileName); strcat(symFileName,".sym"); symmGroup=readListVector(&numOfVars,symFileName); tmpV=symmGroup; while (tmpV) { int i; v=tmpV->first; for (i=0; i<numOfVars; i++) v[i]=v[i]-1; tmpV->first=v; tmpV=tmpV->rest; } symmGroup=generateSymmetryGroup(symmGroup,numOfVars); } basis=expandRepresentativeIntoFullOrbits(basis,symmGroup,numOfVars,10); strcpy(outFileName,fileName); strcat(outFileName,".exp"); printListVectorToFile(outFileName,basis,numOfVars); } if (strncmp(argv[i],"--deg",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); if (argc==3) { printL1NormOfListVector(basis,numOfVars); } else { if (argc==4) { degree=atoi(argv[i+1]); printf("degree = %d\n",degree); strcpy(outFileName,fileName); strcat(outFileName,".deg."); strcat(outFileName,argv[i+1]); printListVectorWithGivenDegreesToFile(outFileName,basis,numOfVars, degree,degree); } else { lowdegree=atoi(argv[i+1]); highdegree=atoi(argv[i+2]); printf("degrees %d..%d\n",lowdegree,highdegree); strcpy(outFileName,fileName); strcat(outFileName,".deg."); strcat(outFileName,argv[i+1]); strcat(outFileName,"-"); strcat(outFileName,argv[i+2]); printListVectorWithGivenDegreesToFile(outFileName,basis,numOfVars, lowdegree,highdegree); } } return(0); } if (strncmp(argv[i],"--sup",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); if (argc==3) { printSupportsOfListVector(basis,numOfVars); } else { if (argc==4) { degree=atoi(argv[i+1]); printf("size of support = %d\n",degree); strcpy(outFileName,fileName); strcat(outFileName,".supp."); strcat(outFileName,argv[i+1]); printListVectorWithGivenSupportsToFile(outFileName,basis,numOfVars, degree,degree); } else { lowdegree=atoi(argv[i+1]); highdegree=atoi(argv[i+2]); printf("sizes of support %d..%d\n",lowdegree,highdegree); strcpy(outFileName,fileName); strcat(outFileName,".supp."); strcat(outFileName,argv[i+1]); strcat(outFileName,"-"); strcat(outFileName,argv[i+2]); printListVectorWithGivenSupportsToFile(outFileName,basis,numOfVars, lowdegree,highdegree); } } return(0); } if (strncmp(argv[i],"--typ",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); sizeOfLayer=atoi(argv[i+1]); printTypesOfListVector(basis,sizeOfLayer,numOfVars); return(0); } if (strncmp(argv[i],"--non",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); if (argc==3) { printf("You need to specify a coordinate!\n"); return(0); } else { coord=atoi(argv[i+1]); strcpy(outFileName,fileName); strcat(outFileName,".nonzero."); strcat(outFileName,argv[i+1]); printListVectorWithGivenNonzeroEntryToFile(outFileName,basis, numOfVars,coord); } return(0); } if (strncmp(argv[i],"--AxB",5)==0) { strcpy(fileName,argv[argc-3]); A=readListVector(&numOfVars,fileName); strcpy(fileName,argv[argc-2]); B=readListVector(&numOfVars,fileName); v=matrixTimesVector(A,B->first,lengthListVector(A),numOfVars); C=createListVector(v); strcpy(fileName,argv[argc-1]); printListVectorToFile(fileName,C,lengthListVector(A)); } if (strncmp(argv[i],"--0-1",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); basis=extractZeroOneVectors(basis,numOfVars); strcpy(outFileName,fileName); strcat(outFileName,".0-1"); printListVectorToFile(outFileName,basis,numOfVars); } if (strncmp(argv[i],"--3wa",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); x=atoi(argv[i+1]); y=atoi(argv[i+2]); z=atoi(argv[i+3]); strcpy(outFileName,fileName); strcat(outFileName,".3way"); print3wayTables(outFileName,basis,x,y,z,numOfVars); } if (strncmp(argv[i],"--tra",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(outFileName,fileName); strcat(outFileName,".tra"); printTransposedListVectorToFile(outFileName,basis,numOfVars); } if (strncmp(argv[i],"--map",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(outFileName,fileName); strcat(outFileName,".maple"); printListVectorMaple(outFileName,basis,numOfVars); } if (strncmp(argv[i],"--mac",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(outFileName,fileName); strcat(outFileName,".macaulay2"); printListVectorMacaulay2(outFileName,basis,numOfVars); } if (strncmp(argv[i],"--mat",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(outFileName,fileName); strcat(outFileName,".mathematica"); printListVectorMaple(outFileName,basis,numOfVars); } if (strncmp(argv[i],"--coc",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(outFileName,fileName); strcat(outFileName,".cocoa"); printListVectorMaple(outFileName,basis,numOfVars); } if (strncmp(argv[i],"--bin",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(outFileName,fileName); strcat(outFileName,".bin"); labels=0; strcpy(varFileName,fileName); strcat(varFileName,".vars"); if ((in = fopen(varFileName,"r"))) { int i; printf("File \"%s\" found. 4ti2 will use it.\n\n",varFileName); if (fscanf(in,"%d %d",&numOfRows, &numOfLabels)!=2 || numOfRows!=1) { printf("ERROR: Unrecognised file format for \"%s\".\n", varFileName); exit(1); } if (numOfLabels != numOfVars) { printf("ERROR: Incorrect number of variable names in \"%s\".\n", varFileName); exit(1); } labels = (char **)malloc(sizeof(char*)*(numOfVars)); for (i=0; i<numOfVars; i++) { s=(char *)malloc(sizeof(char)*127); if (fscanf(in,"%s",s) != 1) { printf("ERROR: Unrecognised file format for \"%s\".\n", varFileName); exit(1); } labels[i]=s; } fclose(in); } printListBinomialsToFile(outFileName,basis,numOfVars,labels); } if (strncmp(argv[i],"--sum",5)==0) { strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); v=createVector(numOfVars); for (i=0; i<numOfVars; i++) v[i]=0; while (basis) { for (i=0; i<numOfVars; i++) v[i]=v[i]+(basis->first)[i]; basis=basis->rest; } printVector(v,numOfVars); } if (strncmp(argv[i],"--sub",5)==0) { strcpy(fileName,argv[argc-2]); basis=readListVector(&numOfVars,fileName); v=basis->first; strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(outFileName,fileName); strcat(outFileName,".submat"); printSubsetOfListVectorToFile(outFileName,basis,v,numOfVars); } if (strncmp(argv[i],"--rem",5)==0) { if (strncmp(argv[i],"--remcol",8)==0) { /* Remove column. */ strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); coord=atoi(argv[argc-2]); strcpy(outFileName,fileName); strcat(outFileName,".remcol"); printListVectorWithoutColumnToFile(outFileName,basis,coord,numOfVars); } } if (strncmp(argv[i],"--sta",5)==0) { /* Extracting those symmetries from a list of given symmetries that keep a given list of vectors fixed. */ strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); strcpy(symFileName,argv[argc-2]); symmGroup=readListVector(&numOfVars,symFileName); symmGroup=extractStabilizer(basis,symmGroup,numOfVars); strcpy(outFileName,symFileName); strcat(outFileName,".stab"); printListVectorToFile(outFileName,symmGroup,numOfVars); } if (strncmp(argv[i],"--fil",5)==0) { /* Fill specified column with specified value. */ strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); coord=atoi(argv[argc-3]); val=atoi(argv[argc-2]); tmp=basis; while (tmp) { (tmp->first)[coord-1]=val; tmp=tmp->rest; } strcpy(outFileName,fileName); strcat(outFileName,".fil"); printListVectorToFile(outFileName,basis,numOfVars); } if (strncmp(argv[i],"--add",5)==0) { /* Add column with specified value. */ strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); coord=atoi(argv[argc-3]); val=atoi(argv[argc-2]); strcpy(outFileName,fileName); strcat(outFileName,".addcol"); printListVectorWithAdditionalColumnToFile(outFileName,basis, coord,val,numOfVars); } if (strncmp(argv[i],"--fix",5)==0) { /* Extracting those vectors that have given coordinates x[i]=i. */ numOfFixPoints=argc-3; fixpoints=createVector(numOfFixPoints); for (j=2;j<argc-1;j++) fixpoints[j-2]=atoi(argv[j]); strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); basis=extractFixedVectors(basis,fixpoints,numOfFixPoints); strcpy(outFileName,fileName); strcat(outFileName,".fix"); printListVectorToFile(outFileName,basis,numOfVars); } if (strncmp(argv[i],"--fox",5)==0) { /* Extracting those vectors that have given coordinates x[i]=i. */ numOfFixPoints=argc-3; fixpoints=createVector(numOfFixPoints); for (j=2;j<argc-1;j++) fixpoints[j-2]=atoi(argv[j]); strcpy(fileName,argv[argc-1]); basis=readListVector(&numOfVars,fileName); basis=extractRelaxedFixedVectors(basis,fixpoints,numOfFixPoints); strcpy(outFileName,fileName); strcat(outFileName,".fox"); printListVectorToFile(outFileName,basis,numOfVars); } if (strncmp(argv[i],"--ini",5)==0) { strcpy(fileName,argv[argc-1]); strcpy(groFileName,fileName); strcat(groFileName,".gro"); basis=readListVector(&numOfVars,groFileName); strcpy(costFileName,argv[argc-1]); strcat(costFileName,".cost"); weights=readListVector(&numOfVars,costFileName); if (weights!=0) { w=weights->first; } else { int i; w=createVector(numOfVars); for (i=0;i<numOfVars;i++) w[i]=1; } basis=extractInitialForms(basis,w,numOfVars); strcpy(outFileName,fileName); strcat(outFileName,".ini"); printListVectorToFile(outFileName,basis,numOfVars); labels=0; strcpy(varFileName,fileName); strcat(varFileName,".vars"); if ((in = fopen(varFileName,"r"))) { int i; printf("File \"%s\" found. 4ti2 will use it.\n\n",varFileName); fscanf(in,"%d %d",&numOfRows, &numOfLabels); labels = (char **)malloc(sizeof(char*)*(numOfVars)); if (fscanf(in,"%d %d",&numOfRows, &numOfLabels)!=2 || numOfRows!=1) { printf("ERROR: Unrecognised file format for \"%s\".\n", varFileName); exit(1); } if (numOfLabels != numOfVars) { printf("ERROR: Incorrect number of variable names in \"%s\".\n", varFileName); exit(1); } for (i=0; i<numOfVars; i++) { s=(char *)malloc(sizeof(char)*127); if (fscanf(in,"%s",s) != 1) { printf("ERROR: Unrecognised file format for \"%s\".\n", varFileName); exit(1); } labels[i]=s; } fclose(in); } strcpy(outFileName,fileName); strcat(outFileName,".ini.bin"); printListMonomialsAndBinomialsToFile(outFileName,basis,numOfVars,labels); } } return (0); }