Skip to content

Commit 8ffd77c

Browse files
authored
Merge pull request #16 from termoshtt/index_type
Use Ix1/Ix2 instead of Ix
2 parents 74d8c7d + 74496ae commit 8ffd77c

File tree

11 files changed

+17
-20
lines changed

11 files changed

+17
-20
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ lapack = "0.11.1"
1414
num-traits = "0.1.36"
1515

1616
[dependencies.ndarray]
17-
version = "0.6.9"
17+
version = "0.7"
1818
features = ["blas"]
1919

2020
[dev-dependencies]
2121
rand = "0.3.14"
22-
ndarray-rand = "0.2.0"
22+
ndarray-rand = "0.3"

src/hermite.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Define trait for Hermite matrices
22
3+
use ndarray::{Ix2, Array, LinalgScalar};
34
use std::fmt::Debug;
4-
use ndarray::prelude::*;
5-
use ndarray::LinalgScalar;
65
use num_traits::float::Float;
76
use lapack::c::Layout;
87

@@ -26,7 +25,7 @@ pub trait HermiteMatrix: SquareMatrix + Matrix {
2625
fn cholesky(self) -> Result<Self, LinalgError>;
2726
}
2827

29-
impl<A> HermiteMatrix for Array<A, (Ix, Ix)>
28+
impl<A> HermiteMatrix for Array<A, Ix2>
3029
where A: ImplQR + ImplSVD + ImplNorm + ImplSolve + ImplEigh + ImplCholesky + LinalgScalar + Float + Debug
3130
{
3231
fn eigh(self) -> Result<(Self::Vector, Self), LinalgError> {

src/matrix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ pub trait Matrix: Sized {
4242
}
4343
}
4444

45-
impl<A> Matrix for Array<A, (Ix, Ix)>
45+
impl<A> Matrix for Array<A, Ix2>
4646
where A: ImplQR + ImplSVD + ImplNorm + ImplSolve + LinalgScalar + Debug
4747
{
4848
type Scalar = A;
49-
type Vector = Array<A, Ix>;
49+
type Vector = Array<A, Ix1>;
5050
type Permutator = Vec<i32>;
5151

5252
fn size(&self) -> (usize, usize) {

src/square.rs

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

87
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 + Debug
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/cholesky.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/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/lu.rs

Lines changed: 2 additions & 2 deletions
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,
@@ -68,7 +68,7 @@ test_permutate_t!(permutate_4x3_t,
6868
&[[1., 4., 7., 10.], [2., 5., 8., 11.], [3., 6., 9., 12.]],
6969
&[[10., 11., 12.], [4., 5., 6.], [7., 8., 9.], [1., 2., 3.]]);
7070

71-
fn test_lu(a: Array<f64, (Ix, Ix)>) {
71+
fn test_lu(a: Array<f64, Ix2>) {
7272
println!("a = \n{:?}", &a);
7373
let (p, l, u) = a.clone().lu().unwrap();
7474
println!("P = \n{:?}", &p);

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,

0 commit comments

Comments
 (0)