Initial commit

This commit is contained in:
Quaternions 2024-08-23 13:00:22 -07:00
commit 713b68adef
8 changed files with 205 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

77
Cargo.lock generated Normal file
View File

@ -0,0 +1,77 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "az"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973"
[[package]]
name = "bnum"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790"
[[package]]
name = "bytemuck"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fd4c6dcc3b0aea2f5c0b4b82c2b15fe39ddbc76041a310848f4706edf76bb31"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "fixed"
version = "1.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85c6e0b89bf864acd20590dbdbad56f69aeb898abfc9443008fd7bd48b2cc85a"
dependencies = [
"az",
"bytemuck",
"half",
"typenum",
]
[[package]]
name = "fixed_linear_algebra"
version = "0.1.0"
dependencies = [
"fixed",
"fixed_wide",
]
[[package]]
name = "fixed_wide"
version = "0.1.0"
dependencies = [
"bnum",
"fixed",
]
[[package]]
name = "half"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
dependencies = [
"cfg-if",
"crunchy",
]
[[package]]
name = "typenum"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"

8
Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "fixed_linear_algebra"
version = "0.1.0"
edition = "2021"
[dependencies]
fixed = "1.28.0"
fixed_wide = { version = "0.1.0", path = "fixed_wide" }

69
fixed_wide/Cargo.lock generated Normal file
View File

@ -0,0 +1,69 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "az"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973"
[[package]]
name = "bnum"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790"
[[package]]
name = "bytemuck"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fd4c6dcc3b0aea2f5c0b4b82c2b15fe39ddbc76041a310848f4706edf76bb31"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "fixed"
version = "1.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85c6e0b89bf864acd20590dbdbad56f69aeb898abfc9443008fd7bd48b2cc85a"
dependencies = [
"az",
"bytemuck",
"half",
"typenum",
]
[[package]]
name = "fixed_wide"
version = "0.1.0"
dependencies = [
"bnum",
"fixed",
]
[[package]]
name = "half"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
dependencies = [
"cfg-if",
"crunchy",
]
[[package]]
name = "typenum"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"

8
fixed_wide/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "fixed_wide"
version = "0.1.0"
edition = "2021"
[dependencies]
bnum = "0.11.0"
fixed = "1.28.0"

1
fixed_wide/src/lib.rs Normal file
View File

@ -0,0 +1 @@
pub mod wide;

4
fixed_wide/src/wide.rs Normal file
View File

@ -0,0 +1,4 @@
pub struct Fixed<I,Frac>{
bits:I,
phantom:std::marker::PhantomData<Frac>,
}

37
src/lib.rs Normal file
View File

@ -0,0 +1,37 @@
use bnum::cast::As;
type Planar64=fixed::types::I32F32;
type Planar64Wide1=fixed::types::I64F64;
type Planar64Wide2=bnum::types::I256;
type Planar64Wide3=bnum::types::I512;
//wouldn't that be nice
//type Planar64Wide2=fixed::FixedI256<fixed::types::extra::U128>;
//type Planar64Wide3=fixed::FixedI512<fixed::types::extra::U256>;
pub fn wide_mul(left: Planar64, right: Planar64) -> Planar64Wide1 {
left.wide_mul(right)
}
pub fn wide_mul_2(left: Planar64Wide1, right: Planar64Wide1) -> Planar64Wide2 {
Planar64Wide2::from(left.to_bits())*Planar64Wide2::from(right.to_bits())
}
pub fn wide_mul_3(left: Planar64Wide2, right: Planar64Wide2) -> Planar64Wide3 {
left.as_::<Planar64Wide3>()*right.as_::<Planar64Wide3>()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2.into(), 2.into());
assert_eq!(result, 4);
}
#[test]
pub fn main(){
let a=6f128;
let max=i32::MAX as i64;
println!("{} {}",max*max,i64::MAX);
}
}