<commit_before>use na::{Scalar, Real, U1, U2, U3, U4, DefaultAllocator,
         Quaternion, Matrix2, Matrix3, Matrix4, Vector1, Vector2, Vector3, Vector4,
         Matrix2x3, Matrix2x4, Matrix3x2, Matrix3x4, Matrix4x2, Matrix4x3};

use traits::{Number, Alloc, Dimension};
use aliases::{Qua, Vec, Mat};

/// Creates a 2x2 matrix from a slice arranged in column-major order.
pub fn make_mat2<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U2> {
    Matrix2::from_column_slice(ptr)
}

/// Creates a 2x2 matrix from a slice arranged in column-major order.
pub fn make_mat2x2<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U2> {
    Matrix2::from_column_slice(ptr)
}

/// Creates a 2x3 matrix from a slice arranged in column-major order.
pub fn make_mat2x3<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U3> {
    Matrix2x3::from_column_slice(ptr)
}

/// Creates a 2x4 matrix from a slice arranged in column-major order.
pub fn make_mat2x4<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U4> {
    Matrix2x4::from_column_slice(ptr)
}

/// Creates a 3 matrix from a slice arranged in column-major order.
pub fn make_mat3<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U3> {
    Matrix3::from_column_slice(ptr)
}

/// Creates a 3x2 matrix from a slice arranged in column-major order.
pub fn make_mat3x2<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U2> {
    Matrix3x2::from_column_slice(ptr)
}

/// Creates a 3x3 matrix from a slice arranged in column-major order.
pub fn make_mat3x3<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U3> {
    Matrix3::from_column_slice(ptr)
}

/// Creates a 3x4 matrix from a slice arranged in column-major order.
pub fn make_mat3x4<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U4> {
    Matrix3x4::from_column_slice(ptr)
}

/// Creates a 4x4 matrix from a slice arranged in column-major order.
pub fn make_mat4<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U4> {
    Matrix4::from_column_slice(ptr)
}

/// Creates a 4x2 matrix from a slice arranged in column-major order.
pub fn make_mat4x2<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U2> {
    Matrix4x2::from_column_slice(ptr)
}

/// Creates a 4x3 matrix from a slice arranged in column-major order.
pub fn make_mat4x3<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U3> {
    Matrix4x3::from_column_slice(ptr)
}

/// Creates a 4x4 matrix from a slice arranged in column-major order.
pub fn make_mat4x4<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U4> {
    Matrix4::from_column_slice(ptr)
}
<commit_msg>Add conversion functions between square matrices.<commit_after>use na::{Scalar, Real, U1, U2, U3, U4, DefaultAllocator,
         Quaternion, Matrix2, Matrix3, Matrix4, Vector1, Vector2, Vector3, Vector4,
         Matrix2x3, Matrix2x4, Matrix3x2, Matrix3x4, Matrix4x2, Matrix4x3};

use traits::{Number, Alloc, Dimension};
use aliases::{Qua, Vec, Mat};

/// Creates a 2x2 matrix from a slice arranged in column-major order.
pub fn make_mat2<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U2> {
    Matrix2::from_column_slice(ptr)
}

/// Creates a 2x2 matrix from a slice arranged in column-major order.
pub fn make_mat2x2<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U2> {
    Matrix2::from_column_slice(ptr)
}

/// Creates a 2x3 matrix from a slice arranged in column-major order.
pub fn make_mat2x3<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U3> {
    Matrix2x3::from_column_slice(ptr)
}

/// Creates a 2x4 matrix from a slice arranged in column-major order.
pub fn make_mat2x4<N: Scalar>(ptr: &[N]) -> Mat<N, U2, U4> {
    Matrix2x4::from_column_slice(ptr)
}

/// Creates a 3 matrix from a slice arranged in column-major order.
pub fn make_mat3<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U3> {
    Matrix3::from_column_slice(ptr)
}

