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

563680 views
1
#include "typedef.h"
2
#include "matrix.h"
3
4
/**************************************************************************\
5
@---------------------------------------------------------------------------
6
@---------------------------------------------------------------------------
7
@ FILE: null_mat.c
8
@---------------------------------------------------------------------------
9
@---------------------------------------------------------------------------
10
@
11
\**************************************************************************/
12
13
/**************************************************************************\
14
@---------------------------------------------------------------------------
15
@ int null_mat(mat)
16
@ matrix_TYP *mat;
17
@
18
@ Checks if the matrix has only 0 as entry.
19
@ return 1 if yes, 0 otherwise.
20
@---------------------------------------------------------------------------
21
@
22
\**************************************************************************/
23
int null_mat(mat)
24
matrix_TYP *mat;
25
{
26
return(save_null_mat(mat));
27
}
28
/*{{{}}}*/
29
/*{{{ save_null_mat*/
30
/**************************************************************************\
31
@---------------------------------------------------------------------------
32
@ int save_null_mat(mat)
33
@ matrix_TYP *mat;
34
@
35
@ The same as null_mat
36
@---------------------------------------------------------------------------
37
@
38
\**************************************************************************/
39
int save_null_mat(mat)
40
matrix_TYP *mat;
41
{
42
int i,j;
43
44
for ( i=0; i < mat->rows;i++) {
45
for ( j=0; j < mat->cols;j++) {
46
if ( mat->array.SZ[i][j] != 0 ) return FALSE;
47
}
48
}
49
return TRUE;
50
}
51
52
/*}}} */
53
/*{{{ quick_null_mat*/
54
/**************************************************************************\
55
@---------------------------------------------------------------------------
56
@ int quick_null_mat(mat)
57
@ matrix_TYP *mat;
58
@
59
@ Checks if the matrix has only 0 as entry using mat->flags.
60
@ If for example mat->flags.Diagonal = 1 only the diagonal entries
61
@ are checked to be 0.
62
@ return 1 if yes, 0 otherwise.
63
@---------------------------------------------------------------------------
64
@
65
\**************************************************************************/
66
int quick_null_mat(mat)
67
matrix_TYP *mat;
68
{
69
int i, j;
70
71
if ( mat->flags.Scalar ) {
72
return( mat->array.SZ[0][0] == 0 );
73
} else if ( mat->flags.Diagonal ) {
74
for ( i=0;i < mat->rows;i++) {
75
if ( mat->array.SZ[i][i] != 0 ) return FALSE;
76
}
77
return TRUE;
78
} else if ( mat->flags.Symmetric ) {
79
for ( i=0;i < mat->rows; i ++ ) {
80
for ( j=i; j < mat->cols; j++ ) {
81
if ( mat->array.SZ[i][j] != 0 ) {
82
return FALSE;
83
}
84
}
85
}
86
return TRUE;
87
} else {
88
return ( save_null_mat(mat) );
89
}
90
}
91
92
93
/*}}} */
94
95