Skip to content

Commit d285bd6

Browse files
committed
Use Ix1/Ix2 instead of Ix #15
1 parent bda6dde commit d285bd6

File tree

8 files changed

+13
-17
lines changed

8 files changed

+13
-17
lines changed

src/hermite.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Define trait for Hermite matrices
22
3-
use ndarray::prelude::*;
4-
use ndarray::LinalgScalar;
3+
use ndarray::{Ix2, Array, LinalgScalar};
54
use num_traits::float::Float;
65

76
use matrix::Matrix;
@@ -21,7 +20,7 @@ pub trait HermiteMatrix: SquareMatrix + Matrix {
2120
fn ssqrt(self) -> Result<Self, LinalgError>;
2221
}
2322

24-
impl<A> HermiteMatrix for Array<A, (Ix, Ix)>
23+
impl<A> HermiteMatrix for Array<A, Ix2>
2524
where A: ImplQR + ImplSVD + ImplNorm + ImplSolve + ImplEigh + LinalgScalar + Float
2625
{
2726
fn eigh(self) -> Result<(Self::Vector, Self), LinalgError> {

src/matrix.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Define trait for general matrix
22
33
use std::cmp::min;
4-
use ndarray::prelude::*;
5-
use ndarray::LinalgScalar;
4+
use ndarray::{Ix1, Ix2, Array, Axis, LinalgScalar};
65

76
use error::LapackError;
87
use qr::ImplQR;
@@ -27,11 +26,11 @@ pub trait Matrix: Sized {
2726
fn qr(self) -> Result<(Self, Self), LapackError>;
2827
}
2928

30-
impl<A> Matrix for Array<A, (Ix, Ix)>
29+
impl<A> Matrix for Array<A, Ix2>
3130
where A: ImplQR + ImplSVD + ImplNorm + LinalgScalar
3231
{
3332
type Scalar = A;
34-
type Vector = Array<A, Ix>;
33+
type Vector = Array<A, Ix1>;
3534
fn size(&self) -> (usize, usize) {
3635
(self.rows(), self.cols())
3736
}

src/square.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Define trait for Hermite matrices
22
3-
use ndarray::prelude::*;
4-
use ndarray::LinalgScalar;
3+
use ndarray::{Ix2, Array, LinalgScalar};
54
use num_traits::float::Float;
65

76
use matrix::Matrix;
@@ -37,7 +36,7 @@ pub trait SquareMatrix: Matrix {
3736
}
3837
}
3938

40-
impl<A> SquareMatrix for Array<A, (Ix, Ix)>
39+
impl<A> SquareMatrix for Array<A, Ix2>
4140
where A: ImplQR + ImplNorm + ImplSVD + ImplSolve + LinalgScalar + Float
4241
{
4342
fn inv(self) -> Result<Self, LinalgError> {

src/vector.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Define trait for vectors
22
3-
use ndarray::prelude::*;
4-
use ndarray::LinalgScalar;
3+
use ndarray::{LinalgScalar, Array, Ix1};
54
use num_traits::float::Float;
65

76
/// Methods for vectors
@@ -11,7 +10,7 @@ pub trait Vector {
1110
fn norm(&self) -> Self::Scalar;
1211
}
1312

14-
impl<A: Float + LinalgScalar> Vector for Array<A, Ix> {
13+
impl<A: Float + LinalgScalar> Vector for Array<A, Ix1> {
1514
type Scalar = A;
1615
fn norm(&self) -> Self::Scalar {
1716
self.dot(&self).sqrt()

tests/inv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use ndarray_linalg::prelude::*;
99
use rand::distributions::*;
1010
use ndarray_rand::RandomExt;
1111

12-
fn all_close(a: Array<f64, (Ix, Ix)>, b: Array<f64, (Ix, Ix)>) {
12+
fn all_close(a: Array<f64, Ix2>, b: Array<f64, Ix2>) {
1313
if !a.all_close(&b, 1.0e-7) {
1414
panic!("\nTwo matrices are not equal:\na = \n{:?}\nb = \n{:?}\n",
1515
a,

tests/qr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use ndarray_linalg::prelude::*;
99
use rand::distributions::*;
1010
use ndarray_rand::RandomExt;
1111

12-
fn all_close(a: Array<f64, (Ix, Ix)>, b: Array<f64, (Ix, Ix)>) {
12+
fn all_close(a: Array<f64, Ix2>, b: Array<f64, Ix2>) {
1313
if !a.all_close(&b, 1.0e-7) {
1414
panic!("\nTwo matrices are not equal:\na = \n{:?}\nb = \n{:?}\n",
1515
a,

tests/ssqrt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use ndarray::prelude::*;
99
use ndarray_linalg::prelude::*;
1010
use ndarray_rand::RandomExt;
1111

12-
fn all_close(a: &Array<f64, (Ix, Ix)>, b: &Array<f64, (Ix, Ix)>) {
12+
fn all_close(a: &Array<f64, Ix2>, b: &Array<f64, Ix2>) {
1313
if !a.all_close(b, 1.0e-7) {
1414
panic!("\nTwo matrices are not equal:\na = \n{:?}\nb = \n{:?}\n",
1515
a,

tests/svd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use ndarray_linalg::prelude::*;
1010
use rand::distributions::*;
1111
use ndarray_rand::RandomExt;
1212

13-
fn all_close(a: Array<f64, (Ix, Ix)>, b: Array<f64, (Ix, Ix)>) {
13+
fn all_close(a: Array<f64, Ix2>, b: Array<f64, Ix2>) {
1414
if !a.all_close(&b, 1.0e-7) {
1515
panic!("\nTwo matrices are not equal:\na = \n{:?}\nb = \n{:?}\n",
1616
a,

0 commit comments

Comments
 (0)