Add .zip archive
This commit is contained in:
parent
98a608ce96
commit
2e79b61845
12 changed files with 223 additions and 189 deletions
|
@ -2,7 +2,6 @@
|
|||
#include "contin_func.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
|
|
BIN
2025.04.18/Krivoruchenko_SK.zip
Normal file
BIN
2025.04.18/Krivoruchenko_SK.zip
Normal file
Binary file not shown.
2
2025.04.18/dist/Krivoruchenko_SK/Makefile
vendored
2
2025.04.18/dist/Krivoruchenko_SK/Makefile
vendored
|
@ -5,7 +5,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pe
|
|||
%.o: %.c
|
||||
gcc -c $(FLAGS) $<
|
||||
|
||||
all: a01.out a02.out a03.out a04.out a05.out
|
||||
all: a01.out a02.out a03.out a04.out a05.out a06.out a07.out a08.out
|
||||
|
||||
solve.o: solve.c solve.h
|
||||
array_io.o: array_io.c array_io.h
|
||||
|
|
34
2025.04.18/dist/Krivoruchenko_SK/a06.c
vendored
Normal file
34
2025.04.18/dist/Krivoruchenko_SK/a06.c
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "io_status.h"
|
||||
#include "solve.h"
|
||||
|
||||
/* ./a.out x eps */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
double x, eps, t, r1 = 0, r2 = 0;
|
||||
int task = 6;
|
||||
|
||||
if (
|
||||
!((argc == 3) &&
|
||||
sscanf(argv[1], "%le", &x) == 1 &&
|
||||
((sscanf(argv[2], "%le", &eps) == 1) && eps > 0))
|
||||
) {
|
||||
fprintf(stderr, "Usage: %s x eps\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
t = clock();
|
||||
r1 = fcos(x, eps);
|
||||
t = (clock() - t) / CLOCKS_PER_SEC;
|
||||
|
||||
r2 = fabs(r1 - cos(x));
|
||||
|
||||
printf("%s : Task = %d Result = %e Residual = %e Elapsed = %.2f\n", argv[0], task, r1, r2, t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
34
2025.04.18/dist/Krivoruchenko_SK/a07.c
vendored
Normal file
34
2025.04.18/dist/Krivoruchenko_SK/a07.c
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "io_status.h"
|
||||
#include "solve.h"
|
||||
|
||||
/* ./a.out x eps */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
double x, eps, t, r1 = 0, r2 = 0;
|
||||
int task = 7;
|
||||
|
||||
if (
|
||||
!((argc == 3) &&
|
||||
sscanf(argv[1], "%le", &x) == 1 &&
|
||||
((sscanf(argv[2], "%le", &eps) == 1) && eps > 0))
|
||||
) {
|
||||
fprintf(stderr, "Usage: %s x eps\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
t = clock();
|
||||
r1 = fexp(x, eps);
|
||||
t = (clock() - t) / CLOCKS_PER_SEC;
|
||||
|
||||
r2 = fabs(r1 - exp(x));
|
||||
|
||||
printf("%s : Task = %d Result = %e Residual = %e Elapsed = %.2f\n", argv[0], task, r1, r2, t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
34
2025.04.18/dist/Krivoruchenko_SK/a08.c
vendored
Normal file
34
2025.04.18/dist/Krivoruchenko_SK/a08.c
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "io_status.h"
|
||||
#include "solve.h"
|
||||
|
||||
/* ./a.out x eps */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
double x, eps, t, r1 = 0, r2 = 0;
|
||||
int task = 8;
|
||||
|
||||
if (
|
||||
!((argc == 3) &&
|
||||
((sscanf(argv[1], "%le", &x) == 1) && x > 0) &&
|
||||
((sscanf(argv[2], "%le", &eps) == 1) && eps > 0))
|
||||
) {
|
||||
fprintf(stderr, "Usage: %s x eps\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
t = clock();
|
||||
r1 = dln(x, eps);
|
||||
t = (clock() - t) / CLOCKS_PER_SEC;
|
||||
|
||||
r2 = fabs(r1 - log(x));
|
||||
|
||||
printf("%s : Task = %d Result = %e Residual = %e Elapsed = %.2f\n", argv[0], task, r1, r2, t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
36
2025.04.18/dist/Krivoruchenko_SK/contin_func.c
vendored
36
2025.04.18/dist/Krivoruchenko_SK/contin_func.c
vendored
|
@ -36,3 +36,39 @@ double scos (const double x, const double eps)
|
|||
|
||||
return value;
|
||||
}
|
||||
|
||||
double sexp (const double x, const double eps)
|
||||
{
|
||||
double value = 1;
|
||||
double monom = x;
|
||||
int i = 1;
|
||||
|
||||
while (monom - eps >= DBL_EPSILON)
|
||||
{
|
||||
value += monom;
|
||||
|
||||
i++;
|
||||
monom *= x/i;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
double fln (const double x, const double eps)
|
||||
{
|
||||
const double z = (x - 1) / (x + 1);
|
||||
double value = 0;
|
||||
double monom = z, el = z;
|
||||
int i = 1;
|
||||
|
||||
while (el - eps > DBL_EPSILON)
|
||||
{
|
||||
value += el;
|
||||
|
||||
i+=2;
|
||||
monom *= z*z;
|
||||
el = monom / i;
|
||||
}
|
||||
|
||||
return 2 * value;
|
||||
}
|
|
@ -3,5 +3,7 @@
|
|||
|
||||
double ssin (const double x, const double eps);
|
||||
double scos (const double x, const double eps);
|
||||
double sexp (const double x, const double eps);
|
||||
double fln (const double x, const double eps);
|
||||
|
||||
#endif
|
||||
|
|
79
2025.04.18/dist/Krivoruchenko_SK/solve.c
vendored
79
2025.04.18/dist/Krivoruchenko_SK/solve.c
vendored
|
@ -2,6 +2,7 @@
|
|||
#include "contin_func.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
|
@ -222,3 +223,81 @@ double fsin (double x, const double eps)
|
|||
|
||||
return answer;
|
||||
}
|
||||
|
||||
double fcos (double x, const double eps)
|
||||
{
|
||||
double answer;
|
||||
short flag = 1;
|
||||
|
||||
if (x - M_PI*2 >= DBL_EPSILON)
|
||||
x = fmod(x, M_PI*2);
|
||||
|
||||
if (x - M_PI >= DBL_EPSILON)
|
||||
{
|
||||
x -= M_PI;
|
||||
flag *= -1;
|
||||
}
|
||||
|
||||
if (x - 1 >= DBL_EPSILON)
|
||||
{
|
||||
x -= M_PI_2;
|
||||
flag *= -2;
|
||||
}
|
||||
|
||||
if (abs(flag) == 2)
|
||||
{
|
||||
x /= 2;
|
||||
|
||||
answer = ((flag > 0) - (flag < 0)) * (2 * ssin(x, eps) * scos(x, eps));
|
||||
} else
|
||||
answer = flag * scos(x, eps);
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
double fexp (double x, const double eps)
|
||||
{
|
||||
double integral, fractal, answer = 1;
|
||||
bool is_negative = false;
|
||||
|
||||
if (x < DBL_EPSILON)
|
||||
{
|
||||
is_negative = true;
|
||||
x = -x;
|
||||
}
|
||||
|
||||
integral = floor(x);
|
||||
fractal = x - integral;
|
||||
|
||||
for (double i = 0; (integral - i) > DBL_EPSILON; ++i)
|
||||
answer *= M_E;
|
||||
|
||||
answer *= sexp(fractal, eps);
|
||||
if (is_negative)
|
||||
answer = 1. / answer;
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
double dln (double x, const double eps)
|
||||
{
|
||||
double value = 0;
|
||||
int b = 0;
|
||||
|
||||
while (x - 2 > DBL_EPSILON)
|
||||
{
|
||||
x *= 0.5;
|
||||
b++;
|
||||
}
|
||||
|
||||
while (x - 1 <= DBL_EPSILON)
|
||||
{
|
||||
x *= 2;
|
||||
b--;
|
||||
}
|
||||
|
||||
value = fln(x, eps);
|
||||
|
||||
value += b * M_LN2;
|
||||
return value;
|
||||
}
|
||||
|
|
3
2025.04.18/dist/Krivoruchenko_SK/solve.h
vendored
3
2025.04.18/dist/Krivoruchenko_SK/solve.h
vendored
|
@ -11,5 +11,8 @@ double t4_solve (
|
|||
double * restrict D
|
||||
);
|
||||
double fsin (double x, const double eps);
|
||||
double fcos (double x, const double eps);
|
||||
double fexp (double x, const double eps);
|
||||
double dln (double x, const double eps);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue