We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e5c2586 commit 1e75543Copy full SHA for 1e75543
src/vector.rs
@@ -1,7 +1,6 @@
1
//! Define trait for vectors
2
3
-use ndarray::{LinalgScalar, Array, Ix1};
4
-use num_traits::float::Float;
+use ndarray::{NdFloat, Array, RcArray, Ix1};
5
6
/// Methods for vectors
7
pub trait Vector {
@@ -10,7 +9,14 @@ pub trait Vector {
10
9
fn norm(&self) -> Self::Scalar;
11
}
12
13
-impl<A: Float + LinalgScalar> Vector for Array<A, Ix1> {
+impl<A: NdFloat> Vector for Array<A, Ix1> {
+ 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> {
20
type Scalar = A;
21
fn norm(&self) -> Self::Scalar {
22
self.dot(&self).sqrt()
0 commit comments