Moar speed!
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -4,6 +4,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pbr 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pbr 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -26,6 +27,11 @@ dependencies = [
|
|||||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
|
|||||||
@@ -7,3 +7,4 @@ authors = ["logaritmisk <anders.e.olsson@gmail.com>"]
|
|||||||
getopts = "0.2"
|
getopts = "0.2"
|
||||||
byteorder = "0.5"
|
byteorder = "0.5"
|
||||||
pbr = "0.2.1"
|
pbr = "0.2.1"
|
||||||
|
lazy_static = "0.2.1"
|
||||||
|
|||||||
1
src/.#main.rs
Symbolic link
1
src/.#main.rs
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
olsson@ralph.local.68703
|
||||||
19
src/main.rs
19
src/main.rs
@@ -1,6 +1,8 @@
|
|||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
extern crate pbr;
|
extern crate pbr;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
@@ -158,14 +160,21 @@ fn series(m: i32, id: i32) -> f64 {
|
|||||||
fn expm(p: f64, ak: f64) -> f64 {
|
fn expm(p: f64, ak: f64) -> f64 {
|
||||||
const NTP : usize = 25;
|
const NTP : usize = 25;
|
||||||
|
|
||||||
let mut tp = vec![1f64; NTP];
|
|
||||||
let mut i : i32 = 0;
|
let mut i : i32 = 0;
|
||||||
let mut p1 : f64 = p;
|
let mut p1 : f64 = p;
|
||||||
let mut pt : f64;
|
let mut pt : f64;
|
||||||
let mut r : f64 = 1.0;
|
let mut r : f64 = 1.0;
|
||||||
|
|
||||||
for n in 1..NTP {
|
lazy_static! {
|
||||||
tp[n] = 2.0 * tp[n - 1];
|
static ref TP : Vec<f64> = {
|
||||||
|
let mut v = vec![1f64; NTP];
|
||||||
|
|
||||||
|
for i in 1..NTP {
|
||||||
|
v[i] = 2.0 * v[i - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
v
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ak == 1.0 {
|
if ak == 1.0 {
|
||||||
@@ -173,13 +182,13 @@ fn expm(p: f64, ak: f64) -> f64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for n in 0..NTP {
|
for n in 0..NTP {
|
||||||
if tp[n] > p {
|
if TP[n] > p {
|
||||||
i = n as i32;
|
i = n as i32;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt = tp[(i - 1) as usize];
|
pt = TP[(i - 1) as usize];
|
||||||
|
|
||||||
for _ in 1..i + 1 {
|
for _ in 1..i + 1 {
|
||||||
if p1 >= pt {
|
if p1 >= pt {
|
||||||
|
|||||||
Reference in New Issue
Block a user