void cmd_insert (char *cp) { Line *line; String *string; if (range_single (cp, &cp, &cur_position) < 0) return; /* see where to insert */ if (*cp == ';') /* if ;, insert the remaining string before current line */ { cur_position.offset = 0; string = string_create (strlen (cp + 1), cp + 1); string_concat (string, 1, "\n"); buffer_dirty (cur_position.buffer, 1); line_insert (cur_position.buffer, cur_position.line, string); return; } if (!eoltest (cp)) return; /* otherwise, that's all there should be */ /* Read tty input until eof into the current buffer just before the current line */ cur_position.offset = 0; while ((string = jnl_readprompt ("\r\n >")) != NULL) { string_concat (string, 1, "\n"); /* put line terminator on string */ buffer_dirty (cur_position.buffer, 1); line_insert (cur_position.buffer, cur_position.line, string); /* insert line just before current line */ } }
void cmd_include (char *cp) { char *input_name; FILE *input_file; Line *line; String *string; if (*cp == 0) /* make sure there's a filename there */ { outerr (0, "no filename specified\n"); return; } input_name = cp; /* get input filename */ cp = uptospace (cp); /* it goes up to next space or eol */ if (range_single (cp, &cp, &cur_position) < 0) return; /* decode the range to get what line to insert before */ if (!eoltest (cp)) return; /* Open the file */ input_file = fopen (input_name, "r"); if (input_file == NULL) { outerr (strlen (input_name) + strlen (strerror (errno)), "error opening %s: %s\n", input_name, strerror (errno)); return; } /* Read it into the current buffer just before the current line */ buffer_dirty (cur_position.buffer, 1); /* it will soon be dirty */ cur_position.offset = 0; /* insert before beginning of current line */ read_file (input_file, cur_position.buffer, cur_position.line); /* read file in */ }
EXT void maxlike_precalculate (maxlike_wk* max) { #define H_Amp 10.0 #define H_Step 65535 #define H_Rez (H_Amp/H_Step) int i = 0, j = 0, theta = 0, x = 0, y = 0, q = 0; int M = max-> state-> n + 1; int T = max-> data-> gd-> x-> n_val; int X = max-> data-> gd-> y-> n_val; int Q = H_Step; int sign = 1; Real accum, thres, a, b; Real rez = max-> data-> gd-> y-> resolution; range* r = range_single(H_Step, H_Amp); hermite_workspace* h = hermite_alloc(max-> state-> n, r); hermite_calculate(h); Real** c_lup = (Real**) malloc( sizeof(Real*) * M ); Real** s_lup = (Real**) malloc( sizeof(Real*) * M ); i = 0; while(M-i) { c_lup[i] = (Real*) malloc( sizeof(Real) * T ); s_lup[i] = (Real*) malloc( sizeof(Real) * T ); theta = 0; while(T-theta) { c_lup[i][theta] = cos( i * (max-> data-> gd-> x-> val[theta]) ); s_lup[i][theta] = sin( i * (max-> data-> gd-> x-> val[theta]) ); theta++; } i++; } i = 0; while(M - i) { j = 0; while(i + 1 - j) { accum = 0.0; thres = rez/2; q = 0; x = (max-> data-> gd-> y-> n_val)/2; while(X - x && Q - q) { accum += h-> harmonics[i][q] * h-> harmonics[j][q]; if ( r-> val[q] >= thres) { thres += rez; accum *= r-> resolution; theta = 0; while(T-theta) { max-> proj_re[theta][x][i][j] = c_lup[i-j][theta] * accum; max-> proj_im[theta][x][i][j] = s_lup[i-j][theta] * accum; theta++; } x++; accum = 0.0; } q++; } j++; } i++; } theta = 0; while(T-theta) { x = (max-> data-> gd-> y-> n_val)/2; y = x; while(X - x ) { i = 0; while(M - i) { j = 0; while(i + 1 - j) { sign = ( (i+j)%2 )? -1 : 1; max-> proj_re[theta][y][i][j] = sign * max-> proj_re[theta][x][i][j]; max-> proj_im[theta][y][i][j] = sign * max-> proj_im[theta][x][i][j]; j++; } i++; } x++; y--; } theta++; } dmatrix* buf = dmatrix_alloc(M-1); theta = 0; while(T-theta) { x = 0; while(X - x ) { i = 0; while(M - i) { j = 0; while(i + 1 - j) { buf-> re[i][j] = max-> proj_re[theta][x][i][j]; buf-> im[i][j] = max-> proj_im[theta][x][i][j]; j++; } i++; } i = 0; while(M - i) { j = 0; while(i + 1 - j) { max-> proj_re[theta][x][j][i] = buf-> re[i][j]; max-> proj_im[theta][x][j][i] =-buf-> im[i][j]; j++; } i++; } x++; } theta++; } dmatrix_free(buf); for (i = 0; i < M; i++) { free( c_lup[i] ); free( s_lup[i] ); } free(c_lup); free(s_lup); hermite_free(h); range_free(r); #undef H_Amp #undef H_Step #undef H_Rez }