Substitute: diag -> diagonal.
This commit is contained in:
parent
0380661bd2
commit
0c84d18850
|
@ -838,10 +838,10 @@ macro_rules! dmat_impl(
|
|||
|
||||
impl<N: Copy + Clone + Zero> Diagonal<$dvector<N>> for $dmatrix<N> {
|
||||
#[inline]
|
||||
fn from_diag(diagonal: &$dvector<N>) -> $dmatrix<N> {
|
||||
fn from_diagonal(diagonal: &$dvector<N>) -> $dmatrix<N> {
|
||||
let mut res = $dmatrix::new_zeros(diagonal.len(), diagonal.len());
|
||||
|
||||
res.set_diag(diagonal);
|
||||
res.set_diagonal(diagonal);
|
||||
|
||||
res
|
||||
}
|
||||
|
@ -862,7 +862,7 @@ macro_rules! dmat_impl(
|
|||
|
||||
impl<N: Copy + Clone + Zero> DiagMut<$dvector<N>> for $dmatrix<N> {
|
||||
#[inline]
|
||||
fn set_diag(&mut self, diagonal: &$dvector<N>) {
|
||||
fn set_diagonal(&mut self, diagonal: &$dvector<N>) {
|
||||
let smallest_dim = cmp::min(self.nrows, self.ncols);
|
||||
|
||||
assert!(diagonal.len() == smallest_dim);
|
||||
|
|
|
@ -499,10 +499,10 @@ macro_rules! diag_impl(
|
|||
($t: ident, $tv: ident, $dimension: expr) => (
|
||||
impl<N: Copy + Zero> Diagonal<$tv<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn from_diag(diagonal: &$tv<N>) -> $t<N> {
|
||||
fn from_diagonal(diagonal: &$tv<N>) -> $t<N> {
|
||||
let mut res: $t<N> = ::zero();
|
||||
|
||||
res.set_diag(diagonal);
|
||||
res.set_diagonal(diagonal);
|
||||
|
||||
res
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ macro_rules! diag_impl(
|
|||
|
||||
impl<N: Copy + Zero> DiagMut<$tv<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn set_diag(&mut self, diagonal: &$tv<N>) {
|
||||
fn set_diagonal(&mut self, diagonal: &$tv<N>) {
|
||||
for i in 0 .. $dimension {
|
||||
unsafe { self.unsafe_set((i, i), diagonal.unsafe_at(i)) }
|
||||
}
|
||||
|
|
|
@ -123,8 +123,8 @@ macro_rules! diag_impl(
|
|||
($t: ident, $tv: ident) => (
|
||||
impl<N: Copy + Zero> Diagonal<$tv<N>> for $t<N> {
|
||||
#[inline]
|
||||
fn from_diag(diagonal: &$tv<N>) -> $t<N> {
|
||||
$t { submatrix: Diagonal::from_diag(diagonal) }
|
||||
fn from_diagonal(diagonal: &$tv<N>) -> $t<N> {
|
||||
$t { submatrix: Diagonal::from_diagonal(diagonal) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -169,7 +169,7 @@ pub trait Dimension: Sized {
|
|||
/// Trait to get the diagonal of square matrices.
|
||||
pub trait Diagonal<V> {
|
||||
/// Creates a new matrix with the given diagonal.
|
||||
fn from_diag(diagonal: &V) -> Self;
|
||||
fn from_diagonal(diagonal: &V) -> Self;
|
||||
|
||||
/// The diagonal of this matrix.
|
||||
fn diagonal(&self) -> V;
|
||||
|
@ -178,7 +178,7 @@ pub trait Diagonal<V> {
|
|||
/// Trait to set the diagonal of square matrices.
|
||||
pub trait DiagMut<V>: Diagonal<V> {
|
||||
/// Sets the diagonal of this matrix.
|
||||
fn set_diag(&mut self, diagonal: &V);
|
||||
fn set_diagonal(&mut self, diagonal: &V);
|
||||
}
|
||||
|
||||
/// The shape of an indexable object.
|
||||
|
|
|
@ -49,7 +49,7 @@ macro_rules! test_cholesky_impl(
|
|||
|
||||
// construct symmetric positive definite matrix
|
||||
let mut randmatrix : $t = random();
|
||||
let mut diagmatrix : $t = Diagonal::from_diag(&na::diagonal(&randmatrix));
|
||||
let mut diagmatrix : $t = Diagonal::from_diagonal(&na::diagonal(&randmatrix));
|
||||
|
||||
diagmatrix = na::abs(&diagmatrix) + 1.0;
|
||||
randmatrix = randmatrix * diagmatrix * na::transpose(&randmatrix);
|
||||
|
@ -98,7 +98,7 @@ macro_rules! test_eigen_qr_impl(
|
|||
let randmatrix = na::transpose(&randmatrix) * randmatrix;
|
||||
let (eigenvectors, eigenvalues) = na::eigen_qr(&randmatrix, &1e-13, 100);
|
||||
|
||||
let diagonal: $t = Diagonal::from_diag(&eigenvalues);
|
||||
let diagonal: $t = Diagonal::from_diagonal(&eigenvalues);
|
||||
let recomp = eigenvectors * diagonal * na::transpose(&eigenvectors);
|
||||
println!("eigenvalues: {:?}", eigenvalues);
|
||||
println!(" matrix: {:?}", randmatrix);
|
||||
|
@ -110,10 +110,10 @@ macro_rules! test_eigen_qr_impl(
|
|||
for _ in 0usize .. 10000 {
|
||||
let randmatrix : $t = random();
|
||||
// Take only diagonal part
|
||||
let randmatrix: $t = Diagonal::from_diag(&randmatrix.diagonal());
|
||||
let randmatrix: $t = Diagonal::from_diagonal(&randmatrix.diagonal());
|
||||
let (eigenvectors, eigenvalues) = na::eigen_qr(&randmatrix, &1e-13, 100);
|
||||
|
||||
let diagonal: $t = Diagonal::from_diag(&eigenvalues);
|
||||
let diagonal: $t = Diagonal::from_diagonal(&eigenvalues);
|
||||
let recomp = eigenvectors * diagonal * na::transpose(&eigenvectors);
|
||||
println!("eigenvalues: {:?}", eigenvalues);
|
||||
println!(" matrix: {:?}", randmatrix);
|
||||
|
|
Loading…
Reference in New Issue