forked from M-Labs/nalgebra
Tests work!
This commit is contained in:
parent
c01d591478
commit
0687318c7a
@ -757,7 +757,6 @@ where
|
|||||||
SB: Storage<T, R2, C2>,
|
SB: Storage<T, R2, C2>,
|
||||||
SC: Storage<T, D3>,
|
SC: Storage<T, D3>,
|
||||||
ShapeConstraint: DimEq<D, R2> + AreMultipliable<R2, C2, D3, U1>,
|
ShapeConstraint: DimEq<D, R2> + AreMultipliable<R2, C2, D3, U1>,
|
||||||
// DefaultAllocator: Allocator<T, D>,
|
|
||||||
{
|
{
|
||||||
let dim1 = self.nrows();
|
let dim1 = self.nrows();
|
||||||
let (nrows2, ncols2) = a.shape();
|
let (nrows2, ncols2) = a.shape();
|
||||||
@ -920,7 +919,7 @@ where
|
|||||||
// matrixmultiply can be used only if the std feature is available.
|
// matrixmultiply can be used only if the std feature is available.
|
||||||
let nrows1 = self.nrows();
|
let nrows1 = self.nrows();
|
||||||
let (nrows2, ncols2) = a.shape();
|
let (nrows2, ncols2) = a.shape();
|
||||||
let (_, ncols3) = b.shape();
|
let (nrows3, ncols3) = b.shape();
|
||||||
|
|
||||||
// Threshold determined empirically.
|
// Threshold determined empirically.
|
||||||
const SMALL_DIM: usize = 5;
|
const SMALL_DIM: usize = 5;
|
||||||
@ -931,7 +930,7 @@ where
|
|||||||
&& ncols2 > SMALL_DIM
|
&& ncols2 > SMALL_DIM
|
||||||
{
|
{
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ncols1, nrows2,
|
ncols2, nrows3,
|
||||||
"gemm: dimensions mismatch for multiplication."
|
"gemm: dimensions mismatch for multiplication."
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -1553,12 +1552,10 @@ where
|
|||||||
/// let mid = DMatrix::from_row_slice(3, 3, &[0.1, 0.2, 0.3,
|
/// let mid = DMatrix::from_row_slice(3, 3, &[0.1, 0.2, 0.3,
|
||||||
/// 0.5, 0.6, 0.7,
|
/// 0.5, 0.6, 0.7,
|
||||||
/// 0.9, 1.0, 1.1]);
|
/// 0.9, 1.0, 1.1]);
|
||||||
/// // The random shows that values on the workspace do not
|
///
|
||||||
/// // matter as they will be overwritten.
|
|
||||||
/// let mut workspace = DVector::new_random(2);
|
|
||||||
/// let expected = &lhs * &mid * lhs.transpose() * 10.0 + &mat * 5.0;
|
/// let expected = &lhs * &mid * lhs.transpose() * 10.0 + &mat * 5.0;
|
||||||
///
|
///
|
||||||
/// mat.quadform_tr_with_workspace(&mut workspace, 10.0, &lhs, &mid, 5.0);
|
/// mat.quadform_tr(10.0, &lhs, &mid, 5.0);
|
||||||
/// assert_relative_eq!(mat, expected);
|
/// assert_relative_eq!(mat, expected);
|
||||||
pub fn quadform_tr<R3: Dim, C3: Dim, S3, D4: Dim, S4>(
|
pub fn quadform_tr<R3: Dim, C3: Dim, S3, D4: Dim, S4>(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -1603,12 +1600,10 @@ where
|
|||||||
/// let mid = DMatrix::from_row_slice(3, 3, &[0.1, 0.2, 0.3,
|
/// let mid = DMatrix::from_row_slice(3, 3, &[0.1, 0.2, 0.3,
|
||||||
/// 0.5, 0.6, 0.7,
|
/// 0.5, 0.6, 0.7,
|
||||||
/// 0.9, 1.0, 1.1]);
|
/// 0.9, 1.0, 1.1]);
|
||||||
/// // The random shows that values on the workspace do not
|
///
|
||||||
/// // matter as they will be overwritten.
|
|
||||||
/// let mut workspace = DVector::new_random(3);
|
|
||||||
/// let expected = rhs.transpose() * &mid * &rhs * 10.0 + &mat * 5.0;
|
/// let expected = rhs.transpose() * &mid * &rhs * 10.0 + &mat * 5.0;
|
||||||
///
|
///
|
||||||
/// mat.quadform(&mut workspace, 10.0, &mid, &rhs, 5.0);
|
/// mat.quadform(10.0, &mid, &rhs, 5.0);
|
||||||
/// assert_relative_eq!(mat, expected);
|
/// assert_relative_eq!(mat, expected);
|
||||||
pub fn quadform<D3: Dim, S3, R4: Dim, C4: Dim, S4>(
|
pub fn quadform<D3: Dim, S3, R4: Dim, C4: Dim, S4>(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -1622,9 +1617,9 @@ where
|
|||||||
ShapeConstraint: DimEq<R4, D3> + DimEq<D3, R4> + DimEq<D1, C4>,
|
ShapeConstraint: DimEq<R4, D3> + DimEq<D3, R4> + DimEq<D1, C4>,
|
||||||
DefaultAllocator: Allocator<T, D3>,
|
DefaultAllocator: Allocator<T, D3>,
|
||||||
{
|
{
|
||||||
// TODO: figure out why type inference wasn't doing its job.
|
// TODO: figure out why type inference isn't doing its job.
|
||||||
let mut work =
|
let mut work =
|
||||||
Matrix::new_uninitialized_generic(D3::from_usize(self.shape().0), Const::<1>);
|
Matrix::new_uninitialized_generic(D3::from_usize(mid.shape().0), Const::<1>);
|
||||||
work.gemv_z::<D3, D3, R4, S3, _>(T::one(), mid, &rhs.column(0));
|
work.gemv_z::<D3, D3, R4, S3, _>(T::one(), mid, &rhs.column(0));
|
||||||
let mut work = unsafe { work.assume_init() };
|
let mut work = unsafe { work.assume_init() };
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
|
|||||||
/// dynamically-sized column vector should be represented as a `Matrix<T, Dynamic, U1, S>` (given
|
/// dynamically-sized column vector should be represented as a `Matrix<T, Dynamic, U1, S>` (given
|
||||||
/// some concrete types for `T` and a compatible data storage type `S`).
|
/// some concrete types for `T` and a compatible data storage type `S`).
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct Matrix<T, R, C, S> {
|
pub struct Matrix<T, R, C, S> {
|
||||||
/// The data storage that contains all the matrix components. Disappointed?
|
/// The data storage that contains all the matrix components. Disappointed?
|
||||||
///
|
///
|
||||||
@ -192,6 +192,12 @@ pub struct Matrix<T, R, C, S> {
|
|||||||
_phantoms: PhantomData<(T, R, C)>,
|
_phantoms: PhantomData<(T, R, C)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T, R: Dim, C: Dim, S: fmt::Debug> fmt::Debug for Matrix<T, R, C, S> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct("Matrix").field("data", &self.data).finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T, R: Dim, C: Dim, S: Default> Default for Matrix<T, R, C, S> {
|
impl<T, R: Dim, C: Dim, S: Default> Default for Matrix<T, R, C, S> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
unsafe { Matrix::from_data_statically_unchecked(Default::default()) }
|
unsafe { Matrix::from_data_statically_unchecked(Default::default()) }
|
||||||
|
@ -9,7 +9,7 @@ use simba::scalar::ComplexField;
|
|||||||
use crate::geometry::Point;
|
use crate::geometry::Point;
|
||||||
|
|
||||||
/// A reflection wrt. a plane.
|
/// A reflection wrt. a plane.
|
||||||
pub struct Reflection<T, D, S> {
|
pub struct Reflection<T, D:Dim, S> {
|
||||||
axis: Vector<T, D, S>,
|
axis: Vector<T, D, S>,
|
||||||
bias: T,
|
bias: T,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user