LUDecomposition::Matrix LUDecomposition::solve (const Matrix& B) const { BOOST_UBLAS_CHECK((int)B.size1() == m, bad_size("Matrix row dimensions must agree.")); BOOST_UBLAS_CHECK(isNonsingular(), singular("Matrix is singular.")); // Copy right hand side with pivoting int nx = B.size2(); Matrix X(m,nx); for (int i = 0; i < m; i++) { row(X,i) = row(B, piv(i)); } // Solve L*Y = B(piv,:) for (int k = 0; k < n; k++) { for (int i = k+1; i < n; i++) { for (int j = 0; j < nx; j++) { X(i,j) -= X(k,j)*LU(i,k); } } } // Solve U*X = Y; for (int k = n-1; k >= 0; k--) { for (int j = 0; j < nx; j++) { X(k,j) /= LU(k,k); } for (int i = 0; i < k; i++) { for (int j = 0; j < nx; j++) { X(i,j) -= X(k,j)*LU(i,k); } } } return X; }
static void run(unsigned int i) { if (i == 0) good_size(); else bad_size(); SAFE_CLOSE(sk); }
BOOST_UBLAS_INLINE void resize (size_type size, value_type init) { BOOST_UBLAS_CHECK (size == N, bad_size ()); std::fill (data_, data_ + N, init); }
// Resizing BOOST_UBLAS_INLINE void resize (size_type size) { BOOST_UBLAS_CHECK (size == N, bad_size ()); }
BOOST_UBLAS_INLINE fixed_size_array (size_type size, const value_type &init) { BOOST_UBLAS_CHECK (size == N, bad_size ()); std::fill (data_, data_ + N, init) ; }
explicit BOOST_UBLAS_INLINE fixed_size_array (size_type size) { BOOST_UBLAS_CHECK (size == N, bad_size ()); }
BOOST_UBLAS_INLINE void resize (size_type size, value_type init) { BOOST_UBLAS_CHECK (size == 0, bad_size ()); }
BOOST_UBLAS_INLINE fixed_size_array (size_type size, const value_type &init) { BOOST_UBLAS_CHECK (size == 0, bad_size ()); }