use patch for num-complex & refactor
This commit is contained in:
parent
f66b690fe8
commit
525bc63de2
12
Cargo.toml
12
Cargo.toml
|
@ -52,8 +52,8 @@ convert-glam020 = [ "glam020" ]
|
|||
## `serde-serialize`.
|
||||
serde-serialize-no-std = [ "serde", "num-complex/serde" ]
|
||||
serde-serialize = [ "serde-serialize-no-std", "serde/std" ]
|
||||
rkyv-serialize-no-std = [ "rkyv", "rkyv_wrappers" ]
|
||||
rkyv-serialize = [ "rkyv-serialize-no-std", "rkyv/std", "rkyv/validation", "bytecheck" ]
|
||||
rkyv-serialize-no-std = [ "rkyv", "rkyv_wrappers", "num-complex/rkyv" ]
|
||||
rkyv-serialize = [ "rkyv-serialize-no-std", "rkyv/std", "rkyv/validation", "bytecheck", "num-complex/bytecheck" ]
|
||||
|
||||
# Randomness
|
||||
## To use rand in a #[no-std] environment, enable the
|
||||
|
@ -71,15 +71,15 @@ nalgebra-macros = { version = "0.1", path = "nalgebra-macros", optional = true }
|
|||
typenum = "1.12"
|
||||
rand-package = { package = "rand", version = "0.8", optional = true, default-features = false }
|
||||
num-traits = { version = "0.2", default-features = false }
|
||||
num-complex = { version = "0.4", git = "https://github.com/zyansheep/num-complex", default-features = false } # { version = "0.4", default-features = false }
|
||||
num-complex = { version = "0.4", default-features = false }
|
||||
num-rational = { version = "0.4", default-features = false }
|
||||
approx = { version = "0.5", default-features = false }
|
||||
simba = { version = "0.7.0", default-features = false }
|
||||
simba = { version = "0.7", default-features = false }
|
||||
alga = { version = "0.9", default-features = false, optional = true }
|
||||
rand_distr = { version = "0.4", default-features = false, optional = true }
|
||||
matrixmultiply = { version = "0.3", optional = true }
|
||||
serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true }
|
||||
rkyv = { version = "0.7", optional = true }
|
||||
rkyv = { version = "0.7", default-features = false, optional = true }
|
||||
rkyv_wrappers = { git = "https://github.com/rkyv/rkyv_contrib", optional = true }
|
||||
bytecheck = { version = "~0.6.1", optional = true }
|
||||
mint = { version = "0.5", optional = true }
|
||||
|
@ -134,3 +134,5 @@ lto = true
|
|||
# Enable certain features when building docs for docs.rs
|
||||
features = [ "proptest-support", "compare", "macros", "rand" ]
|
||||
|
||||
[patch.crates-io]
|
||||
num-complex = { git = "https://github.com/zyansheep/num-complex" }
|
|
@ -27,6 +27,7 @@ use std::mem;
|
|||
/// A array-based statically sized matrix data storage.
|
||||
#[repr(transparent)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
|
@ -38,7 +39,6 @@ use std::mem;
|
|||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]);
|
||||
|
||||
|
|
|
@ -13,11 +13,6 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|||
|
||||
/// Dim of dynamically-sized algebraic entities.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct Dynamic {
|
||||
value: usize,
|
||||
|
@ -203,11 +198,6 @@ dim_ops!(
|
|||
);
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct Const<const R: usize>;
|
||||
|
||||
|
|
|
@ -155,6 +155,7 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
|
|||
/// some concrete types for `T` and a compatible data storage type `S`).
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
|
@ -167,7 +168,6 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
|
|||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct Matrix<T, R, C, S> {
|
||||
/// The data storage that contains all the matrix components. Disappointed?
|
||||
|
|
|
@ -21,6 +21,7 @@ use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealF
|
|||
/// in their documentation, read their dedicated pages directly.
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Hash, Copy)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
|
@ -31,7 +32,6 @@ use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealF
|
|||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
// #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct Unit<T> {
|
||||
pub(crate) value: T,
|
||||
|
|
|
@ -66,6 +66,7 @@ use crate::geometry::{AbstractRotation, Point, Translation};
|
|||
Owned<T, Const<D>>: Deserialize<'de>,
|
||||
T: Scalar"))
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
|
@ -78,7 +79,6 @@ use crate::geometry::{AbstractRotation, Point, Translation};
|
|||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
pub struct Isometry<T, R, const D: usize> {
|
||||
/// The pure rotational part of this isometry.
|
||||
pub rotation: R,
|
||||
|
|
|
@ -36,11 +36,20 @@ use std::mem::MaybeUninit;
|
|||
/// of said transformations for details.
|
||||
#[repr(C)]
|
||||
#[derive(Clone)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
archive(
|
||||
as = "OPoint<T::Archived, D>",
|
||||
bound(archive = "
|
||||
T: rkyv::Archive,
|
||||
T::Archived: Scalar,
|
||||
OVector<T, D>: rkyv::Archive<Archived = OVector<T::Archived, D>>,
|
||||
DefaultAllocator: Allocator<T::Archived, D>,
|
||||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
pub struct OPoint<T: Scalar, D: DimName>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D>,
|
||||
|
|
|
@ -34,6 +34,7 @@ use crate::geometry::{AbstractRotation, Isometry, Point, Translation};
|
|||
DefaultAllocator: Allocator<T, Const<D>>,
|
||||
Owned<T, Const<D>>: Deserialize<'de>"))
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
|
@ -46,7 +47,6 @@ use crate::geometry::{AbstractRotation, Isometry, Point, Translation};
|
|||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
pub struct Similarity<T, R, const D: usize> {
|
||||
/// The part of this similarity that does not include the scaling factor.
|
||||
pub isometry: Isometry<T, R, D>,
|
||||
|
|
|
@ -8,7 +8,7 @@ use na::{
|
|||
use rand;
|
||||
use rkyv::{Archive, Deserialize, Infallible, Serialize};
|
||||
|
||||
macro_rules! test_rkyv_archived_impls(
|
||||
macro_rules! test_rkyv_same_type(
|
||||
($($test: ident, $ty: ident);* $(;)*) => {$(
|
||||
#[test]
|
||||
fn $test() {
|
||||
|
@ -16,44 +16,48 @@ macro_rules! test_rkyv_archived_impls(
|
|||
let bytes = rkyv::to_bytes::<_, 256>(&value).unwrap();
|
||||
|
||||
let archived = rkyv::check_archived_root::<$ty<f32>>(&bytes[..]).unwrap();
|
||||
// Compare archived and non-archived
|
||||
assert_eq!(archived, &value);
|
||||
|
||||
// Make sure Debug implementations are the same for Archived and non-Archived versions.
|
||||
assert_eq!(format!("{:?}", value), format!("{:?}", archived));
|
||||
}
|
||||
)*}
|
||||
);
|
||||
macro_rules! test_rkyv(
|
||||
macro_rules! test_rkyv_diff_type(
|
||||
($($test: ident, $ty: ident);* $(;)*) => {$(
|
||||
#[test]
|
||||
fn $test() {
|
||||
let value: $ty<f32> = rand::random();
|
||||
let value: $ty<String> = Default::default();
|
||||
let bytes = rkyv::to_bytes::<_, 256>(&value).unwrap();
|
||||
|
||||
let archived = rkyv::check_archived_root::<$ty<f32>>(&bytes[..]).unwrap();
|
||||
let deserialized: $ty<f32> = archived.deserialize(&mut Infallible).unwrap();
|
||||
let archived = rkyv::check_archived_root::<$ty<String>>(&bytes[..]).unwrap();
|
||||
let deserialized: $ty<String> = archived.deserialize(&mut Infallible).unwrap();
|
||||
assert_eq!(deserialized, value);
|
||||
}
|
||||
)*}
|
||||
);
|
||||
|
||||
test_rkyv_archived_impls!(
|
||||
rkyv_matrix3x4, Matrix3x4;
|
||||
// Tests to make sure
|
||||
test_rkyv_same_type!(
|
||||
rkyv_same_type_matrix3x4, Matrix3x4;
|
||||
rkyv_same_type_point3, Point3;
|
||||
rkyv_same_type_translation3, Translation3;
|
||||
rkyv_same_type_rotation3, Rotation3;
|
||||
rkyv_same_type_isometry3, Isometry3;
|
||||
rkyv_same_type_isometry_matrix3, IsometryMatrix3;
|
||||
rkyv_same_type_similarity3, Similarity3;
|
||||
rkyv_same_type_similarity_matrix3, SimilarityMatrix3;
|
||||
rkyv_same_type_quaternion, Quaternion;
|
||||
rkyv_same_type_point2, Point2;
|
||||
rkyv_same_type_translation2, Translation2;
|
||||
rkyv_same_type_rotation2, Rotation2;
|
||||
rkyv_same_type_isometry2, Isometry2;
|
||||
rkyv_same_type_isometry_matrix2, IsometryMatrix2;
|
||||
rkyv_same_type_similarity2, Similarity2;
|
||||
rkyv_same_type_similarity_matrix2, SimilarityMatrix2;
|
||||
);
|
||||
|
||||
test_rkyv!(
|
||||
// rkyv_point3, Point3;
|
||||
rkyv_translation3, Translation3;
|
||||
/* rkyv_rotation3, Rotation3;
|
||||
rkyv_isometry3, Isometry3;
|
||||
rkyv_isometry_matrix3, IsometryMatrix3;
|
||||
rkyv_similarity3, Similarity3;
|
||||
rkyv_similarity_matrix3, SimilarityMatrix3;
|
||||
rkyv_quaternion, Quaternion; */
|
||||
// rkyv_point2, Point2;
|
||||
rkyv_translation2, Translation2;
|
||||
/* rkyv_rotation2, Rotation2;
|
||||
rkyv_isometry2, Isometry2;
|
||||
rkyv_isometry_matrix2, IsometryMatrix2;
|
||||
rkyv_similarity2, Similarity2;
|
||||
rkyv_similarity_matrix2, SimilarityMatrix2; */
|
||||
);
|
||||
test_rkyv_diff_type! {
|
||||
rkyv_diff_type_matrix3x4, Matrix3x4;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue