fix: minor refactoring

This commit is contained in:
Volodymyr Orlov
2020-03-31 18:24:01 -07:00
parent 8bb6013430
commit 5766364311
15 changed files with 49 additions and 52 deletions
+11 -11
View File
@@ -6,13 +6,13 @@ use crate::math::num::FloatExt;
use std::fmt::Debug;
#[derive(Debug, Clone)]
pub struct EVD<T: FloatExt + Debug, M: BaseMatrix<T>> {
pub struct EVD<T: FloatExt, M: BaseMatrix<T>> {
pub d: Vec<T>,
pub e: Vec<T>,
pub V: M
}
impl<T: FloatExt + Debug, M: BaseMatrix<T>> EVD<T, M> {
impl<T: FloatExt, M: BaseMatrix<T>> EVD<T, M> {
pub fn new(V: M, d: Vec<T>, e: Vec<T>) -> EVD<T, M> {
EVD {
d: d,
@@ -22,7 +22,7 @@ impl<T: FloatExt + Debug, M: BaseMatrix<T>> EVD<T, M> {
}
}
pub trait EVDDecomposableMatrix<T: FloatExt + Debug>: BaseMatrix<T> {
pub trait EVDDecomposableMatrix<T: FloatExt>: BaseMatrix<T> {
fn evd(&self, symmetric: bool) -> EVD<T, Self>{
self.clone().evd_mut(symmetric)
@@ -68,7 +68,7 @@ pub trait EVDDecomposableMatrix<T: FloatExt + Debug>: BaseMatrix<T> {
}
}
fn tred2<T: FloatExt + Debug, M: BaseMatrix<T>>(V: &mut M, d: &mut Vec<T>, e: &mut Vec<T>) {
fn tred2<T: FloatExt, M: BaseMatrix<T>>(V: &mut M, d: &mut Vec<T>, e: &mut Vec<T>) {
let (n, _) = V.shape();
for i in 0..n {
@@ -172,7 +172,7 @@ fn tred2<T: FloatExt + Debug, M: BaseMatrix<T>>(V: &mut M, d: &mut Vec<T>, e: &m
e[0] = T::zero();
}
fn tql2<T: FloatExt + Debug, M: BaseMatrix<T>>(V: &mut M, d: &mut Vec<T>, e: &mut Vec<T>) {
fn tql2<T: FloatExt, M: BaseMatrix<T>>(V: &mut M, d: &mut Vec<T>, e: &mut Vec<T>) {
let (n, _) = V.shape();
for i in 1..n {
e[i - 1] = e[i];
@@ -288,7 +288,7 @@ fn tql2<T: FloatExt + Debug, M: BaseMatrix<T>>(V: &mut M, d: &mut Vec<T>, e: &mu
}
}
fn balance<T: FloatExt + Debug, M: BaseMatrix<T>>(A: &mut M) -> Vec<T> {
fn balance<T: FloatExt, M: BaseMatrix<T>>(A: &mut M) -> Vec<T> {
let radix = T::two();
let sqrdx = radix * radix;
@@ -341,7 +341,7 @@ fn balance<T: FloatExt + Debug, M: BaseMatrix<T>>(A: &mut M) -> Vec<T> {
return scale;
}
fn elmhes<T: FloatExt + Debug, M: BaseMatrix<T>>(A: &mut M) -> Vec<usize> {
fn elmhes<T: FloatExt, M: BaseMatrix<T>>(A: &mut M) -> Vec<usize> {
let (n, _) = A.shape();
let mut perm = vec![0; n];
@@ -387,7 +387,7 @@ fn elmhes<T: FloatExt + Debug, M: BaseMatrix<T>>(A: &mut M) -> Vec<usize> {
return perm;
}
fn eltran<T: FloatExt + Debug, M: BaseMatrix<T>>(A: &M, V: &mut M, perm: &Vec<usize>) {
fn eltran<T: FloatExt, M: BaseMatrix<T>>(A: &M, V: &mut M, perm: &Vec<usize>) {
let (n, _) = A.shape();
for mp in (1..n - 1).rev() {
for k in mp + 1..n {
@@ -404,7 +404,7 @@ fn eltran<T: FloatExt + Debug, M: BaseMatrix<T>>(A: &M, V: &mut M, perm: &Vec<us
}
}
fn hqr2<T: FloatExt + Debug, M: BaseMatrix<T>>(A: &mut M, V: &mut M, d: &mut Vec<T>, e: &mut Vec<T>) {
fn hqr2<T: FloatExt, M: BaseMatrix<T>>(A: &mut M, V: &mut M, d: &mut Vec<T>, e: &mut Vec<T>) {
let (n, _) = A.shape();
let mut z = T::zero();
let mut s = T::zero();
@@ -742,7 +742,7 @@ fn hqr2<T: FloatExt + Debug, M: BaseMatrix<T>>(A: &mut M, V: &mut M, d: &mut Vec
}
}
fn balbak<T: FloatExt + Debug, M: BaseMatrix<T>>(V: &mut M, scale: &Vec<T>) {
fn balbak<T: FloatExt, M: BaseMatrix<T>>(V: &mut M, scale: &Vec<T>) {
let (n, _) = V.shape();
for i in 0..n {
for j in 0..n {
@@ -751,7 +751,7 @@ fn balbak<T: FloatExt + Debug, M: BaseMatrix<T>>(V: &mut M, scale: &Vec<T>) {
}
}
fn sort<T: FloatExt + Debug, M: BaseMatrix<T>>(d: &mut Vec<T>, e: &mut Vec<T>, V: &mut M) {
fn sort<T: FloatExt, M: BaseMatrix<T>>(d: &mut Vec<T>, e: &mut Vec<T>, V: &mut M) {
let n = d.len();
let mut temp = vec![T::zero(); n];
for j in 1..n {