-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbasiclu_solve_sparse.c
More file actions
63 lines (57 loc) · 1.27 KB
/
basiclu_solve_sparse.c
File metadata and controls
63 lines (57 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* basiclu_solve_sparse.c
*
* Copyright (C) 2016-2018 ERGO-Code
*
*/
#include "lu_internal.h"
lu_int basiclu_solve_sparse
(
lu_int istore[],
double xstore[],
lu_int Li[],
double Lx[],
lu_int Ui[],
double Ux[],
lu_int Wi[],
double Wx[],
lu_int nzrhs,
const lu_int irhs[],
const double xrhs[],
lu_int *p_nzlhs,
lu_int ilhs[],
double lhs[],
char trans
)
{
struct lu this;
lu_int status, n, ok;
status = lu_load(&this, istore, xstore, Li, Lx, Ui, Ux, Wi, Wx);
if (status != BASICLU_OK)
return status;
if (! (Li && Lx && Ui && Ux && Wi && Wx && irhs && xrhs && p_nzlhs && ilhs
&& lhs))
{
status = BASICLU_ERROR_argument_missing;
}
else if (this.nupdate < 0)
{
status = BASICLU_ERROR_invalid_call;
}
else
{
/* check RHS indices */
ok = nzrhs >= 0 && nzrhs <= this.m;
for (n = 0; n < nzrhs && ok; n++)
{
ok = ok && irhs[n] >= 0 && irhs[n] < this.m;
}
if (!ok)
status = BASICLU_ERROR_invalid_argument;
}
if (status == BASICLU_OK)
{
lu_solve_sparse(&this, nzrhs, irhs, xrhs, p_nzlhs, ilhs, lhs, trans);
}
return lu_save(&this, istore, xstore, status);
}