Skip to content

Commit 1733256

Browse files
committed
---
yaml --- r: 151599 b: refs/heads/try2 c: 5ad42b3 h: refs/heads/master i: 151597: efae1dc 151595: da19560 151591: 1a28edb 151583: 35a10d1 v: v3
1 parent 3958601 commit 1733256

File tree

9 files changed

+387
-418
lines changed

9 files changed

+387
-418
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 1ca6b2cc664610dbbe9de07864d2016ead422460
8+
refs/heads/try2: 5ad42b3ae97fd363b1a13c43305995fe139fc8ef
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libnum/complex.rs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ use std::num::{Zero,One,ToStrRadix};
2323

2424
/// A complex number in Cartesian form.
2525
#[deriving(Eq,Clone)]
26-
pub struct Cmplx<T> {
26+
pub struct Complex<T> {
2727
/// Real portion of the complex number
2828
pub re: T,
2929
/// Imaginary portion of the complex number
3030
pub im: T
3131
}
3232

33-
pub type Complex32 = Cmplx<f32>;
34-
pub type Complex64 = Cmplx<f64>;
33+
pub type Complex32 = Complex<f32>;
34+
pub type Complex64 = Complex<f64>;
3535

36-
impl<T: Clone + Num> Cmplx<T> {
37-
/// Create a new Cmplx
36+
impl<T: Clone + Num> Complex<T> {
37+
/// Create a new Complex
3838
#[inline]
39-
pub fn new(re: T, im: T) -> Cmplx<T> {
40-
Cmplx { re: re, im: im }
39+
pub fn new(re: T, im: T) -> Complex<T> {
40+
Complex { re: re, im: im }
4141
}
4242

4343
/**
@@ -52,41 +52,41 @@ impl<T: Clone + Num> Cmplx<T> {
5252

5353
/// Returns the complex conjugate. i.e. `re - i im`
5454
#[inline]
55-
pub fn conj(&self) -> Cmplx<T> {
56-
Cmplx::new(self.re.clone(), -self.im)
55+
pub fn conj(&self) -> Complex<T> {
56+
Complex::new(self.re.clone(), -self.im)
5757
}
5858

5959

6060
/// Multiplies `self` by the scalar `t`.
6161
#[inline]
62-
pub fn scale(&self, t: T) -> Cmplx<T> {
63-
Cmplx::new(self.re * t, self.im * t)
62+
pub fn scale(&self, t: T) -> Complex<T> {
63+
Complex::new(self.re * t, self.im * t)
6464
}
6565

6666
/// Divides `self` by the scalar `t`.
6767
#[inline]
68-
pub fn unscale(&self, t: T) -> Cmplx<T> {
69-
Cmplx::new(self.re / t, self.im / t)
68+
pub fn unscale(&self, t: T) -> Complex<T> {
69+
Complex::new(self.re / t, self.im / t)
7070
}
7171

7272
/// Returns `1/self`
7373
#[inline]
74-
pub fn inv(&self) -> Cmplx<T> {
74+
pub fn inv(&self) -> Complex<T> {
7575
let norm_sqr = self.norm_sqr();
76-
Cmplx::new(self.re / norm_sqr,
76+
Complex::new(self.re / norm_sqr,
7777
-self.im / norm_sqr)
7878
}
7979
}
8080

81-
impl<T: Clone + Float> Cmplx<T> {
81+
impl<T: Clone + Float> Complex<T> {
8282
/// Calculate |self|
8383
#[inline]
8484
pub fn norm(&self) -> T {
8585
self.re.hypot(self.im)
8686
}
8787
}
8888

89-
impl<T: Clone + Float> Cmplx<T> {
89+
impl<T: Clone + Float> Complex<T> {
9090
/// Calculate the principal Arg of self.
9191
#[inline]
9292
pub fn arg(&self) -> T {
@@ -100,58 +100,58 @@ impl<T: Clone + Float> Cmplx<T> {
100100
}
101101
/// Convert a polar representation into a complex number.
102102
#[inline]
103-
pub fn from_polar(r: &T, theta: &T) -> Cmplx<T> {
104-
Cmplx::new(*r * theta.cos(), *r * theta.sin())
103+
pub fn from_polar(r: &T, theta: &T) -> Complex<T> {
104+
Complex::new(*r * theta.cos(), *r * theta.sin())
105105
}
106106
}
107107

108108
/* arithmetic */
109109
// (a + i b) + (c + i d) == (a + c) + i (b + d)
110-
impl<T: Clone + Num> Add<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
110+
impl<T: Clone + Num> Add<Complex<T>, Complex<T>> for Complex<T> {
111111
#[inline]
112-
fn add(&self, other: &Cmplx<T>) -> Cmplx<T> {
113-
Cmplx::new(self.re + other.re, self.im + other.im)
112+
fn add(&self, other: &Complex<T>) -> Complex<T> {
113+
Complex::new(self.re + other.re, self.im + other.im)
114114
}
115115
}
116116
// (a + i b) - (c + i d) == (a - c) + i (b - d)
117-
impl<T: Clone + Num> Sub<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
117+
impl<T: Clone + Num> Sub<Complex<T>, Complex<T>> for Complex<T> {
118118
#[inline]
119-
fn sub(&self, other: &Cmplx<T>) -> Cmplx<T> {
120-
Cmplx::new(self.re - other.re, self.im - other.im)
119+
fn sub(&self, other: &Complex<T>) -> Complex<T> {
120+
Complex::new(self.re - other.re, self.im - other.im)
121121
}
122122
}
123123
// (a + i b) * (c + i d) == (a*c - b*d) + i (a*d + b*c)
124-
impl<T: Clone + Num> Mul<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
124+
impl<T: Clone + Num> Mul<Complex<T>, Complex<T>> for Complex<T> {
125125
#[inline]
126-
fn mul(&self, other: &Cmplx<T>) -> Cmplx<T> {
127-
Cmplx::new(self.re*other.re - self.im*other.im,
126+
fn mul(&self, other: &Complex<T>) -> Complex<T> {
127+
Complex::new(self.re*other.re - self.im*other.im,
128128
self.re*other.im + self.im*other.re)
129129
}
130130
}
131131

132132
// (a + i b) / (c + i d) == [(a + i b) * (c - i d)] / (c*c + d*d)
133133
// == [(a*c + b*d) / (c*c + d*d)] + i [(b*c - a*d) / (c*c + d*d)]
134-
impl<T: Clone + Num> Div<Cmplx<T>, Cmplx<T>> for Cmplx<T> {
134+
impl<T: Clone + Num> Div<Complex<T>, Complex<T>> for Complex<T> {
135135
#[inline]
136-
fn div(&self, other: &Cmplx<T>) -> Cmplx<T> {
136+
fn div(&self, other: &Complex<T>) -> Complex<T> {
137137
let norm_sqr = other.norm_sqr();
138-
Cmplx::new((self.re*other.re + self.im*other.im) / norm_sqr,
138+
Complex::new((self.re*other.re + self.im*other.im) / norm_sqr,
139139
(self.im*other.re - self.re*other.im) / norm_sqr)
140140
}
141141
}
142142

143-
impl<T: Clone + Num> Neg<Cmplx<T>> for Cmplx<T> {
143+
impl<T: Clone + Num> Neg<Complex<T>> for Complex<T> {
144144
#[inline]
145-
fn neg(&self) -> Cmplx<T> {
146-
Cmplx::new(-self.re, -self.im)
145+
fn neg(&self) -> Complex<T> {
146+
Complex::new(-self.re, -self.im)
147147
}
148148
}
149149

150150
/* constants */
151-
impl<T: Clone + Num> Zero for Cmplx<T> {
151+
impl<T: Clone + Num> Zero for Complex<T> {
152152
#[inline]
153-
fn zero() -> Cmplx<T> {
154-
Cmplx::new(Zero::zero(), Zero::zero())
153+
fn zero() -> Complex<T> {
154+
Complex::new(Zero::zero(), Zero::zero())
155155
}
156156

157157
#[inline]
@@ -160,15 +160,15 @@ impl<T: Clone + Num> Zero for Cmplx<T> {
160160
}
161161
}
162162

163-
impl<T: Clone + Num> One for Cmplx<T> {
163+
impl<T: Clone + Num> One for Complex<T> {
164164
#[inline]
165-
fn one() -> Cmplx<T> {
166-
Cmplx::new(One::one(), Zero::zero())
165+
fn one() -> Complex<T> {
166+
Complex::new(One::one(), Zero::zero())
167167
}
168168
}
169169

170170
/* string conversions */
171-
impl<T: fmt::Show + Num + Ord> fmt::Show for Cmplx<T> {
171+
impl<T: fmt::Show + Num + Ord> fmt::Show for Complex<T> {
172172
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
173173
if self.im < Zero::zero() {
174174
write!(f.buf, "{}-{}i", self.re, -self.im)
@@ -178,7 +178,7 @@ impl<T: fmt::Show + Num + Ord> fmt::Show for Cmplx<T> {
178178
}
179179
}
180180

181-
impl<T: ToStrRadix + Num + Ord> ToStrRadix for Cmplx<T> {
181+
impl<T: ToStrRadix + Num + Ord> ToStrRadix for Complex<T> {
182182
fn to_str_radix(&self, radix: uint) -> ~str {
183183
if self.im < Zero::zero() {
184184
format!("{}-{}i", self.re.to_str_radix(radix), (-self.im).to_str_radix(radix))
@@ -192,22 +192,22 @@ impl<T: ToStrRadix + Num + Ord> ToStrRadix for Cmplx<T> {
192192
mod test {
193193
#![allow(non_uppercase_statics)]
194194

195-
use super::{Complex64, Cmplx};
195+
use super::{Complex64, Complex};
196196
use std::num::{Zero,One,Float};
197197

198-
pub static _0_0i : Complex64 = Cmplx { re: 0.0, im: 0.0 };
199-
pub static _1_0i : Complex64 = Cmplx { re: 1.0, im: 0.0 };
200-
pub static _1_1i : Complex64 = Cmplx { re: 1.0, im: 1.0 };
201-
pub static _0_1i : Complex64 = Cmplx { re: 0.0, im: 1.0 };
202-
pub static _neg1_1i : Complex64 = Cmplx { re: -1.0, im: 1.0 };
203-
pub static _05_05i : Complex64 = Cmplx { re: 0.5, im: 0.5 };
198+
pub static _0_0i : Complex64 = Complex { re: 0.0, im: 0.0 };
199+
pub static _1_0i : Complex64 = Complex { re: 1.0, im: 0.0 };
200+
pub static _1_1i : Complex64 = Complex { re: 1.0, im: 1.0 };
201+
pub static _0_1i : Complex64 = Complex { re: 0.0, im: 1.0 };
202+
pub static _neg1_1i : Complex64 = Complex { re: -1.0, im: 1.0 };
203+
pub static _05_05i : Complex64 = Complex { re: 0.5, im: 0.5 };
204204
pub static all_consts : [Complex64, .. 5] = [_0_0i, _1_0i, _1_1i, _neg1_1i, _05_05i];
205205

206206
#[test]
207207
fn test_consts() {
208-
// check our constants are what Cmplx::new creates
208+
// check our constants are what Complex::new creates
209209
fn test(c : Complex64, r : f64, i: f64) {
210-
assert_eq!(c, Cmplx::new(r,i));
210+
assert_eq!(c, Complex::new(r,i));
211211
}
212212
test(_0_0i, 0.0, 0.0);
213213
test(_1_0i, 1.0, 0.0);
@@ -246,7 +246,7 @@ mod test {
246246
#[test]
247247
fn test_conj() {
248248
for &c in all_consts.iter() {
249-
assert_eq!(c.conj(), Cmplx::new(c.re, -c.im));
249+
assert_eq!(c.conj(), Complex::new(c.re, -c.im));
250250
assert_eq!(c.conj().conj(), c);
251251
}
252252
}
@@ -280,7 +280,7 @@ mod test {
280280
fn test_polar_conv() {
281281
fn test(c: Complex64) {
282282
let (r, theta) = c.to_polar();
283-
assert!((c - Cmplx::from_polar(&r, &theta)).norm() < 1e-6);
283+
assert!((c - Complex::from_polar(&r, &theta)).norm() < 1e-6);
284284
}
285285
for &c in all_consts.iter() { test(c); }
286286
}

branches/try2/src/librustc/middle/borrowck/mod.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,9 @@ pub mod gather_loans;
4949

5050
pub mod move_data;
5151

52+
#[deriving(Clone)]
5253
pub struct LoanDataFlowOperator;
5354

54-
/// FIXME(pcwalton): Should just be #[deriving(Clone)], but that doesn't work
55-
/// yet on unit structs.
56-
impl Clone for LoanDataFlowOperator {
57-
fn clone(&self) -> LoanDataFlowOperator {
58-
LoanDataFlowOperator
59-
}
60-
}
61-
6255
pub type LoanDataFlow<'a> = DataFlowContext<'a, LoanDataFlowOperator>;
6356

6457
impl<'a> Visitor<()> for BorrowckCtxt<'a> {

branches/try2/src/librustc/middle/borrowck/move_data.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -147,28 +147,14 @@ pub struct Assignment {
147147
pub span: Span,
148148
}
149149

150+
#[deriving(Clone)]
150151
pub struct MoveDataFlowOperator;
151152

152-
/// FIXME(pcwalton): Should just be #[deriving(Clone)], but that doesn't work
153-
/// yet on unit structs.
154-
impl Clone for MoveDataFlowOperator {
155-
fn clone(&self) -> MoveDataFlowOperator {
156-
MoveDataFlowOperator
157-
}
158-
}
159-
160153
pub type MoveDataFlow<'a> = DataFlowContext<'a, MoveDataFlowOperator>;
161154

155+
#[deriving(Clone)]
162156
pub struct AssignDataFlowOperator;
163157

164-
/// FIXME(pcwalton): Should just be #[deriving(Clone)], but that doesn't work
165-
/// yet on unit structs.
166-
impl Clone for AssignDataFlowOperator {
167-
fn clone(&self) -> AssignDataFlowOperator {
168-
AssignDataFlowOperator
169-
}
170-
}
171-
172158
pub type AssignDataFlow<'a> = DataFlowContext<'a, AssignDataFlowOperator>;
173159

174160
impl MoveData {

0 commit comments

Comments
 (0)