matrixd UnscentedExpectedImprovement::convertMatrixNoise(const matrixd& matrix, const double scale , const int dim ) { matrixd matrix_output = matrix; // Scale Matrix matrix_output *= (dim + scale); // Square root Matrix if (!isDiag(matrix_output)) { matrixd L; utils::cholesky_decompose(matrix_output, L); matrix_output = L; } else { for (size_t idx = 0; idx < matrix_output.size1(); ++idx) { matrix_output(idx, idx) = std::sqrt(matrix_output(idx, idx)); } } return matrix_output; }
void ex1() { printf("Введите размерность массива в формате NxM:"); int n,m; scanf("\n%dx%d",&n,&m); float array[n*m]; matrix_input(array,n,m); printf("\nВведенная вами матрица:\n"); matrix_output(array,n,m); s_points(array,n,m); }
void matrixsub(float a[][25],float b[][25],int m, int n) { int i,j;float integral[25][25]; for(i=0;i<m;i++) { for(j=0;j<n;j++) integral[i][j]=a[i][j] - b[i][j]; } printf("The subtraction of the two matrix is \n"); matrix_output(integral,m,n); }
void transpose_input() { int i,j,n;float a[25][25],b[25][25]; printf("Calculation of Matrix Transpose\n"); printf("Enter the dimension of square Matrix:\t"); scanf("%d",&n); printf("\nEnter the Matrix element of %dX%d matrix\n",n,n); for(i=0;i<n;i++) { for(j=0;j<n;j++) scanf("%f",&a[i][j]); } for (i=0;i<n;i++) { for (j=0;j<n;j++) { b[i][j]=a[j][i]; } } printf("The transpose of a matrix is:\n"); matrix_output(b,n,n); }
/** * Data Prep */ int main(int argc, char **argv) { static const char* cmds[] = { "b", "buffer", "1", "buffer size (k): default 1024", "f", "file", "1", "output file name: default is '-' (stdout)", "i", "inject", "1", "inject 0=2up, 1=1up, 2=raw 1up", "o", "output", "1", "[bin|delta|inject|raw|xor|wrap] data", "r", "repeat", "1", "repeat inject sequence", "s", "start", "1", "start value inject sequence", "u", "upper", "1", "inject sequence upper bound", "v", "verbose", "1", "verbose reporting", "h", "help", "0", "This help" }; char *outputs[] = {"bin","delta","inject","raw","xor","wrap",NULL}; static int nopts = sizeof(cmds)/(4*sizeof(char *)); struct option long_options[nopts+1]; char short_options[1+nopts*2]; struct pparams params; FILE *f; U_INT i, j, n; int c; char *s; for(i=j=0;j<(nopts*4);j+=4) { long_options[i].name = cmds[j+1]; long_options[i].has_arg = atoi(cmds[j+2]); long_options[i].flag = NULL; long_options[i].val = cmds[j][0]; strcat(short_options,cmds[j]); if (long_options[i].has_arg!=0) strcat(short_options,":"); i += 1; } memset(&long_options[i], 0, sizeof(struct option)); memset(¶ms, 0, sizeof(struct pparams)); params.outpath = "-"; params.bsize = NDSIZECOLLECT; params.xs = 1.0; do { c = getopt_long (argc, argv, short_options, long_options, NULL); switch(c) { case 'b': params.bsize = atoi(optarg); params.xs = params.bsize; while(params.xs >= 10.0) params.xs /= 10.0; break; case 'f': params.outpath = optarg; break; case 'i': params.options = atoi(optarg); break; case 'o': n = strlen(optarg); for(i=0;outputs[i]!=NULL;i++) if (!strncmp(optarg, outputs[i], n)) { params.cmd = optarg[0]; break; } break; case 'r': params.repeat = atoi(optarg); break; case 's': params.value = atoi(optarg); break; case 'u': params.limit = atoi(optarg); break; case 'v': params.cmd = atoi(optarg); break; case '?': case 'h': usage(nopts, long_options, cmds); case -1: break; } } while (c!=-1); if (0==params.cmd || optind != (argc-1)) usage(nopts, long_options, cmds); if (!strcmp(argv[1],"-")) params.input = stdin; else { params.input = fopen(argv[optind], "rb"); if (NULL == params.input) { fprintf(stderr, "Unable to open input %s\n", argv[optind]); exit(2); } } if (!strcmp(params.outpath, "-")) params.output = stdout; else { params.output = fopen(params.outpath, "wb"); if (NULL == params.output) { fprintf(stderr, "Unable to open %s\n", params.outpath); exit(3); } fprintf(stdout, "writing to %s\n", params.outpath); } switch(params.cmd) { case 'i': while(inject_output(¶ms)>0) ; break; case 'b': matrix_output(¶ms); break; case 'd': case 'r': case 'x': case 'w': sequence_output(¶ms); break; } if (params.output != stdout) fclose(params.output); return 0; }