1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright © 2023 Marcel Luca Schmidt
//
// This file is part of qFALL-math.
//
// qFALL-math is free software: you can redistribute it and/or modify it under
// the terms of the Mozilla Public License Version 2.0 as published by the
// Mozilla Foundation. See <https://mozilla.org/en-US/MPL/2.0/>.
//! [`MatZq`] is a type of matrix with integer entries of arbitrary length modulo `q`.
//! This implementation uses the [FLINT](https://flintlib.org/) library.
// For **DEVELOPERS**: Many functions assume that the [`MatZq`] instances are reduced.
// To avoid unnecessary checks and reductions, always return canonical/reduced
// values. The end-user should be unable to obtain a non-reduced value.
use crate::;
use fmpz_mod_mat_struct;
use fmt;
/// [`MatZq`] is a matrix with entries of type [`Zq`](crate::integer_mod_q::Zq).
///
/// Attributes:
/// - `matrix`: holds [FLINT](https://flintlib.org/)'s [struct](fmpz_mod_mat_struct)
/// of the [`Zq`](crate::integer_mod_q::Zq) matrix
///
/// # Examples
/// ## Matrix usage
/// ```
/// use qfall_math::{
/// integer::Z,
/// integer_mod_q::MatZq,
/// traits::{MatrixGetEntry, MatrixSetEntry},
/// };
/// use std::str::FromStr;
///
/// // instantiate new matrix
/// let id_mat = MatZq::from_str("[[1, 0],[0, 1]] mod 2").unwrap();
///
/// // clone object, set and get entry
/// let mut clone = id_mat.clone();
/// clone.set_entry(0, 0, 2);
/// let entry:Z = clone.get_entry(1, 1).unwrap();
/// assert_eq!(entry, Z::ONE);
///
/// // to_string incl. (de-)serialization
/// assert_eq!("[[1, 0],[0, 1]] mod 2", &id_mat.to_string());
/// ```
///
/// ## Vector usage
/// ```
/// use qfall_math::{
/// integer::Z,
/// integer_mod_q::MatZq,
/// };
/// use std::str::FromStr;
///
/// let row_vec = MatZq::from_str("[[1, 1, 1]] mod 2").unwrap();
/// let col_vec = MatZq::from_str("[[1],[-1],[0]] mod 2").unwrap();
///
/// // check if matrix instance is vector
/// assert!(row_vec.is_row_vector());
/// assert!(col_vec.is_column_vector());
/// ```