Skip to content

Conversation

@loiseaujc
Copy link
Contributor

@loiseaujc loiseaujc commented Oct 22, 2025

Following #1044, this PR implements an equality-constrained least-squares solver based on xGGLSE from lapack.

Proposed interfaces

  • call solve_constrained_lstsq(A, b, C, d, x [, storage, overwrite_matrices, err])
  • x = constrained_lstsq(A, b, C, d [, overwrite_matrices, err])

where A and b define the least-squares cost, while Cx = d define the equality constraints.

Progress

  • Interface
  • Base implementation
  • Tests
  • In-code documentation
  • Specifications
  • Example

Ping: @perazz, @jvdp1, @jalvesz

@loiseaujc loiseaujc linked an issue Oct 23, 2025 that may be closed by this pull request
@loiseaujc loiseaujc marked this pull request as ready for review October 23, 2025 15:17
@loiseaujc
Copy link
Contributor Author

Unless I forgot something, I think this PR is ready to be reviewed :)

@jalvesz jalvesz requested a review from Copilot November 1, 2025 19:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for equality-constrained least-squares solving to the stdlib_linalg module. It introduces functionality to solve problems of the form: minimize ||Ax - b||² subject to Cx = d, using LAPACK's GGLSE backend.

Key changes:

  • New constrained least-squares solver with both function and subroutine interfaces
  • Support for workspace pre-allocation via constrained_lstsq_space
  • Comprehensive test coverage and documentation examples

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/stdlib_linalg.fypp Adds public interfaces for constrained_lstsq, solve_constrained_lstsq, and constrained_lstsq_space
src/stdlib_linalg_least_squares.fypp Implements constrained least-squares solver, fixes typo "byu" → "by", adds check_problem_size validation
src/lapack/stdlib_linalg_lapack_aux.fypp Adds handle_gglse_info error handler for GGLSE LAPACK routines
test/linalg/test_linalg_constrained_lstsq.fypp Adds comprehensive test suite covering function, subroutine, and pre-allocated workspace interfaces
test/linalg/CMakeLists.txt Registers new test file in build system
example/linalg/example_constrained_lstsq1.f90 Demonstrates functional interface usage
example/linalg/example_constrained_lstsq2.f90 Demonstrates subroutine interface with pre-allocated workspace
example/linalg/CMakeLists.txt Registers example programs in build system
doc/specs/stdlib_linalg.md Adds documentation for all three new interfaces
Comments suppressed due to low confidence (2)

doc/specs/stdlib_linalg.md:1

  • Corrected spelling of 'GLSE' to 'GGLSE' to match the actual LAPACK routine names.
---

doc/specs/stdlib_linalg.md:1

  • Corrected spelling of 'GLSE' to 'GGLSE' to match the actual LAPACK routine names.
---

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@9e4c230). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1046   +/-   ##
=========================================
  Coverage          ?   25.13%           
=========================================
  Files             ?      570           
  Lines             ?   234201           
  Branches          ?    41267           
=========================================
  Hits              ?    58870           
  Misses            ?   175331           
  Partials          ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constrained least-squares solver

1 participant