Implement Clone, Debug, Copy for all linalg structures.
This commit is contained in:
parent
b84c7e10df
commit
70bb2cbe46
|
@ -10,6 +10,7 @@ use geometry::Reflection;
|
|||
|
||||
|
||||
/// The bidiagonalization of a general matrix.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Bidiagonal<N: Real, R: DimMin<C>, C: Dim>
|
||||
where DimMinimum<R, C>: DimSub<U1>,
|
||||
DefaultAllocator: Allocator<N, R, C> +
|
||||
|
@ -25,6 +26,15 @@ pub struct Bidiagonal<N: Real, R: DimMin<C>, C: Dim>
|
|||
upper_diagonal: bool
|
||||
}
|
||||
|
||||
impl<N: Real, R: DimMin<C>, C: Dim> Copy for Bidiagonal<N, R, C>
|
||||
where DimMinimum<R, C>: DimSub<U1>,
|
||||
DefaultAllocator: Allocator<N, R, C> +
|
||||
Allocator<N, DimMinimum<R, C>> +
|
||||
Allocator<N, DimDiff<DimMinimum<R, C>, U1>>,
|
||||
MatrixMN<N, R, C>: Copy,
|
||||
VectorN<N, DimMinimum<R, C>>: Copy,
|
||||
VectorN<N, DimDiff<DimMinimum<R, C>, U1>>: Copy { }
|
||||
|
||||
impl<N: Real, R: DimMin<C>, C: Dim> Bidiagonal<N, R, C>
|
||||
where DimMinimum<R, C>: DimSub<U1>,
|
||||
DefaultAllocator: Allocator<N, R, C> +
|
||||
|
|
|
@ -7,11 +7,16 @@ use allocator::Allocator;
|
|||
use dimension::{Dim, Dynamic, DimSub};
|
||||
|
||||
/// The cholesky decomposion of a symmetric-definite-positive matrix.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Cholesky<N: Real, D: Dim>
|
||||
where DefaultAllocator: Allocator<N, D, D> {
|
||||
chol: MatrixN<N, D>
|
||||
}
|
||||
|
||||
impl<N: Real, D: Dim> Copy for Cholesky<N, D>
|
||||
where DefaultAllocator: Allocator<N, D, D>,
|
||||
MatrixN<N, D>: Copy { }
|
||||
|
||||
impl<N: Real, D: DimSub<Dynamic>> Cholesky<N, D>
|
||||
where DefaultAllocator: Allocator<N, D, D> {
|
||||
/// Attempts to compute the sholesky decomposition of `matrix`.
|
||||
|
|
|
@ -16,6 +16,7 @@ use geometry::{Reflection, UnitComplex};
|
|||
|
||||
|
||||
/// The eigendecomposition of a matrix with real eigenvalues.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RealEigen<N: Real, D: Dim>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, D> {
|
||||
|
@ -23,6 +24,13 @@ pub struct RealEigen<N: Real, D: Dim>
|
|||
pub eigenvalues: VectorN<N, D>
|
||||
}
|
||||
|
||||
|
||||
impl<N: Real, D: Dim> Copy for RealEigen<N, D>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, D>,
|
||||
MatrixN<N, D>: Copy,
|
||||
VectorN<N, D>: Copy { }
|
||||
|
||||
impl<N: Real, D: Dim> RealEigen<N, D>
|
||||
where D: DimSub<U1>, // For Hessenberg.
|
||||
ShapeConstraint: DimEq<Dynamic, DimDiff<D, U1>>, // For Hessenberg.
|
||||
|
|
|
@ -11,6 +11,7 @@ use linalg::PermutationSequence;
|
|||
|
||||
|
||||
/// LU decomposition with full pivoting.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct FullPivLU<N: Real, R: DimMin<C>, C: Dim>
|
||||
where DefaultAllocator: Allocator<N, R, C> +
|
||||
Allocator<(usize, usize), DimMinimum<R, C>> {
|
||||
|
@ -20,6 +21,13 @@ pub struct FullPivLU<N: Real, R: DimMin<C>, C: Dim>
|
|||
}
|
||||
|
||||
|
||||
impl<N: Real, R: DimMin<C>, C: Dim> Copy for FullPivLU<N, R, C>
|
||||
where DefaultAllocator: Allocator<N, R, C> +
|
||||
Allocator<(usize, usize), DimMinimum<R, C>>,
|
||||
MatrixMN<N, R, C>: Copy,
|
||||
PermutationSequence<DimMinimum<R, C>>: Copy { }
|
||||
|
||||
|
||||
impl<N: Real, R: DimMin<C>, C: Dim> FullPivLU<N, R, C>
|
||||
where DefaultAllocator: Allocator<N, R, C> +
|
||||
Allocator<(usize, usize), DimMinimum<R, C>> {
|
||||
|
|
|
@ -8,6 +8,7 @@ use constraint::{ShapeConstraint, DimEq};
|
|||
use linalg::householder;
|
||||
|
||||
/// The Hessenberg decomposition of a general matrix.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Hessenberg<N: Real, D: DimSub<U1>>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, DimDiff<D, U1>> {
|
||||
|
@ -16,6 +17,12 @@ pub struct Hessenberg<N: Real, D: DimSub<U1>>
|
|||
subdiag: VectorN<N, DimDiff<D, U1>>
|
||||
}
|
||||
|
||||
impl<N: Real, D: DimSub<U1>> Copy for Hessenberg<N, D>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, DimDiff<D, U1>>,
|
||||
MatrixN<N, D>: Copy,
|
||||
VectorN<N, DimDiff<D, U1>>: Copy { }
|
||||
|
||||
impl<N: Real, D: DimSub<U1>> Hessenberg<N, D>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, D> +
|
||||
|
|
|
@ -11,6 +11,7 @@ use linalg::PermutationSequence;
|
|||
|
||||
|
||||
/// LU decomposition with partial (row) pivoting.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct LU<N: Real, R: DimMin<C>, C: Dim>
|
||||
where DefaultAllocator: Allocator<N, R, C> +
|
||||
Allocator<(usize, usize), DimMinimum<R, C>> {
|
||||
|
@ -18,6 +19,12 @@ pub struct LU<N: Real, R: DimMin<C>, C: Dim>
|
|||
p: PermutationSequence<DimMinimum<R, C>>
|
||||
}
|
||||
|
||||
impl<N: Real, R: DimMin<C>, C: Dim> Copy for LU<N, R, C>
|
||||
where DefaultAllocator: Allocator<N, R, C> +
|
||||
Allocator<(usize, usize), DimMinimum<R, C>>,
|
||||
MatrixMN<N, R, C>: Copy,
|
||||
PermutationSequence<DimMinimum<R, C>>: Copy { }
|
||||
|
||||
/// Performs a LU decomposition to overwrite `out` with the inverse of `matrix`.
|
||||
///
|
||||
/// If `matrix` is not invertible, `false` is returned and `out` may contain invalid data.
|
||||
|
|
|
@ -8,12 +8,17 @@ use allocator::Allocator;
|
|||
|
||||
|
||||
/// A sequence of permutations.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PermutationSequence<D: Dim>
|
||||
where DefaultAllocator: Allocator<(usize, usize), D>{
|
||||
where DefaultAllocator: Allocator<(usize, usize), D> {
|
||||
len: usize,
|
||||
ipiv: VectorN<(usize, usize), D>
|
||||
}
|
||||
|
||||
impl<D: Dim> Copy for PermutationSequence<D>
|
||||
where DefaultAllocator: Allocator<(usize, usize), D>,
|
||||
VectorN<(usize, usize), D>: Copy { }
|
||||
|
||||
impl<D: Dim> PermutationSequence<D>
|
||||
where DefaultAllocator: Allocator<(usize, usize), D> {
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use geometry::Reflection;
|
|||
|
||||
|
||||
/// The QR decomposition of a general matrix.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct QR<N: Real, R: DimMin<C>, C: Dim>
|
||||
where DefaultAllocator: Allocator<N, R, C> +
|
||||
Allocator<N, DimMinimum<R, C>> {
|
||||
|
@ -17,6 +18,13 @@ pub struct QR<N: Real, R: DimMin<C>, C: Dim>
|
|||
diag: VectorN<N, DimMinimum<R, C>>,
|
||||
}
|
||||
|
||||
|
||||
impl<N: Real, R: DimMin<C>, C: Dim> Copy for QR<N, R, C>
|
||||
where DefaultAllocator: Allocator<N, R, C> +
|
||||
Allocator<N, DimMinimum<R, C>>,
|
||||
MatrixMN<N, R, C>: Copy,
|
||||
VectorN<N, DimMinimum<R, C>>: Copy { }
|
||||
|
||||
impl<N: Real, R: DimMin<C>, C: Dim> QR<N, R, C>
|
||||
where DefaultAllocator: Allocator<N, R, C> +
|
||||
Allocator<N, R> +
|
||||
|
|
|
@ -15,6 +15,7 @@ use geometry::{Reflection, UnitComplex};
|
|||
|
||||
|
||||
/// Real RealSchur decomposition of a square matrix.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RealSchur<N: Real, D: Dim>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, D> {
|
||||
|
@ -22,6 +23,12 @@ pub struct RealSchur<N: Real, D: Dim>
|
|||
t: MatrixN<N, D>
|
||||
}
|
||||
|
||||
|
||||
impl<N: Real, D: Dim> Copy for RealSchur<N, D>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, D>,
|
||||
MatrixN<N, D>: Copy { }
|
||||
|
||||
impl<N: Real, D: Dim> RealSchur<N, D>
|
||||
where D: DimSub<U1>, // For Hessenberg.
|
||||
ShapeConstraint: DimEq<Dynamic, DimDiff<D, U1>>, // For Hessenberg.
|
||||
|
|
|
@ -16,7 +16,7 @@ use geometry::UnitComplex;
|
|||
|
||||
|
||||
/// The Singular Value Decomposition of a real matrix.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SVD<N: Real, R: DimMin<C>, C: Dim>
|
||||
where DefaultAllocator: Allocator<N, R, C> +
|
||||
Allocator<N, DimMinimum<R, C>, C> +
|
||||
|
@ -30,6 +30,16 @@ pub struct SVD<N: Real, R: DimMin<C>, C: Dim>
|
|||
pub singular_values: VectorN<N, DimMinimum<R, C>>,
|
||||
}
|
||||
|
||||
|
||||
impl<N: Real, R: DimMin<C>, C: Dim> SVD<N, R, C>
|
||||
where DefaultAllocator: Allocator<N, R, C> +
|
||||
Allocator<N, DimMinimum<R, C>, C> +
|
||||
Allocator<N, R, DimMinimum<R, C>> +
|
||||
Allocator<N, DimMinimum<R, C>>,
|
||||
MatrixMN<N, R, DimMinimum<R, C>>: Copy,
|
||||
MatrixMN<N, DimMinimum<R, C>, C>: Copy,
|
||||
VectorN<N, DimMinimum<R, C>>: Copy { }
|
||||
|
||||
impl<N: Real, R: DimMin<C>, C: Dim> SVD<N, R, C>
|
||||
where DimMinimum<R, C>: DimSub<U1>, // for Bidiagonal.
|
||||
DefaultAllocator: Allocator<N, R, C> +
|
||||
|
|
|
@ -13,6 +13,7 @@ use geometry::UnitComplex;
|
|||
|
||||
|
||||
/// The eigendecomposition of a symmetric matrix.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SymmetricEigen<N: Real, D: Dim>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, D> {
|
||||
|
@ -23,6 +24,12 @@ pub struct SymmetricEigen<N: Real, D: Dim>
|
|||
pub eigenvalues: VectorN<N, D>
|
||||
}
|
||||
|
||||
impl<N: Real, D: Dim> SymmetricEigen<N, D>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, D>,
|
||||
MatrixN<N, D>: Copy,
|
||||
VectorN<N, D>: Copy { }
|
||||
|
||||
impl<N: Real, D: Dim> SymmetricEigen<N, D>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, D> {
|
||||
|
|
|
@ -8,6 +8,7 @@ use linalg::householder;
|
|||
|
||||
|
||||
/// The tridiagonalization of a symmetric matrix.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SymmetricTridiagonal<N: Real, D: DimSub<U1>>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, DimDiff<D, U1>> {
|
||||
|
@ -15,6 +16,12 @@ pub struct SymmetricTridiagonal<N: Real, D: DimSub<U1>>
|
|||
off_diagonal: VectorN<N, DimDiff<D, U1>>
|
||||
}
|
||||
|
||||
impl<N: Real, D: DimSub<U1>> SymmetricTridiagonal<N, D>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, DimDiff<D, U1>>,
|
||||
MatrixN<N, D>: Copy,
|
||||
VectorN<N, DimDiff<D, U1>>: Copy { }
|
||||
|
||||
impl<N: Real, D: DimSub<U1>> SymmetricTridiagonal<N, D>
|
||||
where DefaultAllocator: Allocator<N, D, D> +
|
||||
Allocator<N, DimDiff<D, U1>> {
|
||||
|
|
Loading…
Reference in New Issue