Add calculation for tridiagonal matrices (solve, factorize, det, rcond)#196
Merged
termoshtt merged 8 commits intorust-ndarray:masterfrom Jun 28, 2020
Merged
Add calculation for tridiagonal matrices (solve, factorize, det, rcond)#196termoshtt merged 8 commits intorust-ndarray:masterfrom
termoshtt merged 8 commits intorust-ndarray:masterfrom
Conversation
Contributor
Author
|
I removed a 1-norm field |
termoshtt
approved these changes
Jun 25, 2020
termoshtt
reviewed
Jun 28, 2020
| } | ||
|
|
||
| /// An interface for making a Tridiagonal struct. | ||
| pub trait ToTridiagonal<A: Scalar> { |
Member
There was a problem hiding this comment.
Suggested change
| pub trait ToTridiagonal<A: Scalar> { | |
| pub trait ExtractTridiagonal<A: Scalar> { |
Comment on lines
+30
to
+37
| pub trait TridiagIndex { | ||
| fn to_tuple(&self) -> (i32, i32); | ||
| } | ||
| impl TridiagIndex for [Ix; 2] { | ||
| fn to_tuple(&self) -> (i32, i32) { | ||
| (self[0] as i32, self[1] as i32) | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
I think ndarray::NdIndex<Ix2> could be better for it, but it does not enough iterface for implementing this PR, e.g. Into<Ix2>. I keep this code as it is.
Member
|
Thank a lot :) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I added the calculation for tridiagonal matrices, which might be important for solving differential equations.
First, I made a struct of
TriDiagonalfor LU factorization and solving equation using LAPACK. It represents a tridiagonal matrix as 3 one-dimensionalArray(diagonal, sub-diagonal and super-diagonal elements).And this struct also holds the layout and 1-norm of the raw matrix. They are used in some methods (
solve_tridiagonal,rcond_tridiagonal, etc.)Second,
LUFactorizedTriDiagonalstruct contains additional 1DArrayof the second super-diagonal of matrix U andipiv, just likeLUFactorized.These structs and
ArrayBase<S, Ix2>havelu (*gttrf),rcond (*gtcon),solve (*gttrs)like methods using LAPACK and adetlike method using a recurrent relation implemented in Rust.I also added an example and some test functions. Please confirm that you can use them just like any other methods implemented for general or triangular matrices.