Im using the blitz library and have created this prototype.
This is the first time I have ever used this lib and was wandering if there is
a better way to get the minor than I am doing
the case where its element by element copying is ugly
Code:int determinate(Array<int,2>& MatA,int n) { cout << "entering n=\n"<<n; if (n==1) return MatA(1,1); if (n==2) return MatA(1,1)*MatA(2,2)-MatA(1,2)*MatA(2,1); Array<int,2> Minor(n-1,n-1,fortranArray); int det = 0; int coefficient; for (int j = 1; j<=n; j++) { if (j==1) Minor = MatA(Range(2,n),Range(2,n)); else if (j==n) Minor = MatA(Range(2,n),Range(1,n-1)); else { for (int c=1; c<=j-1; c++){ for (int r=2; r<=n; r++){ Minor(r-1,c) = MatA(r,c); } } for (int c=j+1; c<=n ;c++){ for (int r=2; r<=n; r++){ Minor(r-1,c-1) = MatA(r,c); } } } cout << "Minor :"<< Minor << endl; cout << "J="<<j<<"n="<<n; int p; cin >> p; det=det+MatA(1,j)*(int)pow(-1.0,1+j)*determinate(Minor,n-1); } return det; }



LinkBack URL
About LinkBacks


