use russell_tensor::{Mandel, StrError, Tensor2, SQRT_2}; fn main() -> Result<(), StrError> { // general let a = Tensor2::from_matrix( &[ [1.0, SQRT_2 * 2.0, SQRT_2 * 3.0], [SQRT_2 * 4.0, 5.0, SQRT_2 * 6.0], [SQRT_2 * 7.0, SQRT_2 * 8.0, 9.0], ], Mandel::General, )?; assert_eq!( format!("{:.1}", a.vector()), "┌ ┐\n\ │ 1.0 │\n\ │ 5.0 │\n\ │ 9.0 │\n\ │ 6.0 │\n\ │ 14.0 │\n\ │ 10.0 │\n\ │ -2.0 │\n\ │ -2.0 │\n\ │ -4.0 │\n\ └ ┘" ); // symmetric-3D let b = Tensor2::from_matrix( &[ [1.0, 4.0 / SQRT_2, 6.0 / SQRT_2], [4.0 / SQRT_2, 2.0, 5.0 / SQRT_2], [6.0 / SQRT_2, 5.0 / SQRT_2, 3.0], ], Mandel::Symmetric, )?; assert_eq!( format!("{:.1}", b.vector()), "┌ ┐\n\ │ 1.0 │\n\ │ 2.0 │\n\ │ 3.0 │\n\ │ 4.0 │\n\ │ 5.0 │\n\ │ 6.0 │\n\ └ ┘" ); // symmetric-2D let c = Tensor2::from_matrix( &[[1.0, 4.0 / SQRT_2, 0.0], [4.0 / SQRT_2, 2.0, 0.0], [0.0, 0.0, 3.0]], Mandel::Symmetric2D, )?; assert_eq!( format!("{:.1}", c.vector()), "┌ ┐\n\ │ 1.0 │\n\ │ 2.0 │\n\ │ 3.0 │\n\ │ 4.0 │\n\ └ ┘" ); Ok(()) }