Skip to content

Commit 752a215

Browse files
authored
Merge pull request #1 from Akari202/matrix
Merge matrix overhaul into main.
2 parents 0558bd8 + fa7592a commit 752a215

18 files changed

Lines changed: 1104 additions & 424 deletions

File tree

.github/workflows/rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v3
1919
- name: Build
20-
run: cargo build --verbose
20+
run: cargo build --verbose --all-features
2121
- name: Run tests
22-
run: cargo test --verbose
22+
run: cargo test --verbose --all-features

Cargo.lock

Lines changed: 38 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ https://www.cs.utexas.edu/~ear/cs341/automatabook/AutomataTheoryBook.pdf
2222
https://dl.acm.org/doi/pdf/10.1145/360825.360855
2323
https://docs.google.com/document/d/1KkKC2-ozJkvbWQIAXeJ1MUGqxjn19c-Mmc7RtxFTA3c/edit?tab=t.0
2424
https://ntrs.nasa.gov/api/citations/19900013774/downloads/19900013774.pdf
25+
26+
https://www.cs.unc.edu/techreports/96-043.pdf

update_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = "0.2.5"
1+
VERSION = "0.3.0"
22

33
locations = [
44
"./vec-utils/Cargo.toml",

vec-utils-py/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "vec-utils-py"
3-
version = "0.2.5"
3+
version = "0.3.0"
44
edition = "2024"
55
authors = ["Akari Harada <akaritwo0two@gmail.com>"]
66
license = "GPL-3"
@@ -17,4 +17,4 @@ pyo3 = { version = "0.27.2", features = [
1717
"generate-import-lib"
1818
] }
1919
rayon = "1.11.0"
20-
vec-utils = { path = "../vec-utils" }
20+
vec-utils = { path = "../vec-utils", features = ["matrix"] }

vec-utils-py/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "vec-utils-py"
3-
version = "0.2.5"
3+
version = "0.3.0"
44
requires-python = ">=3.9"
55
authors = [
66
{ name="Akari202", email="akaritwo0two@gmail.com" }

vec-utils-py/src/quat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl Quat {
104104
}
105105

106106
fn to_rotation_matrix(&self) -> [[f64; 3]; 3] {
107-
self.inner.to_rotation_matrix()
107+
self.inner.to_rotation_matrix().to_nested_arr()
108108
}
109109

110110
fn rotate(&self, v: &Vec3d) -> Vec3d {

vec-utils/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "vec-utils"
3-
version = "0.2.5"
3+
version = "0.3.0"
44
edition = "2024"
55
authors = ["Akari Harada <akaritwo0two@gmail.com>"]
66
license = "GPL-3"
@@ -10,6 +10,9 @@ name = "vec_utils"
1010

1111
[dependencies]
1212
libm = { version = "0.2.15" }
13+
matrixmultiply = { version = "0.3.10", default-features = false, features = [
14+
"cgemm"
15+
], optional = true }
1316
rkyv = { version = "0.8.12", default-features = false, features = ["bytecheck"], optional = true }
1417
serde = { version = "1.0.219", default-features = false, features = ["derive"], optional = true }
1518

@@ -19,6 +22,7 @@ pretty_assertions = "1.4.1"
1922

2023
[features]
2124
default = ["std"]
25+
matrix = ["dep:matrixmultiply"]
2226
rkyv = ["dep:rkyv"]
2327
serde = ["dep:serde"]
24-
std = ["rkyv?/std", "serde?/std"]
28+
std = ["matrixmultiply?/std", "rkyv?/std", "serde?/std"]

vec-utils/src/complex.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use core::cmp::Ordering;
12
use core::fmt;
23
use core::ops::{Add, Div, Index, Mul, Sub};
34

@@ -7,6 +8,7 @@ use crate::{
78
};
89

910
/// A complex number
11+
#[repr(C)]
1012
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
1113
#[cfg_attr(
1214
feature = "rkyv",
@@ -241,6 +243,42 @@ impl_single_op_variants_other!(
241243
"Divide a real number by a complex number"
242244
);
243245

246+
impl PartialOrd for Complex {
247+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
248+
let self_mag_sq = self.real * self.real + self.imaginary * self.imaginary;
249+
let other_mag_sq = other.real * other.real + other.imaginary * other.imaginary;
250+
251+
self_mag_sq.partial_cmp(&other_mag_sq)
252+
}
253+
}
254+
255+
impl PartialEq<f64> for Complex {
256+
fn eq(&self, other: &f64) -> bool {
257+
self.imaginary == 0.0 && self.real == *other
258+
}
259+
}
260+
261+
impl PartialOrd<f64> for Complex {
262+
fn partial_cmp(&self, other: &f64) -> Option<Ordering> {
263+
let self_mag_sq = self.real * self.real + self.imaginary * self.imaginary;
264+
let other_mag_sq = other * other;
265+
266+
self_mag_sq.partial_cmp(&other_mag_sq)
267+
}
268+
}
269+
270+
impl PartialEq<Complex> for f64 {
271+
fn eq(&self, other: &Complex) -> bool {
272+
other.eq(self)
273+
}
274+
}
275+
276+
impl PartialOrd<Complex> for f64 {
277+
fn partial_cmp(&self, other: &Complex) -> Option<Ordering> {
278+
other.partial_cmp(self).map(Ordering::reverse)
279+
}
280+
}
281+
244282
impl Index<usize> for Complex {
245283
type Output = f64;
246284

vec-utils/src/geometry.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//! Geometry module
2-
//! This module contains geometric shapes and operations on them.
3-
41
/// Circles
52
pub mod circle;
63
/// Intersections

0 commit comments

Comments
 (0)