From e915df723574996002dbe6e758b137fb71f3b175 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 9 May 2024 10:37:07 +0000 Subject: [PATCH] Use unbounded_array_wrapper with custom_allocator in type aliases --- omnn/extrapolator/Extrapolator.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/omnn/extrapolator/Extrapolator.cpp b/omnn/extrapolator/Extrapolator.cpp index f3fb88ca0..176bcad47 100644 --- a/omnn/extrapolator/Extrapolator.cpp +++ b/omnn/extrapolator/Extrapolator.cpp @@ -15,10 +15,10 @@ using namespace boost::numeric::ublas; // Correct usage of Boost Ublas vector and matrix with custom_allocator // Replace incorrect allocator functions with correct Boost Ublas container functions -// Ensure that matrix_t, vector_t, and permutation_matrix_t are using std::vector with custom_allocator -using matrix_t = boost::numeric::ublas::matrix, std::vector>>; -using vector_t = boost::numeric::ublas::vector>>; -using permutation_matrix_t = boost::numeric::ublas::permutation_matrix>>; +// Ensure that matrix_t, vector_t, and permutation_matrix_t are using unbounded_array_wrapper with custom_allocator +using matrix_t = boost::numeric::ublas::matrix, unbounded_array_wrapper>; +using vector_t = boost::numeric::ublas::vector>; +using permutation_matrix_t = boost::numeric::ublas::permutation_matrix>; // This function calculates the determinant of a matrix using LU factorization auto det_fast(matrix_t matrix) { @@ -110,7 +110,8 @@ Extrapolator::solution_t Extrapolator::Solve(const vector_t& augment) const auto sz1 = size1(); auto sz2 = size2(); - vector_t a(sz2); // Initialize vector with size using custom_allocator implicitly + // Initialize vector with size and default value + vector_t a(sz2, Valuable(0)); const vector_t* au = &augment; if (sz1 > sz2 + 1 /*augment*/) { // make square matrix to make it solvable by boost ublas @@ -124,14 +125,14 @@ Extrapolator::solution_t Extrapolator::Solve(const vector_t& augment) const for (auto j = sz2; j--;) { e(0, j) += operator()(i, j); } - a(0) += augment(i); // Use vector's operator[] provided by unbounded_array_wrapper for element access + a(i - d) = (*au)(i); // Use vector's operator() provided by Boost Ublas for element access } for (auto i = d; i < sz1; ++i) { for (auto j = sz2; j--;) { e(i - d, j) = operator()(i, j); } - a(i - d) = augment(i); // Use vector's operator[] provided by unbounded_array_wrapper for element access + a(i - d) = (*au)(i); // Use vector's operator() provided by Boost Ublas for element access } au = &a; }