mirror of
https://github.com/ivabus/pantry
synced 2024-11-14 04:25:08 +03:00
24 lines
746 B
C
24 lines
746 B
C
|
#include <stdio.h>
|
||
|
#include "klu.h"
|
||
|
|
||
|
int n = 5 ;
|
||
|
int Ap [ ] = {0, 2, 5, 9, 10, 12} ;
|
||
|
int Ai [ ] = { 0, 1, 0, 2, 4, 1, 2, 3, 4, 2, 1, 4} ;
|
||
|
double Ax [ ] = {2., 3., 3., -1., 4., 4., -3., 1., 2., 2., 6., 1.} ;
|
||
|
double b [ ] = {8., 45., -3., 3., 19.} ;
|
||
|
|
||
|
int main (void)
|
||
|
{
|
||
|
klu_symbolic *Symbolic ;
|
||
|
klu_numeric *Numeric ;
|
||
|
klu_common Common ;
|
||
|
int i ;
|
||
|
klu_defaults (&Common) ;
|
||
|
Symbolic = klu_analyze (n, Ap, Ai, &Common) ;
|
||
|
Numeric = klu_factor (Ap, Ai, Ax, Symbolic, &Common) ;
|
||
|
klu_solve (Symbolic, Numeric, 5, 1, b, &Common) ;
|
||
|
klu_free_symbolic (&Symbolic, &Common) ;
|
||
|
klu_free_numeric (&Numeric, &Common) ;
|
||
|
for (i = 0 ; i < n ; i++) printf ("x [%d] = %g\n", i, b [i]) ;
|
||
|
return (0) ;
|
||
|
}
|