-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmex_w_times_x_symmetric.cpp
57 lines (47 loc) · 1.29 KB
/
mex_w_times_x_symmetric.cpp
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
/*================================================================
* mex_w_times_x_symmetric.c = used by ncuthard2.m in eigensolver.
*
* Examples:
* mex_w_times_x_c_symmetric(x,triu(A)) = A*x;
* A is sparse and symmetric, but x is full
*
* Timothee Cour, Oct 12, 2003.
% test sequence:
m=100;
n=50;
x=rand(n,1);
A=sprand(m,n,0.01);
y2 = mex_w_times_x_c_symmetric(x,triu(A));
y1=A*x;
max(abs(y1-y2))
*=================================================================*/
# include "math.h"
# include "mex.h"
# include "a_times_b_cmplx.cpp"
/*# include "a_times_b.c"*/
void mexFunction(
int nargout,
mxArray *out[],
int nargin,
const mxArray *in[]
)
{
int np, nc;
mwIndex*ir, *jc;
double *x, *y, *pr;
if (nargin < 2) {//voir
mexErrMsgTxt("Four input arguments required !");
}
if (nargout>1) {
mexErrMsgTxt("Too many output arguments.");
}
x = mxGetPr(in[0]);
pr = mxGetPr(in[1]);
ir = mxGetIr(in[1]);
jc = mxGetJc(in[1]);
np = mxGetM(in[1]);
nc = mxGetN(in[1]);
out[0] = mxCreateDoubleMatrix(np,1,mxREAL);
y = mxGetPr(out[0]);
CSRsymm_VecMult_CAB_double(np,nc,pr,ir,jc,x,y);
}