CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

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

Views: 418384
1
#include"typedef.h"
2
#include"getput.h"
3
#include"longtools.h"
4
5
6
int INFO_LEVEL;
7
int SFLAG;
8
9
10
main (int argc, char *argv[])
11
{
12
13
matrix_TYP **A, **B, **X;
14
int i, Aanz, Banz;
15
16
17
read_header(argc, argv);
18
if(FILEANZ != 1 && FILEANZ != 2)
19
{
20
printf("Usage: %s 'file1' ['file2']\n", argv[0]);
21
printf("\n");
22
printf("file1: matrix_TYP containing the matrices A_i\n");
23
printf("file2: matrix_TYP containing the matrices B_i\n");
24
printf("\n");
25
printf("Calculates matrices X_i such that A_i X_i = B_i for all matrices\n");
26
printf("A_i in file1. If 'file2' is omitted the B_i are assumed to be 0.\n");
27
printf("\n");
28
printf("Cf. Gauss.\n");
29
if (is_option('h')){
30
exit(0);
31
}
32
else{
33
exit(31);
34
}
35
}
36
37
if (is_option('h')){ INFO_LEVEL = optionnumber('h');}
38
if (INFO_LEVEL & 8){
39
SFLAG = 1;
40
}
41
42
A = mget_mat (FILENAMES[0], &Aanz);
43
if(FILEANZ == 2){
44
B = mget_mat(FILENAMES[1], &Banz);
45
}
46
else{
47
Banz = 0;
48
}
49
if(Aanz > 1)
50
printf("#%d\n", Aanz);
51
for(i=0;i<Aanz;i++)
52
{
53
if(i<Banz)
54
X = long_solve_mat(A[i], B[i]);
55
else
56
X = long_solve_mat(A[i], NULL);
57
if(X[0] != 0)
58
{
59
put_mat(X[0], NULL, "inhomogenous solution", 2);
60
free_mat(X[0]);
61
}
62
else if (i<Banz && B[i] != NULL){
63
printf("there does not exists an inhomogenous solution\n");
64
}
65
if(X[1] != NULL)
66
{
67
put_mat(X[1], NULL, "homogenous solutions as columns", 0);
68
free_mat(X[1]);
69
}
70
free(X);
71
}
72
73
for (i=0;i<Aanz;i++) free_mat(A[i]);
74
for (i=0;i<Banz;i++) free_mat(B[i]);
75
free(A);
76
if (B!=NULL) free(B);
77
if (INFO_LEVEL & 8){
78
pointer_statistics(0,0);
79
}
80
81
exit(0);
82
}
83
84