/// Creates a 3x2 matrix from a slice arranged in column-major order.
pub fn make_mat3x2<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U2> {
    Matrix3x2::from_column_slice(ptr)
}

/// Creates a 3x3 matrix from a slice arranged in column-major order.
pub fn make_mat3x3<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U3> {
    Matrix3::from_column_slice(ptr)
}

/// Creates a 3x4 matrix from a slice arranged in column-major order.
pub fn make_mat3x4<N: Scalar>(ptr: &[N]) -> Mat<N, U3, U4> {
    Matrix3x4::from_column_slice(ptr)
}

/// Creates a 4x4 matrix from a slice arranged in column-major order.
pub fn make_mat4<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U4> {
    Matrix4::from_column_slice(ptr)
}

/// Creates a 4x2 matrix from a slice arranged in column-major order.
pub fn make_mat4x2<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U2> {
    Matrix4x2::from_column_slice(ptr)
}

/// Creates a 4x3 matrix from a slice arranged in column-major order.
pub fn make_mat4x3<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U3> {
    Matrix4x3::from_column_slice(ptr)
}

/// Creates a 4x4 matrix from a slice arranged in column-major order.
pub fn make_mat4x4<N: Scalar>(ptr: &[N]) -> Mat<N, U4, U4> {
    Matrix4::from_column_slice(ptr)
}

/// Converts a 2x2 matrix to a 3x3 matrix.
pub fn mat2_to_mat3<N: Number>(m: &Mat<N, U2, U2>) -> Mat<N, U3, U3> {
    let _0 = N::zero();
    let _1 = N::one();

    Matrix3::new(
        m.m11, m.m12, _0,
        m.m21, m.m22, _0,
        _0, _0, _1
    )
}

/// Converts a 3x3 matrix to a 2x2 matrix.
pub fn mat3_to_mat2<N: Scalar>(m: &Mat<N, U3, U3>) -> Mat<N, U2, U2> {
    Matrix2::new(
        m.m11, m.m12,
        m.m21, m.m22
    )
}

/// Converts a 3x3 matrix to a 4x4 matrix.
pub fn mat3_to_mat4<N: Number>(m: &Mat<N, U3, U3>) -> Mat<N, U4, U4> {
    let _0 = N::zero();
    let _1 = N::one();

    Matrix4::new(
        m.m11, m.m12, m.m13, _0,
        m.m21, m.m22, m.m23, _0,
        m.m31, m.m32, m.m33, _0,
        _0, _0, _0, _1,
    )
}

/// Converts a 4x4 matrix to a 3x3 matrix.
pub fn mat4_to_mat3<N: Scalar>(m: &Mat<N, U4, U4>) -> Mat<N, U3, U3> {
    Matrix3::new(
        m.m11, m.m12, m.m13,
        m.m21, m.m22, m.m23,
        m.m31, m.m32, m.m33,
    )
}

/// Converts a 2x2 matrix to a 4x4 matrix.
pub fn mat2_to_mat4<N: Number>(m: &Mat<N, U2, U2>) -> Mat<N, U4, U4> {
    let _0 = N::zero();
    let _1 = N::one();

    Matrix4::new(
        m.m11, m.m12, _0, _0,
        m.m21, m.m22, _0, _0,
        _0, _0, _1, _0,
        _0, _0, _0, _1,
    )
}

/// Converts a 4x4 matrix to a 2x2 matrix.
pub fn mat4_to_mat2<N: Scalar>(m: &Mat<N, U4, U4>) -> Mat<N, U2, U2> {
    Matrix2::new(
        m.m11, m.m12,
        m.m21, m.m22,
    )
}

{'fraction_non_alphanumeric': 0.16028938906752413, 'fraction_numerical': 0.06141479099678457, 'mean_word_length': 3.260958904109589, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 99, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4310784', 'n_tokens_mistral': 2680, 'n_tokens_neox': 2612, 'n_words': 735}