Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63353078
cg_blas.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, May 19, 12:43
Size
1 KB
Mime Type
text/x-c
Expires
Tue, May 21, 12:43 (2 d)
Engine
blob
Format
Raw Data
Handle
17744466
Attached To
rCGPHPC CG-PHPC
cg_blas.c
View Options
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include "blas.h"
#include "cg.h"
#include "parameters.h"
/*
main function
*/
int
main
(
int
argc
,
char
**
argv
)
{
double
*
A
;
double
*
At
;
double
*
b
;
double
*
x
;
double
*
x0
;
//double * x_check;
int
n
,
m
;
n
=
2
;
m
=
n
;
A
=
(
double
*
)
malloc
(
m
*
n
*
sizeof
(
double
));
At
=
(
double
*
)
malloc
(
m
*
n
*
sizeof
(
double
));
b
=
(
double
*
)
malloc
(
n
*
sizeof
(
double
));
x
=
(
double
*
)
malloc
(
n
*
sizeof
(
double
));
x0
=
(
double
*
)
malloc
(
n
*
sizeof
(
double
));
//x_check = (double*) malloc(n* sizeof(double));
// {{ 4, 1},{ 1, 3}}
A
[
id
(
n
,
0
,
0
)]
=
4.
;
A
[
id
(
n
,
0
,
1
)]
=
1.
;
A
[
id
(
n
,
1
,
0
)]
=
1.
;
A
[
id
(
n
,
1
,
1
)]
=
3.
;
cblas_dtra
(
m
,
n
,
A
,
At
);
// vec B = { 1, 2 };
b
[
0
]
=
1.
;
b
[
1
]
=
2.
;
x0
[
0
]
=
2
;
x0
[
1
]
=
1
;
// print_mat( "matrice A:\n", A,m,n );
// print_mat( "matrice A transpose:\n", At,m,n );
// print_mat( "vecteur b: \n", b,1,n );
cgsolver
(
A
,
b
,
x
,
m
,
n
);
printf
(
"Solves AX = B
\n
"
);
print_mat
(
"
\n
X:"
,
x
,
1
,
n
);
cblas_dgemv
(
1
,
0
,
m
,
n
,
1.
,
A
,
1.
,
x
,
1
,
1.
,
x
,
1.
);
print_mat
(
"
\n
Check AX:
\n
"
,
x0
,
1
,
n
);
/*
free(A);
free(b);
free(x);
free(x0);
free(x_check);
*/
return
0
;
}
Event Timeline
Log In to Comment