Moar speed!

This commit is contained in:
2016-06-02 10:10:43 +02:00
parent c31fbc1a09
commit bbd2a2ecaf
4 changed files with 22 additions and 5 deletions

6
Cargo.lock generated
View File

@@ -4,6 +4,7 @@ version = "0.1.0"
dependencies = [
"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)",
"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)",
]
@@ -26,6 +27,11 @@ dependencies = [
"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]]
name = "libc"
version = "0.2.11"

View File

@@ -7,3 +7,4 @@ authors = ["logaritmisk <anders.e.olsson@gmail.com>"]
getopts = "0.2"
byteorder = "0.5"
pbr = "0.2.1"
lazy_static = "0.2.1"

1
src/.#main.rs Symbolic link
View File

@@ -0,0 +1 @@
olsson@ralph.local.68703

View File

@@ -1,6 +1,8 @@
extern crate getopts;
extern crate byteorder;
extern crate pbr;
#[macro_use]
extern crate lazy_static;
use std::env;
use std::fs;
@@ -158,14 +160,21 @@ fn series(m: i32, id: i32) -> f64 {
fn expm(p: f64, ak: f64) -> f64 {
const NTP : usize = 25;
let mut tp = vec![1f64; NTP];
let mut i : i32 = 0;
let mut p1 : f64 = p;
let mut pt : f64;
let mut r : f64 = 1.0;
for n in 1..NTP {
tp[n] = 2.0 * tp[n - 1];
lazy_static! {
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 {
@@ -173,13 +182,13 @@ fn expm(p: f64, ak: f64) -> f64 {
}
for n in 0..NTP {
if tp[n] > p {
if TP[n] > p {
i = n as i32;
break;
}
}
pt = tp[(i - 1) as usize];
pt = TP[(i - 1) as usize];
for _ in 1..i + 1 {
if p1 >= pt {