Docmuntation added #7

Merged
merged 3 commits into from Sep 5, 2012
Jump to file
+657 −516
Split
View
@@ -1,7 +1,14 @@
+// ZGETRF computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.
+
namespace zgetrf_func{
const int PRINT_DEBUG_STUFF = 0;
+/*
+ A: COMPLEX*16 array, dimension (LDA,N)
+ IPIV: INTEGER array, dimension (min(M,N))
+*/
+
function zgetrf_exec(var A,int ipiv)
{
var pla = loadlib("linalg_group");
@@ -12,6 +19,14 @@ function zgetrf_exec(var A,int ipiv)
say("Given Matrix:");
say(A);
+/*
+ A is COMPLEX*16 array, dimension (LDA,N)
+ On entry, the M-by-N matrix to be factored.
+ On exit, the factors L and U from the factorization
+ A = P*L*U; the unit diagonal elements of L are not stored.
+ */
+
+
int m,n,lda,ipiv_size,info;
m=A.rows;
n=A.cols;
@@ -25,6 +40,16 @@ function zgetrf_exec(var A,int ipiv)
zgetrf(m,n,A,lda,ipiv,info);
return info;
+/*
+INFO is INTEGER
+ = 0: successful exit
+ < 0: if INFO = -i, the i-th argument had an illegal value
+ > 0: if INFO = i, U(i,i) is exactly zero. The factorization
+ has been completed, but the factor U is exactly
+ singular, and division by zero will occur if it is used
+ to solve a system of equations.
+*/
+
}
function max(var a,var b)
@@ -56,34 +81,3 @@ function debug(var matrix, string msg, var args [slurpy])
}
}
-
-/*
-
-function main[main](var args)
-{
-
- var pla = loadlib("linalg_group");
- var a = new 'ComplexMatrix2D';
- a.initialize_from_args(3, 3,
- 1.0, 0.0, 0.0,
- 0.0, 1.0, 0.0,
- 0.0, 0.0, 1.0);
- using zgetrf_func.ipiv_size;
- int ipiv_size_v;
- ipiv_size_v=ipiv_size(a);
- say(ipiv_size_v);
- int ipiv[ipiv_size_v];
- int i;
- for(i=0;i<ipiv_size_v;i++)
- ipiv[i]=0;
- say("printing ipiv:\n",ipiv);
- using zgetrf_func.zgetrf_exec;
- int info;
- info=zgetrf_exec(a,ipiv);
- say("printing A");
- say(a);
- say();
- say(ipiv);
-}
-
-*/
@@ -1,13 +1,33 @@
+//ZGEEV computes for an N-by-N complex nonsymmetric matrix A, the eigenvalues and, optionally, the left and/or right eigenvectors.
+//The computed eigenvectors are normalized to have Euclidean norm equal to 1 and largest component real.
+
+
namespace zgeev_func_eva{
const int PRINT_DEBUG_STUFF = 0;
+/*
+ A: COMPLEX*16 array, dimension (LDA,N)
+ W: COMPLEX*16 array, dimension (N)
+ JOBVL: CHARACTER
+ JOBVR: CHARACTER
+ = 'N': left eigenvectors of A are not computed;
+ = 'V': left eigenvectors of A are computed.
+*/
+
function zgeev_exec_eva(var A,var W,int jobvl,int jobvr)
{
var pla = loadlib("linalg_group");
var lapack = loadlib('liblapack.so');
if (lapack == null || !lapack)
die("Cannot find liblapack. Search for the correct paths");
+
+/*
+ A is COMPLEX*16 array, dimension (LDA,N)
+ On entry, the N-by-N matrix A.
+ On exit, A has been overwritten.
+*/
+
var VL=new 'ComplexMatrix2D';
var VR=new 'ComplexMatrix2D';
int m,n,lda,ldvl,ldvr,lwork,info,rwork;
@@ -35,7 +55,19 @@ function zgeev_exec_eva(var A,var W,int jobvl,int jobvr)
zgeev(jobvl,jobvr,n,A,lda,W,VL,ldvl,VR,ldvr,WORK,lwork,rwork,info);
+
return info;
+
+/*
+ INFO is INTEGER
+ = 0: successful exit
+ < 0: if INFO = -i, the i-th argument had an illegal value.
+ > 0: if INFO = i, the QR algorithm failed to compute all the
+ eigenvalues, and no eigenvectors have been computed;
+ elements i+1:N of WR and WI contain eigenvalues which
+ have converged.
+ */
+
}
function max(var a,var b)
@@ -44,33 +76,3 @@ function max(var a,var b)
}
}
-
-/*
-
-function main[main](var args)
-{
-
- var pla = loadlib("linalg_group");
- var a = new 'ComplexMatrix2D';
- var w=new 'ComplexMatrix2D';
-
- int jobvl,jobvr;
- jobvl=jobvr= ord('N', 0);
- var info;
- a.initialize_from_args(3, 3,
- 1.0, 0.0, 0.0,
- 0.0, 1.0, 0.0,
- 0.0, 0.0, 1.0);
-
- using zgeev_func_eva.zgeev_exec_eva;
- info=zgeev_exec_eva(a,w,jobvl,jobvr);
-
- if(info==0)
- {
- say("successful\n");
- say("eigen values=\n");
- say(w);
- }
-}
-
-*/
@@ -1,7 +1,20 @@
+//ZGEEV computes for an N-by-N complex nonsymmetric matrix A, the eigenvalues and, optionally, the left and/or right eigenvectors.
+//The computed eigenvectors are normalized to have Euclidean norm equal to 1 and largest component real.
+
+
namespace zgeev_func_eve{
const int PRINT_DEBUG_STUFF = 0;
+/*
+ A: COMPLEX*16 array, dimension (LDA,N)
+ W: COMPLEX*16 array, dimension (N)
+ JOBVL: CHARACTER
+ JOBVR: CHARACTER
+ = 'N': left eigenvectors of A are not computed;
+ = 'V': left eigenvectors of A are computed.
+*/
+
function zgeev_exec_eve(var A,var W,var VL,var VR)
{
var pla = loadlib("linalg_group");
@@ -16,6 +29,12 @@ function zgeev_exec_eve(var A,var W,var VL,var VR)
if(zgeev == null || !zgeev)
die("Not zgeev");
+/*
+ A is COMPLEX*16 array, dimension (LDA,N)
+ On entry, the N-by-N matrix A.
+ On exit, A has been overwritten.
+*/
+
var WORK=new 'ComplexMatrix2D';
jobvl=jobvr= ord('V', 0);
m=A.rows;
@@ -33,9 +52,36 @@ function zgeev_exec_eve(var A,var W,var VL,var VR)
WORK.resize(lwork,lwork);
}
+/*
+VL is COMPLEX*16 array, dimension (LDVL,N)
+ If JOBVL = 'V', the left eigenvectors u(j) are stored one
+ after another in the columns of VL, in the same order
+ as their eigenvalues.
+ If JOBVL = 'N', VL is not referenced.
+ u(j) = VL(:,j), the j-th column of VL.
+
+VR is COMPLEX*16 array, dimension (LDVR,N)
+ If JOBVR = 'V', the right eigenvectors v(j) are stored one
+ after another in the columns of VR, in the same order
+ as their eigenvalues.
+ If JOBVR = 'N', VR is not referenced.
+ v(j) = VR(:,j), the j-th column of VR.
+
+*/
zgeev(jobvl,jobvr,n,A,lda,W,VL,ldvl,VR,ldvr,WORK,lwork,rwork,info);
+
return info;
+/*
+ INFO is INTEGER
+ = 0: successful exit
+ < 0: if INFO = -i, the i-th argument had an illegal value.
+ > 0: if INFO = i, the QR algorithm failed to compute all the
+ eigenvalues, and no eigenvectors have been computed;
+ elements i+1:N of WR and WI contain eigenvalues which
+ have converged.
+ */
+
}
function max(var a,var b)
@@ -44,31 +90,3 @@ function max(var a,var b)
}
}
-
-/*
-
-function main[main](var args)
-{
-
- var pla = loadlib("linalg_group");
- var a = new 'ComplexMatrix2D';
- var w=new 'ComplexMatrix2D';
- var vl=new 'ComplexMatrix2D';
- var vr=new 'ComplexMatrix2D';
- var info;
- a.initialize_from_args(3, 3,
- 1.0, 0.0, 0.0,
- 0.0, 1.0, 0.0,
- 0.0, 0.0, 1.0);
-
- using zgeev_func_eve.zgeev_exec_eve;
- info=zgeev_exec_eve(a,w,vl,vr);
-
- if(info==0)
- {
- say("right eigenvectors=\n",vr);
- say("left eigenvectors=\n",vl);
- }
-}
-
-*/
@@ -1,9 +1,15 @@
+//ZGETRI computes the inverse of a matrix using the LU factorization computed by ZGETRF.
+//This method inverts U and then computes inv(A) by solving the system inv(A)*L = inv(U) for inv(A).
+
+
$load "C_Double.pbc";
namespace zgetri_func{
const int PRINT_DEBUG_STUFF = 0;
+// A is COMPLEX*16 array, dimension (LDA,N)
+
function zgetri_exec(var a)
{
var pla = loadlib("linalg_group");
@@ -21,8 +27,15 @@ function zgetri_exec(var a)
ipiv[i]=0;
say("Given Matrix:");
- say(a);
+ say(a);
+/*
+ A is COMPLEX*16 array, dimension (LDA,N)
+ On entry, the factors L and U from the factorization
+ A = P*L*U as computed by ZGETRF.
+ On exit, if INFO = 0, the inverse of the original matrix A.
+*/
+
var zgetri = dlfunc(lapack, "zgetri_", "vppppppp");
if(zgetri == null || !zgetri)
die("Not ZGETRI");
@@ -42,6 +55,15 @@ function zgetri_exec(var a)
zgetri(n,a,lda,ipiv,work,lwork,info);
return info;
+/*
+INFO is INTEGER
+ = 0: successful exit
+ < 0: if INFO = -i, the i-th argument had an illegal value
+ > 0: if INFO = i, U(i,i) is exactly zero; the matrix is
+ singular and its inverse could not be computed.
+
+*/
+
}
@@ -66,23 +88,3 @@ function debug(var matrix, string msg, var args [slurpy])
}
-/*
-
-function main[main](var args)
-{
-
- var pla = loadlib("linalg_group");
- var a = new 'ComplexMatrix2D';
- a.initialize_from_args(3, 3,
- 1.0, 0.0, 0.0,
- 0.0, 1.0, 0.0,
- 0.0, 0.0, 1.0);
- using zgetri_func.zgetri_exec;
- int info;
- info=zgetri_exec(a);
- if(info==0)
- say(a);
- say("");
-}
-
-*/
Oops, something went wrong.