All tasks are done!
This commit is contained in:
parent
ab0fbf59d0
commit
48b359f34c
131 changed files with 2713 additions and 438 deletions
29
2025.03.14/04Ex/solve.c
Normal file
29
2025.03.14/04Ex/solve.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "solve.h"
|
||||
#include "math.h"
|
||||
|
||||
#define eps 1e-9
|
||||
|
||||
int compare(const double a, const double b)
|
||||
{
|
||||
if (a - b > eps) return 1;
|
||||
else if (b - a > eps) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
double t4_solve(const double *A, const double *X, double *B, int m, int n)
|
||||
{
|
||||
double maximum = 0, cur;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
cur = -B[i];
|
||||
for (j = 0; j < m; j++)
|
||||
cur += A[i * m + j] * X[j];
|
||||
cur = fabs(cur);
|
||||
if (compare(cur, maximum) == 1) maximum = cur;
|
||||
}
|
||||
|
||||
return maximum;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue