Skip to content

Commit 43cdad2

Browse files
committed
Print failures in api example
1 parent e6798c1 commit 43cdad2

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

highs/ipm/hipo/factorhighs/FactorHighs_c_api_example.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ int main() {
5555
// initialise with default number of threads
5656
const int num_threads = 0;
5757
int initialise_status = FactorHighs_initialise(num_threads);
58-
if (initialise_status) return 1;
58+
if (initialise_status) {
59+
printf("HiPO or its dependencies are not available in this build\n");
60+
return 1;
61+
}
5962
void* S = FactorHighs_symbolic_create();
6063
void* FH = FactorHighs_create();
6164

@@ -74,12 +77,18 @@ int main() {
7477
// compute ordering with metis
7578
int perm[N];
7679
int metis_status = FactorHighs_reorderMetis(FH, N, NZ, rows, ptr, perm);
77-
if (metis_status) return 1;
80+
if (metis_status) {
81+
printf("Failed to compute a fill-reducing ordering with Metis\n");
82+
return 1;
83+
}
7884

7985
// perform analyse phase
8086
int analyse_status =
8187
FactorHighs_analyse(FH, S, N, NZ, rows, ptr, signs, perm);
82-
if (analyse_status) return 1;
88+
if (analyse_status) {
89+
printf("Failed to compute symbolic factorisation\n");
90+
return 1;
91+
}
8392

8493
// print extended statistics of symbolic factorisation
8594
int verbose = 1;
@@ -94,7 +103,10 @@ int main() {
94103

95104
// factorise the matrix
96105
int factorise_status = FactorHighs_factorise(FH, S, N, NZ, rows, ptr, vals);
97-
if (factorise_status) return 1;
106+
if (factorise_status) {
107+
printf("Failed to factorise the matrix\n");
108+
return 1;
109+
}
98110

99111
// compute the inertia of the factorisation
100112
int pos, neg, zero;
@@ -104,7 +116,10 @@ int main() {
104116

105117
// triangular solve
106118
int solve_status = FactorHighs_solve(FH, rhs, 1);
107-
if (solve_status) return 1;
119+
if (solve_status) {
120+
printf("Failed to solve the linear system\n");
121+
return 1;
122+
}
108123

109124
/*
110125
could also perform:

0 commit comments

Comments
 (0)