Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563580 views
1
#include "typedef.h"
2
#include "matrix.h"
3
#include "tools.h"
4
5
/**************************************************************************\
6
@---------------------------------------------------------------------------
7
@---------------------------------------------------------------------------
8
@ FILE: find_max_entry.c
9
@---------------------------------------------------------------------------
10
@---------------------------------------------------------------------------
11
@
12
\**************************************************************************/
13
14
static int max_abs( a, b )
15
int a, b;
16
{
17
int aa = abs(a), ab=abs(b);
18
19
return ( aa >= ab ? aa : ab );
20
21
}
22
23
/*{{{}}}*/
24
/*{{{ find_max_entry*/
25
26
27
/**************************************************************************\
28
@---------------------------------------------------------------------------
29
@ int find_max_entry(mat)
30
@ matrix_TYP *mat;
31
@
32
@ calculates the maximal entry of mat->array.SZ
33
@ if mat->array.Z != 0 or mat->prime != 0 the functions return 0.
34
@---------------------------------------------------------------------------
35
@
36
\**************************************************************************/
37
int find_max_entry(mat)
38
matrix_TYP *mat;
39
{
40
int i,j;
41
int **Z, *S_i;
42
boolean flag;
43
44
if( mat->prime != 0 || mat->array.N != NULL ) {
45
return 0;
46
}
47
48
flag = 0;
49
Z = mat->array.SZ;
50
if(mat->flags.Diagonal) {
51
if(mat->flags.Scalar) {
52
return abs(Z[0][0]);
53
} else {
54
for (i = 0; i < mat->rows; i++) {
55
flag = max_abs(flag,Z[i][i]);
56
}
57
return flag;
58
}
59
}
60
if(mat->flags.Symmetric) {
61
for(i = 0; i < mat->rows; i++) {
62
for(j = i; j < mat->cols; j++) {
63
if(Z[i][j]) flag = max_abs(flag,Z[i][j]);
64
}
65
}
66
return flag;
67
}
68
69
for(i = 0; i < mat->rows; i++) {
70
S_i = Z[i];
71
for(j = 0; j < mat->cols; j++) {
72
if(S_i[j]) {
73
if(abs(S_i[j]) > flag) {
74
flag = abs(S_i[j]);
75
}
76
}
77
}
78
}
79
return flag;
80
}
81
82
/*}}} */
83
84
85