# Autodiff compatible least squares package

**URL:** https://discourse.julialang.org/t/autodiff-compatible-least-squares-package/106115
**Category:** Machine Learning
**Created:** [November 12, 2023, 3:43pm UTC](https://discourse.julialang.org/t/autodiff-compatible-least-squares-package/106115 "2023-11-12T15:43:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![RahulManavalan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rahulmanavalan/32/31945_2.png) [@RahulManavalan](https://discourse.julialang.org/u/RahulManavalan)
#### Post date: [November 12, 2023, 3:43pm UTC](https://discourse.julialang.org/t/autodiff-compatible-least-squares-package/106115/1 "2023-11-12T15:43:14Z")

</div>

Greetings.  
I am searching for a Julia package, that can emulate `pinv(A)` from LinearAlgebra.jl but has an all Julia implementation to leverage the AD ecosystem to evaluate the gradients with respect to the parameters used in my computation (where pinv is a subroutine). Any leads on this matter is highly appreciated.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [November 12, 2023, 3:55pm UTC](https://discourse.julialang.org/t/autodiff-compatible-least-squares-package/106115/2 "2023-11-12T15:55:54Z")

</div>

You don’t need to use `pinv` to solve a least squares problem, `A\b` will do it.

But if you’re looking for something that lets you change algorithms to say GMRES and sparse linear solvers, you can use LinearSolve.jl

> **[GitHub - SciML/LinearSolve.jl: LinearSolve.jl: High-Performance Unified...](https://github.com/SciML/LinearSolve.jl)**
>
> LinearSolve.jl: High-Performance Unified Interface for Linear Solvers in Julia. Easily switch between factorization and Krylov methods, add preconditioners, and all in one interface. - GitHub - Sci...

LinearSolve.jl recently added support for Enzyme and more AD backends are coming rather soon.
