Skip to content

Commit 63293af

Browse files
committed
Implement negation trait for Array
1 parent bcd9909 commit 63293af

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/arith/mod.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ use array::Array;
66
use defines::AfError;
77
use error::HANDLE_ERROR;
88
use self::libc::{c_int};
9-
use data::{constant, tile};
9+
use data::{constant, constant_like, tile};
1010
use self::num::Complex;
1111

12+
use std::ops::Neg;
13+
1214
type MutAfArray = *mut self::libc::c_longlong;
1315
type MutDouble = *mut self::libc::c_double;
1416
type MutUint = *mut self::libc::c_uint;
@@ -485,3 +487,12 @@ bit_assign_func!(BitOrAssign, bitor_assign, bitor);
485487
bit_assign_func!(BitXorAssign, bitxor_assign, bitxor);
486488

487489
}
490+
491+
///Implement negation trait for Array
492+
impl Neg for Array {
493+
type Output = Array;
494+
495+
fn neg(self) -> Self::Output {
496+
constant_like(0.0, &self) - self
497+
}
498+
}

0 commit comments

Comments
 (0)