From 0a10914e4f3c5e11f192e6b541ba9cebb3efd679 Mon Sep 17 00:00:00 2001 From: justanothercatgirl Date: Mon, 14 Oct 2024 21:03:47 +0300 Subject: initial commit --- 5_2.c | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 5_2.c (limited to '5_2.c') diff --git a/5_2.c b/5_2.c deleted file mode 100644 index 00152e6..0000000 --- a/5_2.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include "matrix.h" - -#define MRX_SZ 6 -#define add_func(name, func) \ - double name (double x){ \ - return func; \ - } - -add_func(x2, x*x) -add_func(x2_sinx, x2(sin(x))) -add_func(sqrtx_x2, sqrt(x) * x2(x)) -add_func(sqrt_sin_x2, sqrt(sin(x2(x)))) - -const func_t funcs[MRX_SZ] = { - x2, sin, sqrt, x2_sinx, sqrtx_x2, sqrt_sin_x2 -}; - -int main(void) { - srand(time(NULL)); - // выбираем интервал для генерации случайных чисел -interval_selection: - printf("Input the borders of the interval for generated values, separated by a whitespace:\n"); - double a, b; - if (scanf("%lf %lf", &a, &b) != 2) { - SKIP_INPUT; - goto interval_selection; - } - // создаём матрицы - struct matrix m = matrix_new(1, MRX_SZ); - matrix_fill(&m, a, b); - struct matrix f_mem = matrix_new(1, MRX_SZ); - struct fmatrix f = *(struct fmatrix*)&f_mem; - for (usz i = 0; i < f.columns; ++i) f.funcs[0][i] = funcs[i]; - // делаем грязную работу - puts("A = "); matrix_print(&m); - matrix_apply(&m, &f); - puts("f(A) = "); matrix_print(&m); - // очищаем память - matrix_free(m); - matrix_free(f_mem); - return 0; -} -- cgit v1.2.3-70-g09d2