Skip to content

Commit

Permalink
project update
Browse files Browse the repository at this point in the history
  • Loading branch information
seharshah committed Aug 5, 2019
1 parent 6656d45 commit 7272333
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
10 changes: 5 additions & 5 deletions src/S.txt
@@ -1,5 +1,5 @@
7.0582e-07 -1.7965e-07 2.0789e-07 2.0937e-08 2.348e-08 2.8434e-07
2.5598e-07 9.5657e-08 7.9435e-08 3.9232e-09 6.6423e-08 -1.0946e-07
-1.4375e-08 5.0701e-08 2.084e-07 1.0267e-07 6.2087e-08 -1.0946e-07
1.5282e-07 -3.9283e-08 -3.1781e-07 -8.0349e-07 1.6174e-09 -9.9902e-08
-2.3985e-07 1.1494e-07 -5.1098e-08 -6.4127e-08 1.2269e-07 -1.0022e-07
-2.01534674257439e-09 -1.42244457591595e-09 -1.31748090887372e-09 -1.51128477480679e-09 -1.66937804610817e-09 -1.33263713953393e-09
7.63994372485061e-11 -1.39605129534115e-09 -5.93718435972515e-10 -7.37681601418940e-10 -5.72199707768228e-10 -2.52987827306217e-10
3.40819346255001e-10 1.35355144965444e-10 -1.25768523870125e-09 -9.81323768677423e-11 1.64261272070620e-10 -2.09951863738081e-10
-5.55338953031563e-10 -3.10219740569681e-10 -6.00475280910624e-10 1.03007181754935e-09 -1.13330139178493e-10 -2.65724413498319e-11
1.13692232125441e-10 3.57096594144709e-11 2.38647703378844e-10 1.24738895941032e-10 -1.57548662812834e-09 3.42473351077908e-10
16 changes: 8 additions & 8 deletions src/bgmres.c
Expand Up @@ -167,7 +167,7 @@ scal = calloc(rhs*rhs, sizeof(double)); //R factor of QR factorization of R

for(i =0; i<rows;i++){
for (j = 0; j<rhs; j++){
B[i*rhs+j]= randf(-1,1);
B[i*rhs+j]= randf(0,1);
}
}

Expand Down Expand Up @@ -296,7 +296,7 @@ for (int initer = p;initer<m;initer++){
H[initer*restart+k_in] = vecnorm(rows,w, w);
cblas_dscal(rows, 1.0/H[initer*restart+k_in],w, 1);
cblas_dcopy(rows, w, 1, &V[initer*rows], 1);

}
/**************
End of Arnoldi
***************/
Expand Down Expand Up @@ -325,14 +325,14 @@ for (int initer = p;initer<m;initer++){

cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans, rows, rhs, restart, 1.0, V, rows, S, rhs, 0.0, C, rhs); //V(:,1:k_in)*S = C
//X = X0+(V*S = C), num = rows*cols
// matrixadd(double xx[], double yy[], double result[], int num);
// matrixadd(double xx[], double yy[], double result[], int num);

matrixadd(X, C, X,rows*rhs);
printf("\n\n X we obtained\n");
print_matrix(X, rows, rhs);
matrixadd(X, C, X,rows*rhs);
// printf("\n\n X we obtained\n");
// print_matrix(X, rows, rhs);

//Assigning transpose of X to tmp so that its columns gets called for multiplication
get_trans(X, tmp1, rows, rhs);
get_trans(X, tmp1, rows, rhs);
// printf("\n\nThe transpose of X is\n\n")
for (i = 0;i<rhs;i++){
csr_mvp_oski2(&A,&tmp1[i*rows],&R1[i*rows]);
Expand All @@ -351,7 +351,7 @@ for (int initer = p;initer<m;initer++){
// print_matrix(R, rhs, rows);
//subtract(

} //End of outer for loop
// } //End of outer for loop

/************
Debugging
Expand Down
32 changes: 16 additions & 16 deletions src/dbgmres.c
Expand Up @@ -314,7 +314,7 @@ for (int initer = pd;initer<m;initer++){
cblas_dscal(rows, 1.0/H[initer*restart+k_in],w, 1);
cblas_dcopy(rows, w, 1, &V[initer*rows], 1);

hh = H[initer*restart+k_in];
// hh = H[initer*restart+k_in];
/**************
End of Arnoldi
***************/
Expand All @@ -323,13 +323,13 @@ for (int initer = pd;initer<m;initer++){
Rotate
**************/

for (k =0;k<k_in;k++){
// for (k =0;k<k_in;k++){
/* APRot(H[k*restart+k_in], H[(k+1)*restart+k_in],cs[k], sn[k]);
GRot(H[initer*restart+k_in], H[(initer+1)*restart+k_in],cs[initer], sn[initer]);
APRot(H[initer*restart+k_in], H[(initer+1)*restart+k_in],cs[initer], sn[initer]);
APRot(S1[initer*restart+k_in], S1[(initer+1)*restart+k_in],cs[initer], sn[initer]);
*/

/*
r1 = H[ k*restart+k_in];
r2 = H[(k+1)*restart +k_in];
H[k*restart +k_in] = cs[k] * r1 - sn[k] * r2;
Expand All @@ -342,9 +342,9 @@ for (int initer = pd;initer<m;initer++){
printf("\n\n The value of hh is %.2e\n",hh);
hv = sqrt(rr * rr + hh * hh); /* temporary variable */
cs[k_in] = rr / hv;
sn[k_in] = -hh / hv;
H[k_in*restart+k_in] = hv;
// cs[k_in] = rr / hv;
// sn[k_in] = -hh / hv;
// H[k_in*restart+k_in] = hv;



Expand All @@ -354,7 +354,7 @@ for (int initer = pd;initer<m;initer++){

//Matrix Read

/* fp = fopen("S1.txt", "r");//Right Now I am reading S obtained from MATLAB results
fp = fopen("S1.txt", "r");//Right Now I am reading S obtained from MATLAB results
if (fp == NULL)
exit(0);

Expand All @@ -365,17 +365,17 @@ for (int initer = pd;initer<m;initer++){
}
}
} //End of while loop for reading matrix
*/
/*
//Sigma*VT
/*
*/
for (i =0; i<pd;i++){
scalvec(pd, Sigma_title[i], &VT[i*pd], &VT1[i*pd], 1);
}

cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans, rows, pd, pd, 1.0, V, rows, S1, pd, 0.0, C, pd);
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, rows, pd, pd, 1.0, C, pd, VT1, pd, 1.0, X, pd);
*/



} //End of outer for loop
Expand All @@ -384,7 +384,7 @@ for (int initer = pd;initer<m;initer++){
/************
Debugging
*************/
/*

printf("\n\nThe Left Singular Values are\n");
print_matrix(U, rhs, rhs);

Expand All @@ -404,24 +404,24 @@ printf("\n\nThe Orthogonal basis V is\n");
print_matrix(V,m, rows);

print_vector("w is\n",w,rows);
*/

printf("\n\nThe Hessenberg Matrix is\n\n");
print_matrix(H,m, restart);


printf("\n\nThe matrix S is\n");
print_matrix(S1, pd, pd);
/*

printf("\n\nV and S gives\n");
print_matrix(C, rows, pd);

printf("\n\n The final solution is\n");
print_matrix(X, rows, pd);
*/

print_vector("\n\n CS\n", cs, restart);

print_vector("\n\n SN\n", sn, restart);
//print_vector("\n\n CS\n", cs, restart);

//print_vector("\n\n SN\n", sn, restart);


/******************************
Expand Down

0 comments on commit 7272333

Please sign in to comment.