Example #1
0
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;
   }
 // Element access
 BOOST_UBLAS_INLINE
 const_reference operator [] (size_type i) const {
     BOOST_UBLAS_CHECK (i < size_, bad_index ());
     return data_ [i];
 }
Example #3
0
 BOOST_UBLAS_INLINE 
 void resize (size_type size, value_type init) { 
     BOOST_UBLAS_CHECK (size == N, bad_size ()); 
     std::fill (data_, data_ + N, init); 
 }
Example #4
0
 BOOST_UBLAS_INLINE 
 reference operator [] (size_type i) { 
     BOOST_UBLAS_CHECK (i < N, bad_index ()); 
     return data_ [i]; 
 } 
Example #5
0
 // Resizing 
 BOOST_UBLAS_INLINE 
 void resize (size_type size) { 
     BOOST_UBLAS_CHECK (size == N, bad_size ()); 
 } 
Example #6
0
 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) ; 
 } 
Example #7
0
 explicit BOOST_UBLAS_INLINE 
 fixed_size_array (size_type size) { 
     BOOST_UBLAS_CHECK (size == N, bad_size ()); 
 }
Example #8
0
 BOOST_UBLAS_INLINE 
 void resize (size_type size, value_type init) { 
     BOOST_UBLAS_CHECK (size == 0, bad_size ()); 
 } 
Example #9
0
 BOOST_UBLAS_INLINE 
 fixed_size_array (size_type size, const value_type &init) { 
     BOOST_UBLAS_CHECK (size == 0, bad_size ()); 
 }