Skip to content

Commit 1e75543

Browse files
committed
Implement Vector for RcArray<NdFloat, Ix1>
1 parent e5c2586 commit 1e75543

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/vector.rs

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

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

13-
impl<A: Float + LinalgScalar> Vector for Array<A, Ix1> {
12+
impl<A: NdFloat> Vector for Array<A, Ix1> {
13+
type Scalar = A;
14+
fn norm(&self) -> Self::Scalar {
15+
self.dot(&self).sqrt()
16+
}
17+
}
18+
19+
impl<A: NdFloat> Vector for RcArray<A, Ix1> {
1420
type Scalar = A;
1521
fn norm(&self) -> Self::Scalar {
1622
self.dot(&self).sqrt()

0 commit comments

Comments
 (0)