void lu_decompose(int n, complex_array& a_in, int_array& ip, int ndim) { /* cout << "atlas_a = "; to_octave(a_in,n,ndim); */ // copy the input matrix a_in into a temporary array (transposing as we go) // complex_array A(n,n); int_array piv(n); /* for (int row = 0; row < n; row++ ) { int col_index = row * ndim; for (int col = 0; col < n; col++ ) { A.set(row,col,a_in[col_index++]); } }*/ int info = clapack_zgetrf (CblasColMajor, n, n, (void*) a_in.get_ptr(), ndim, piv.get_ptr()); if (0 != info) { /* 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. */ cout << "nec++: LU Decomposition Failed: " << info; } /* IPIV (output) INTEGER array, dimension (min(M,N)) The pivot indices; for 1 <= i <= min(M,N), row i of the matrix was interchanged with row IPIV(i). */ for (int j = 0; j < n; j++ ) { ip[j] = piv[j] + 1; } // copy the output back into the a_in array. /* for (int row = 0; row < n; row++ ) { int col_index = row*ndim; for (int col = 0; col < n; col++ ) { a_in[col_index++] = A.get(row,col); } }*/ /* cout << "atlas_solved = "; to_octave(a_in,n,ndim); cout << "atlas_ip = "; to_octave(ip,n);*/ }
void to_octave(complex_array& a, int n, int ndim) { to_octave(a.get_ptr(),n,ndim); }