-
Notifications
You must be signed in to change notification settings - Fork 192
linalg: least squares #801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
892bf1e
templated BLAS/LAPACK initials
perazz 465d230
base implementation
perazz 7475680
submodule
perazz 285aed2
remove `xdp`
perazz f725160
add test
perazz 71a1fe5
add example
perazz 2b2ade9
add specs
perazz 905692c
document interface
perazz cd9b3e6
clarify space; remove `goto`; fix allocation leak
perazz 56bf7f7
typo
perazz c587e11
doc typo
perazz c1d0100
Update doc/specs/stdlib_linalg.md
perazz 47d4793
Update doc/specs/stdlib_linalg.md
perazz 6d6f49a
Update doc/specs/stdlib_linalg.md
perazz 37857f0
Update doc/specs/stdlib_linalg.md
perazz 09f1a5b
remove unused state variable
perazz 63d297e
add test with random input
perazz 78a8f6e
cleanup
perazz 90f553f
Merge branch 'least_squares' of github.com:perazz/stdlib into least_s…
perazz dafa081
fix comment
perazz 1773de8
Merge branch 'master' into least_squares
perazz 42f2de1
subroutine interface
perazz 2e370f4
export working space interface
perazz 70da4c8
Update src/stdlib_linalg.fypp
perazz 18151e6
`solve_lstsq` example program
perazz c55583d
document `solve_lstsq` and `lstsq_space`
perazz 2a1a88a
Merge branch 'fortran-lang:master' into least_squares
perazz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ ADD_EXAMPLE(state1) | |
ADD_EXAMPLE(state2) | ||
ADD_EXAMPLE(blas_gemv) | ||
ADD_EXAMPLE(lapack_getrf) | ||
ADD_EXAMPLE(lstsq) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
program example_lstsq | ||
use stdlib_linalg_constants, only: dp | ||
use stdlib_linalg, only: lstsq | ||
use stdlib_linalg_state, only: linalg_state_type | ||
perazz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
implicit none | ||
type(linalg_state_type) :: err | ||
|
||
integer, allocatable :: x(:),y(:) | ||
real(dp), allocatable :: A(:,:),b(:),coef(:) | ||
|
||
! Data set | ||
x = [1, 2, 2] | ||
y = [5, 13, 25] | ||
|
||
! Fit three points using a parabola, least squares method | ||
! A = [1 x x**2] | ||
A = reshape([[1,1,1],x,x**2],[3,3]) | ||
b = y | ||
|
||
! Get coefficients of y = coef(1) + x*coef(2) + x^2*coef(3) | ||
coef = lstsq(A,b) | ||
|
||
print *, 'parabola: ',coef | ||
! parabola: -0.42857142857141695 1.1428571428571503 4.2857142857142811 | ||
|
||
|
||
end program example_lstsq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.