pub struct IntegerVector {
pub elements: Vec<Integer>,
}Expand description
A vector whose elements are Integers.
Its dimension is the number of elements, and the 0-dimensional vector has none. The field is
public, since every Vec of Integers is a valid vector: unlike a polynomial, a vector has
no normal form to maintain, and two vectors are equal exactly when their elements are.
An IntegerVector is serialized as the list of its elements, each serialized the way a
Integer is.
§Examples
use malachite_base::num::basic::traits::{One, Two};
use malachite_base::vector::Vector;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector {
elements: vec![Integer::ONE, Integer::TWO, Integer::from(3u32)],
};
assert_eq!(v.dimension(), 3);Fields§
§elements: Vec<Integer>Implementations§
Source§impl IntegerVector
impl IntegerVector
Sourcepub fn multi_balanced_crt(
moduli: &[Limb],
residues: &[UnsignedVector<Limb>],
) -> Option<Self>
pub fn multi_balanced_crt( moduli: &[Limb], residues: &[UnsignedVector<Limb>], ) -> Option<Self>
Combines vectors of residues modulo pairwise-coprime word-sized moduli into the vector whose
every element is the representative of smallest absolute value that is congruent to each of
its residues, returning None if the moduli are unusable.
residues[j] holds the residues of every element modulo moduli[j], so element $i$ of the
result is the combination of residues[0][i], residues[1][i], and so on, as
Integer::multi_balanced_crt would compute it. Each element $x$ of the result satisfies
$-M/2 < x \leq M/2$, where $M$ is the product of the moduli, so a tie at $M/2$ is positive.
The work that depends only on the moduli is done once, not once per element. The residues
must be already reduced, and the moduli are unusable under the conditions of
Integer::multi_balanced_crt: with one modulus, if it is 0; with more, if any is 0 or 1
or two are not coprime.
For the representatives in $[0, M)$ instead, use
NaturalVector::multi_crt.
§Worst-case complexity
$T(n, d) = O(n (\log n)^3 \log\log n + dn (\log n)^2 \log\log n)$
$M(n, d) = O(n \log n + dn)$
where $T$ is time, $M$ is additional memory, $n$ is the number of significant bits of the product of the moduli, and $d$ is the dimension of the residue vectors.
§Panics
Panics if moduli is empty, if the number of residue vectors differs from the number of
moduli, if the residue vectors do not all have the same dimension, or if, when the moduli
are usable, any residue is greater than or equal to its modulus.
§Examples
use core::str::FromStr;
use malachite_base::unsigned_vector::UnsignedVector;
use malachite_nz::integer_vector::IntegerVector;
// 23 is 2 mod 3, 3 mod 5, and 2 mod 7; 6 is 0, 1, and 6; and -5 is 1, 0, and 2.
let residues = [
UnsignedVector::from_str("(2, 0, 1)").unwrap(),
UnsignedVector::from_str("(3, 1, 0)").unwrap(),
UnsignedVector::from_str("(2, 6, 2)").unwrap(),
];
assert_eq!(
IntegerVector::multi_balanced_crt(&[3, 5, 7], &residues)
.unwrap()
.to_string(),
"(23, 6, -5)"
);
// 4 and 6 are not coprime.
assert!(IntegerVector::multi_balanced_crt(&[4, 6], &residues[..2]).is_none());This is equivalent to _fmpz_vec_multi_CRT_ui from fmpz_vec/multi_CRT_ui.c, FLINT 3.6.0,
with sign = 1 and the residues required to be reduced.
Trait Implementations§
Source§impl AbsSquared for IntegerVector
impl AbsSquared for IntegerVector
Source§fn abs_squared(self) -> Natural
fn abs_squared(self) -> Natural
Computes the squared norm of an IntegerVector, the sum of the squares of its elements,
taking the vector by value.
This is the dot product of the vector with itself, $|v|^2$. The squared norm of the
0-dimensional vector is 0. The squared norm is non-negative, so it is returned as a
Natural.
$$ f(v) = |v|^2 = \sum_{i=0}^{n-1} v_i^2, $$
where $n$ is the dimension of $v$.
§Worst-case complexity
$T(n, m) = O(nm \log m \log\log m)$
$M(m) = O(m \log m)$
where $T$ is time, $M$ is additional memory, $n$ is the dimension of the vector, and $m$ is the largest number of significant bits of any element.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::AbsSquared;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(3, -4, 12)").unwrap();
assert_eq!(v.abs_squared(), 169);
let v = IntegerVector::from_str("()").unwrap();
assert_eq!(v.abs_squared(), 0);This is equivalent to _fmpz_vec_dot from fmpz_vec/dot.c, FLINT 3.6.0, with both vectors
the same, which squares each element instead of multiplying it by itself.
type Output = Natural
Source§impl AbsSquared for &IntegerVector
impl AbsSquared for &IntegerVector
Source§fn abs_squared(self) -> Natural
fn abs_squared(self) -> Natural
Computes the squared norm of an IntegerVector, the sum of the squares of its elements,
taking the vector by reference.
This is the dot product of the vector with itself, $|v|^2$. The squared norm of the
0-dimensional vector is 0. The squared norm is non-negative, so it is returned as a
Natural.
$$ f(v) = |v|^2 = \sum_{i=0}^{n-1} v_i^2, $$
where $n$ is the dimension of $v$.
§Worst-case complexity
$T(n, m) = O(nm \log m \log\log m)$
$M(m) = O(m \log m)$
where $T$ is time, $M$ is additional memory, $n$ is the dimension of the vector, and $m$ is the largest number of significant bits of any element.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::AbsSquared;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(3, -4, 12)").unwrap();
assert_eq!((&v).abs_squared(), 169);
let v = IntegerVector::from_str("()").unwrap();
assert_eq!((&v).abs_squared(), 0);This is equivalent to _fmpz_vec_dot from fmpz_vec/dot.c, FLINT 3.6.0, with both vectors
the same, which squares each element instead of multiplying it by itself.
type Output = Natural
Source§impl Add for IntegerVector
impl Add for IntegerVector
Source§fn add(self, other: Self) -> Self
fn add(self, other: Self) -> Self
Adds two IntegerVectors, taking both by value.
The sum is taken element by element, so the result has the same dimension as the summands.
$$ f(v, w) = v + w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!((v + w).to_string(), "(0, 3, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
+ operator.Source§impl Add<&IntegerVector> for IntegerVector
impl Add<&IntegerVector> for IntegerVector
Source§fn add(self, other: &Self) -> Self
fn add(self, other: &Self) -> Self
Adds two IntegerVectors, taking the first by value and the second by reference.
The sum is taken element by element, so the result has the same dimension as the summands.
$$ f(v, w) = v + w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!((v + &w).to_string(), "(0, 3, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
+ operator.Source§impl Add<&IntegerVector> for &IntegerVector
impl Add<&IntegerVector> for &IntegerVector
Source§fn add(self, other: &IntegerVector) -> IntegerVector
fn add(self, other: &IntegerVector) -> IntegerVector
Adds two IntegerVectors, taking both by reference.
The sum is taken element by element, so the result has the same dimension as the summands.
$$ f(v, w) = v + w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!((&v + &w).to_string(), "(0, 3, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
+ operator.Source§impl Add<IntegerVector> for &IntegerVector
impl Add<IntegerVector> for &IntegerVector
Source§fn add(self, other: IntegerVector) -> IntegerVector
fn add(self, other: IntegerVector) -> IntegerVector
Adds two IntegerVectors, taking the first by reference and the second by value.
The sum is taken element by element, so the result has the same dimension as the summands.
$$ f(v, w) = v + w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!((&v + w).to_string(), "(0, 3, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
+ operator.Source§impl AddAssign for IntegerVector
impl AddAssign for IntegerVector
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Adds an IntegerVector to an IntegerVector in place, taking the IntegerVector on
the right-hand side by value.
The sum is taken element by element, so the result has the same dimension as the summands.
$$ f(v, w) = v + w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
v += IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!(v.to_string(), "(0, 3, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§impl AddAssign<&IntegerVector> for IntegerVector
impl AddAssign<&IntegerVector> for IntegerVector
Source§fn add_assign(&mut self, other: &Self)
fn add_assign(&mut self, other: &Self)
Adds an IntegerVector to an IntegerVector in place, taking the IntegerVector on
the right-hand side by reference.
The sum is taken element by element, so the result has the same dimension as the summands.
$$ f(v, w) = v + w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
v += &IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!(v.to_string(), "(0, 3, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§impl<'a, 'b> AddMul<&'a IntegerVector, &'b Integer> for IntegerVector
impl<'a, 'b> AddMul<&'a IntegerVector, &'b Integer> for IntegerVector
Source§fn add_mul(self, w: &'a Self, c: &'b Integer) -> Self
fn add_mul(self, w: &'a Self, c: &'b Integer) -> Self
Adds the product of an IntegerVector and an Integer to an IntegerVector, taking
the first vector by value, the second vector by reference, and the scalar by reference.
See the documentation for the AddMul implementation that takes all three by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_addmul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl<'a> AddMul<&'a IntegerVector, Integer> for IntegerVector
impl<'a> AddMul<&'a IntegerVector, Integer> for IntegerVector
Source§fn add_mul(self, w: &'a Self, c: Integer) -> Self
fn add_mul(self, w: &'a Self, c: Integer) -> Self
Adds the product of an IntegerVector and an Integer to an IntegerVector, taking
the first vector by value, the second vector by reference, and the scalar by value.
See the documentation for the AddMul implementation that takes all three by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_addmul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl AddMul<&IntegerVector, &Integer> for &IntegerVector
impl AddMul<&IntegerVector, &Integer> for &IntegerVector
Source§fn add_mul(self, w: &IntegerVector, c: &Integer) -> IntegerVector
fn add_mul(self, w: &IntegerVector, c: &Integer) -> IntegerVector
Adds the product of an IntegerVector and an Integer to an IntegerVector, taking
all three by reference.
See the documentation for the AddMul implementation that takes all three by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_addmul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl<'b> AddMul<IntegerVector, &'b Integer> for IntegerVector
impl<'b> AddMul<IntegerVector, &'b Integer> for IntegerVector
Source§fn add_mul(self, w: Self, c: &'b Integer) -> Self
fn add_mul(self, w: Self, c: &'b Integer) -> Self
Adds the product of an IntegerVector and an Integer to an IntegerVector, taking
the first vector by value, the second vector by value, and the scalar by reference.
See the documentation for the AddMul implementation that takes all three by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_addmul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl AddMul<IntegerVector, Integer> for IntegerVector
impl AddMul<IntegerVector, Integer> for IntegerVector
Source§fn add_mul(self, w: Self, c: Integer) -> Self
fn add_mul(self, w: Self, c: Integer) -> Self
Adds the product of an IntegerVector and an Integer to an IntegerVector, taking
all three by value.
The operation is taken element by element, so the result has the same dimension as the vectors. Like FLINT’s, this special-cases multiplication by 0, 1, and $-1$.
$$ f(v, w, c) = v + cw = (v_0 + cw_0, v_1 + cw_1, \ldots, v_{n-1} + cw_{n-1}). $$
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_addmul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl<'a, 'b> AddMulAssign<&'a IntegerVector, &'b Integer> for IntegerVector
impl<'a, 'b> AddMulAssign<&'a IntegerVector, &'b Integer> for IntegerVector
Source§fn add_mul_assign(&mut self, w: &'a Self, c: &'b Integer)
fn add_mul_assign(&mut self, w: &'a Self, c: &'b Integer)
Adds the product of an IntegerVector and an Integer to an IntegerVector in
place, taking the vector and the scalar on the right-hand side by reference.
See the documentation for the AddMulAssign implementation that takes both by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_addmul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl<'a> AddMulAssign<&'a IntegerVector, Integer> for IntegerVector
impl<'a> AddMulAssign<&'a IntegerVector, Integer> for IntegerVector
Source§fn add_mul_assign(&mut self, w: &'a Self, c: Integer)
fn add_mul_assign(&mut self, w: &'a Self, c: Integer)
Adds the product of an IntegerVector and an Integer to an IntegerVector in
place, taking the vector on the right-hand side by reference and the scalar by value.
See the documentation for the AddMulAssign implementation that takes both by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_addmul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl<'b> AddMulAssign<IntegerVector, &'b Integer> for IntegerVector
impl<'b> AddMulAssign<IntegerVector, &'b Integer> for IntegerVector
Source§fn add_mul_assign(&mut self, w: Self, c: &'b Integer)
fn add_mul_assign(&mut self, w: Self, c: &'b Integer)
Adds the product of an IntegerVector and an Integer to an IntegerVector in
place, taking the vector on the right-hand side by value and the scalar by reference.
See the documentation for the AddMulAssign implementation that takes both by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_addmul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl AddMulAssign<IntegerVector, Integer> for IntegerVector
impl AddMulAssign<IntegerVector, Integer> for IntegerVector
Source§fn add_mul_assign(&mut self, w: Self, c: Integer)
fn add_mul_assign(&mut self, w: Self, c: Integer)
Adds the product of an IntegerVector and an Integer to an IntegerVector in
place, taking the vector and the scalar on the right-hand side by value.
The operation is taken element by element. Like FLINT’s, this special-cases multiplication by 0, 1, and $-1$.
$$ v \gets v + cw. $$
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_addmul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl AddMulShl<&IntegerVector, &Integer> for IntegerVector
impl AddMulShl<&IntegerVector, &Integer> for IntegerVector
Source§fn add_mul_shl(self, w: &Self, c: &Integer, bits: u64) -> Self
fn add_mul_shl(self, w: &Self, c: &Integer, bits: u64) -> Self
Adds a scalar multiple of an IntegerVector, shifted left by bits, to an
IntegerVector, taking the first vector by value, the second by reference, and the scalar
by reference.
See the documentation for the AddMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::AddMulShl;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(
v.add_mul_shl(&w, &Integer::from(10), 2).to_string(),
"(161, 198, -237)"
);
let v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
assert_eq!(
v.add_mul_shl(&w, &Integer::from_str("18446744073709551617").unwrap(), 3)
.to_string(),
"(2722258935367507707706996859454145691641, -147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_addmul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
type Output = IntegerVector
Source§impl AddMulShl<&IntegerVector, &Integer> for &IntegerVector
impl AddMulShl<&IntegerVector, &Integer> for &IntegerVector
Source§fn add_mul_shl(self, w: &IntegerVector, c: &Integer, bits: u64) -> IntegerVector
fn add_mul_shl(self, w: &IntegerVector, c: &Integer, bits: u64) -> IntegerVector
Adds a scalar multiple of an IntegerVector, shifted left by bits, to an
IntegerVector, taking both vectors and the scalar by reference.
See the documentation for the AddMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::AddMulShl;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(
(&v).add_mul_shl(&w, &Integer::from(10), 2).to_string(),
"(161, 198, -237)"
);
let v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
assert_eq!(
(&v).add_mul_shl(&w, &Integer::from_str("18446744073709551617").unwrap(), 3)
.to_string(),
"(2722258935367507707706996859454145691641, -147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_addmul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
type Output = IntegerVector
Source§impl AddMulShl<&IntegerVector, Integer> for IntegerVector
impl AddMulShl<&IntegerVector, Integer> for IntegerVector
Source§fn add_mul_shl(self, w: &Self, c: Integer, bits: u64) -> Self
fn add_mul_shl(self, w: &Self, c: Integer, bits: u64) -> Self
Adds a scalar multiple of an IntegerVector, shifted left by bits, to an
IntegerVector, taking the first vector by value, the second by reference, and the scalar
by value.
See the documentation for the AddMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::AddMulShl;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(
v.add_mul_shl(&w, Integer::from(10), 2).to_string(),
"(161, 198, -237)"
);
let v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
assert_eq!(
v.add_mul_shl(&w, Integer::from_str("18446744073709551617").unwrap(), 3)
.to_string(),
"(2722258935367507707706996859454145691641, -147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_addmul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
type Output = IntegerVector
Source§impl AddMulShl<IntegerVector, &Integer> for IntegerVector
impl AddMulShl<IntegerVector, &Integer> for IntegerVector
Source§fn add_mul_shl(self, w: Self, c: &Integer, bits: u64) -> Self
fn add_mul_shl(self, w: Self, c: &Integer, bits: u64) -> Self
Adds a scalar multiple of an IntegerVector, shifted left by bits, to an
IntegerVector, taking the first vector by value, the second by value, and the scalar by
reference.
See the documentation for the AddMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::AddMulShl;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(
v.add_mul_shl(w, &Integer::from(10), 2).to_string(),
"(161, 198, -237)"
);
let v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
assert_eq!(
v.add_mul_shl(w, &Integer::from_str("18446744073709551617").unwrap(), 3)
.to_string(),
"(2722258935367507707706996859454145691641, -147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_addmul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
type Output = IntegerVector
Source§impl AddMulShl<IntegerVector, Integer> for IntegerVector
impl AddMulShl<IntegerVector, Integer> for IntegerVector
Source§fn add_mul_shl(self, w: Self, c: Integer, bits: u64) -> Self
fn add_mul_shl(self, w: Self, c: Integer, bits: u64) -> Self
Adds a scalar multiple of an IntegerVector, shifted left by bits, to an
IntegerVector, taking both vectors and the scalar by value.
The operation is taken element by element, so the result has the same dimension as the vectors. Like FLINT’s, this special-cases multiplication by 0, 1, and $-1$, and a shift by 0.
$$ f(v, w, c, k) = v + cw2^k. $$
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::AddMulShl;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(
v.add_mul_shl(w, Integer::from(10), 2).to_string(),
"(161, 198, -237)"
);
let v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
assert_eq!(
v.add_mul_shl(w, Integer::from_str("18446744073709551617").unwrap(), 3)
.to_string(),
"(2722258935367507707706996859454145691641, -147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_addmul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
type Output = IntegerVector
Source§impl AddMulShlAssign<&IntegerVector, &Integer> for IntegerVector
impl AddMulShlAssign<&IntegerVector, &Integer> for IntegerVector
Source§fn add_mul_shl_assign(&mut self, w: &Self, c: &Integer, bits: u64)
fn add_mul_shl_assign(&mut self, w: &Self, c: &Integer, bits: u64)
Adds a scalar multiple of an IntegerVector, shifted left by bits, to an
IntegerVector, in place, taking the vector and the scalar on the right-hand side by
reference.
See the documentation for the AddMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::AddMulShlAssign;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
v.add_mul_shl_assign(&w, &Integer::from(10), 2);
assert_eq!(v.to_string(), "(161, 198, -237)");
let mut v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
v.add_mul_shl_assign(&w, &Integer::from_str("18446744073709551617").unwrap(), 3);
assert_eq!(
v.to_string(),
"(2722258935367507707706996859454145691641, -147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_addmul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl AddMulShlAssign<&IntegerVector, Integer> for IntegerVector
impl AddMulShlAssign<&IntegerVector, Integer> for IntegerVector
Source§fn add_mul_shl_assign(&mut self, w: &Self, c: Integer, bits: u64)
fn add_mul_shl_assign(&mut self, w: &Self, c: Integer, bits: u64)
Adds a scalar multiple of an IntegerVector, shifted left by bits, to an
IntegerVector, in place, taking the vector on the right-hand side by reference and the
scalar by value.
See the documentation for the AddMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::AddMulShlAssign;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
v.add_mul_shl_assign(&w, Integer::from(10), 2);
assert_eq!(v.to_string(), "(161, 198, -237)");
let mut v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
v.add_mul_shl_assign(&w, Integer::from_str("18446744073709551617").unwrap(), 3);
assert_eq!(
v.to_string(),
"(2722258935367507707706996859454145691641, -147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_addmul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl AddMulShlAssign<IntegerVector, &Integer> for IntegerVector
impl AddMulShlAssign<IntegerVector, &Integer> for IntegerVector
Source§fn add_mul_shl_assign(&mut self, w: Self, c: &Integer, bits: u64)
fn add_mul_shl_assign(&mut self, w: Self, c: &Integer, bits: u64)
Adds a scalar multiple of an IntegerVector, shifted left by bits, to an
IntegerVector, in place, taking the vector on the right-hand side by value and the
scalar by reference.
See the documentation for the AddMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::AddMulShlAssign;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
v.add_mul_shl_assign(w, &Integer::from(10), 2);
assert_eq!(v.to_string(), "(161, 198, -237)");
let mut v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
v.add_mul_shl_assign(w, &Integer::from_str("18446744073709551617").unwrap(), 3);
assert_eq!(
v.to_string(),
"(2722258935367507707706996859454145691641, -147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_addmul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl AddMulShlAssign<IntegerVector, Integer> for IntegerVector
impl AddMulShlAssign<IntegerVector, Integer> for IntegerVector
Source§fn add_mul_shl_assign(&mut self, w: Self, c: Integer, bits: u64)
fn add_mul_shl_assign(&mut self, w: Self, c: Integer, bits: u64)
Adds a scalar multiple of an IntegerVector, shifted left by bits, to an
IntegerVector, in place, taking the vector and the scalar on the right-hand side by
value.
See the documentation for the AddMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::AddMulShlAssign;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
v.add_mul_shl_assign(w, Integer::from(10), 2);
assert_eq!(v.to_string(), "(161, 198, -237)");
let mut v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
v.add_mul_shl_assign(w, Integer::from_str("18446744073709551617").unwrap(), 3);
assert_eq!(
v.to_string(),
"(2722258935367507707706996859454145691641, -147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_addmul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl<'a> BalancedMod<&'a Integer> for IntegerVector
impl<'a> BalancedMod<&'a Integer> for IntegerVector
Source§fn balanced_mod(self, m: &'a Integer) -> Self
fn balanced_mod(self, m: &'a Integer) -> Self
Reduces every element of an IntegerVector modulo an Integer to the representative
closest to zero, taking the vector by value and the modulus by reference.
See the documentation for the BalancedMod implementation on IntegerVector that takes
both arguments by value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::BalancedMod;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
// Each element goes to the representative closest to zero, and half the modulus is
// positive.
let v = IntegerVector::from_str("(1, 27, -23, -5)").unwrap();
assert_eq!(
v.clone().balanced_mod(&Integer::from(10)).to_string(),
"(1, -3, -3, 5)"
);
// Only the modulus's magnitude matters, and an element that reduces to zero stays.
let v = IntegerVector::from_str("(10, 7)").unwrap();
assert_eq!(
v.clone().balanced_mod(&Integer::from(-10)).to_string(),
"(0, -3)"
);type Output = IntegerVector
Source§impl<'a> BalancedMod<&'a Integer> for &IntegerVector
impl<'a> BalancedMod<&'a Integer> for &IntegerVector
Source§fn balanced_mod(self, m: &'a Integer) -> IntegerVector
fn balanced_mod(self, m: &'a Integer) -> IntegerVector
Reduces every element of an IntegerVector modulo an Integer to the representative
closest to zero, taking the vector by reference and the modulus by reference.
See the documentation for the BalancedMod implementation on IntegerVector that takes
both arguments by value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::BalancedMod;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
// Each element goes to the representative closest to zero, and half the modulus is
// positive.
let v = IntegerVector::from_str("(1, 27, -23, -5)").unwrap();
assert_eq!(
(&v).balanced_mod(&Integer::from(10)).to_string(),
"(1, -3, -3, 5)"
);
// Only the modulus's magnitude matters, and an element that reduces to zero stays.
let v = IntegerVector::from_str("(10, 7)").unwrap();
assert_eq!(
(&v).balanced_mod(&Integer::from(-10)).to_string(),
"(0, -3)"
);type Output = IntegerVector
Source§impl BalancedMod<Integer> for IntegerVector
impl BalancedMod<Integer> for IntegerVector
Source§fn balanced_mod(self, m: Integer) -> Self
fn balanced_mod(self, m: Integer) -> Self
Reduces every element of an IntegerVector modulo an Integer to the representative
closest to zero, taking the vector by value and the modulus by value.
Each element $w_i$ of the result satisfies $-|m|/2 < w_i \leq |m|/2$ and $w_i \equiv v_i
\bmod m$, which determine it uniquely, as with BalancedMod for Integers. A remainder
of exactly $|m|/2$ is positive, and only the magnitude of $m$ matters. The dimension is
unchanged: unlike a polynomial, a vector keeps the elements that reduce to zero.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::BalancedMod;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
// Each element goes to the representative closest to zero, and half the modulus is
// positive.
let v = IntegerVector::from_str("(1, 27, -23, -5)").unwrap();
assert_eq!(
v.clone().balanced_mod(Integer::from(10)).to_string(),
"(1, -3, -3, 5)"
);
// Only the modulus's magnitude matters, and an element that reduces to zero stays.
let v = IntegerVector::from_str("(10, 7)").unwrap();
assert_eq!(
v.clone().balanced_mod(Integer::from(-10)).to_string(),
"(0, -3)"
);This is equivalent to _fmpz_vec_scalar_smod_fmpz from fmpz_vec/scalar_smod.c, FLINT
3.6.0, for a positive modulus.
type Output = IntegerVector
Source§impl BalancedMod<Integer> for &IntegerVector
impl BalancedMod<Integer> for &IntegerVector
Source§fn balanced_mod(self, m: Integer) -> IntegerVector
fn balanced_mod(self, m: Integer) -> IntegerVector
Reduces every element of an IntegerVector modulo an Integer to the representative
closest to zero, taking the vector by reference and the modulus by value.
See the documentation for the BalancedMod implementation on IntegerVector that takes
both arguments by value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::BalancedMod;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
// Each element goes to the representative closest to zero, and half the modulus is
// positive.
let v = IntegerVector::from_str("(1, 27, -23, -5)").unwrap();
assert_eq!(
(&v).balanced_mod(Integer::from(10)).to_string(),
"(1, -3, -3, 5)"
);
// Only the modulus's magnitude matters, and an element that reduces to zero stays.
let v = IntegerVector::from_str("(10, 7)").unwrap();
assert_eq!((&v).balanced_mod(Integer::from(-10)).to_string(), "(0, -3)");type Output = IntegerVector
Source§impl<'a> BalancedModAssign<&'a Integer> for IntegerVector
impl<'a> BalancedModAssign<&'a Integer> for IntegerVector
Source§fn balanced_mod_assign(&mut self, m: &'a Integer)
fn balanced_mod_assign(&mut self, m: &'a Integer)
Reduces every element of an IntegerVector modulo an Integer to the representative
closest to zero, in place, taking the modulus by reference.
See the documentation for the BalancedMod implementation on IntegerVector that takes
both arguments by value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::BalancedModAssign;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, 27, -23, -5)").unwrap();
v.balanced_mod_assign(&Integer::from(10));
assert_eq!(v.to_string(), "(1, -3, -3, 5)");
let mut v = IntegerVector::from_str("(10, 7)").unwrap();
v.balanced_mod_assign(&Integer::from(-10));
assert_eq!(v.to_string(), "(0, -3)");Source§impl BalancedModAssign<Integer> for IntegerVector
impl BalancedModAssign<Integer> for IntegerVector
Source§fn balanced_mod_assign(&mut self, m: Integer)
fn balanced_mod_assign(&mut self, m: Integer)
Reduces every element of an IntegerVector modulo an Integer to the representative
closest to zero, in place, taking the modulus by value.
See the documentation for the BalancedMod implementation on IntegerVector that takes
both arguments by value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::BalancedModAssign;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, 27, -23, -5)").unwrap();
v.balanced_mod_assign(Integer::from(10));
assert_eq!(v.to_string(), "(1, -3, -3, 5)");
let mut v = IntegerVector::from_str("(10, 7)").unwrap();
v.balanced_mod_assign(Integer::from(-10));
assert_eq!(v.to_string(), "(0, -3)");Source§impl BalancedModPowerOf2 for IntegerVector
impl BalancedModPowerOf2 for IntegerVector
Source§fn balanced_mod_power_of_2(self, pow: u64) -> Self
fn balanced_mod_power_of_2(self, pow: u64) -> Self
Reduces every element of an IntegerVector modulo $2^k$ to the representative closest to
zero, taking the vector by value.
Each element $r_i$ of the result satisfies $-2^{k-1} < r_i \leq 2^{k-1}$ and is congruent to
the original element modulo $2^k$, which determine it uniquely, as with
BalancedModPowerOf2 for Integers; for $k = 0$ every element
is 0. A remainder of exactly $2^{k-1}$ is positive.
The dimension is unchanged: unlike a polynomial, a vector keeps the elements that reduce to zero.
§Worst-case complexity
$T(n, m) = O(nm)$
$M(n, m) = O(nm)$
where $T$ is time, $M$ is additional memory, $n$ is the number of elements, and $m$ is
pow.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::BalancedModPowerOf2;
use malachite_nz::integer_vector::IntegerVector;
// Each element goes to its balanced remainder modulo 8, and half the modulus
// stays positive.
let v = IntegerVector::from_str("(-19, 23, -20)").unwrap();
assert_eq!(
v.clone().balanced_mod_power_of_2(3).to_string(),
"(-3, -1, 4)"
);
let v = IntegerVector::from_str("(-8, 7)").unwrap();
assert_eq!(v.clone().balanced_mod_power_of_2(3).to_string(), "(0, -1)");type Output = IntegerVector
Source§impl BalancedModPowerOf2 for &IntegerVector
impl BalancedModPowerOf2 for &IntegerVector
Source§fn balanced_mod_power_of_2(self, pow: u64) -> IntegerVector
fn balanced_mod_power_of_2(self, pow: u64) -> IntegerVector
Reduces every element of an IntegerVector modulo $2^k$ to the representative closest to
zero, taking the vector by reference.
See the documentation for the BalancedModPowerOf2 implementation on IntegerVector
that takes the vector by value for details.
§Worst-case complexity
$T(n, m) = O(nm)$
$M(n, m) = O(nm)$
where $T$ is time, $M$ is additional memory, $n$ is the number of elements, and $m$ is
pow.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::BalancedModPowerOf2;
use malachite_nz::integer_vector::IntegerVector;
// Each element goes to its balanced remainder modulo 8, and half the modulus
// stays positive.
let v = IntegerVector::from_str("(-19, 23, -20)").unwrap();
assert_eq!((&v).balanced_mod_power_of_2(3).to_string(), "(-3, -1, 4)");
let v = IntegerVector::from_str("(-8, 7)").unwrap();
assert_eq!((&v).balanced_mod_power_of_2(3).to_string(), "(0, -1)");type Output = IntegerVector
Source§impl BalancedModPowerOf2Assign for IntegerVector
impl BalancedModPowerOf2Assign for IntegerVector
Source§fn balanced_mod_power_of_2_assign(&mut self, pow: u64)
fn balanced_mod_power_of_2_assign(&mut self, pow: u64)
Reduces every element of an IntegerVector modulo $2^k$ to the representative closest to
zero, in place.
See the documentation for the BalancedModPowerOf2 implementation on IntegerVector
that takes the vector by value for details.
§Worst-case complexity
$T(n, m) = O(nm)$
$M(n, m) = O(m)$
where $T$ is time, $M$ is additional memory, $n$ is the number of elements, and $m$ is
pow.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::BalancedModPowerOf2Assign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(-19, 23, -20)").unwrap();
v.balanced_mod_power_of_2_assign(3);
assert_eq!(v.to_string(), "(-3, -1, 4)");Source§impl CanonicalPrimitivePart for IntegerVector
impl CanonicalPrimitivePart for IntegerVector
Source§fn canonical_primitive_part(self) -> Self
fn canonical_primitive_part(self) -> Self
Computes the canonical primitive part of an IntegerVector, taking the vector by value.
This is the
primitive_part,
negated if its first nonzero element is negative, so that the first nonzero element is
positive. A vector and its negation have the same canonical primitive part. The canonical
primitive part of a vector of zeros is itself, keeping its dimension.
$$ v = \pm \operatorname{cont}(v) \operatorname{cpp}(v). $$
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::CanonicalPrimitivePart;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
assert_eq!(v.canonical_primitive_part().to_string(), "(3, -2, 5)");
// Leading zeros are skipped: the first nonzero element is made positive.
let v = IntegerVector::from_str("(0, -2, 4)").unwrap();
assert_eq!(v.canonical_primitive_part().to_string(), "(0, 1, -2)");type Output = IntegerVector
Source§impl CanonicalPrimitivePart for &IntegerVector
impl CanonicalPrimitivePart for &IntegerVector
Source§fn canonical_primitive_part(self) -> IntegerVector
fn canonical_primitive_part(self) -> IntegerVector
Computes the canonical primitive part of an IntegerVector, taking the vector by
reference.
This is the
primitive_part,
negated if its first nonzero element is negative, so that the first nonzero element is
positive. A vector and its negation have the same canonical primitive part. The canonical
primitive part of a vector of zeros is itself, keeping its dimension.
$$ v = \pm \operatorname{cont}(v) \operatorname{cpp}(v). $$
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::CanonicalPrimitivePart;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
assert_eq!((&v).canonical_primitive_part().to_string(), "(3, -2, 5)");type Output = IntegerVector
Source§impl CanonicalPrimitivePartAssign for IntegerVector
impl CanonicalPrimitivePartAssign for IntegerVector
Source§fn canonical_primitive_part_assign(&mut self)
fn canonical_primitive_part_assign(&mut self)
Replaces an IntegerVector with its canonical primitive part.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::CanonicalPrimitivePartAssign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
v.canonical_primitive_part_assign();
assert_eq!(v.to_string(), "(3, -2, 5)");Source§impl CanonicalizeSign for IntegerVector
impl CanonicalizeSign for IntegerVector
Source§fn canonicalize_sign(self) -> Self
fn canonicalize_sign(self) -> Self
Brings an IntegerVector into canonical sign form, taking the vector by value: negates it
if its pivot, its first nonzero element, is negative.
A vector and its negation are the same up to multiplication by $\pm 1$, the units of the integers, and this picks the one whose pivot is positive to represent both. A vector of zeros has no pivot and is left alone.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::CanonicalizeSign;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(0, -2, 3)").unwrap();
assert_eq!(v.canonicalize_sign().to_string(), "(0, 2, -3)");
let v = IntegerVector::from_str("(0, 2, -3)").unwrap();
assert_eq!(v.canonicalize_sign().to_string(), "(0, 2, -3)");type Output = IntegerVector
Source§impl CanonicalizeSign for &IntegerVector
impl CanonicalizeSign for &IntegerVector
Source§fn canonicalize_sign(self) -> IntegerVector
fn canonicalize_sign(self) -> IntegerVector
Brings an IntegerVector into canonical sign form, taking the vector by reference:
negates it if its pivot, its first nonzero element, is negative.
See the documentation for the CanonicalizeSign implementation on IntegerVector.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::CanonicalizeSign;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(0, -2, 3)").unwrap();
assert_eq!((&v).canonicalize_sign().to_string(), "(0, 2, -3)");type Output = IntegerVector
Source§impl CanonicalizeSignAssign for IntegerVector
impl CanonicalizeSignAssign for IntegerVector
Source§fn canonicalize_sign_assign(&mut self)
fn canonicalize_sign_assign(&mut self)
Replaces an IntegerVector with its canonical sign form: negates it if its pivot, its
first nonzero element, is negative.
See the documentation for the CanonicalizeSign implementation on IntegerVector.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::CanonicalizeSignAssign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(0, -2, 3)").unwrap();
v.canonicalize_sign_assign();
assert_eq!(v.to_string(), "(0, 2, -3)");Source§impl Clone for IntegerVector
impl Clone for IntegerVector
Source§impl Content for IntegerVector
impl Content for IntegerVector
Source§fn content(self) -> Natural
fn content(self) -> Natural
Computes the content of an IntegerVector, the GCD of its elements, taking the vector by
value.
The content of the 0-dimensional vector, and of a vector of zeros, is zero. The GCD is taken element by element, stopping early once it reaches 1.
$$ f(v) = \gcd(v_0, v_1, \ldots, v_{n-1}), $$
where $n$ is the dimension of $v$.
The content is the GCD of the absolute values, so it is non-negative.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Content;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
assert_eq!(v.content(), 2u32);
assert_eq!(IntegerVector::from_str("()").unwrap().content(), 0u32);This is equivalent to _fmpz_vec_content from fmpz_vec/content.c, FLINT 3.6.0.
type Output = Natural
Source§impl Content for &IntegerVector
impl Content for &IntegerVector
Source§fn content(self) -> Natural
fn content(self) -> Natural
Computes the content of an IntegerVector, the GCD of its elements, taking the vector by
reference.
The content of the 0-dimensional vector, and of a vector of zeros, is zero. The GCD is taken element by element, stopping early once it reaches 1.
$$ f(v) = \gcd(v_0, v_1, \ldots, v_{n-1}), $$
where $n$ is the dimension of $v$.
The content is the GCD of the absolute values, so it is non-negative.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Content;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
assert_eq!((&v).content(), 2u32);
assert_eq!(
(&IntegerVector::from_str("(0, 0)").unwrap()).content(),
0u32
);This is equivalent to _fmpz_vec_content from fmpz_vec/content.c, FLINT 3.6.0.
type Output = Natural
Source§impl ContentAndCanonicalPrimitivePart for IntegerVector
impl ContentAndCanonicalPrimitivePart for IntegerVector
Source§fn content_and_canonical_primitive_part(self) -> (Natural, Self)
fn content_and_canonical_primitive_part(self) -> (Natural, Self)
Computes the content and the canonical primitive part of an IntegerVector together,
taking the vector by value.
See content and
canonical_primitive_part; the content
is found once rather than twice.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ContentAndCanonicalPrimitivePart;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
let (content, primitive_part) = v.content_and_canonical_primitive_part();
assert_eq!(content, 2u32);
assert_eq!(primitive_part.to_string(), "(3, -2, 5)");type Content = Natural
type CanonicalPrimitivePart = IntegerVector
Source§impl ContentAndCanonicalPrimitivePart for &IntegerVector
impl ContentAndCanonicalPrimitivePart for &IntegerVector
Source§fn content_and_canonical_primitive_part(self) -> (Natural, IntegerVector)
fn content_and_canonical_primitive_part(self) -> (Natural, IntegerVector)
Computes the content and the canonical primitive part of an IntegerVector together,
taking the vector by reference.
See content and
canonical_primitive_part; the content
is found once rather than twice.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ContentAndCanonicalPrimitivePart;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
let (content, primitive_part) = (&v).content_and_canonical_primitive_part();
assert_eq!(content, 2u32);
assert_eq!(primitive_part.to_string(), "(3, -2, 5)");type Content = Natural
type CanonicalPrimitivePart = IntegerVector
Source§impl ContentAndPrimitivePart for IntegerVector
impl ContentAndPrimitivePart for IntegerVector
Source§fn content_and_primitive_part(self) -> (Natural, Self)
fn content_and_primitive_part(self) -> (Natural, Self)
Computes the content and the primitive part of an IntegerVector together, taking the
vector by value.
See content and primitive_part; the
content is found once rather than twice.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ContentAndPrimitivePart;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
let (content, primitive_part) = v.content_and_primitive_part();
assert_eq!(content, 2u32);
assert_eq!(primitive_part.to_string(), "(-3, 2, -5)");type Content = Natural
type PrimitivePart = IntegerVector
Source§impl ContentAndPrimitivePart for &IntegerVector
impl ContentAndPrimitivePart for &IntegerVector
Source§fn content_and_primitive_part(self) -> (Natural, IntegerVector)
fn content_and_primitive_part(self) -> (Natural, IntegerVector)
Computes the content and the primitive part of an IntegerVector together, taking the
vector by reference.
See content and primitive_part; the
content is found once rather than twice.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ContentAndPrimitivePart;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
let (content, primitive_part) = (&v).content_and_primitive_part();
assert_eq!(content, 2u32);
assert_eq!(primitive_part.to_string(), "(-3, 2, -5)");type Content = Natural
type PrimitivePart = IntegerVector
Source§impl ContentChained<&Natural> for IntegerVector
impl ContentChained<&Natural> for IntegerVector
Source§fn content_chained(self, x: &Natural) -> Natural
fn content_chained(self, x: &Natural) -> Natural
Computes the GCD of x and the elements of an IntegerVector, taking the vector by value
and x by reference.
The GCD of x and the elements of the 0-dimensional vector, or of a vector of zeros, is
x. The computation stops as soon as the GCD reaches 1.
$$ f(v, x) = \gcd(x, v_0, v_1, \ldots, v_{n-1}), $$
where $n$ is the dimension of $v$.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of x.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ContentChained;
use malachite_base::num::basic::traits::Zero;
use malachite_nz::integer_vector::IntegerVector;
use malachite_nz::natural::Natural;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
assert_eq!(v.clone().content_chained(&Natural::from(4u32)), 2u32);
assert_eq!(v.content_chained(&Natural::ZERO), 2u32);
let v = IntegerVector::from_str("()").unwrap();
assert_eq!(v.content_chained(&Natural::from(6u32)), 6u32);This is equivalent to _fmpz_vec_content_chained from fmpz_vec/content_chained.c, FLINT
3.6.0.
type Output = Natural
Source§impl ContentChained<&Natural> for &IntegerVector
impl ContentChained<&Natural> for &IntegerVector
Source§fn content_chained(self, x: &Natural) -> Natural
fn content_chained(self, x: &Natural) -> Natural
Computes the GCD of x and the elements of an IntegerVector, taking the vector by
reference and x by reference.
The GCD of x and the elements of the 0-dimensional vector, or of a vector of zeros, is
x. The computation stops as soon as the GCD reaches 1.
$$ f(v, x) = \gcd(x, v_0, v_1, \ldots, v_{n-1}), $$
where $n$ is the dimension of $v$.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of x.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ContentChained;
use malachite_base::num::basic::traits::Zero;
use malachite_nz::integer_vector::IntegerVector;
use malachite_nz::natural::Natural;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
assert_eq!((&v).content_chained(&Natural::from(4u32)), 2u32);
assert_eq!((&v).content_chained(&Natural::ZERO), 2u32);
let v = IntegerVector::from_str("()").unwrap();
assert_eq!((&v).content_chained(&Natural::from(6u32)), 6u32);This is equivalent to _fmpz_vec_content_chained from fmpz_vec/content_chained.c, FLINT
3.6.0.
type Output = Natural
Source§impl ContentChained<Natural> for IntegerVector
impl ContentChained<Natural> for IntegerVector
Source§fn content_chained(self, x: Natural) -> Natural
fn content_chained(self, x: Natural) -> Natural
Computes the GCD of x and the elements of an IntegerVector, taking the vector by value
and x by value.
The GCD of x and the elements of the 0-dimensional vector, or of a vector of zeros, is
x. The computation stops as soon as the GCD reaches 1.
$$ f(v, x) = \gcd(x, v_0, v_1, \ldots, v_{n-1}), $$
where $n$ is the dimension of $v$.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of x.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ContentChained;
use malachite_base::num::basic::traits::Zero;
use malachite_nz::integer_vector::IntegerVector;
use malachite_nz::natural::Natural;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
assert_eq!(v.clone().content_chained(Natural::from(4u32)), 2u32);
assert_eq!(v.content_chained(Natural::ZERO), 2u32);
let v = IntegerVector::from_str("()").unwrap();
assert_eq!(v.content_chained(Natural::from(6u32)), 6u32);This is equivalent to _fmpz_vec_content_chained from fmpz_vec/content_chained.c, FLINT
3.6.0.
type Output = Natural
Source§impl ContentChained<Natural> for &IntegerVector
impl ContentChained<Natural> for &IntegerVector
Source§fn content_chained(self, x: Natural) -> Natural
fn content_chained(self, x: Natural) -> Natural
Computes the GCD of x and the elements of an IntegerVector, taking the vector by
reference and x by value.
The GCD of x and the elements of the 0-dimensional vector, or of a vector of zeros, is
x. The computation stops as soon as the GCD reaches 1.
$$ f(v, x) = \gcd(x, v_0, v_1, \ldots, v_{n-1}), $$
where $n$ is the dimension of $v$.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of x.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ContentChained;
use malachite_base::num::basic::traits::Zero;
use malachite_nz::integer_vector::IntegerVector;
use malachite_nz::natural::Natural;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
assert_eq!((&v).content_chained(Natural::from(4u32)), 2u32);
assert_eq!((&v).content_chained(Natural::ZERO), 2u32);
let v = IntegerVector::from_str("()").unwrap();
assert_eq!((&v).content_chained(Natural::from(6u32)), 6u32);This is equivalent to _fmpz_vec_content_chained from fmpz_vec/content_chained.c, FLINT
3.6.0.
type Output = Natural
Source§impl ConvertibleFrom<&IntegerVector> for NaturalVector
impl ConvertibleFrom<&IntegerVector> for NaturalVector
Source§fn convertible_from(v: &IntegerVector) -> bool
fn convertible_from(v: &IntegerVector) -> bool
Determines whether an IntegerVector can be converted to a NaturalVector (when none
of its elements is negative). Takes the IntegerVector by reference.
Unlike checking whether TryFrom succeeds, this allocates nothing.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is v.dimension().
§Examples
See here.
Source§impl<T: PrimitiveUnsigned + for<'a> ConvertibleFrom<&'a Integer>> ConvertibleFrom<&IntegerVector> for UnsignedVector<T>
impl<T: PrimitiveUnsigned + for<'a> ConvertibleFrom<&'a Integer>> ConvertibleFrom<&IntegerVector> for UnsignedVector<T>
Source§fn convertible_from(v: &IntegerVector) -> bool
fn convertible_from(v: &IntegerVector) -> bool
Determines whether an IntegerVector can be converted to an UnsignedVector (when
every element is representable as a T). Takes the IntegerVector by reference.
Unlike checking whether TryFrom succeeds, this allocates nothing.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is v.dimension().
§Examples
See here.
Source§impl Debug for IntegerVector
impl Debug for IntegerVector
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Converts an IntegerVector to a String.
This is the same as the Display::fmt implementation, so that a collection of
IntegerVectors is written the same way its elements are displayed.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the sum of the bits of the elements.
§Examples
use malachite_base::strings::ToDebugString;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let xs = vec![
IntegerVector {
elements: vec![Integer::from(1u32), Integer::from(2u32)],
},
IntegerVector {
elements: Vec::new(),
},
];
assert_eq!(xs[0].to_debug_string(), "(1, 2)");
assert_eq!(xs.to_debug_string(), "[(1, 2), ()]");Source§impl Display for IntegerVector
impl Display for IntegerVector
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Converts an IntegerVector to a String.
The elements are written in order, separated by , and enclosed in parentheses, as a
vector’s coordinates are written by hand. The 0-dimensional vector is ().
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the sum of the bits of the elements.
§Examples
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector {
elements: vec![Integer::from(1u32), Integer::from(2u32), Integer::from(3u32)],
};
assert_eq!(v.to_string(), "(1, 2, 3)");
assert_eq!(
IntegerVector {
elements: vec![Integer::from(5u32)]
}
.to_string(),
"(5)"
);
assert_eq!(
IntegerVector {
elements: Vec::new()
}
.to_string(),
"()"
);Source§impl Div<&Integer> for IntegerVector
impl Div<&Integer> for IntegerVector
Source§fn div(self, c: &Integer) -> Self
fn div(self, c: &Integer) -> Self
Divides every element of an IntegerVector by an Integer, taking the vector by value
and the scalar by reference.
The quotient is taken element by element, so the result has the same dimension as the vector.
Each quotient is rounded toward zero, as by Div on Integers.
$$ f(v, c)_i = \operatorname{sgn}(cv_i) \left\lfloor \left|\frac{v_i}{c}\right| \right\rfloor. $$
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements of elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_tdiv_q_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
/ operator.Source§impl Div<&Integer> for &IntegerVector
impl Div<&Integer> for &IntegerVector
Source§fn div(self, c: &Integer) -> IntegerVector
fn div(self, c: &Integer) -> IntegerVector
Divides every element of an IntegerVector by an Integer, taking the vector by
reference and the scalar by reference.
The quotient is taken element by element, so the result has the same dimension as the vector.
Each quotient is rounded toward zero, as by Div on Integers.
$$ f(v, c)_i = \operatorname{sgn}(cv_i) \left\lfloor \left|\frac{v_i}{c}\right| \right\rfloor. $$
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements of elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_tdiv_q_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
/ operator.Source§impl Div<Integer> for IntegerVector
impl Div<Integer> for IntegerVector
Source§fn div(self, c: Integer) -> Self
fn div(self, c: Integer) -> Self
Divides every element of an IntegerVector by an Integer, taking the vector by value
and the scalar by value.
The quotient is taken element by element, so the result has the same dimension as the vector.
Each quotient is rounded toward zero, as by Div on Integers.
$$ f(v, c)_i = \operatorname{sgn}(cv_i) \left\lfloor \left|\frac{v_i}{c}\right| \right\rfloor. $$
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements of elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_tdiv_q_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
/ operator.Source§impl Div<Integer> for &IntegerVector
impl Div<Integer> for &IntegerVector
Source§fn div(self, c: Integer) -> IntegerVector
fn div(self, c: Integer) -> IntegerVector
Divides every element of an IntegerVector by an Integer, taking the vector by
reference and the scalar by value.
The quotient is taken element by element, so the result has the same dimension as the vector.
Each quotient is rounded toward zero, as by Div on Integers.
$$ f(v, c)_i = \operatorname{sgn}(cv_i) \left\lfloor \left|\frac{v_i}{c}\right| \right\rfloor. $$
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements of elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_tdiv_q_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
/ operator.Source§impl DivAssign<&Integer> for IntegerVector
impl DivAssign<&Integer> for IntegerVector
Source§fn div_assign(&mut self, c: &Integer)
fn div_assign(&mut self, c: &Integer)
Divides every element of an IntegerVector by an Integer, in place, taking the scalar
by reference.
Every element is divided by c.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements of elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_tdiv_q_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl DivAssign<Integer> for IntegerVector
impl DivAssign<Integer> for IntegerVector
Source§fn div_assign(&mut self, c: Integer)
fn div_assign(&mut self, c: Integer)
Divides every element of an IntegerVector by an Integer, in place, taking the scalar
by value.
Every element is divided by c.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements of elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_tdiv_q_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl DivExact<&Integer> for IntegerVector
impl DivExact<&Integer> for IntegerVector
Source§fn div_exact(self, c: &Integer) -> Self
fn div_exact(self, c: &Integer) -> Self
Divides every element of an IntegerVector by an Integer, taking the vector by value
and the Integer by reference. Every element must be exactly divisible by the Integer.
If some element is not exactly divisible by c, this function may panic or return a
meaningless result. Dividing by 1 returns the vector unchanged, and dividing by $-1$ negates
it.
$f(v, c) = v/c$.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_divexact_fmpz from fmpz_vec/scalar_divexact.c,
FLINT 3.6.0.
type Output = IntegerVector
Source§impl DivExact<&Integer> for &IntegerVector
impl DivExact<&Integer> for &IntegerVector
Source§fn div_exact(self, c: &Integer) -> IntegerVector
fn div_exact(self, c: &Integer) -> IntegerVector
Divides every element of an IntegerVector by an Integer, taking the vector by
reference and the Integer by reference. Every element must be exactly divisible by the
Integer.
If some element is not exactly divisible by c, this function may panic or return a
meaningless result. Dividing by 1 returns the vector unchanged, and dividing by $-1$ negates
it.
$f(v, c) = v/c$.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_divexact_fmpz from fmpz_vec/scalar_divexact.c,
FLINT 3.6.0.
type Output = IntegerVector
Source§impl DivExact<Integer> for IntegerVector
impl DivExact<Integer> for IntegerVector
Source§fn div_exact(self, c: Integer) -> Self
fn div_exact(self, c: Integer) -> Self
Divides every element of an IntegerVector by an Integer, taking the vector by value
and the Integer by value. Every element must be exactly divisible by the Integer.
If some element is not exactly divisible by c, this function may panic or return a
meaningless result. Dividing by 1 returns the vector unchanged, and dividing by $-1$ negates
it.
$f(v, c) = v/c$.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_divexact_fmpz from fmpz_vec/scalar_divexact.c,
FLINT 3.6.0.
type Output = IntegerVector
Source§impl DivExact<Integer> for &IntegerVector
impl DivExact<Integer> for &IntegerVector
Source§fn div_exact(self, c: Integer) -> IntegerVector
fn div_exact(self, c: Integer) -> IntegerVector
Divides every element of an IntegerVector by an Integer, taking the vector by
reference and the Integer by value. Every element must be exactly divisible by the
Integer.
If some element is not exactly divisible by c, this function may panic or return a
meaningless result. Dividing by 1 returns the vector unchanged, and dividing by $-1$ negates
it.
$f(v, c) = v/c$.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_divexact_fmpz from fmpz_vec/scalar_divexact.c,
FLINT 3.6.0.
type Output = IntegerVector
Source§impl DivExactAssign<&Integer> for IntegerVector
impl DivExactAssign<&Integer> for IntegerVector
Source§fn div_exact_assign(&mut self, c: &Integer)
fn div_exact_assign(&mut self, c: &Integer)
Divides every element of an IntegerVector by an Integer, in place, taking the
Integer by reference. Every element must be exactly divisible by the Integer.
If some element is not exactly divisible by c, this function may panic or return a
meaningless result. Dividing by 1 returns the vector unchanged, and dividing by $-1$ negates
it.
$v \gets v/c$.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_divexact_fmpz from fmpz_vec/scalar_divexact.c,
FLINT 3.6.0.
Source§impl DivExactAssign<Integer> for IntegerVector
impl DivExactAssign<Integer> for IntegerVector
Source§fn div_exact_assign(&mut self, c: Integer)
fn div_exact_assign(&mut self, c: Integer)
Divides every element of an IntegerVector by an Integer, in place, taking the
Integer by value. Every element must be exactly divisible by the Integer.
If some element is not exactly divisible by c, this function may panic or return a
meaningless result. Dividing by 1 returns the vector unchanged, and dividing by $-1$ negates
it.
$v \gets v/c$.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_divexact_fmpz from fmpz_vec/scalar_divexact.c,
FLINT 3.6.0.
Source§impl Dot for IntegerVector
impl Dot for IntegerVector
Source§fn dot(self, other: Self) -> Integer
fn dot(self, other: Self) -> Integer
Computes the dot product of two IntegerVectors, taking the first by value and the second
by value.
The dot product is the sum of the products of corresponding elements, and is 0 for two 0-dimensional vectors.
$$ f(v, w) = \sum_{i=0}^{n-1} v_iw_i, $$
where $n$ is the dimension of $v$ and $w$.
§Worst-case complexity
$T(n, m) = O(nm \log m \log\log m)$
$M(m) = O(m \log m)$
where $T$ is time, $M$ is additional memory, $n$ is the dimension of the vectors, and $m$ is the largest number of significant bits of any element.
§Panics
Panics if the vectors have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Dot;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(v.clone().dot(w.clone()), -24);
assert_eq!(
IntegerVector::from_str("()")
.unwrap()
.dot(IntegerVector::from_str("()").unwrap()),
0
);This is equivalent to _fmpz_vec_dot from fmpz_vec/dot.c, FLINT 3.6.0.
type Output = Integer
Source§impl Dot<&IntegerVector> for IntegerVector
impl Dot<&IntegerVector> for IntegerVector
Source§fn dot(self, other: &Self) -> Integer
fn dot(self, other: &Self) -> Integer
Computes the dot product of two IntegerVectors, taking the first by value and the second
by reference.
The dot product is the sum of the products of corresponding elements, and is 0 for two 0-dimensional vectors.
$$ f(v, w) = \sum_{i=0}^{n-1} v_iw_i, $$
where $n$ is the dimension of $v$ and $w$.
§Worst-case complexity
$T(n, m) = O(nm \log m \log\log m)$
$M(m) = O(m \log m)$
where $T$ is time, $M$ is additional memory, $n$ is the dimension of the vectors, and $m$ is the largest number of significant bits of any element.
§Panics
Panics if the vectors have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Dot;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(v.clone().dot(&w), -24);
assert_eq!(
IntegerVector::from_str("()")
.unwrap()
.dot(IntegerVector::from_str("()").unwrap()),
0
);This is equivalent to _fmpz_vec_dot from fmpz_vec/dot.c, FLINT 3.6.0.
type Output = Integer
Source§impl Dot<&IntegerVector> for &IntegerVector
impl Dot<&IntegerVector> for &IntegerVector
Source§fn dot(self, other: &IntegerVector) -> Integer
fn dot(self, other: &IntegerVector) -> Integer
Computes the dot product of two IntegerVectors, taking the first by reference and the
second by reference.
The dot product is the sum of the products of corresponding elements, and is 0 for two 0-dimensional vectors.
$$ f(v, w) = \sum_{i=0}^{n-1} v_iw_i, $$
where $n$ is the dimension of $v$ and $w$.
§Worst-case complexity
$T(n, m) = O(nm \log m \log\log m)$
$M(m) = O(m \log m)$
where $T$ is time, $M$ is additional memory, $n$ is the dimension of the vectors, and $m$ is the largest number of significant bits of any element.
§Panics
Panics if the vectors have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Dot;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!((&v).dot(&w), -24);
assert_eq!(
IntegerVector::from_str("()")
.unwrap()
.dot(IntegerVector::from_str("()").unwrap()),
0
);This is equivalent to _fmpz_vec_dot from fmpz_vec/dot.c, FLINT 3.6.0.
type Output = Integer
Source§impl Dot<IntegerVector> for &IntegerVector
impl Dot<IntegerVector> for &IntegerVector
Source§fn dot(self, other: IntegerVector) -> Integer
fn dot(self, other: IntegerVector) -> Integer
Computes the dot product of two IntegerVectors, taking the first by reference and the
second by value.
The dot product is the sum of the products of corresponding elements, and is 0 for two 0-dimensional vectors.
$$ f(v, w) = \sum_{i=0}^{n-1} v_iw_i, $$
where $n$ is the dimension of $v$ and $w$.
§Worst-case complexity
$T(n, m) = O(nm \log m \log\log m)$
$M(m) = O(m \log m)$
where $T$ is time, $M$ is additional memory, $n$ is the dimension of the vectors, and $m$ is the largest number of significant bits of any element.
§Panics
Panics if the vectors have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Dot;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!((&v).dot(w.clone()), -24);
assert_eq!(
IntegerVector::from_str("()")
.unwrap()
.dot(IntegerVector::from_str("()").unwrap()),
0
);This is equivalent to _fmpz_vec_dot from fmpz_vec/dot.c, FLINT 3.6.0.
type Output = Integer
Source§impl DotSign for IntegerVector
impl DotSign for IntegerVector
Source§fn dot_sign(self, other: Self) -> Ordering
fn dot_sign(self, other: Self) -> Ordering
Determines the sign of the dot product of two IntegerVectors, taking the first by value
and the second by value.
The result is the ordering of the dot product against 0. It is found with as few
multiplications as possible. For two-dimensional vectors it is
Integer::cmp_products_neg on
the two pairs of elements. Otherwise the terms are split by sign, and when one side is
empty, when there is one term on each side (compared through
Natural::cmp_products), or when
the bit lengths of the largest terms on the two sides are far enough apart, no product is
formed at all; nor is one when the largest term alone outweighs all the others. Otherwise,
if the largest term’s product is at least twice as wide as any other, the dot product of the
other terms is computed and the largest term is weighed against it by
Integer::cmp_product_neg, which
forms that product only if it must; if not, the whole dot product is computed.
$$ f(v, w) = \operatorname{sgn}\left ( \sum_{i=0}^{n-1} v_iw_i \right ), $$
where $n$ is the dimension of $v$ and $w$.
§Worst-case complexity
$T(n, m) = O(nm \log m \log\log m)$
$M(m) = O(m \log m)$
where $T$ is time, $M$ is additional memory, $n$ is the dimension of the vectors, and $m$ is the largest number of significant bits of any element.
§Panics
Panics if the vectors have different dimensions.
§Examples
use core::cmp::Ordering::*;
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::DotSign;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(3, 7)").unwrap();
let w = IntegerVector::from_str("(8, -3)").unwrap();
assert_eq!(v.clone().dot_sign(w.clone()), Greater);
let w = IntegerVector::from_str("(7, -3)").unwrap();
assert_eq!(v.clone().dot_sign(w.clone()), Equal);Source§impl DotSign<&IntegerVector> for IntegerVector
impl DotSign<&IntegerVector> for IntegerVector
Source§fn dot_sign(self, other: &Self) -> Ordering
fn dot_sign(self, other: &Self) -> Ordering
Determines the sign of the dot product of two IntegerVectors, taking the first by value
and the second by reference.
The result is the ordering of the dot product against 0. It is found with as few
multiplications as possible. For two-dimensional vectors it is
Integer::cmp_products_neg on
the two pairs of elements. Otherwise the terms are split by sign, and when one side is
empty, when there is one term on each side (compared through
Natural::cmp_products), or when
the bit lengths of the largest terms on the two sides are far enough apart, no product is
formed at all; nor is one when the largest term alone outweighs all the others. Otherwise,
if the largest term’s product is at least twice as wide as any other, the dot product of the
other terms is computed and the largest term is weighed against it by
Integer::cmp_product_neg, which
forms that product only if it must; if not, the whole dot product is computed.
$$ f(v, w) = \operatorname{sgn}\left ( \sum_{i=0}^{n-1} v_iw_i \right ), $$
where $n$ is the dimension of $v$ and $w$.
§Worst-case complexity
$T(n, m) = O(nm \log m \log\log m)$
$M(m) = O(m \log m)$
where $T$ is time, $M$ is additional memory, $n$ is the dimension of the vectors, and $m$ is the largest number of significant bits of any element.
§Panics
Panics if the vectors have different dimensions.
§Examples
use core::cmp::Ordering::*;
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::DotSign;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(3, 7)").unwrap();
let w = IntegerVector::from_str("(8, -3)").unwrap();
assert_eq!(v.clone().dot_sign(&w), Greater);
let w = IntegerVector::from_str("(7, -3)").unwrap();
assert_eq!(v.clone().dot_sign(&w), Equal);Source§impl DotSign<&IntegerVector> for &IntegerVector
impl DotSign<&IntegerVector> for &IntegerVector
Source§fn dot_sign(self, other: &IntegerVector) -> Ordering
fn dot_sign(self, other: &IntegerVector) -> Ordering
Determines the sign of the dot product of two IntegerVectors, taking the first by
reference and the second by reference.
The result is the ordering of the dot product against 0. It is found with as few
multiplications as possible. For two-dimensional vectors it is
Integer::cmp_products_neg on
the two pairs of elements. Otherwise the terms are split by sign, and when one side is
empty, when there is one term on each side (compared through
Natural::cmp_products), or when
the bit lengths of the largest terms on the two sides are far enough apart, no product is
formed at all; nor is one when the largest term alone outweighs all the others. Otherwise,
if the largest term’s product is at least twice as wide as any other, the dot product of the
other terms is computed and the largest term is weighed against it by
Integer::cmp_product_neg, which
forms that product only if it must; if not, the whole dot product is computed.
$$ f(v, w) = \operatorname{sgn}\left ( \sum_{i=0}^{n-1} v_iw_i \right ), $$
where $n$ is the dimension of $v$ and $w$.
§Worst-case complexity
$T(n, m) = O(nm \log m \log\log m)$
$M(m) = O(m \log m)$
where $T$ is time, $M$ is additional memory, $n$ is the dimension of the vectors, and $m$ is the largest number of significant bits of any element.
§Panics
Panics if the vectors have different dimensions.
§Examples
use core::cmp::Ordering::*;
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::DotSign;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(3, 7)").unwrap();
let w = IntegerVector::from_str("(8, -3)").unwrap();
assert_eq!((&v).dot_sign(&w), Greater);
let w = IntegerVector::from_str("(7, -3)").unwrap();
assert_eq!((&v).dot_sign(&w), Equal);Source§impl DotSign<IntegerVector> for &IntegerVector
impl DotSign<IntegerVector> for &IntegerVector
Source§fn dot_sign(self, other: IntegerVector) -> Ordering
fn dot_sign(self, other: IntegerVector) -> Ordering
Determines the sign of the dot product of two IntegerVectors, taking the first by
reference and the second by value.
The result is the ordering of the dot product against 0. It is found with as few
multiplications as possible. For two-dimensional vectors it is
Integer::cmp_products_neg on
the two pairs of elements. Otherwise the terms are split by sign, and when one side is
empty, when there is one term on each side (compared through
Natural::cmp_products), or when
the bit lengths of the largest terms on the two sides are far enough apart, no product is
formed at all; nor is one when the largest term alone outweighs all the others. Otherwise,
if the largest term’s product is at least twice as wide as any other, the dot product of the
other terms is computed and the largest term is weighed against it by
Integer::cmp_product_neg, which
forms that product only if it must; if not, the whole dot product is computed.
$$ f(v, w) = \operatorname{sgn}\left ( \sum_{i=0}^{n-1} v_iw_i \right ), $$
where $n$ is the dimension of $v$ and $w$.
§Worst-case complexity
$T(n, m) = O(nm \log m \log\log m)$
$M(m) = O(m \log m)$
where $T$ is time, $M$ is additional memory, $n$ is the dimension of the vectors, and $m$ is the largest number of significant bits of any element.
§Panics
Panics if the vectors have different dimensions.
§Examples
use core::cmp::Ordering::*;
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::DotSign;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(3, 7)").unwrap();
let w = IntegerVector::from_str("(8, -3)").unwrap();
assert_eq!((&v).dot_sign(w.clone()), Greater);
let w = IntegerVector::from_str("(7, -3)").unwrap();
assert_eq!((&v).dot_sign(w.clone()), Equal);Source§impl ElementLcm for IntegerVector
impl ElementLcm for IntegerVector
Source§fn to_element_lcm(&self) -> Natural
fn to_element_lcm(&self) -> Natural
Returns the LCM of the elements of a IntegerVector, taking the vector by reference.
The LCM of the elements of the 0-dimensional vector is 1. If an element is 0 the LCM is 0, and the elements after it are not examined. The LCM is the LCM of the absolute values, so it is non-negative.
$$ f(v) = \operatorname{lcm}(v_0, v_1, \ldots, v_{n-1}), $$
where $n$ is the dimension of $v$.
§Worst-case complexity
$T(n, m) = O(mn (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements, and $m$ is the dimension of the vector.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ElementLcm;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(-4, 6, -10)")
.unwrap()
.to_element_lcm(),
60
);
assert_eq!(
IntegerVector::from_str("(-4, 0, 6)")
.unwrap()
.to_element_lcm(),
0
);
assert_eq!(IntegerVector::from_str("()").unwrap().to_element_lcm(), 1);This is equivalent to _fmpz_vec_lcm from fmpz_vec/lcm.c, FLINT 3.6.0.
Source§fn into_element_lcm(self) -> Natural
fn into_element_lcm(self) -> Natural
Returns the LCM of the elements of a IntegerVector, taking the vector by value.
The LCM of the elements of the 0-dimensional vector is 1. If an element is 0 the LCM is 0, and the elements after it are not examined. The LCM is the LCM of the absolute values, so it is non-negative.
$$ f(v) = \operatorname{lcm}(v_0, v_1, \ldots, v_{n-1}), $$
where $n$ is the dimension of $v$.
§Worst-case complexity
$T(n, m) = O(mn (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements, and $m$ is the dimension of the vector.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ElementLcm;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(-4, 6, -10)")
.unwrap()
.into_element_lcm(),
60
);
assert_eq!(
IntegerVector::from_str("(-4, 0, 6)")
.unwrap()
.into_element_lcm(),
0
);
assert_eq!(IntegerVector::from_str("()").unwrap().into_element_lcm(), 1);This is equivalent to _fmpz_vec_lcm from fmpz_vec/lcm.c, FLINT 3.6.0.
type Output = Natural
Source§impl ElementProduct for IntegerVector
impl ElementProduct for IntegerVector
Source§fn to_element_product(&self) -> Integer
fn to_element_product(&self) -> Integer
Returns the product of the elements of an IntegerVector, taking the vector by reference.
The 0-dimensional vector has no elements, and their product is 1. The elements are multiplied in a balanced tree, so that the operands of each multiplication have similar sizes, and multiplication stops as soon as a zero element is found.
$$ f(v) = \prod_i v_i. $$
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ElementProduct;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(2, -3, 7)")
.unwrap()
.to_element_product(),
-42
);
assert_eq!(
IntegerVector::from_str("()").unwrap().to_element_product(),
1
);This is equivalent to _fmpz_vec_prod from fmpz_vec/prod.c, FLINT 3.6.0.
Source§fn into_element_product(self) -> Integer
fn into_element_product(self) -> Integer
Returns the product of the elements of an IntegerVector, taking the vector by value.
The 0-dimensional vector has no elements, and their product is 1. The elements are multiplied in a balanced tree, so that the operands of each multiplication have similar sizes, and multiplication stops as soon as a zero element is found.
$$ f(v) = \prod_i v_i. $$
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ElementProduct;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(2, -3, 7)")
.unwrap()
.into_element_product(),
-42
);
assert_eq!(
IntegerVector::from_str("()")
.unwrap()
.into_element_product(),
1
);This is equivalent to _fmpz_vec_prod from fmpz_vec/prod.c, FLINT 3.6.0.
type Output = Integer
Source§impl ElementSum for IntegerVector
impl ElementSum for IntegerVector
Source§fn to_element_sum(&self) -> Integer
fn to_element_sum(&self) -> Integer
Returns the sum of the elements of an IntegerVector, taking the vector by reference.
The 0-dimensional vector has no elements, and their sum is 0.
$$ f(v) = \sum_i v_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ElementSum;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -5, 2)")
.unwrap()
.to_element_sum(),
-2
);
assert_eq!(IntegerVector::from_str("()").unwrap().to_element_sum(), 0);This is equivalent to _fmpz_vec_sum from fmpz_vec/sum.c, FLINT 3.6.0.
Source§fn into_element_sum(self) -> Integer
fn into_element_sum(self) -> Integer
Returns the sum of the elements of an IntegerVector, taking the vector by value.
The 0-dimensional vector has no elements, and their sum is 0.
$$ f(v) = \sum_i v_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ElementSum;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -5, 2)")
.unwrap()
.into_element_sum(),
-2
);
assert_eq!(IntegerVector::from_str("()").unwrap().into_element_sum(), 0);This is equivalent to _fmpz_vec_sum from fmpz_vec/sum.c, FLINT 3.6.0.
type Output = Integer
Source§impl EntrywiseAbs for IntegerVector
impl EntrywiseAbs for IntegerVector
Source§fn entrywise_abs(self) -> Self
fn entrywise_abs(self) -> Self
Replaces every element of an IntegerVector by its absolute value, taking the vector by
value.
The dimension is unchanged. This is not Abs, which for a vector would be its Euclidean
length. For the result as a NaturalVector, use EntrywiseUnsignedAbs.
$$ f(v) = (|v_0|, |v_1|, \ldots, |v_{n-1}|). $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseAbs;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 0, -3)").unwrap();
assert_eq!(v.clone().entrywise_abs().to_string(), "(1, 2, 0, 3)");This is equivalent to _fmpz_vec_scalar_abs from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseAbs for &IntegerVector
impl EntrywiseAbs for &IntegerVector
Source§fn entrywise_abs(self) -> IntegerVector
fn entrywise_abs(self) -> IntegerVector
Replaces every element of an IntegerVector by its absolute value, taking the vector by
reference.
See the documentation for the EntrywiseAbs implementation on IntegerVector that
takes the vector by value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseAbs;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 0, -3)").unwrap();
assert_eq!((&v).entrywise_abs().to_string(), "(1, 2, 0, 3)");This is equivalent to _fmpz_vec_scalar_abs from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseAbsAssign for IntegerVector
impl EntrywiseAbsAssign for IntegerVector
Source§fn entrywise_abs_assign(&mut self)
fn entrywise_abs_assign(&mut self)
Replaces every element of an IntegerVector by its absolute value, in place.
See the documentation for the EntrywiseAbs implementation on IntegerVector that
takes the vector by value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseAbsAssign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 0, -3)").unwrap();
v.entrywise_abs_assign();
assert_eq!(v.to_string(), "(1, 2, 0, 3)");This is equivalent to _fmpz_vec_scalar_abs from fmpz_vec/scalar.c, FLINT 3.6.0, with
vec1 equal to vec2.
Source§impl EntrywiseDivRound<&Integer> for IntegerVector
impl EntrywiseDivRound<&Integer> for IntegerVector
Source§fn entrywise_div_round(self, c: &Integer, rm: RoundingMode) -> Self
fn entrywise_div_round(self, c: &Integer, rm: RoundingMode) -> Self
Divides every element of an IntegerVector by an Integer, taking the vector by value
and the scalar by reference, and rounds every quotient according to the specified rounding
mode.
Each quotient is rounded as by DivRound, but no Ordering is
returned, since with Nearest different elements may be rounded in different directions.
Passing Down is equivalent to using /.
$f(v, c, r)_i = \operatorname{round}(v_i/c)$, where $\operatorname{round}$ rounds according
to rm.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero, or if rm is Exact and some element is not divisible by c.
§Examples
See here.
With rm equal to Floor, this is equivalent to _fmpz_vec_scalar_fdiv_q_fmpz from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseDivRound<&Integer> for &IntegerVector
impl EntrywiseDivRound<&Integer> for &IntegerVector
Source§fn entrywise_div_round(self, c: &Integer, rm: RoundingMode) -> IntegerVector
fn entrywise_div_round(self, c: &Integer, rm: RoundingMode) -> IntegerVector
Divides every element of an IntegerVector by an Integer, taking the vector by
reference and the scalar by reference, and rounds every quotient according to the specified
rounding mode.
Each quotient is rounded as by DivRound, but no Ordering is
returned, since with Nearest different elements may be rounded in different directions.
Passing Down is equivalent to using /.
$f(v, c, r)_i = \operatorname{round}(v_i/c)$, where $\operatorname{round}$ rounds according
to rm.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero, or if rm is Exact and some element is not divisible by c.
§Examples
See here.
With rm equal to Floor, this is equivalent to _fmpz_vec_scalar_fdiv_q_fmpz from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseDivRound<Integer> for IntegerVector
impl EntrywiseDivRound<Integer> for IntegerVector
Source§fn entrywise_div_round(self, c: Integer, rm: RoundingMode) -> Self
fn entrywise_div_round(self, c: Integer, rm: RoundingMode) -> Self
Divides every element of an IntegerVector by an Integer, taking the vector by value
and the scalar by value, and rounds every quotient according to the specified rounding mode.
Each quotient is rounded as by DivRound, but no Ordering is
returned, since with Nearest different elements may be rounded in different directions.
Passing Down is equivalent to using /.
$f(v, c, r)_i = \operatorname{round}(v_i/c)$, where $\operatorname{round}$ rounds according
to rm.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero, or if rm is Exact and some element is not divisible by c.
§Examples
See here.
With rm equal to Floor, this is equivalent to _fmpz_vec_scalar_fdiv_q_fmpz from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseDivRound<Integer> for &IntegerVector
impl EntrywiseDivRound<Integer> for &IntegerVector
Source§fn entrywise_div_round(self, c: Integer, rm: RoundingMode) -> IntegerVector
fn entrywise_div_round(self, c: Integer, rm: RoundingMode) -> IntegerVector
Divides every element of an IntegerVector by an Integer, taking the vector by
reference and the scalar by value, and rounds every quotient according to the specified
rounding mode.
Each quotient is rounded as by DivRound, but no Ordering is
returned, since with Nearest different elements may be rounded in different directions.
Passing Down is equivalent to using /.
$f(v, c, r)_i = \operatorname{round}(v_i/c)$, where $\operatorname{round}$ rounds according
to rm.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero, or if rm is Exact and some element is not divisible by c.
§Examples
See here.
With rm equal to Floor, this is equivalent to _fmpz_vec_scalar_fdiv_q_fmpz from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseDivRoundAssign<&Integer> for IntegerVector
impl EntrywiseDivRoundAssign<&Integer> for IntegerVector
Source§fn entrywise_div_round_assign(&mut self, c: &Integer, rm: RoundingMode)
fn entrywise_div_round_assign(&mut self, c: &Integer, rm: RoundingMode)
Divides every element of an IntegerVector by an Integer, in place, taking the scalar
by reference, and rounds every quotient according to the specified rounding mode.
Each quotient is rounded as by DivRound, but no Ordering is
returned, since with Nearest different elements may be rounded in different directions.
Passing Down is equivalent to using /.
$v_i \gets \operatorname{round}(v_i/c)$, where $\operatorname{round}$ rounds according to
rm.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero, or if rm is Exact and some element is not divisible by c.
§Examples
See here.
With rm equal to Floor, this is equivalent to _fmpz_vec_scalar_fdiv_q_fmpz from
fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl EntrywiseDivRoundAssign<Integer> for IntegerVector
impl EntrywiseDivRoundAssign<Integer> for IntegerVector
Source§fn entrywise_div_round_assign(&mut self, c: Integer, rm: RoundingMode)
fn entrywise_div_round_assign(&mut self, c: Integer, rm: RoundingMode)
Divides every element of an IntegerVector by an Integer, in place, taking the scalar
by value, and rounds every quotient according to the specified rounding mode.
Each quotient is rounded as by DivRound, but no Ordering is
returned, since with Nearest different elements may be rounded in different directions.
Passing Down is equivalent to using /.
$v_i \gets \operatorname{round}(v_i/c)$, where $\operatorname{round}$ rounds according to
rm.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the
elements and of c.
§Panics
Panics if c is zero, or if rm is Exact and some element is not divisible by c.
§Examples
See here.
With rm equal to Floor, this is equivalent to _fmpz_vec_scalar_fdiv_q_fmpz from
fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl EntrywiseMax for IntegerVector
impl EntrywiseMax for IntegerVector
Source§fn entrywise_max(self, other: Self) -> Self
fn entrywise_max(self, other: Self) -> Self
Takes the entrywise maximum of two IntegerVectors, taking the first by value and the
second by value.
Every element of the result is the larger of the corresponding elements of the two vectors, so the result has the same dimension as both.
$$ f(v, w) = (\max(v_0, w_0), \max(v_1, w_1), \ldots, \max(v_{n-1}, w_{n-1})). $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMax;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
assert_eq!(v.entrywise_max(w).to_string(), "(1, 2, 3)");This is equivalent to _fmpz_vec_max from fmpz_vec/max.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseMax<&IntegerVector> for IntegerVector
impl EntrywiseMax<&IntegerVector> for IntegerVector
Source§fn entrywise_max(self, other: &Self) -> Self
fn entrywise_max(self, other: &Self) -> Self
Takes the entrywise maximum of two IntegerVectors, taking the first by value and the
second by reference.
See the documentation for the EntrywiseMax implementation that takes both vectors by
value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMax;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
assert_eq!(v.entrywise_max(&w).to_string(), "(1, 2, 3)");This is equivalent to _fmpz_vec_max from fmpz_vec/max.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseMax<&IntegerVector> for &IntegerVector
impl EntrywiseMax<&IntegerVector> for &IntegerVector
Source§fn entrywise_max(self, other: &IntegerVector) -> IntegerVector
fn entrywise_max(self, other: &IntegerVector) -> IntegerVector
Takes the entrywise maximum of two IntegerVectors, taking the first by reference and the
second by reference.
See the documentation for the EntrywiseMax implementation that takes both vectors by
value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMax;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
assert_eq!((&v).entrywise_max(&w).to_string(), "(1, 2, 3)");This is equivalent to _fmpz_vec_max from fmpz_vec/max.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseMax<IntegerVector> for &IntegerVector
impl EntrywiseMax<IntegerVector> for &IntegerVector
Source§fn entrywise_max(self, other: IntegerVector) -> IntegerVector
fn entrywise_max(self, other: IntegerVector) -> IntegerVector
Takes the entrywise maximum of two IntegerVectors, taking the first by reference and the
second by value.
See the documentation for the EntrywiseMax implementation that takes both vectors by
value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMax;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
assert_eq!((&v).entrywise_max(w).to_string(), "(1, 2, 3)");This is equivalent to _fmpz_vec_max from fmpz_vec/max.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseMaxAssign for IntegerVector
impl EntrywiseMaxAssign for IntegerVector
Source§fn entrywise_max_assign(&mut self, other: Self)
fn entrywise_max_assign(&mut self, other: Self)
Replaces an IntegerVector by its entrywise maximum with another IntegerVector,
taking the other by value.
Every element becomes the larger of itself and the corresponding element of other.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMaxAssign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
v.entrywise_max_assign(w);
assert_eq!(v.to_string(), "(1, 2, 3)");This is equivalent to _fmpz_vec_max_inplace from fmpz_vec/max.c, FLINT 3.6.0.
Source§impl EntrywiseMaxAssign<&IntegerVector> for IntegerVector
impl EntrywiseMaxAssign<&IntegerVector> for IntegerVector
Source§fn entrywise_max_assign(&mut self, other: &Self)
fn entrywise_max_assign(&mut self, other: &Self)
Replaces an IntegerVector by its entrywise maximum with another IntegerVector,
taking the other by reference.
Every element becomes the larger of itself and the corresponding element of other.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMaxAssign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
v.entrywise_max_assign(&w);
assert_eq!(v.to_string(), "(1, 2, 3)");This is equivalent to _fmpz_vec_max_inplace from fmpz_vec/max.c, FLINT 3.6.0.
Source§impl EntrywiseMin for IntegerVector
impl EntrywiseMin for IntegerVector
Source§fn entrywise_min(self, other: Self) -> Self
fn entrywise_min(self, other: Self) -> Self
Takes the entrywise minimum of two IntegerVectors, taking the first by value and the
second by value.
Every element of the result is the smaller of the corresponding elements of the two vectors, so the result has the same dimension as both.
$$ f(v, w) = (\min(v_0, w_0), \min(v_1, w_1), \ldots, \min(v_{n-1}, w_{n-1})). $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMin;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
assert_eq!(v.entrywise_min(w).to_string(), "(-4, -5, 3)");This is equivalent to _fmpz_vec_min from fmpz_vec/min.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseMin<&IntegerVector> for IntegerVector
impl EntrywiseMin<&IntegerVector> for IntegerVector
Source§fn entrywise_min(self, other: &Self) -> Self
fn entrywise_min(self, other: &Self) -> Self
Takes the entrywise minimum of two IntegerVectors, taking the first by value and the
second by reference.
See the documentation for the EntrywiseMin implementation that takes both vectors by
value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMin;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
assert_eq!(v.entrywise_min(&w).to_string(), "(-4, -5, 3)");This is equivalent to _fmpz_vec_min from fmpz_vec/min.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseMin<&IntegerVector> for &IntegerVector
impl EntrywiseMin<&IntegerVector> for &IntegerVector
Source§fn entrywise_min(self, other: &IntegerVector) -> IntegerVector
fn entrywise_min(self, other: &IntegerVector) -> IntegerVector
Takes the entrywise minimum of two IntegerVectors, taking the first by reference and the
second by reference.
See the documentation for the EntrywiseMin implementation that takes both vectors by
value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMin;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
assert_eq!((&v).entrywise_min(&w).to_string(), "(-4, -5, 3)");This is equivalent to _fmpz_vec_min from fmpz_vec/min.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseMin<IntegerVector> for &IntegerVector
impl EntrywiseMin<IntegerVector> for &IntegerVector
Source§fn entrywise_min(self, other: IntegerVector) -> IntegerVector
fn entrywise_min(self, other: IntegerVector) -> IntegerVector
Takes the entrywise minimum of two IntegerVectors, taking the first by reference and the
second by value.
See the documentation for the EntrywiseMin implementation that takes both vectors by
value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMin;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
assert_eq!((&v).entrywise_min(w).to_string(), "(-4, -5, 3)");This is equivalent to _fmpz_vec_min from fmpz_vec/min.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseMinAssign for IntegerVector
impl EntrywiseMinAssign for IntegerVector
Source§fn entrywise_min_assign(&mut self, other: Self)
fn entrywise_min_assign(&mut self, other: Self)
Replaces an IntegerVector by its entrywise minimum with another IntegerVector,
taking the other by value.
Every element becomes the smaller of itself and the corresponding element of other.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMinAssign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
v.entrywise_min_assign(w);
assert_eq!(v.to_string(), "(-4, -5, 3)");This is equivalent to _fmpz_vec_min_inplace from fmpz_vec/min.c, FLINT 3.6.0.
Source§impl EntrywiseMinAssign<&IntegerVector> for IntegerVector
impl EntrywiseMinAssign<&IntegerVector> for IntegerVector
Source§fn entrywise_min_assign(&mut self, other: &Self)
fn entrywise_min_assign(&mut self, other: &Self)
Replaces an IntegerVector by its entrywise minimum with another IntegerVector,
taking the other by reference.
Every element becomes the smaller of itself and the corresponding element of other.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseMinAssign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -5, 3)").unwrap();
let w = IntegerVector::from_str("(-4, 2, 3)").unwrap();
v.entrywise_min_assign(&w);
assert_eq!(v.to_string(), "(-4, -5, 3)");This is equivalent to _fmpz_vec_min_inplace from fmpz_vec/min.c, FLINT 3.6.0.
Source§impl EntrywiseShlRound<i8> for IntegerVector
impl EntrywiseShlRound<i8> for IntegerVector
Source§fn entrywise_shl_round(self, bits: i8, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: i8, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRound<i8> for &IntegerVector
impl EntrywiseShlRound<i8> for &IntegerVector
Source§fn entrywise_shl_round(self, bits: i8, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: i8, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRound<i16> for IntegerVector
impl EntrywiseShlRound<i16> for IntegerVector
Source§fn entrywise_shl_round(self, bits: i16, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: i16, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRound<i16> for &IntegerVector
impl EntrywiseShlRound<i16> for &IntegerVector
Source§fn entrywise_shl_round(self, bits: i16, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: i16, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRound<i32> for IntegerVector
impl EntrywiseShlRound<i32> for IntegerVector
Source§fn entrywise_shl_round(self, bits: i32, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: i32, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRound<i32> for &IntegerVector
impl EntrywiseShlRound<i32> for &IntegerVector
Source§fn entrywise_shl_round(self, bits: i32, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: i32, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRound<i64> for IntegerVector
impl EntrywiseShlRound<i64> for IntegerVector
Source§fn entrywise_shl_round(self, bits: i64, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: i64, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRound<i64> for &IntegerVector
impl EntrywiseShlRound<i64> for &IntegerVector
Source§fn entrywise_shl_round(self, bits: i64, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: i64, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRound<i128> for IntegerVector
impl EntrywiseShlRound<i128> for IntegerVector
Source§fn entrywise_shl_round(self, bits: i128, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: i128, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRound<i128> for &IntegerVector
impl EntrywiseShlRound<i128> for &IntegerVector
Source§fn entrywise_shl_round(self, bits: i128, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: i128, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRound<isize> for IntegerVector
impl EntrywiseShlRound<isize> for IntegerVector
Source§fn entrywise_shl_round(self, bits: isize, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: isize, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRound<isize> for &IntegerVector
impl EntrywiseShlRound<isize> for &IntegerVector
Source§fn entrywise_shl_round(self, bits: isize, rm: RoundingMode) -> IntegerVector
fn entrywise_shl_round(self, bits: isize, rm: RoundingMode) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$f(v, k, r)_i = \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShlRoundAssign<i8> for IntegerVector
impl EntrywiseShlRoundAssign<i8> for IntegerVector
Source§fn entrywise_shl_round_assign(&mut self, bits: i8, rm: RoundingMode)
fn entrywise_shl_round_assign(&mut self, bits: i8, rm: RoundingMode)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$v_i \gets \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
Source§impl EntrywiseShlRoundAssign<i16> for IntegerVector
impl EntrywiseShlRoundAssign<i16> for IntegerVector
Source§fn entrywise_shl_round_assign(&mut self, bits: i16, rm: RoundingMode)
fn entrywise_shl_round_assign(&mut self, bits: i16, rm: RoundingMode)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$v_i \gets \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
Source§impl EntrywiseShlRoundAssign<i32> for IntegerVector
impl EntrywiseShlRoundAssign<i32> for IntegerVector
Source§fn entrywise_shl_round_assign(&mut self, bits: i32, rm: RoundingMode)
fn entrywise_shl_round_assign(&mut self, bits: i32, rm: RoundingMode)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$v_i \gets \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
Source§impl EntrywiseShlRoundAssign<i64> for IntegerVector
impl EntrywiseShlRoundAssign<i64> for IntegerVector
Source§fn entrywise_shl_round_assign(&mut self, bits: i64, rm: RoundingMode)
fn entrywise_shl_round_assign(&mut self, bits: i64, rm: RoundingMode)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$v_i \gets \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
Source§impl EntrywiseShlRoundAssign<i128> for IntegerVector
impl EntrywiseShlRoundAssign<i128> for IntegerVector
Source§fn entrywise_shl_round_assign(&mut self, bits: i128, rm: RoundingMode)
fn entrywise_shl_round_assign(&mut self, bits: i128, rm: RoundingMode)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$v_i \gets \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
Source§impl EntrywiseShlRoundAssign<isize> for IntegerVector
impl EntrywiseShlRoundAssign<isize> for IntegerVector
Source§fn entrywise_shl_round_assign(&mut self, bits: isize, rm: RoundingMode)
fn entrywise_shl_round_assign(&mut self, bits: isize, rm: RoundingMode)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShlRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using <<.
Rounding might only be necessary if bits is negative.
$v_i \gets \operatorname{round}(2^kv_i)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact, bits is negative, and some element is not divisible by
$2^{-k}$.
§Examples
See here.
Source§impl EntrywiseShrRound<i8> for IntegerVector
impl EntrywiseShrRound<i8> for IntegerVector
Source§fn entrywise_shr_round(self, bits: i8, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: i8, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<i8> for &IntegerVector
impl EntrywiseShrRound<i8> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: i8, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: i8, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<i16> for IntegerVector
impl EntrywiseShrRound<i16> for IntegerVector
Source§fn entrywise_shr_round(self, bits: i16, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: i16, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<i16> for &IntegerVector
impl EntrywiseShrRound<i16> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: i16, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: i16, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<i32> for IntegerVector
impl EntrywiseShrRound<i32> for IntegerVector
Source§fn entrywise_shr_round(self, bits: i32, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: i32, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<i32> for &IntegerVector
impl EntrywiseShrRound<i32> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: i32, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: i32, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<i64> for IntegerVector
impl EntrywiseShrRound<i64> for IntegerVector
Source§fn entrywise_shr_round(self, bits: i64, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: i64, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<i64> for &IntegerVector
impl EntrywiseShrRound<i64> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: i64, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: i64, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<i128> for IntegerVector
impl EntrywiseShrRound<i128> for IntegerVector
Source§fn entrywise_shr_round(self, bits: i128, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: i128, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<i128> for &IntegerVector
impl EntrywiseShrRound<i128> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: i128, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: i128, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<isize> for IntegerVector
impl EntrywiseShrRound<isize> for IntegerVector
Source§fn entrywise_shr_round(self, bits: isize, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: isize, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<isize> for &IntegerVector
impl EntrywiseShrRound<isize> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: isize, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: isize, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
type Output = IntegerVector
Source§impl EntrywiseShrRound<u8> for IntegerVector
impl EntrywiseShrRound<u8> for IntegerVector
Source§fn entrywise_shr_round(self, bits: u8, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: u8, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by value,
and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRound<u8> for &IntegerVector
impl EntrywiseShrRound<u8> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: u8, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: u8, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by
reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRound<u16> for IntegerVector
impl EntrywiseShrRound<u16> for IntegerVector
Source§fn entrywise_shr_round(self, bits: u16, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: u16, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by value,
and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRound<u16> for &IntegerVector
impl EntrywiseShrRound<u16> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: u16, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: u16, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by
reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRound<u32> for IntegerVector
impl EntrywiseShrRound<u32> for IntegerVector
Source§fn entrywise_shr_round(self, bits: u32, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: u32, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by value,
and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRound<u32> for &IntegerVector
impl EntrywiseShrRound<u32> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: u32, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: u32, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by
reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRound<u64> for IntegerVector
impl EntrywiseShrRound<u64> for IntegerVector
Source§fn entrywise_shr_round(self, bits: u64, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: u64, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by value,
and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRound<u64> for &IntegerVector
impl EntrywiseShrRound<u64> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: u64, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: u64, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by
reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRound<u128> for IntegerVector
impl EntrywiseShrRound<u128> for IntegerVector
Source§fn entrywise_shr_round(self, bits: u128, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: u128, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by value,
and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRound<u128> for &IntegerVector
impl EntrywiseShrRound<u128> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: u128, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: u128, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by
reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRound<usize> for IntegerVector
impl EntrywiseShrRound<usize> for IntegerVector
Source§fn entrywise_shr_round(self, bits: usize, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: usize, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by value,
and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRound<usize> for &IntegerVector
impl EntrywiseShrRound<usize> for &IntegerVector
Source§fn entrywise_shr_round(self, bits: usize, rm: RoundingMode) -> IntegerVector
fn entrywise_shr_round(self, bits: usize, rm: RoundingMode) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2), taking it by
reference, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$f(v, k, r)_i = \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. /// With rm
equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl EntrywiseShrRoundAssign<i8> for IntegerVector
impl EntrywiseShrRoundAssign<i8> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: i8, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: i8, rm: RoundingMode)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
Source§impl EntrywiseShrRoundAssign<i16> for IntegerVector
impl EntrywiseShrRoundAssign<i16> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: i16, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: i16, rm: RoundingMode)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
Source§impl EntrywiseShrRoundAssign<i32> for IntegerVector
impl EntrywiseShrRoundAssign<i32> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: i32, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: i32, rm: RoundingMode)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
Source§impl EntrywiseShrRoundAssign<i64> for IntegerVector
impl EntrywiseShrRoundAssign<i64> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: i64, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: i64, rm: RoundingMode)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
Source§impl EntrywiseShrRoundAssign<i128> for IntegerVector
impl EntrywiseShrRoundAssign<i128> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: i128, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: i128, rm: RoundingMode)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
Source§impl EntrywiseShrRoundAssign<isize> for IntegerVector
impl EntrywiseShrRoundAssign<isize> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: isize, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: isize, rm: RoundingMode)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place, and rounds every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
A negative bits shifts left, multiplying every element by $2^{-k}$; no rounding is
needed then.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here.
Source§impl EntrywiseShrRoundAssign<u8> for IntegerVector
impl EntrywiseShrRoundAssign<u8> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: u8, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: u8, rm: RoundingMode)
Right-shifts an IntegerVector (divides it by a power of 2), in place, and rounds
every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. ///
With rm equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl EntrywiseShrRoundAssign<u16> for IntegerVector
impl EntrywiseShrRoundAssign<u16> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: u16, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: u16, rm: RoundingMode)
Right-shifts an IntegerVector (divides it by a power of 2), in place, and rounds
every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. ///
With rm equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl EntrywiseShrRoundAssign<u32> for IntegerVector
impl EntrywiseShrRoundAssign<u32> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: u32, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: u32, rm: RoundingMode)
Right-shifts an IntegerVector (divides it by a power of 2), in place, and rounds
every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. ///
With rm equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl EntrywiseShrRoundAssign<u64> for IntegerVector
impl EntrywiseShrRoundAssign<u64> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: u64, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: u64, rm: RoundingMode)
Right-shifts an IntegerVector (divides it by a power of 2), in place, and rounds
every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. ///
With rm equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl EntrywiseShrRoundAssign<u128> for IntegerVector
impl EntrywiseShrRoundAssign<u128> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: u128, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: u128, rm: RoundingMode)
Right-shifts an IntegerVector (divides it by a power of 2), in place, and rounds
every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. ///
With rm equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl EntrywiseShrRoundAssign<usize> for IntegerVector
impl EntrywiseShrRoundAssign<usize> for IntegerVector
Source§fn entrywise_shr_round_assign(&mut self, bits: usize, rm: RoundingMode)
fn entrywise_shr_round_assign(&mut self, bits: usize, rm: RoundingMode)
Right-shifts an IntegerVector (divides it by a power of 2), in place, and rounds
every element according to the specified rounding mode.
Each element is rounded as by
ShrRound, but no
Ordering is returned, since with Nearest different
elements may be rounded in different directions. Passing Floor is equivalent to
using >>.
$v_i \gets \operatorname{round}(v_i/2^k)$, where $\operatorname{round}$ rounds
according to rm.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Panics
Panics if rm is Exact and some element is not divisible by $2^k$.
§Examples
See here. ///
With rm equal to Down, this is equivalent to _fmpz_vec_scalar_tdiv_q_2exp from
fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl EntrywiseUnsignedAbs for IntegerVector
impl EntrywiseUnsignedAbs for IntegerVector
Source§fn entrywise_unsigned_abs(self) -> NaturalVector
fn entrywise_unsigned_abs(self) -> NaturalVector
Replaces every element of an IntegerVector by its absolute value, returning the result
as a NaturalVector and taking the vector by value.
Every absolute value is non-negative, so the result fits in a NaturalVector, as
UnsignedAbs gives a Natural for a single Integer. The
dimension is unchanged.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseUnsignedAbs;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 0, -3)").unwrap();
assert_eq!(
v.clone().entrywise_unsigned_abs().to_string(),
"(1, 2, 0, 3)"
);type Output = NaturalVector
Source§impl EntrywiseUnsignedAbs for &IntegerVector
impl EntrywiseUnsignedAbs for &IntegerVector
Source§fn entrywise_unsigned_abs(self) -> NaturalVector
fn entrywise_unsigned_abs(self) -> NaturalVector
Replaces every element of an IntegerVector by its absolute value, returning the result
as a NaturalVector and taking the vector by reference.
See the documentation for the EntrywiseUnsignedAbs implementation on IntegerVector
that takes the vector by value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::EntrywiseUnsignedAbs;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 0, -3)").unwrap();
assert_eq!((&v).entrywise_unsigned_abs().to_string(), "(1, 2, 0, 3)");type Output = NaturalVector
impl Eq for IntegerVector
Source§impl Extend<Integer> for IntegerVector
impl Extend<Integer> for IntegerVector
Source§fn extend<I: IntoIterator<Item = Integer>>(&mut self, xs: I)
fn extend<I: IntoIterator<Item = Integer>>(&mut self, xs: I)
Appends the elements produced by an iterator to the end of an IntegerVector, increasing
its dimension by their number.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension() plus the number
of elements produced, not counting the cost of producing them.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, 2)").unwrap();
v.extend([-3, 4].map(Integer::from));
assert_eq!(v.to_string(), "(1, 2, -3, 4)");Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl From<NaturalVector> for IntegerVector
impl From<NaturalVector> for IntegerVector
Source§fn from(v: NaturalVector) -> Self
fn from(v: NaturalVector) -> Self
Converts a NaturalVector to an IntegerVector.
Every Natural is an Integer, so nothing is lost and nothing
can fail. The elements are converted one by one, without copying their limbs, so the
dimension is unchanged.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is v.dimension().
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
use malachite_nz::natural_vector::NaturalVector;
let v = NaturalVector::from_str("(1, 2, 3)").unwrap();
assert_eq!(IntegerVector::from(v).to_string(), "(1, 2, 3)");
assert_eq!(
IntegerVector::from(NaturalVector::from_str("()").unwrap()).to_string(),
"()"
);Source§impl<T: PrimitiveUnsigned> From<UnsignedVector<T>> for IntegerVector
impl<T: PrimitiveUnsigned> From<UnsignedVector<T>> for IntegerVector
Source§fn from(v: UnsignedVector<T>) -> Self
fn from(v: UnsignedVector<T>) -> Self
Converts an UnsignedVector to an IntegerVector.
Every unsigned primitive is an Integer, so nothing is lost and nothing can fail. The
elements are converted one by one, so the dimension is unchanged.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is v.dimension().
§Examples
use core::str::FromStr;
use malachite_base::unsigned_vector::UnsignedVector;
use malachite_nz::integer_vector::IntegerVector;
let v = UnsignedVector::<u64>::from_str("(1, 2, 3)").unwrap();
assert_eq!(IntegerVector::from(v).to_string(), "(1, 2, 3)");
assert_eq!(
IntegerVector::from(UnsignedVector::<u8>::from_str("()").unwrap()).to_string(),
"()"
);Source§impl FromIterator<Integer> for IntegerVector
impl FromIterator<Integer> for IntegerVector
Source§fn from_iter<I: IntoIterator<Item = Integer>>(xs: I) -> Self
fn from_iter<I: IntoIterator<Item = Integer>>(xs: I) -> Self
Collects an iterator of Integers into an IntegerVector.
The vector’s dimension is the number of elements the iterator produces, and every finite iterator gives a valid vector.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the number of elements produced, not counting the cost of producing them.
§Examples
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v: IntegerVector = (-1..=1).map(Integer::from).collect();
assert_eq!(v.to_string(), "(-1, 0, 1)");
let v: IntegerVector = core::iter::empty().collect();
assert_eq!(v.to_string(), "()");Source§impl FromStr for IntegerVector
impl FromStr for IntegerVector
Source§fn from_str(s: &str) -> Result<Self, ()>
fn from_str(s: &str) -> Result<Self, ()>
Converts a string to an IntegerVector.
This reads back what Display writes: the elements in order,
separated by ", " and enclosed in parentheses, with () for the 0-dimensional vector.
Each element is read the way Integer::from_str reads one, so it may have leading zeros
and a single leading '-' or '+'. Any other spacing, such as (1,2) or ( 1, 2 ), is
rejected, as is an empty element.
If the string does not represent an IntegerVector, an Err is returned.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len().
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, 2, 3)").unwrap().to_string(),
"(1, 2, 3)"
);
assert_eq!(IntegerVector::from_str("(5)").unwrap().to_string(), "(5)");
assert_eq!(IntegerVector::from_str("()").unwrap().dimension(), 0);
// An element may be written as `Integer::from_str` accepts it.
assert_eq!(
IntegerVector::from_str("(-1, -0, +2)").unwrap().to_string(),
"(-1, 0, 2)"
);
assert_eq!(
IntegerVector::from_str("(007, +8)").unwrap().to_string(),
"(7, 8)"
);
assert!(IntegerVector::from_str("").is_err());
assert!(IntegerVector::from_str("1, 2").is_err());
assert!(IntegerVector::from_str("(1,2)").is_err());
assert!(IntegerVector::from_str("( 1, 2 )").is_err());
assert!(IntegerVector::from_str("(1, )").is_err());
assert!(IntegerVector::from_str("(--1)").is_err());Source§impl Hash for IntegerVector
impl Hash for IntegerVector
Source§impl Height for IntegerVector
impl Height for IntegerVector
Source§fn to_height(&self) -> Natural
fn to_height(&self) -> Natural
Returns the height of an IntegerVector: the largest of the absolute values of its
elements, taking the vector by reference and cloning.
The 0-dimensional vector has no elements, and its height is 0.
$$ f(v) = H(v) = \max_i |v_i|. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(m)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements, and $m$ is the number of bits of the height.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Height;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -3, 2)").unwrap().to_height(),
3
);
assert_eq!(IntegerVector::from_str("()").unwrap().to_height(), 0);This is equivalent to _fmpz_vec_height from fmpz_vec/height.c, FLINT 3.6.0.
Source§fn into_height(self) -> Natural
fn into_height(self) -> Natural
Returns the height of an IntegerVector: the largest of the absolute values of its
elements, taking the vector by value.
The element of largest height, or the part of it that is the height, is moved out of the vector rather than cloned.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Height;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -3, 2)").unwrap().into_height(),
3
);
assert_eq!(IntegerVector::from_str("()").unwrap().into_height(), 0);Source§fn height_significant_bits(&self) -> u64
fn height_significant_bits(&self) -> u64
Returns the number of significant bits of the height of an IntegerVector.
Since bit length is monotone, this is the largest of the elements’ heights’ bit lengths, and 0 for the 0-dimensional vector, without materializing the height.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Height;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -3, 2)")
.unwrap()
.height_significant_bits(),
2
);
assert_eq!(
IntegerVector::from_str("()")
.unwrap()
.height_significant_bits(),
0
);This is the absolute value of _fmpz_vec_max_bits from fmpz_vec/max_bits.c, FLINT 3.6.0.
type Output = Natural
Source§impl HeightRef for IntegerVector
impl HeightRef for IntegerVector
Source§fn height_ref(&self) -> &Natural
fn height_ref(&self) -> &Natural
Returns a reference to the height of an IntegerVector: the largest of the absolute
values of its elements.
The height is one of the magnitudes the vector already holds, so it is lent rather than built. For the 0-dimensional vector, a reference to 0 is returned.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::HeightRef;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
*IntegerVector::from_str("(1, -3, 2)").unwrap().height_ref(),
3
);
assert_eq!(*IntegerVector::from_str("()").unwrap().height_ref(), 0);Source§impl Index<usize> for IntegerVector
impl Index<usize> for IntegerVector
Source§fn index(&self, i: usize) -> &Integer
fn index(&self, i: usize) -> &Integer
Gets a reference to the element of an IntegerVector at an index.
Indices start at 0, as they do for a Vec.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if i is greater than or equal to the dimension of the vector.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, 2, 3)").unwrap();
assert_eq!(v[0], 1);
assert_eq!(v[2], 3);Source§impl IndexMut<usize> for IntegerVector
impl IndexMut<usize> for IntegerVector
Source§fn index_mut(&mut self, i: usize) -> &mut Integer
fn index_mut(&mut self, i: usize) -> &mut Integer
Gets a mutable reference to the element of an IntegerVector at an index.
Indices start at 0, as they do for a Vec.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if i is greater than or equal to the dimension of the vector.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, 2, 3)").unwrap();
v[1] = Integer::from(10u32);
v[2] += Integer::from(4u32);
assert_eq!(v.to_string(), "(1, 10, 7)");Source§impl IntoIterator for IntegerVector
impl IntoIterator for IntegerVector
Source§fn into_iter(self) -> IntoIter<Integer> ⓘ
fn into_iter(self) -> IntoIter<Integer> ⓘ
Converts an IntegerVector into an iterator over its elements, taking the vector by
value.
The elements are produced in order, starting with the element at index 0.
§Worst-case complexity
Constant time and additional memory.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
assert_eq!(
v.into_iter().map(|x| x.to_string()).collect::<Vec<_>>(),
["1", "-2", "3"]
);Source§impl<'a> IntoIterator for &'a IntegerVector
impl<'a> IntoIterator for &'a IntegerVector
Source§fn into_iter(self) -> Iter<'a, Integer> ⓘ
fn into_iter(self) -> Iter<'a, Integer> ⓘ
Converts a reference to an IntegerVector into an iterator over references to its
elements.
The elements are produced in order, starting with the element at index 0. This is what for x in &v uses.
§Worst-case complexity
Constant time and additional memory.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let mut strings = Vec::new();
for x in &v {
strings.push(x.to_string());
}
assert_eq!(strings, ["1", "-2", "3"]);Source§impl<'a> IntoIterator for &'a mut IntegerVector
impl<'a> IntoIterator for &'a mut IntegerVector
Source§fn into_iter(self) -> IterMut<'a, Integer> ⓘ
fn into_iter(self) -> IterMut<'a, Integer> ⓘ
Converts a mutable reference to an IntegerVector into an iterator over mutable
references to its elements.
The elements are produced in order, starting with the element at index 0. This is what for x in &mut v uses; since every list of elements is a valid vector, any element may be
changed.
§Worst-case complexity
Constant time and additional memory.
§Examples
use core::str::FromStr;
use malachite_base::num::basic::traits::One;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
for x in &mut v {
*x += Integer::ONE;
}
assert_eq!(v.to_string(), "(2, -1, 4)");Source§impl L1Norm for IntegerVector
impl L1Norm for IntegerVector
Source§fn to_l1_norm(&self) -> Natural
fn to_l1_norm(&self) -> Natural
Returns the $\ell^1$ norm of an IntegerVector: the sum of the absolute values of its
elements, taking the vector by reference.
The 0-dimensional vector has no elements, and its norm is 0.
$$ f(v) = |v|_1 = \sum_i |v_i|. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::L1Norm;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -5, 2)").unwrap().to_l1_norm(),
8
);
assert_eq!(IntegerVector::from_str("()").unwrap().to_l1_norm(), 0);Source§fn into_l1_norm(self) -> Natural
fn into_l1_norm(self) -> Natural
Returns the $\ell^1$ norm of an IntegerVector: the sum of the absolute values of its
elements, taking the vector by value.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::L1Norm;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -5, 2)")
.unwrap()
.into_l1_norm(),
8
);
assert_eq!(IntegerVector::from_str("()").unwrap().into_l1_norm(), 0);Source§fn l1_norm_significant_bits(&self) -> u64
fn l1_norm_significant_bits(&self) -> u64
Returns the number of significant bits of the $\ell^1$ norm of an IntegerVector.
While every element fits in one limb, the absolute values are added in two limbs, so nothing
is allocated, as in FLINT’s _fmpz_vec_sum_max_bits.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::L1Norm;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -5, 2)")
.unwrap()
.l1_norm_significant_bits(),
4
);
assert_eq!(
IntegerVector::from_str("()")
.unwrap()
.l1_norm_significant_bits(),
0
);type Output = Natural
Source§impl<'a> Mod<&'a Natural> for IntegerVector
impl<'a> Mod<&'a Natural> for IntegerVector
Source§fn mod_op(self, m: &'a Natural) -> NaturalVector
fn mod_op(self, m: &'a Natural) -> NaturalVector
Divides every element of an IntegerVector by a Natural, keeping the remainders as a
NaturalVector, taking the vector by value and the modulus by reference.
See the documentation for the Mod implementation on IntegerVector that takes both
arguments by value for details, including how negative elements are handled.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Mod;
use malachite_nz::integer_vector::IntegerVector;
use malachite_nz::natural::Natural;
// Every element is taken modulo 3, and negative ones become non-negative.
let v = IntegerVector::from_str("(1, -4, -5)").unwrap();
assert_eq!(
v.clone().mod_op(&Natural::from(3u32)).to_string(),
"(1, 2, 1)"
);
// An element that reduces to zero stays, so the dimension is unchanged.
let v = IntegerVector::from_str("(-6, 3)").unwrap();
assert_eq!(v.clone().mod_op(&Natural::from(3u32)).to_string(), "(0, 0)");type Output = NaturalVector
Source§impl<'a> Mod<&'a Natural> for &IntegerVector
impl<'a> Mod<&'a Natural> for &IntegerVector
Source§fn mod_op(self, m: &'a Natural) -> NaturalVector
fn mod_op(self, m: &'a Natural) -> NaturalVector
Divides every element of an IntegerVector by a Natural, keeping the remainders as a
NaturalVector, taking the vector by reference and the modulus by reference.
See the documentation for the Mod implementation on IntegerVector that takes both
arguments by value for details, including how negative elements are handled.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Mod;
use malachite_nz::integer_vector::IntegerVector;
use malachite_nz::natural::Natural;
// Every element is taken modulo 3, and negative ones become non-negative.
let v = IntegerVector::from_str("(1, -4, -5)").unwrap();
assert_eq!((&v).mod_op(&Natural::from(3u32)).to_string(), "(1, 2, 1)");
// An element that reduces to zero stays, so the dimension is unchanged.
let v = IntegerVector::from_str("(-6, 3)").unwrap();
assert_eq!((&v).mod_op(&Natural::from(3u32)).to_string(), "(0, 0)");type Output = NaturalVector
Source§impl Mod<Natural> for IntegerVector
impl Mod<Natural> for IntegerVector
Source§fn mod_op(self, m: Natural) -> NaturalVector
fn mod_op(self, m: Natural) -> NaturalVector
Divides every element of an IntegerVector by a Natural, keeping the remainders as a
NaturalVector, taking the vector by value and the modulus by value.
Each remainder is taken in $[0, m)$, the way Mod does for Integers, so a negative
element $x$ that is not a multiple of $m$ becomes $m - (-x \bmod m)$. The result is
therefore reduced modulo $m$, which is to say that
mod_is_reduced
returns true for it, and every element of the result is congruent to the corresponding
element of the input. The dimension is unchanged: unlike a polynomial, a vector keeps the
elements that reduce to zero.
$$ f(v, m) = w, \quad \text{where} \quad w_i = v_i - m \left \lfloor \frac{v_i}{m} \right \rfloor. $$
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Mod;
use malachite_nz::integer_vector::IntegerVector;
use malachite_nz::natural::Natural;
// Every element is taken modulo 3, and negative ones become non-negative.
let v = IntegerVector::from_str("(1, -4, -5)").unwrap();
assert_eq!(
v.clone().mod_op(Natural::from(3u32)).to_string(),
"(1, 2, 1)"
);
// An element that reduces to zero stays, so the dimension is unchanged.
let v = IntegerVector::from_str("(-6, 3)").unwrap();
assert_eq!(v.clone().mod_op(Natural::from(3u32)).to_string(), "(0, 0)");This is equivalent to _fmpz_vec_scalar_mod_fmpz from fmpz_vec/scalar_mod.c, FLINT 3.6.0,
for a positive modulus.
type Output = NaturalVector
Source§impl Mod<Natural> for &IntegerVector
impl Mod<Natural> for &IntegerVector
Source§fn mod_op(self, m: Natural) -> NaturalVector
fn mod_op(self, m: Natural) -> NaturalVector
Divides every element of an IntegerVector by a Natural, keeping the remainders as a
NaturalVector, taking the vector by reference and the modulus by value.
See the documentation for the Mod implementation on IntegerVector that takes both
arguments by value for details, including how negative elements are handled.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Mod;
use malachite_nz::integer_vector::IntegerVector;
use malachite_nz::natural::Natural;
// Every element is taken modulo 3, and negative ones become non-negative.
let v = IntegerVector::from_str("(1, -4, -5)").unwrap();
assert_eq!((&v).mod_op(Natural::from(3u32)).to_string(), "(1, 2, 1)");
// An element that reduces to zero stays, so the dimension is unchanged.
let v = IntegerVector::from_str("(-6, 3)").unwrap();
assert_eq!((&v).mod_op(Natural::from(3u32)).to_string(), "(0, 0)");type Output = NaturalVector
Source§impl<T: PrimitiveUnsigned + for<'a> ExactFrom<&'a Natural>> Mod<T> for &IntegerVector
impl<T: PrimitiveUnsigned + for<'a> ExactFrom<&'a Natural>> Mod<T> for &IntegerVector
Source§fn mod_op(self, m: T) -> UnsignedVector<T>
fn mod_op(self, m: T) -> UnsignedVector<T>
Divides every element of an IntegerVector by a value of an unsigned primitive integer
type, keeping the remainders as an UnsignedVector with that element type, taking the
vector by reference.
Each remainder is taken in $[0, m)$, so negative elements become non-negative, and every
remainder fits in m’s type. Apart from the result’s type, this is the same operation as
reducing modulo Natural::from(m); see the documentation for the Mod implementation on
IntegerVector that takes both arguments by value for details.
The result is reduced modulo $m$, which is to say that
mod_is_reduced
returns true for it.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(m)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits in the vector’s
elements, and $m$ is self.dimension().
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Mod;
use malachite_base::unsigned_vector::UnsignedVector;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(-1000000000001, 2000000000003, -5)").unwrap();
let w: UnsignedVector<u8> = (&v).mod_op(7u8);
assert_eq!(w.to_string(), "(5, 5, 2)");
// An element that reduces to zero stays, so the dimension is unchanged.
let v = IntegerVector::from_str("(-1024, -3)").unwrap();
assert_eq!((&v).mod_op(4u64).to_string(), "(0, 1)");This is equivalent to _fmpz_vec_get_nmod_vec from fmpz_vec/get_nmod_vec.c, FLINT 3.6.0.
type Output = UnsignedVector<T>
Source§impl<T: PrimitiveUnsigned + for<'a> ExactFrom<&'a Natural>> Mod<T> for IntegerVector
impl<T: PrimitiveUnsigned + for<'a> ExactFrom<&'a Natural>> Mod<T> for IntegerVector
Source§fn mod_op(self, m: T) -> UnsignedVector<T>
fn mod_op(self, m: T) -> UnsignedVector<T>
Divides every element of an IntegerVector by a value of an unsigned primitive integer
type, keeping the remainders as an UnsignedVector with that element type, taking the
vector by value.
Taking the vector by value saves nothing, since the remainders go into new storage either
way. See the documentation for the Mod implementation that takes the vector by reference
for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(m)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits in the vector’s
elements, and $m$ is self.dimension().
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::Mod;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -4, -5)").unwrap();
assert_eq!(v.mod_op(3u32).to_string(), "(1, 2, 1)");This is equivalent to _fmpz_vec_get_nmod_vec from fmpz_vec/get_nmod_vec.c, FLINT 3.6.0.
type Output = UnsignedVector<T>
Source§impl ModPowerOf2 for IntegerVector
impl ModPowerOf2 for IntegerVector
Source§fn mod_power_of_2(self, pow: u64) -> NaturalVector
fn mod_power_of_2(self, pow: u64) -> NaturalVector
Divides every element of an IntegerVector by $2^k$, keeping the remainders as a
NaturalVector, taking the vector by value.
Each remainder is non-negative, as with ModPowerOf2 for
Integer: a negative element $x$ becomes $2^k - (-x \bmod 2^k)$
unless it is a multiple of $2^k$. So the result has natural elements, and is reduced modulo
$2^k$, which is to say that mod_power_of_2_is_reduced
returns true for it. The dimension is unchanged: unlike a polynomial, a vector keeps the
elements that reduce to zero.
$$ f(v, k) = w, \quad \text{where} \quad w_i = v_i - 2^k \left \lfloor \frac{v_i}{2^k} \right \rfloor. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ModPowerOf2;
use malachite_nz::integer_vector::IntegerVector;
// Every element is taken modulo 4, and negative ones become non-negative.
let v = IntegerVector::from_str("(1, -3, -2)").unwrap();
assert_eq!(v.clone().mod_power_of_2(2).to_string(), "(1, 1, 2)");
// An element that reduces to zero stays, so the dimension is unchanged.
let v = IntegerVector::from_str("(-4, 3)").unwrap();
assert_eq!(v.clone().mod_power_of_2(2).to_string(), "(0, 3)");type Output = NaturalVector
Source§impl ModPowerOf2 for &IntegerVector
impl ModPowerOf2 for &IntegerVector
Source§fn mod_power_of_2(self, pow: u64) -> NaturalVector
fn mod_power_of_2(self, pow: u64) -> NaturalVector
Divides every element of an IntegerVector by $2^k$, keeping the remainders as a
NaturalVector, taking the vector by reference.
See the documentation for the ModPowerOf2 implementation on IntegerVector that takes
the vector by value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::ModPowerOf2;
use malachite_nz::integer_vector::IntegerVector;
// Every element is taken modulo 4, and negative ones become non-negative.
let v = IntegerVector::from_str("(1, -3, -2)").unwrap();
assert_eq!((&v).mod_power_of_2(2).to_string(), "(1, 1, 2)");
// An element that reduces to zero stays, so the dimension is unchanged.
let v = IntegerVector::from_str("(-4, 3)").unwrap();
assert_eq!((&v).mod_power_of_2(2).to_string(), "(0, 3)");type Output = NaturalVector
Source§impl Mul<&Integer> for IntegerVector
impl Mul<&Integer> for IntegerVector
Source§fn mul(self, c: &Integer) -> Self
fn mul(self, c: &Integer) -> Self
Multiplies every element of an IntegerVector by an Integer, taking the vector by
value and the scalar by reference.
See the documentation for the Mul implementation that takes the vector and the scalar by
value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements and of the scalar.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let c = Integer::from(-3);
assert_eq!((v * &c).to_string(), "(-3, 6, -9)");This is equivalent to _fmpz_vec_scalar_mul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
* operator.Source§impl Mul<&Integer> for &IntegerVector
impl Mul<&Integer> for &IntegerVector
Source§fn mul(self, c: &Integer) -> IntegerVector
fn mul(self, c: &Integer) -> IntegerVector
Multiplies every element of an IntegerVector by an Integer, taking the vector by
reference and the scalar by reference.
See the documentation for the Mul implementation that takes the vector and the scalar by
value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements and of the scalar.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let c = Integer::from(-3);
assert_eq!((&v * &c).to_string(), "(-3, 6, -9)");This is equivalent to _fmpz_vec_scalar_mul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
* operator.Source§impl Mul<&IntegerVector> for Integer
impl Mul<&IntegerVector> for Integer
Source§fn mul(self, v: &IntegerVector) -> IntegerVector
fn mul(self, v: &IntegerVector) -> IntegerVector
Multiplies an Integer by every element of an IntegerVector, taking the scalar by
value and the vector by reference.
Scalar multiplication is commutative, so this is v * c; see the documentation for the
Mul implementation that takes the vector and the scalar by value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements and of the scalar.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let c = Integer::from(-3);
assert_eq!((c * &v).to_string(), "(-3, 6, -9)");This is equivalent to _fmpz_vec_scalar_mul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
* operator.Source§impl Mul<&IntegerVector> for &Integer
impl Mul<&IntegerVector> for &Integer
Source§fn mul(self, v: &IntegerVector) -> IntegerVector
fn mul(self, v: &IntegerVector) -> IntegerVector
Multiplies an Integer by every element of an IntegerVector, taking the scalar by
reference and the vector by reference.
Scalar multiplication is commutative, so this is v * c; see the documentation for the
Mul implementation that takes the vector and the scalar by value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements and of the scalar.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let c = Integer::from(-3);
assert_eq!((&c * &v).to_string(), "(-3, 6, -9)");This is equivalent to _fmpz_vec_scalar_mul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
* operator.Source§impl Mul<Integer> for IntegerVector
impl Mul<Integer> for IntegerVector
Source§fn mul(self, c: Integer) -> Self
fn mul(self, c: Integer) -> Self
Multiplies every element of an IntegerVector by an Integer, taking the vector by
value and the scalar by value.
The product is taken element by element, so the result has the same dimension as the vector.
$$ f(v, c) = cv = (cv_0, cv_1, \ldots, cv_{n-1}). $$
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements and of the scalar.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let c = Integer::from(-3);
assert_eq!((v * c).to_string(), "(-3, 6, -9)");This is equivalent to _fmpz_vec_scalar_mul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
* operator.Source§impl Mul<Integer> for &IntegerVector
impl Mul<Integer> for &IntegerVector
Source§fn mul(self, c: Integer) -> IntegerVector
fn mul(self, c: Integer) -> IntegerVector
Multiplies every element of an IntegerVector by an Integer, taking the vector by
reference and the scalar by value.
See the documentation for the Mul implementation that takes the vector and the scalar by
value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements and of the scalar.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let c = Integer::from(-3);
assert_eq!((&v * c).to_string(), "(-3, 6, -9)");This is equivalent to _fmpz_vec_scalar_mul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
* operator.Source§impl Mul<IntegerVector> for Integer
impl Mul<IntegerVector> for Integer
Source§fn mul(self, v: IntegerVector) -> IntegerVector
fn mul(self, v: IntegerVector) -> IntegerVector
Multiplies an Integer by every element of an IntegerVector, taking the scalar by
value and the vector by value.
Scalar multiplication is commutative, so this is v * c; see the documentation for the
Mul implementation that takes the vector and the scalar by value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements and of the scalar.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let c = Integer::from(-3);
assert_eq!((c * v).to_string(), "(-3, 6, -9)");This is equivalent to _fmpz_vec_scalar_mul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
* operator.Source§impl Mul<IntegerVector> for &Integer
impl Mul<IntegerVector> for &Integer
Source§fn mul(self, v: IntegerVector) -> IntegerVector
fn mul(self, v: IntegerVector) -> IntegerVector
Multiplies an Integer by every element of an IntegerVector, taking the scalar by
reference and the vector by value.
Scalar multiplication is commutative, so this is v * c; see the documentation for the
Mul implementation that takes the vector and the scalar by value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements and of the scalar.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let c = Integer::from(-3);
assert_eq!((&c * v).to_string(), "(-3, 6, -9)");This is equivalent to _fmpz_vec_scalar_mul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
* operator.Source§impl MulAssign<&Integer> for IntegerVector
impl MulAssign<&Integer> for IntegerVector
Source§fn mul_assign(&mut self, c: &Integer)
fn mul_assign(&mut self, c: &Integer)
Multiplies every element of an IntegerVector by an Integer in place, taking the
scalar by reference.
See the documentation for the Mul implementation that takes the vector and the scalar by
value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements and of the scalar.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
v *= &Integer::from(-3);
assert_eq!(v.to_string(), "(-3, 6, -9)");This is equivalent to _fmpz_vec_scalar_mul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0,
with vec1 equal to vec2.
Source§impl MulAssign<Integer> for IntegerVector
impl MulAssign<Integer> for IntegerVector
Source§fn mul_assign(&mut self, c: Integer)
fn mul_assign(&mut self, c: Integer)
Multiplies every element of an IntegerVector by an Integer in place, taking the
scalar by value.
See the documentation for the Mul implementation that takes the vector and the scalar by
value for details.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements and of the scalar.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
v *= Integer::from(-3);
assert_eq!(v.to_string(), "(-3, 6, -9)");This is equivalent to _fmpz_vec_scalar_mul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0,
with vec1 equal to vec2.
Source§impl Named for IntegerVector
impl Named for IntegerVector
Source§impl Neg for IntegerVector
impl Neg for IntegerVector
Source§fn neg(self) -> Self
fn neg(self) -> Self
Negates an IntegerVector, taking it by value.
Every element is negated, so the dimension is unchanged.
$$ f(v) = -v. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension().
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -3, 2)").unwrap();
assert_eq!((-v).to_string(), "(-1, 3, -2)");
assert_eq!((-IntegerVector::from_str("()").unwrap()).to_string(), "()");This is equivalent to _fmpz_vec_neg from fmpz_vec/neg.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
- operator.Source§impl Neg for &IntegerVector
impl Neg for &IntegerVector
Source§fn neg(self) -> IntegerVector
fn neg(self) -> IntegerVector
Negates an IntegerVector, taking it by reference.
Every element is negated, so the dimension is unchanged.
$$ f(v) = -v. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -3, 2)").unwrap();
assert_eq!((-&v).to_string(), "(-1, 3, -2)");This is equivalent to _fmpz_vec_neg from fmpz_vec/neg.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
- operator.Source§impl NegAssign for IntegerVector
impl NegAssign for IntegerVector
Source§fn neg_assign(&mut self)
fn neg_assign(&mut self)
Negates an IntegerVector in place.
$$ v \gets -v. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::NegAssign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -3, 2)").unwrap();
v.neg_assign();
assert_eq!(v.to_string(), "(-1, 3, -2)");Source§impl PartialEq for IntegerVector
impl PartialEq for IntegerVector
Source§impl PartialEq<IntegerVector> for NaturalVector
impl PartialEq<IntegerVector> for NaturalVector
Source§fn eq(&self, other: &IntegerVector) -> bool
fn eq(&self, other: &IntegerVector) -> bool
Determines whether a NaturalVector is equal to an IntegerVector.
The two are equal when they have the same dimension and equal elements in each position, so the 0-dimensional vectors are equal.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension(). Vectors of
different dimensions are compared in constant time.
§Examples
See here.
Source§impl<T: PrimitiveUnsigned> PartialEq<IntegerVector> for UnsignedVector<T>
impl<T: PrimitiveUnsigned> PartialEq<IntegerVector> for UnsignedVector<T>
Source§fn eq(&self, other: &IntegerVector) -> bool
fn eq(&self, other: &IntegerVector) -> bool
Determines whether an UnsignedVector is equal to an IntegerVector.
The two are equal when they have the same dimension and equal elements in each position, so the 0-dimensional vectors are equal.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension(). Vectors of
different dimensions are compared in constant time.
§Examples
See here.
Source§impl PartialEq<NaturalVector> for IntegerVector
impl PartialEq<NaturalVector> for IntegerVector
Source§fn eq(&self, other: &NaturalVector) -> bool
fn eq(&self, other: &NaturalVector) -> bool
Determines whether an IntegerVector is equal to a NaturalVector.
The two are equal when they have the same dimension and equal elements in each position. So
the 0-dimensional vectors are equal, and an IntegerVector with a negative element is
equal to no NaturalVector.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension(). Vectors of
different dimensions are compared in constant time.
§Examples
See here.
Source§impl<T: PrimitiveUnsigned> PartialEq<UnsignedVector<T>> for IntegerVector
impl<T: PrimitiveUnsigned> PartialEq<UnsignedVector<T>> for IntegerVector
Source§fn eq(&self, other: &UnsignedVector<T>) -> bool
fn eq(&self, other: &UnsignedVector<T>) -> bool
Determines whether an IntegerVector is equal to an UnsignedVector.
The two are equal when they have the same dimension and equal elements in each position. So
the 0-dimensional vectors are equal, and an IntegerVector with an element that is
negative or too large for T is equal to no UnsignedVector<T>.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension(). Vectors of
different dimensions are compared in constant time.
§Examples
See here.
Source§impl PrimitivePart for IntegerVector
impl PrimitivePart for IntegerVector
Source§fn primitive_part(self) -> Self
fn primitive_part(self) -> Self
Computes the primitive part of an IntegerVector, taking the vector by value.
This is the vector divided by its content, with every element keeping its sign, so the
primitive part of $-v$ is the negation of the primitive part of $v$. For the one whose first
nonzero element is positive, see canonical_primitive_part.
$$ v = \operatorname{cont}(v) \operatorname{pp}(v). $$
The primitive part of a vector of zeros is itself, keeping its dimension.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::PrimitivePart;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
assert_eq!(v.primitive_part().to_string(), "(-3, 2, -5)");
assert_eq!(
IntegerVector::from_str("(0, 0)")
.unwrap()
.primitive_part()
.to_string(),
"(0, 0)"
);type Output = IntegerVector
Source§impl PrimitivePart for &IntegerVector
impl PrimitivePart for &IntegerVector
Source§fn primitive_part(self) -> IntegerVector
fn primitive_part(self) -> IntegerVector
Computes the primitive part of an IntegerVector, taking the vector by reference.
This is the vector divided by its content, with every element keeping its sign, so the
primitive part of $-v$ is the negation of the primitive part of $v$. For the one whose first
nonzero element is positive, see canonical_primitive_part.
$$ v = \operatorname{cont}(v) \operatorname{pp}(v). $$
The primitive part of a vector of zeros is itself, keeping its dimension.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::PrimitivePart;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
assert_eq!((&v).primitive_part().to_string(), "(-3, 2, -5)");type Output = IntegerVector
Source§impl PrimitivePartAssign for IntegerVector
impl PrimitivePartAssign for IntegerVector
Source§fn primitive_part_assign(&mut self)
fn primitive_part_assign(&mut self)
Replaces an IntegerVector with its primitive part, the vector divided by its content.
See primitive_part.
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::PrimitivePartAssign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(-6, 4, -10)").unwrap();
v.primitive_part_assign();
assert_eq!(v.to_string(), "(-3, 2, -5)");Source§impl<'a> Rem<&'a Integer> for IntegerVector
impl<'a> Rem<&'a Integer> for IntegerVector
Source§fn rem(self, m: &'a Integer) -> Self
fn rem(self, m: &'a Integer) -> Self
Divides every element of an IntegerVector by an Integer, keeping the remainders,
taking the vector by value and the modulus by reference.
See the documentation for the Rem implementation on IntegerVector that takes both
arguments by value for details, including the signs of the remainders.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
// Every element is taken modulo 3, keeping its sign.
let v = IntegerVector::from_str("(1, -4, -5)").unwrap();
assert_eq!((v.clone() % &Integer::from(3)).to_string(), "(1, -1, -2)");
// The sign of the modulus makes no difference, and an element that reduces to zero stays.
let v = IntegerVector::from_str("(-6, 3, -1)").unwrap();
assert_eq!((v.clone() % &Integer::from(-3)).to_string(), "(0, 0, -1)");Source§type Output = IntegerVector
type Output = IntegerVector
% operator.Source§impl<'a> Rem<&'a Integer> for &IntegerVector
impl<'a> Rem<&'a Integer> for &IntegerVector
Source§fn rem(self, m: &'a Integer) -> IntegerVector
fn rem(self, m: &'a Integer) -> IntegerVector
Divides every element of an IntegerVector by an Integer, keeping the remainders,
taking the vector by reference and the modulus by reference.
See the documentation for the Rem implementation on IntegerVector that takes both
arguments by value for details, including the signs of the remainders.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
// Every element is taken modulo 3, keeping its sign.
let v = IntegerVector::from_str("(1, -4, -5)").unwrap();
assert_eq!((&v % &Integer::from(3)).to_string(), "(1, -1, -2)");
// The sign of the modulus makes no difference, and an element that reduces to zero stays.
let v = IntegerVector::from_str("(-6, 3, -1)").unwrap();
assert_eq!((&v % &Integer::from(-3)).to_string(), "(0, 0, -1)");Source§type Output = IntegerVector
type Output = IntegerVector
% operator.Source§impl Rem<Integer> for IntegerVector
impl Rem<Integer> for IntegerVector
Source§fn rem(self, m: Integer) -> Self
fn rem(self, m: Integer) -> Self
Divides every element of an IntegerVector by an Integer, keeping the remainders,
taking the vector by value and the modulus by value.
Each remainder has the sign of its element and a smaller absolute value than $m$, as with
Rem for Integers, so the sign of $m$ makes no difference. This is the remainder of
truncating division. For a remainder that is always non-negative, and a NaturalVector
result, use Mod. The dimension is unchanged.
$$ f(v, m) = w, \quad \text{where} \quad w_i = v_i - m \operatorname{sgn}(v_im) \left \lfloor \left | \frac{v_i}{m} \right | \right \rfloor. $$
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
// Every element is taken modulo 3, keeping its sign.
let v = IntegerVector::from_str("(1, -4, -5)").unwrap();
assert_eq!((v.clone() % Integer::from(3)).to_string(), "(1, -1, -2)");
// The sign of the modulus makes no difference, and an element that reduces to zero stays.
let v = IntegerVector::from_str("(-6, 3, -1)").unwrap();
assert_eq!((v.clone() % Integer::from(-3)).to_string(), "(0, 0, -1)");Source§type Output = IntegerVector
type Output = IntegerVector
% operator.Source§impl Rem<Integer> for &IntegerVector
impl Rem<Integer> for &IntegerVector
Source§fn rem(self, m: Integer) -> IntegerVector
fn rem(self, m: Integer) -> IntegerVector
Divides every element of an IntegerVector by an Integer, keeping the remainders,
taking the vector by reference and the modulus by value.
See the documentation for the Rem implementation on IntegerVector that takes both
arguments by value for details, including the signs of the remainders.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
// Every element is taken modulo 3, keeping its sign.
let v = IntegerVector::from_str("(1, -4, -5)").unwrap();
assert_eq!((&v % Integer::from(3)).to_string(), "(1, -1, -2)");
// The sign of the modulus makes no difference, and an element that reduces to zero stays.
let v = IntegerVector::from_str("(-6, 3, -1)").unwrap();
assert_eq!((&v % Integer::from(-3)).to_string(), "(0, 0, -1)");Source§type Output = IntegerVector
type Output = IntegerVector
% operator.Source§impl<'a> RemAssign<&'a Integer> for IntegerVector
impl<'a> RemAssign<&'a Integer> for IntegerVector
Source§fn rem_assign(&mut self, m: &'a Integer)
fn rem_assign(&mut self, m: &'a Integer)
Divides every element of an IntegerVector by an Integer, replacing each element by
the remainder, taking the modulus by reference.
See the documentation for the Rem implementation on IntegerVector that takes both
arguments by value for details, including the signs of the remainders.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -4, -5)").unwrap();
v %= &Integer::from(3);
assert_eq!(v.to_string(), "(1, -1, -2)");
let mut v = IntegerVector::from_str("(-6, 3, -1)").unwrap();
v %= &Integer::from(-3);
assert_eq!(v.to_string(), "(0, 0, -1)");Source§impl RemAssign<Integer> for IntegerVector
impl RemAssign<Integer> for IntegerVector
Source§fn rem_assign(&mut self, m: Integer)
fn rem_assign(&mut self, m: Integer)
Divides every element of an IntegerVector by an Integer, replacing each element by
the remainder, taking the modulus by value.
See the documentation for the Rem implementation on IntegerVector that takes both
arguments by value for details, including the signs of the remainders.
§Worst-case complexity
$T(n) = O(n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits in the vector’s elements.
§Panics
Panics if m is zero.
§Examples
use core::str::FromStr;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -4, -5)").unwrap();
v %= Integer::from(3);
assert_eq!(v.to_string(), "(1, -1, -2)");
let mut v = IntegerVector::from_str("(-6, 3, -1)").unwrap();
v %= Integer::from(-3);
assert_eq!(v.to_string(), "(0, 0, -1)");Source§impl RemPowerOf2 for IntegerVector
impl RemPowerOf2 for IntegerVector
Source§fn rem_power_of_2(self, pow: u64) -> Self
fn rem_power_of_2(self, pow: u64) -> Self
Divides every element of an IntegerVector by $2^k$, keeping the remainders, taking the
vector by value.
Each remainder has the sign of its element and a smaller absolute value than $2^k$, as with
RemPowerOf2 for Integers. This is the remainder of
truncating division, and the result stays an IntegerVector; for a remainder that is
always non-negative, and a NaturalVector result, use ModPowerOf2. The dimension is
unchanged.
$$ f(v, k) = w, \quad \text{where} \quad w_i = v_i - 2^k \operatorname{sgn}(v_i) \left \lfloor \frac{|v_i|}{2^k} \right \rfloor. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::RemPowerOf2;
use malachite_nz::integer_vector::IntegerVector;
// Every element is taken modulo 4, keeping its sign.
let v = IntegerVector::from_str("(1, -7, -2)").unwrap();
assert_eq!(v.clone().rem_power_of_2(2).to_string(), "(1, -3, -2)");
// An element that reduces to zero stays, so the dimension is unchanged.
let v = IntegerVector::from_str("(-4, -3)").unwrap();
assert_eq!(v.clone().rem_power_of_2(2).to_string(), "(0, -3)");type Output = IntegerVector
Source§impl RemPowerOf2 for &IntegerVector
impl RemPowerOf2 for &IntegerVector
Source§fn rem_power_of_2(self, pow: u64) -> IntegerVector
fn rem_power_of_2(self, pow: u64) -> IntegerVector
Divides every element of an IntegerVector by $2^k$, keeping the remainders, taking the
vector by reference.
See the documentation for the RemPowerOf2 implementation on IntegerVector that takes
the vector by value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::RemPowerOf2;
use malachite_nz::integer_vector::IntegerVector;
// Every element is taken modulo 4, keeping its sign.
let v = IntegerVector::from_str("(1, -7, -2)").unwrap();
assert_eq!((&v).rem_power_of_2(2).to_string(), "(1, -3, -2)");
// An element that reduces to zero stays, so the dimension is unchanged.
let v = IntegerVector::from_str("(-4, -3)").unwrap();
assert_eq!((&v).rem_power_of_2(2).to_string(), "(0, -3)");type Output = IntegerVector
Source§impl RemPowerOf2Assign for IntegerVector
impl RemPowerOf2Assign for IntegerVector
Source§fn rem_power_of_2_assign(&mut self, pow: u64)
fn rem_power_of_2_assign(&mut self, pow: u64)
Divides every element of an IntegerVector by $2^k$, replacing each element by the
remainder.
See the documentation for the RemPowerOf2 implementation on IntegerVector that takes
the vector by value for details.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::RemPowerOf2Assign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -7, -2)").unwrap();
v.rem_power_of_2_assign(2);
assert_eq!(v.to_string(), "(1, -3, -2)");Source§impl SelectCoordinates for IntegerVector
impl SelectCoordinates for IntegerVector
Source§fn select_coordinates(self, indices: &[u64]) -> Self
fn select_coordinates(self, indices: &[u64]) -> Self
Selects coordinates of an IntegerVector by index, taking the vector by value.
Element $j$ of the result is element indices[j] of the original, so the result’s dimension
is the number of indices. The indices may repeat and may appear in any order.
Elements are moved rather than cloned wherever possible: when the indices are strictly increasing, nothing is cloned or allocated, and otherwise an element is cloned only once for each extra time it is selected.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension() plus
indices.len(), plus the total size of the elements that are cloned.
§Panics
Panics if any index is greater than or equal to self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::vector::SelectCoordinates;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
assert_eq!(v.clone().select_coordinates(&[2, 0]).to_string(), "(3, 1)");
assert_eq!(
v.clone().select_coordinates(&[1, 1, 1]).to_string(),
"(-2, -2, -2)"
);
assert_eq!(v.select_coordinates(&[0, 2]).to_string(), "(1, 3)");type Output = IntegerVector
Source§impl SelectCoordinates for &IntegerVector
impl SelectCoordinates for &IntegerVector
Source§fn select_coordinates(self, indices: &[u64]) -> IntegerVector
fn select_coordinates(self, indices: &[u64]) -> IntegerVector
Selects coordinates of an IntegerVector by index, taking the vector by reference.
Element $j$ of the result is element indices[j] of the original, so the result’s dimension
is the number of indices. The indices may repeat and may appear in any order.
The selected elements are cloned.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is indices.len() plus the total size
of the selected elements.
§Panics
Panics if any index is greater than or equal to self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::vector::SelectCoordinates;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
assert_eq!((&v).select_coordinates(&[2, 0]).to_string(), "(3, 1)");
assert_eq!(
(&v).select_coordinates(&[1, 1, 1]).to_string(),
"(-2, -2, -2)"
);
assert_eq!((&v).select_coordinates(&[]).to_string(), "()");type Output = IntegerVector
Source§impl SelectCoordinatesAssign for IntegerVector
impl SelectCoordinatesAssign for IntegerVector
Source§fn select_coordinates_assign(&mut self, indices: &[u64])
fn select_coordinates_assign(&mut self, indices: &[u64])
Selects coordinates of an IntegerVector by index, in place.
Afterwards, element $j$ of the vector is what element indices[j] was before, so its
dimension is the number of indices. The indices may repeat and may appear in any order.
Elements are moved rather than cloned wherever possible: when the indices are strictly increasing, nothing is cloned or allocated, and otherwise an element is cloned only once for each extra time it is selected.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension() plus
indices.len(), plus the total size of the elements that are cloned.
§Panics
Panics if any index is greater than or equal to self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::vector::SelectCoordinatesAssign;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
v.select_coordinates_assign(&[2, 0]);
assert_eq!(v.to_string(), "(3, 1)");
v.select_coordinates_assign(&[1, 1]);
assert_eq!(v.to_string(), "(1, 1)");Source§impl Shl<i8> for IntegerVector
impl Shl<i8> for IntegerVector
Source§fn shl(self, bits: i8) -> IntegerVector
fn shl(self, bits: i8) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<i8> for &IntegerVector
impl Shl<i8> for &IntegerVector
Source§fn shl(self, bits: i8) -> IntegerVector
fn shl(self, bits: i8) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<i16> for IntegerVector
impl Shl<i16> for IntegerVector
Source§fn shl(self, bits: i16) -> IntegerVector
fn shl(self, bits: i16) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<i16> for &IntegerVector
impl Shl<i16> for &IntegerVector
Source§fn shl(self, bits: i16) -> IntegerVector
fn shl(self, bits: i16) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<i32> for IntegerVector
impl Shl<i32> for IntegerVector
Source§fn shl(self, bits: i32) -> IntegerVector
fn shl(self, bits: i32) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<i32> for &IntegerVector
impl Shl<i32> for &IntegerVector
Source§fn shl(self, bits: i32) -> IntegerVector
fn shl(self, bits: i32) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<i64> for IntegerVector
impl Shl<i64> for IntegerVector
Source§fn shl(self, bits: i64) -> IntegerVector
fn shl(self, bits: i64) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<i64> for &IntegerVector
impl Shl<i64> for &IntegerVector
Source§fn shl(self, bits: i64) -> IntegerVector
fn shl(self, bits: i64) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<i128> for IntegerVector
impl Shl<i128> for IntegerVector
Source§fn shl(self, bits: i128) -> IntegerVector
fn shl(self, bits: i128) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<i128> for &IntegerVector
impl Shl<i128> for &IntegerVector
Source§fn shl(self, bits: i128) -> IntegerVector
fn shl(self, bits: i128) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<isize> for IntegerVector
impl Shl<isize> for IntegerVector
Source§fn shl(self, bits: isize) -> IntegerVector
fn shl(self, bits: isize) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<isize> for &IntegerVector
impl Shl<isize> for &IntegerVector
Source§fn shl(self, bits: isize) -> IntegerVector
fn shl(self, bits: isize) -> IntegerVector
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<u8> for IntegerVector
impl Shl<u8> for IntegerVector
Source§fn shl(self, bits: u8) -> IntegerVector
fn shl(self, bits: u8) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<u8> for &IntegerVector
impl Shl<u8> for &IntegerVector
Source§fn shl(self, bits: u8) -> IntegerVector
fn shl(self, bits: u8) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<u16> for IntegerVector
impl Shl<u16> for IntegerVector
Source§fn shl(self, bits: u16) -> IntegerVector
fn shl(self, bits: u16) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<u16> for &IntegerVector
impl Shl<u16> for &IntegerVector
Source§fn shl(self, bits: u16) -> IntegerVector
fn shl(self, bits: u16) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<u32> for IntegerVector
impl Shl<u32> for IntegerVector
Source§fn shl(self, bits: u32) -> IntegerVector
fn shl(self, bits: u32) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<u32> for &IntegerVector
impl Shl<u32> for &IntegerVector
Source§fn shl(self, bits: u32) -> IntegerVector
fn shl(self, bits: u32) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<u64> for IntegerVector
impl Shl<u64> for IntegerVector
Source§fn shl(self, bits: u64) -> IntegerVector
fn shl(self, bits: u64) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<u64> for &IntegerVector
impl Shl<u64> for &IntegerVector
Source§fn shl(self, bits: u64) -> IntegerVector
fn shl(self, bits: u64) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<u128> for IntegerVector
impl Shl<u128> for IntegerVector
Source§fn shl(self, bits: u128) -> IntegerVector
fn shl(self, bits: u128) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<u128> for &IntegerVector
impl Shl<u128> for &IntegerVector
Source§fn shl(self, bits: u128) -> IntegerVector
fn shl(self, bits: u128) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<usize> for IntegerVector
impl Shl<usize> for IntegerVector
Source§fn shl(self, bits: usize) -> IntegerVector
fn shl(self, bits: usize) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl Shl<usize> for &IntegerVector
impl Shl<usize> for &IntegerVector
Source§fn shl(self, bits: usize) -> IntegerVector
fn shl(self, bits: usize) -> IntegerVector
Left-shifts an IntegerVector (multiplies it by a power of 2), taking it by
reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
<< operator.Source§impl ShlAssign<i8> for IntegerVector
impl ShlAssign<i8> for IntegerVector
Source§fn shl_assign(&mut self, bits: i8)
fn shl_assign(&mut self, bits: i8)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShlAssign<i16> for IntegerVector
impl ShlAssign<i16> for IntegerVector
Source§fn shl_assign(&mut self, bits: i16)
fn shl_assign(&mut self, bits: i16)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShlAssign<i32> for IntegerVector
impl ShlAssign<i32> for IntegerVector
Source§fn shl_assign(&mut self, bits: i32)
fn shl_assign(&mut self, bits: i32)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShlAssign<i64> for IntegerVector
impl ShlAssign<i64> for IntegerVector
Source§fn shl_assign(&mut self, bits: i64)
fn shl_assign(&mut self, bits: i64)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShlAssign<i128> for IntegerVector
impl ShlAssign<i128> for IntegerVector
Source§fn shl_assign(&mut self, bits: i128)
fn shl_assign(&mut self, bits: i128)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShlAssign<isize> for IntegerVector
impl ShlAssign<isize> for IntegerVector
Source§fn shl_assign(&mut self, bits: isize)
fn shl_assign(&mut self, bits: isize)
Left-shifts an IntegerVector (multiplies or divides it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
A negative bits shifts right, rounding every element down (toward negative
infinity); to round differently, use
entrywise_shl_round.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShlAssign<u8> for IntegerVector
impl ShlAssign<u8> for IntegerVector
Source§fn shl_assign(&mut self, bits: u8)
fn shl_assign(&mut self, bits: u8)
Left-shifts an IntegerVector (multiplies it by a power of 2), in place. Every
element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl ShlAssign<u16> for IntegerVector
impl ShlAssign<u16> for IntegerVector
Source§fn shl_assign(&mut self, bits: u16)
fn shl_assign(&mut self, bits: u16)
Left-shifts an IntegerVector (multiplies it by a power of 2), in place. Every
element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl ShlAssign<u32> for IntegerVector
impl ShlAssign<u32> for IntegerVector
Source§fn shl_assign(&mut self, bits: u32)
fn shl_assign(&mut self, bits: u32)
Left-shifts an IntegerVector (multiplies it by a power of 2), in place. Every
element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl ShlAssign<u64> for IntegerVector
impl ShlAssign<u64> for IntegerVector
Source§fn shl_assign(&mut self, bits: u64)
fn shl_assign(&mut self, bits: u64)
Left-shifts an IntegerVector (multiplies it by a power of 2), in place. Every
element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl ShlAssign<u128> for IntegerVector
impl ShlAssign<u128> for IntegerVector
Source§fn shl_assign(&mut self, bits: u128)
fn shl_assign(&mut self, bits: u128)
Left-shifts an IntegerVector (multiplies it by a power of 2), in place. Every
element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl ShlAssign<usize> for IntegerVector
impl ShlAssign<usize> for IntegerVector
Source§fn shl_assign(&mut self, bits: usize)
fn shl_assign(&mut self, bits: usize)
Left-shifts an IntegerVector (multiplies it by a power of 2), in place. Every
element is shifted, and the dimension is unchanged.
$v \gets 2^kv$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits, and $k$ is self.dimension().
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_mul_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl Shr<i8> for IntegerVector
impl Shr<i8> for IntegerVector
Source§fn shr(self, bits: i8) -> IntegerVector
fn shr(self, bits: i8) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<i8> for &IntegerVector
impl Shr<i8> for &IntegerVector
Source§fn shr(self, bits: i8) -> IntegerVector
fn shr(self, bits: i8) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<i16> for IntegerVector
impl Shr<i16> for IntegerVector
Source§fn shr(self, bits: i16) -> IntegerVector
fn shr(self, bits: i16) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<i16> for &IntegerVector
impl Shr<i16> for &IntegerVector
Source§fn shr(self, bits: i16) -> IntegerVector
fn shr(self, bits: i16) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<i32> for IntegerVector
impl Shr<i32> for IntegerVector
Source§fn shr(self, bits: i32) -> IntegerVector
fn shr(self, bits: i32) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<i32> for &IntegerVector
impl Shr<i32> for &IntegerVector
Source§fn shr(self, bits: i32) -> IntegerVector
fn shr(self, bits: i32) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<i64> for IntegerVector
impl Shr<i64> for IntegerVector
Source§fn shr(self, bits: i64) -> IntegerVector
fn shr(self, bits: i64) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<i64> for &IntegerVector
impl Shr<i64> for &IntegerVector
Source§fn shr(self, bits: i64) -> IntegerVector
fn shr(self, bits: i64) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<i128> for IntegerVector
impl Shr<i128> for IntegerVector
Source§fn shr(self, bits: i128) -> IntegerVector
fn shr(self, bits: i128) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<i128> for &IntegerVector
impl Shr<i128> for &IntegerVector
Source§fn shr(self, bits: i128) -> IntegerVector
fn shr(self, bits: i128) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<isize> for IntegerVector
impl Shr<isize> for IntegerVector
Source§fn shr(self, bits: isize) -> IntegerVector
fn shr(self, bits: isize) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<isize> for &IntegerVector
impl Shr<isize> for &IntegerVector
Source§fn shr(self, bits: isize) -> IntegerVector
fn shr(self, bits: isize) -> IntegerVector
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), taking
it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<u8> for IntegerVector
impl Shr<u8> for IntegerVector
Source§fn shr(self, bits: u8) -> IntegerVector
fn shr(self, bits: u8) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<u8> for &IntegerVector
impl Shr<u8> for &IntegerVector
Source§fn shr(self, bits: u8) -> IntegerVector
fn shr(self, bits: u8) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<u16> for IntegerVector
impl Shr<u16> for IntegerVector
Source§fn shr(self, bits: u16) -> IntegerVector
fn shr(self, bits: u16) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<u16> for &IntegerVector
impl Shr<u16> for &IntegerVector
Source§fn shr(self, bits: u16) -> IntegerVector
fn shr(self, bits: u16) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<u32> for IntegerVector
impl Shr<u32> for IntegerVector
Source§fn shr(self, bits: u32) -> IntegerVector
fn shr(self, bits: u32) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<u32> for &IntegerVector
impl Shr<u32> for &IntegerVector
Source§fn shr(self, bits: u32) -> IntegerVector
fn shr(self, bits: u32) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<u64> for IntegerVector
impl Shr<u64> for IntegerVector
Source§fn shr(self, bits: u64) -> IntegerVector
fn shr(self, bits: u64) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<u64> for &IntegerVector
impl Shr<u64> for &IntegerVector
Source§fn shr(self, bits: u64) -> IntegerVector
fn shr(self, bits: u64) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<u128> for IntegerVector
impl Shr<u128> for IntegerVector
Source§fn shr(self, bits: u128) -> IntegerVector
fn shr(self, bits: u128) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<u128> for &IntegerVector
impl Shr<u128> for &IntegerVector
Source§fn shr(self, bits: u128) -> IntegerVector
fn shr(self, bits: u128) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<usize> for IntegerVector
impl Shr<usize> for IntegerVector
Source§fn shr(self, bits: usize) -> IntegerVector
fn shr(self, bits: usize) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by value. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl Shr<usize> for &IntegerVector
impl Shr<usize> for &IntegerVector
Source§fn shr(self, bits: usize) -> IntegerVector
fn shr(self, bits: usize) -> IntegerVector
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
taking it by reference. Every element is shifted, and the dimension is unchanged.
$f(v, k) = \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(n, k) = O(n + k)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
>> operator.Source§impl ShrAssign<i8> for IntegerVector
impl ShrAssign<i8> for IntegerVector
Source§fn shr_assign(&mut self, bits: i8)
fn shr_assign(&mut self, bits: i8)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShrAssign<i16> for IntegerVector
impl ShrAssign<i16> for IntegerVector
Source§fn shr_assign(&mut self, bits: i16)
fn shr_assign(&mut self, bits: i16)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShrAssign<i32> for IntegerVector
impl ShrAssign<i32> for IntegerVector
Source§fn shr_assign(&mut self, bits: i32)
fn shr_assign(&mut self, bits: i32)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShrAssign<i64> for IntegerVector
impl ShrAssign<i64> for IntegerVector
Source§fn shr_assign(&mut self, bits: i64)
fn shr_assign(&mut self, bits: i64)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShrAssign<i128> for IntegerVector
impl ShrAssign<i128> for IntegerVector
Source§fn shr_assign(&mut self, bits: i128)
fn shr_assign(&mut self, bits: i128)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShrAssign<isize> for IntegerVector
impl ShrAssign<isize> for IntegerVector
Source§fn shr_assign(&mut self, bits: isize)
fn shr_assign(&mut self, bits: isize)
Right-shifts an IntegerVector (divides or multiplies it by a power of 2), in
place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
A negative bits shifts left, multiplying every element by $2^{-k}$.
§Worst-case complexity
$T(n, m, k) = O(n + km)$
$M(n, m, k) = O(n + km)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, $m$ is bits.unsigned_abs(), and $k$ is self.dimension().
§Examples
See here.
Source§impl ShrAssign<u8> for IntegerVector
impl ShrAssign<u8> for IntegerVector
Source§fn shr_assign(&mut self, bits: u8)
fn shr_assign(&mut self, bits: u8)
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
in place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl ShrAssign<u16> for IntegerVector
impl ShrAssign<u16> for IntegerVector
Source§fn shr_assign(&mut self, bits: u16)
fn shr_assign(&mut self, bits: u16)
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
in place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl ShrAssign<u32> for IntegerVector
impl ShrAssign<u32> for IntegerVector
Source§fn shr_assign(&mut self, bits: u32)
fn shr_assign(&mut self, bits: u32)
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
in place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl ShrAssign<u64> for IntegerVector
impl ShrAssign<u64> for IntegerVector
Source§fn shr_assign(&mut self, bits: u64)
fn shr_assign(&mut self, bits: u64)
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
in place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl ShrAssign<u128> for IntegerVector
impl ShrAssign<u128> for IntegerVector
Source§fn shr_assign(&mut self, bits: u128)
fn shr_assign(&mut self, bits: u128)
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
in place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl ShrAssign<usize> for IntegerVector
impl ShrAssign<usize> for IntegerVector
Source§fn shr_assign(&mut self, bits: usize)
fn shr_assign(&mut self, bits: usize)
Right-shifts an IntegerVector (divides it by a power of 2 and takes the floor),
in place. Every element is shifted, and the dimension is unchanged.
$v \gets \lfloor v/2^k \rfloor$. The floor is taken entrywise, rounding toward
negative infinity; to round differently, use
entrywise_shr_round.
§Worst-case complexity
$T(n, k) = O(n + k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the
elements, and $k$ is self.dimension().
§Examples
See here. /// This is equivalent to
_fmpz_vec_scalar_fdiv_q_2exp from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl SignificantBits for &IntegerVector
impl SignificantBits for &IntegerVector
Source§fn significant_bits(self) -> u64
fn significant_bits(self) -> u64
Returns the sum of the numbers of significant bits of the elements of an IntegerVector.
This is the number of bits needed to store all of the elements, and 0 for the 0-dimensional vector.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::num::logic::traits::SignificantBits;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -5, 2)")
.unwrap()
.significant_bits(),
6
);
assert_eq!(IntegerVector::from_str("()").unwrap().significant_bits(), 0);impl StructuralPartialEq for IntegerVector
Source§impl Sub for IntegerVector
impl Sub for IntegerVector
Source§fn sub(self, other: Self) -> Self
fn sub(self, other: Self) -> Self
Subtracts two IntegerVectors, taking both by value.
The difference is taken element by element, so the result has the same dimension as the operands.
$$ f(v, w) = v - w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!((v - w).to_string(), "(2, -7, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
- operator.Source§impl Sub<&IntegerVector> for IntegerVector
impl Sub<&IntegerVector> for IntegerVector
Source§fn sub(self, other: &Self) -> Self
fn sub(self, other: &Self) -> Self
Subtracts two IntegerVectors, taking the first by value and the second by reference.
The difference is taken element by element, so the result has the same dimension as the operands.
$$ f(v, w) = v - w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!((v - &w).to_string(), "(2, -7, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
- operator.Source§impl Sub<&IntegerVector> for &IntegerVector
impl Sub<&IntegerVector> for &IntegerVector
Source§fn sub(self, other: &IntegerVector) -> IntegerVector
fn sub(self, other: &IntegerVector) -> IntegerVector
Subtracts two IntegerVectors, taking both by reference.
The difference is taken element by element, so the result has the same dimension as the operands.
$$ f(v, w) = v - w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!((&v - &w).to_string(), "(2, -7, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
- operator.Source§impl Sub<IntegerVector> for &IntegerVector
impl Sub<IntegerVector> for &IntegerVector
Source§fn sub(self, other: IntegerVector) -> IntegerVector
fn sub(self, other: IntegerVector) -> IntegerVector
Subtracts two IntegerVectors, taking the first by reference and the second by value.
The difference is taken element by element, so the result has the same dimension as the operands.
$$ f(v, w) = v - w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!((&v - w).to_string(), "(2, -7, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§type Output = IntegerVector
type Output = IntegerVector
- operator.Source§impl SubAssign for IntegerVector
impl SubAssign for IntegerVector
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Adds an IntegerVector to an IntegerVector in place, taking the IntegerVector on
the right-hand side by value.
The difference is taken element by element, so the result has the same dimension as the operands.
$$ f(v, w) = v - w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
v -= IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!(v.to_string(), "(2, -7, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§impl SubAssign<&IntegerVector> for IntegerVector
impl SubAssign<&IntegerVector> for IntegerVector
Source§fn sub_assign(&mut self, other: &Self)
fn sub_assign(&mut self, other: &Self)
Adds an IntegerVector to an IntegerVector in place, taking the IntegerVector on
the right-hand side by reference.
The difference is taken element by element, so the result has the same dimension as the operands.
$$ f(v, w) = v - w. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of both vectors.
§Panics
Panics if self and other have different dimensions.
§Examples
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
v -= &IntegerVector::from_str("(-1, 5, 0)").unwrap();
assert_eq!(v.to_string(), "(2, -7, 3)");This is equivalent to _fmpz_vec_add from fmpz_vec/add.c, FLINT 3.6.0.
Source§impl<'a, 'b> SubMul<&'a IntegerVector, &'b Integer> for IntegerVector
impl<'a, 'b> SubMul<&'a IntegerVector, &'b Integer> for IntegerVector
Source§fn sub_mul(self, w: &'a Self, c: &'b Integer) -> Self
fn sub_mul(self, w: &'a Self, c: &'b Integer) -> Self
Subtracts the product of an IntegerVector and an Integer from an IntegerVector,
taking the first vector by value, the second vector by reference, and the scalar by
reference.
See the documentation for the SubMul implementation that takes all three by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_submul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl<'a> SubMul<&'a IntegerVector, Integer> for IntegerVector
impl<'a> SubMul<&'a IntegerVector, Integer> for IntegerVector
Source§fn sub_mul(self, w: &'a Self, c: Integer) -> Self
fn sub_mul(self, w: &'a Self, c: Integer) -> Self
Subtracts the product of an IntegerVector and an Integer from an IntegerVector,
taking the first vector by value, the second vector by reference, and the scalar by value.
See the documentation for the SubMul implementation that takes all three by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_submul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl SubMul<&IntegerVector, &Integer> for &IntegerVector
impl SubMul<&IntegerVector, &Integer> for &IntegerVector
Source§fn sub_mul(self, w: &IntegerVector, c: &Integer) -> IntegerVector
fn sub_mul(self, w: &IntegerVector, c: &Integer) -> IntegerVector
Subtracts the product of an IntegerVector and an Integer from an IntegerVector,
taking all three by reference.
See the documentation for the SubMul implementation that takes all three by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_submul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl<'b> SubMul<IntegerVector, &'b Integer> for IntegerVector
impl<'b> SubMul<IntegerVector, &'b Integer> for IntegerVector
Source§fn sub_mul(self, w: Self, c: &'b Integer) -> Self
fn sub_mul(self, w: Self, c: &'b Integer) -> Self
Subtracts the product of an IntegerVector and an Integer from an IntegerVector,
taking the first vector by value, the second vector by value, and the scalar by reference.
See the documentation for the SubMul implementation that takes all three by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_submul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl SubMul<IntegerVector, Integer> for IntegerVector
impl SubMul<IntegerVector, Integer> for IntegerVector
Source§fn sub_mul(self, w: Self, c: Integer) -> Self
fn sub_mul(self, w: Self, c: Integer) -> Self
Subtracts the product of an IntegerVector and an Integer from an IntegerVector,
taking all three by value.
The operation is taken element by element, so the result has the same dimension as the vectors. Like FLINT’s, this special-cases multiplication by 0, 1, and $-1$.
$$ f(v, w, c) = v - cw = (v_0 - cw_0, v_1 - cw_1, \ldots, v_{n-1} - cw_{n-1}). $$
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_submul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
type Output = IntegerVector
Source§impl<'a, 'b> SubMulAssign<&'a IntegerVector, &'b Integer> for IntegerVector
impl<'a, 'b> SubMulAssign<&'a IntegerVector, &'b Integer> for IntegerVector
Source§fn sub_mul_assign(&mut self, w: &'a Self, c: &'b Integer)
fn sub_mul_assign(&mut self, w: &'a Self, c: &'b Integer)
Subtracts the product of an IntegerVector and an Integer from an IntegerVector
in place, taking the vector and the scalar on the right-hand side by reference.
See the documentation for the SubMulAssign implementation that takes both by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_submul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl<'a> SubMulAssign<&'a IntegerVector, Integer> for IntegerVector
impl<'a> SubMulAssign<&'a IntegerVector, Integer> for IntegerVector
Source§fn sub_mul_assign(&mut self, w: &'a Self, c: Integer)
fn sub_mul_assign(&mut self, w: &'a Self, c: Integer)
Subtracts the product of an IntegerVector and an Integer from an IntegerVector
in place, taking the vector on the right-hand side by reference and the scalar by value.
See the documentation for the SubMulAssign implementation that takes both by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_submul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl<'b> SubMulAssign<IntegerVector, &'b Integer> for IntegerVector
impl<'b> SubMulAssign<IntegerVector, &'b Integer> for IntegerVector
Source§fn sub_mul_assign(&mut self, w: Self, c: &'b Integer)
fn sub_mul_assign(&mut self, w: Self, c: &'b Integer)
Subtracts the product of an IntegerVector and an Integer from an IntegerVector
in place, taking the vector on the right-hand side by value and the scalar by reference.
See the documentation for the SubMulAssign implementation that takes both by value for
details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_submul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl SubMulAssign<IntegerVector, Integer> for IntegerVector
impl SubMulAssign<IntegerVector, Integer> for IntegerVector
Source§fn sub_mul_assign(&mut self, w: Self, c: Integer)
fn sub_mul_assign(&mut self, w: Self, c: Integer)
Subtracts the product of an IntegerVector and an Integer from an IntegerVector
in place, taking the vector and the scalar on the right-hand side by value.
The operation is taken element by element. Like FLINT’s, this special-cases multiplication by 0, 1, and $-1$.
$$ v \gets v - cw. $$
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self.
§Panics
Panics if self and w have different dimensions.
§Examples
See here.
This is equivalent to _fmpz_vec_scalar_submul_fmpz from fmpz_vec/scalar.c, FLINT 3.6.0.
Source§impl SubMulShl<&IntegerVector, &Integer> for IntegerVector
impl SubMulShl<&IntegerVector, &Integer> for IntegerVector
Source§fn sub_mul_shl(self, w: &Self, c: &Integer, bits: u64) -> Self
fn sub_mul_shl(self, w: &Self, c: &Integer, bits: u64) -> Self
Subtracts a scalar multiple of an IntegerVector, shifted left by bits, from an
IntegerVector, taking the first vector by value, the second by reference, and the scalar
by reference.
See the documentation for the SubMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::SubMulShl;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(
v.sub_mul_shl(&w, &Integer::from(10), 2).to_string(),
"(-159, -202, 243)"
);
let v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
assert_eq!(
v.sub_mul_shl(&w, &Integer::from_str("18446744073709551617").unwrap(), 3)
.to_string(),
"(-2722258935367507707706996859454145691639, 147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_submul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
type Output = IntegerVector
Source§impl SubMulShl<&IntegerVector, &Integer> for &IntegerVector
impl SubMulShl<&IntegerVector, &Integer> for &IntegerVector
Source§fn sub_mul_shl(self, w: &IntegerVector, c: &Integer, bits: u64) -> IntegerVector
fn sub_mul_shl(self, w: &IntegerVector, c: &Integer, bits: u64) -> IntegerVector
Subtracts a scalar multiple of an IntegerVector, shifted left by bits, from an
IntegerVector, taking both vectors and the scalar by reference.
See the documentation for the SubMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::SubMulShl;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(
(&v).sub_mul_shl(&w, &Integer::from(10), 2).to_string(),
"(-159, -202, 243)"
);
let v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
assert_eq!(
(&v).sub_mul_shl(&w, &Integer::from_str("18446744073709551617").unwrap(), 3)
.to_string(),
"(-2722258935367507707706996859454145691639, 147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_submul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
type Output = IntegerVector
Source§impl SubMulShl<&IntegerVector, Integer> for IntegerVector
impl SubMulShl<&IntegerVector, Integer> for IntegerVector
Source§fn sub_mul_shl(self, w: &Self, c: Integer, bits: u64) -> Self
fn sub_mul_shl(self, w: &Self, c: Integer, bits: u64) -> Self
Subtracts a scalar multiple of an IntegerVector, shifted left by bits, from an
IntegerVector, taking the first vector by value, the second by reference, and the scalar
by value.
See the documentation for the SubMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::SubMulShl;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(
v.sub_mul_shl(&w, Integer::from(10), 2).to_string(),
"(-159, -202, 243)"
);
let v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
assert_eq!(
v.sub_mul_shl(&w, Integer::from_str("18446744073709551617").unwrap(), 3)
.to_string(),
"(-2722258935367507707706996859454145691639, 147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_submul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
type Output = IntegerVector
Source§impl SubMulShl<IntegerVector, &Integer> for IntegerVector
impl SubMulShl<IntegerVector, &Integer> for IntegerVector
Source§fn sub_mul_shl(self, w: Self, c: &Integer, bits: u64) -> Self
fn sub_mul_shl(self, w: Self, c: &Integer, bits: u64) -> Self
Subtracts a scalar multiple of an IntegerVector, shifted left by bits, from an
IntegerVector, taking the first vector by value, the second by value, and the scalar by
reference.
See the documentation for the SubMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::SubMulShl;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(
v.sub_mul_shl(w, &Integer::from(10), 2).to_string(),
"(-159, -202, 243)"
);
let v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
assert_eq!(
v.sub_mul_shl(w, &Integer::from_str("18446744073709551617").unwrap(), 3)
.to_string(),
"(-2722258935367507707706996859454145691639, 147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_submul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
type Output = IntegerVector
Source§impl SubMulShl<IntegerVector, Integer> for IntegerVector
impl SubMulShl<IntegerVector, Integer> for IntegerVector
Source§fn sub_mul_shl(self, w: Self, c: Integer, bits: u64) -> Self
fn sub_mul_shl(self, w: Self, c: Integer, bits: u64) -> Self
Subtracts a scalar multiple of an IntegerVector, shifted left by bits, from an
IntegerVector, taking both vectors and the scalar by value.
The operation is taken element by element, so the result has the same dimension as the vectors. Like FLINT’s, this special-cases multiplication by 0, 1, and $-1$, and a shift by 0.
$$ f(v, w, c, k) = v - cw2^k. $$
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::SubMulShl;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
assert_eq!(
v.sub_mul_shl(w, Integer::from(10), 2).to_string(),
"(-159, -202, 243)"
);
let v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
assert_eq!(
v.sub_mul_shl(w, Integer::from_str("18446744073709551617").unwrap(), 3)
.to_string(),
"(-2722258935367507707706996859454145691639, 147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_submul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
type Output = IntegerVector
Source§impl SubMulShlAssign<&IntegerVector, &Integer> for IntegerVector
impl SubMulShlAssign<&IntegerVector, &Integer> for IntegerVector
Source§fn sub_mul_shl_assign(&mut self, w: &Self, c: &Integer, bits: u64)
fn sub_mul_shl_assign(&mut self, w: &Self, c: &Integer, bits: u64)
Subtracts a scalar multiple of an IntegerVector, shifted left by bits, from an
IntegerVector, in place, taking the vector and the scalar on the right-hand side by
reference.
See the documentation for the SubMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::SubMulShlAssign;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
v.sub_mul_shl_assign(&w, &Integer::from(10), 2);
assert_eq!(v.to_string(), "(-159, -202, 243)");
let mut v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
v.sub_mul_shl_assign(&w, &Integer::from_str("18446744073709551617").unwrap(), 3);
assert_eq!(
v.to_string(),
"(-2722258935367507707706996859454145691639, 147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_submul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl SubMulShlAssign<&IntegerVector, Integer> for IntegerVector
impl SubMulShlAssign<&IntegerVector, Integer> for IntegerVector
Source§fn sub_mul_shl_assign(&mut self, w: &Self, c: Integer, bits: u64)
fn sub_mul_shl_assign(&mut self, w: &Self, c: Integer, bits: u64)
Subtracts a scalar multiple of an IntegerVector, shifted left by bits, from an
IntegerVector, in place, taking the vector on the right-hand side by reference and the
scalar by value.
See the documentation for the SubMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::SubMulShlAssign;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
v.sub_mul_shl_assign(&w, Integer::from(10), 2);
assert_eq!(v.to_string(), "(-159, -202, 243)");
let mut v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
v.sub_mul_shl_assign(&w, Integer::from_str("18446744073709551617").unwrap(), 3);
assert_eq!(
v.to_string(),
"(-2722258935367507707706996859454145691639, 147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_submul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl SubMulShlAssign<IntegerVector, &Integer> for IntegerVector
impl SubMulShlAssign<IntegerVector, &Integer> for IntegerVector
Source§fn sub_mul_shl_assign(&mut self, w: Self, c: &Integer, bits: u64)
fn sub_mul_shl_assign(&mut self, w: Self, c: &Integer, bits: u64)
Subtracts a scalar multiple of an IntegerVector, shifted left by bits, from an
IntegerVector, in place, taking the vector on the right-hand side by value and the
scalar by reference.
See the documentation for the SubMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::SubMulShlAssign;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
v.sub_mul_shl_assign(w, &Integer::from(10), 2);
assert_eq!(v.to_string(), "(-159, -202, 243)");
let mut v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
v.sub_mul_shl_assign(w, &Integer::from_str("18446744073709551617").unwrap(), 3);
assert_eq!(
v.to_string(),
"(-2722258935367507707706996859454145691639, 147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_submul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl SubMulShlAssign<IntegerVector, Integer> for IntegerVector
impl SubMulShlAssign<IntegerVector, Integer> for IntegerVector
Source§fn sub_mul_shl_assign(&mut self, w: Self, c: Integer, bits: u64)
fn sub_mul_shl_assign(&mut self, w: Self, c: Integer, bits: u64)
Subtracts a scalar multiple of an IntegerVector, shifted left by bits, from an
IntegerVector, in place, taking the vector and the scalar on the right-hand side by
value.
See the documentation for the SubMulShl implementation that takes everything by value
for details.
§Worst-case complexity
$T(n, m) = O(m + n \log n \log\log n)$
$M(n, m) = O(m + n \log n)$
where $T$ is time, $M$ is additional memory, $n$ is the total number of bits of the elements
of w and of c, and $m$ is the total number of bits of the elements of self plus bits
times self.dimension().
§Panics
Panics if self and w have different dimensions.
§Examples
use core::str::FromStr;
use malachite_base::num::arithmetic::traits::SubMulShlAssign;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
let w = IntegerVector::from_str("(4, 5, -6)").unwrap();
v.sub_mul_shl_assign(w, Integer::from(10), 2);
assert_eq!(v.to_string(), "(-159, -202, 243)");
let mut v = IntegerVector::from_str("(1, 0)").unwrap();
let w = IntegerVector::from_str("(18446744073709551615, -1)").unwrap();
v.sub_mul_shl_assign(w, Integer::from_str("18446744073709551617").unwrap(), 3);
assert_eq!(
v.to_string(),
"(-2722258935367507707706996859454145691639, 147573952589676412936)"
);This is equivalent to _fmpz_vec_scalar_submul_si_2exp from fmpz_vec/scalar.c, FLINT
3.6.0.
Source§impl Sum for IntegerVector
impl Sum for IntegerVector
Source§fn sum<I>(xs: I) -> Selfwhere
I: Iterator<Item = Self>,
fn sum<I>(xs: I) -> Selfwhere
I: Iterator<Item = Self>,
Adds up all the IntegerVectors in an iterator, entry by entry.
The vectors must all have the same dimension, which is also the dimension of the sum. Since the dimension of the zero vector cannot be inferred from an empty iterator, an empty iterator panics rather than summing to zero.
$$ f((v_i)_ {i=0}^{n-1}) = \sum_ {i=0}^{n-1} v_i. $$
§Worst-case complexity
$T(n) = O(n^2)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of all the vectors.
§Panics
Panics if the iterator is empty or if the vectors do not all have the same dimension.
§Examples
use core::iter::Sum;
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let vs = ["(1, -2, 3)", "(-4, 5, -6)", "(7, 8, -9)"]
.map(|s| IntegerVector::from_str(s).unwrap());
assert_eq!(
IntegerVector::sum(vs.into_iter()).to_string(),
"(4, 11, -12)"
);
let vs = [
"(18446744073709551615, -1)",
"(-18446744073709551616, 1267650600228229401496703205376)",
]
.map(|s| IntegerVector::from_str(s).unwrap());
assert_eq!(
IntegerVector::sum(vs.into_iter()).to_string(),
"(-1, 1267650600228229401496703205375)"
);Source§impl<'a> Sum<&'a IntegerVector> for IntegerVector
impl<'a> Sum<&'a IntegerVector> for IntegerVector
Source§fn sum<I>(xs: I) -> Selfwhere
I: Iterator<Item = &'a Self>,
fn sum<I>(xs: I) -> Selfwhere
I: Iterator<Item = &'a Self>,
Adds up all the IntegerVectors in an iterator of references, entry by entry.
The vectors must all have the same dimension, which is also the dimension of the sum. Since the dimension of the zero vector cannot be inferred from an empty iterator, an empty iterator panics rather than summing to zero.
$$ f((v_i)_ {i=0}^{n-1}) = \sum_ {i=0}^{n-1} v_i. $$
§Worst-case complexity
$T(n) = O(n^2)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements of all the vectors.
§Panics
Panics if the iterator is empty or if the vectors do not all have the same dimension.
§Examples
use core::iter::Sum;
use core::str::FromStr;
use malachite_nz::integer_vector::IntegerVector;
let vs = ["(1, -2, 3)", "(-4, 5, -6)", "(7, 8, -9)"]
.map(|s| IntegerVector::from_str(s).unwrap());
assert_eq!(IntegerVector::sum(vs.iter()).to_string(), "(4, 11, -12)");
let vs = [
"(18446744073709551615, -1)",
"(-18446744073709551616, 1267650600228229401496703205376)",
]
.map(|s| IntegerVector::from_str(s).unwrap());
assert_eq!(
IntegerVector::sum(vs.iter()).to_string(),
"(-1, 1267650600228229401496703205375)"
);Source§impl ToLatex for IntegerVector
impl ToLatex for IntegerVector
Source§fn fmt_latex(&self, f: &mut Formatter<'_>) -> Result
fn fmt_latex(&self, f: &mut Formatter<'_>) -> Result
Writes an IntegerVector as a LaTeX math-mode fragment.
The elements’ fragments are separated by commas and enclosed in parentheses that grow to fit
their contents, as a vector’s coordinates are written by hand. The 0-dimensional vector is
\left(\right).
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the sum of the bits of the elements.
§Examples
use malachite_base::strings::latex::ToLatex;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector {
elements: vec![Integer::from(1u32), Integer::from(2u32), Integer::from(3u32)],
};
assert_eq!(v.to_latex_string(), "\\left(1, 2, 3\\right)");
assert_eq!(
IntegerVector {
elements: vec![Integer::from(5u32)]
}
.to_latex_string(),
"\\left(5\\right)"
);
assert_eq!(
IntegerVector {
elements: Vec::new()
}
.to_latex_string(),
"\\left(\\right)"
);The value column holds each vector as Display writes it.
| value | fragment | renders as |
|---|---|---|
(1, 2, 3) | \left(1, 2, 3\right) | $\left(1, 2, 3\right)$ |
(5) | \left(5\right) | $\left(5\right)$ |
() | \left(\right) | $\left(\right)$ |
Source§impl ToTypst for IntegerVector
impl ToTypst for IntegerVector
Source§fn fmt_typst(&self, f: &mut Formatter<'_>) -> Result
fn fmt_typst(&self, f: &mut Formatter<'_>) -> Result
Writes an IntegerVector as a Typst math-mode fragment.
The elements’ fragments are separated by commas and enclosed in parentheses, as a vector’s
coordinates are written by hand; Typst grows the parentheses to fit their contents. The
0-dimensional vector is ().
§Worst-case complexity
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is the sum of the bits of the elements.
§Examples
use malachite_base::strings::typst::ToTypst;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector {
elements: vec![Integer::from(1u32), Integer::from(2u32), Integer::from(3u32)],
};
assert_eq!(v.to_typst_string(), "(1, 2, 3)");
assert_eq!(
IntegerVector {
elements: vec![Integer::from(5u32)]
}
.to_typst_string(),
"(5)"
);
assert_eq!(
IntegerVector {
elements: Vec::new()
}
.to_typst_string(),
"()"
);The value column holds each vector as Display writes it.
| value | fragment |
|---|---|
(1, 2, 3) | (1, 2, 3) |
(5) | (5) |
() | () |
Source§impl TryFrom<&IntegerVector> for NaturalVector
impl TryFrom<&IntegerVector> for NaturalVector
Source§fn try_from(v: &IntegerVector) -> Result<Self, Self::Error>
fn try_from(v: &IntegerVector) -> Result<Self, Self::Error>
Converts an IntegerVector to a NaturalVector, taking the IntegerVector by
reference and returning an error if any element is negative.
A successful conversion keeps the dimension.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of limbs of the elements.
§Examples
See here.
Source§type Error = NaturalVectorFromIntegerVectorError
type Error = NaturalVectorFromIntegerVectorError
Source§impl<T: PrimitiveUnsigned + for<'a> TryFrom<&'a Integer>> TryFrom<&IntegerVector> for UnsignedVector<T>
impl<T: PrimitiveUnsigned + for<'a> TryFrom<&'a Integer>> TryFrom<&IntegerVector> for UnsignedVector<T>
Source§fn try_from(v: &IntegerVector) -> Result<Self, Self::Error>
fn try_from(v: &IntegerVector) -> Result<Self, Self::Error>
Converts an IntegerVector to an UnsignedVector, taking the IntegerVector by
reference and returning an error if any element is negative or too large for T.
No element is ever wrapped, and no negative element is ever reinterpreted as unsigned. A successful conversion keeps the dimension.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is v.dimension().
§Examples
See here.
Source§type Error = UnsignedVectorFromIntegerVectorError
type Error = UnsignedVectorFromIntegerVectorError
Source§impl TryFrom<IntegerVector> for NaturalVector
impl TryFrom<IntegerVector> for NaturalVector
Source§fn try_from(v: IntegerVector) -> Result<Self, Self::Error>
fn try_from(v: IntegerVector) -> Result<Self, Self::Error>
Converts an IntegerVector to a NaturalVector, taking the IntegerVector by value
and returning an error if any element is negative.
Each element’s limbs are reused rather than copied. A successful conversion keeps the dimension.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is v.dimension().
§Examples
See here.
Source§type Error = NaturalVectorFromIntegerVectorError
type Error = NaturalVectorFromIntegerVectorError
Source§impl<T: PrimitiveUnsigned + for<'a> TryFrom<&'a Integer>> TryFrom<IntegerVector> for UnsignedVector<T>
impl<T: PrimitiveUnsigned + for<'a> TryFrom<&'a Integer>> TryFrom<IntegerVector> for UnsignedVector<T>
Source§fn try_from(v: IntegerVector) -> Result<Self, Self::Error>
fn try_from(v: IntegerVector) -> Result<Self, Self::Error>
Converts an IntegerVector to an UnsignedVector, taking the IntegerVector by
value and returning an error if any element is negative or too large for T.
Taking the vector by value saves nothing, since the elements are copied into new storage either way; this is here so that a conversion can be written without a borrow.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is v.dimension().
§Examples
See here.
Source§type Error = UnsignedVectorFromIntegerVectorError
type Error = UnsignedVectorFromIntegerVectorError
Source§impl Vector for IntegerVector
impl Vector for IntegerVector
Source§fn from_elements(xs: &[Integer]) -> Self
fn from_elements(xs: &[Integer]) -> Self
Converts a slice of Integers to an IntegerVector, cloning them.
The vector’s dimension is the length of the slice. Every slice is a valid vector, so this cannot fail; the empty slice gives the 0-dimensional vector.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use malachite_base::num::basic::traits::{One, Two};
use malachite_base::vector::Vector;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_elements(&[Integer::ONE, Integer::TWO]).to_string(),
"(1, 2)"
);
assert_eq!(IntegerVector::from_elements(&[]).to_string(), "()");Source§fn from_owned_elements(xs: Vec<Integer>) -> Self
fn from_owned_elements(xs: Vec<Integer>) -> Self
Converts a Vec of Integers to an IntegerVector, taking ownership of it.
The vector’s dimension is the length of the Vec. Every Vec is a valid vector, so
this cannot fail, and nothing is copied or allocated.
§Worst-case complexity
Constant time and additional memory.
§Examples
use malachite_base::num::basic::traits::{One, Two};
use malachite_base::vector::Vector;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_owned_elements(vec![Integer::ONE, Integer::TWO]).to_string(),
"(1, 2)"
);
assert_eq!(
IntegerVector::from_owned_elements(Vec::new()).to_string(),
"()"
);Source§fn zero(dimension: u64) -> Self
fn zero(dimension: u64) -> Self
Returns the zero vector of a given dimension: a vector of dimension zeros.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is dimension.
§Panics
Panics if dimension is greater than usize::MAX.
§Examples
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(IntegerVector::zero(3).to_string(), "(0, 0, 0)");
assert_eq!(IntegerVector::zero(0).to_string(), "()");This is equivalent to fmpz_vec_init from fmpz_vec/vec.c, FLINT 3.6.0, and to
_fmpz_vec_init from fmpz_vec.h.
Source§fn standard_basis_vector(dimension: u64, index: u64) -> Self
fn standard_basis_vector(dimension: u64, index: u64) -> Self
Returns the standard basis vector $e_i$ of a given dimension: the vector whose element at
index is 1 and whose other elements are 0.
Indices start at 0, as they do for Index.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is dimension.
§Panics
Panics if index is greater than or equal to dimension, or if dimension is greater than
usize::MAX.
§Examples
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::standard_basis_vector(3, 1).to_string(),
"(0, 1, 0)"
);
assert_eq!(
IntegerVector::standard_basis_vector(1, 0).to_string(),
"(1)"
);Source§fn push(&mut self, x: Integer)
fn push(&mut self, x: Integer)
Appends an element to the end of an IntegerVector, increasing its dimension by 1.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension(). The capacity
grows geometrically, so pushing $n$ elements onto an empty vector takes $O(n)$ time in
total.
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, 2)").unwrap();
v.push(Integer::from(-3));
assert_eq!(v.to_string(), "(1, 2, -3)");
let mut v = IntegerVector::zero(0);
v.push(Integer::from(5));
assert_eq!(v.to_string(), "(5)");This is equivalent to fmpz_vec_append from fmpz_vec/vec.c, FLINT 3.6.0.
Source§fn set_dimension(&mut self, dimension: u64)
fn set_dimension(&mut self, dimension: u64)
Sets the dimension of an IntegerVector, removing elements from the end if the new
dimension is smaller, and appending zeros if it is larger.
Reducing the dimension keeps the first dimension coordinates: it is the projection onto
them.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the larger of self.dimension() and
dimension.
§Panics
Panics if dimension is greater than usize::MAX.
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, 2, 3)").unwrap();
v.set_dimension(5);
assert_eq!(v.to_string(), "(1, 2, 3, 0, 0)");
v.set_dimension(2);
assert_eq!(v.to_string(), "(1, 2)");
v.set_dimension(0);
assert_eq!(v.to_string(), "()");This is equivalent to fmpz_vec_set_length from fmpz_vec/vec.c, FLINT 3.6.0.
Source§fn set_zero(&mut self)
fn set_zero(&mut self)
Sets every element of an IntegerVector to zero, keeping its dimension.
Afterwards the vector equals zero of the same dimension.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(1, -2, 3)").unwrap();
v.set_zero();
assert_eq!(v.to_string(), "(0, 0, 0)");
let mut v = IntegerVector::from_str("()").unwrap();
v.set_zero();
assert_eq!(v.to_string(), "()");This is equivalent to _fmpz_vec_zero from fmpz_vec/zero.c, FLINT 3.6.0.
Source§fn sort(&mut self)
fn sort(&mut self)
Sorts the elements of an IntegerVector in ascending order, keeping its dimension.
Equal elements are indistinguishable, so the sort does not need to be stable, and an unstable sort is used.
§Worst-case complexity
$T(n) = O(n \log n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension(), assuming that
comparing two elements takes constant time; comparing large elements takes time proportional
to their sizes.
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
let mut v = IntegerVector::from_str("(3, -1, 2, 0)").unwrap();
v.sort();
assert_eq!(v.to_string(), "(-1, 0, 2, 3)");This is equivalent to _fmpz_vec_sort from fmpz_vec/sort.c, FLINT 3.6.0.
Source§fn to_elements(&self) -> Vec<Integer>
fn to_elements(&self) -> Vec<Integer>
Returns an IntegerVector’s elements as a Vec, cloning them.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::strings::ToDebugString;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, 2, 3)").unwrap();
assert_eq!(v.to_elements().to_debug_string(), "[1, 2, 3]");
assert_eq!(
IntegerVector::from_str("()")
.unwrap()
.to_elements()
.to_debug_string(),
"[]"
);Source§fn into_elements(self) -> Vec<Integer>
fn into_elements(self) -> Vec<Integer>
Returns an IntegerVector’s elements as a Vec, taking ownership of the
IntegerVector.
Nothing is copied or allocated.
§Worst-case complexity
Constant time and additional memory.
§Examples
use core::str::FromStr;
use malachite_base::strings::ToDebugString;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, 2, 3)").unwrap();
assert_eq!(v.into_elements().to_debug_string(), "[1, 2, 3]");
assert_eq!(
IntegerVector::from_str("()")
.unwrap()
.into_elements()
.to_debug_string(),
"[]"
);Source§fn elements_ref(&self) -> &[Integer]
fn elements_ref(&self) -> &[Integer]
Returns a reference to an IntegerVector’s elements, as a slice.
§Worst-case complexity
Constant time and additional memory.
§Examples
use core::str::FromStr;
use malachite_base::strings::ToDebugString;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector::from_str("(1, 2, 3)").unwrap();
assert_eq!(v.elements_ref().to_debug_string(), "[1, 2, 3]");
// A slice of the elements can be taken directly.
let tail = &v.elements_ref()[1..];
assert_eq!(tail.to_debug_string(), "[2, 3]");
assert_eq!(
IntegerVector::from_str("()")
.unwrap()
.elements_ref()
.to_debug_string(),
"[]"
);Source§fn dimension(&self) -> u64
fn dimension(&self) -> u64
Returns the dimension of an IntegerVector: the number of its elements.
§Worst-case complexity
Constant time and additional memory.
§Examples
use malachite_base::vector::Vector;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
let v = IntegerVector {
elements: vec![Integer::from(4u32), Integer::from(5u32)],
};
assert_eq!(v.dimension(), 2);
assert_eq!(
IntegerVector {
elements: Vec::new()
}
.dimension(),
0
);Source§fn pivot(&self) -> Option<&Integer>
fn pivot(&self) -> Option<&Integer>
Returns the pivot of an IntegerVector: its first nonzero element.
This is the element that leads the vector when it is a row of a matrix in echelon form. It
returns a reference to it, or None if every element is zero, which includes the
0-dimensional vector.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer::Integer;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(0, 0, -3, 0, 5)").unwrap().pivot(),
Some(&Integer::from(-3))
);
assert_eq!(IntegerVector::from_str("(0, 0)").unwrap().pivot(), None);
assert_eq!(IntegerVector::from_str("()").unwrap().pivot(), None);Source§fn pivot_index(&self) -> Option<u64>
fn pivot_index(&self) -> Option<u64>
Returns the index of the pivot of an IntegerVector: the position of its first nonzero
element.
Indices start at 0, as they do for Index. Returns None if every
element is zero, which includes the 0-dimensional vector. When it returns Some(i),
pivot is the element at i.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(0, 0, -3, 0, 5)")
.unwrap()
.pivot_index(),
Some(2)
);
assert_eq!(
IntegerVector::from_str("(0, 0)").unwrap().pivot_index(),
None
);
assert_eq!(IntegerVector::from_str("()").unwrap().pivot_index(), None);Source§fn height_index(&self) -> Option<u64>
fn height_index(&self) -> Option<u64>
Returns the index of an element of largest absolute value of an IntegerVector: the first
one, when several are tied.
Indices start at 0, as they do for Index. Returns None for the
0-dimensional vector.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -3, 3, 2)")
.unwrap()
.height_index(),
Some(1)
);
assert_eq!(
IntegerVector::from_str("(-5, 5)").unwrap().height_index(),
Some(0)
);
assert_eq!(IntegerVector::from_str("()").unwrap().height_index(), None);This is equivalent to _fmpz_vec_height_index from fmpz_vec/height_index.c, FLINT 3.6.0,
except that it returns None for the 0-dimensional vector, where FLINT requires a nonempty
vector.
Source§fn is_zero(&self) -> bool
fn is_zero(&self) -> bool
Determines whether every element of an IntegerVector is zero.
The 0-dimensional vector, which has no elements, counts as zero.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
assert!(IntegerVector::from_str("(0, 0)").unwrap().is_zero());
assert!(IntegerVector::from_str("()").unwrap().is_zero());
assert!(!IntegerVector::from_str("(0, 1, 0)").unwrap().is_zero());This is equivalent to _fmpz_vec_is_zero from fmpz_vec/is_zero.c, FLINT 3.6.0.
Source§fn standard_basis_index(&self) -> Option<u64>
fn standard_basis_index(&self) -> Option<u64>
Determines whether an IntegerVector is a standard basis vector, returning the index of
its 1 if it is.
A standard basis vector has a single element equal to 1 and every other element 0. Returns
None for every other vector, including the zero vectors and the 0-dimensional vector.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is self.dimension().
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(0, 1, 0)")
.unwrap()
.standard_basis_index(),
Some(1)
);
assert_eq!(
IntegerVector::from_str("(0, -1, 0)")
.unwrap()
.standard_basis_index(),
None
);
assert_eq!(
IntegerVector::from_str("(1, 0, 1)")
.unwrap()
.standard_basis_index(),
None
);
assert_eq!(
IntegerVector::from_str("(0, 0)")
.unwrap()
.standard_basis_index(),
None
);Source§fn max_bits(&self) -> (u64, bool)
fn max_bits(&self) -> (u64, bool)
Returns the number of significant bits of the height of an IntegerVector, together with
whether any of its elements is negative.
The top limbs of the elements with the most limbs are or-ed together, so no element’s bit length is computed separately.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the number of elements.
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -5, 2)").unwrap().max_bits(),
(3, true)
);
assert_eq!(
IntegerVector::from_str("()").unwrap().max_bits(),
(0, false)
);This is equivalent to _fmpz_vec_max_bits from fmpz_vec/max_bits.c, FLINT 3.6.0, which
returns the two results combined, as a count that is negated when some element is negative.
Source§fn sum_max_bits(&self) -> (u64, u64)
fn sum_max_bits(&self) -> (u64, u64)
Returns the number of significant bits of the sum of the absolute values of the elements of
an IntegerVector (its $\ell^1$ norm), together with the number of significant bits of
its height.
While every element fits in one limb, the absolute values are added in two limbs, so nothing is allocated.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is the total number of bits of the elements.
§Examples
use core::str::FromStr;
use malachite_base::vector::Vector;
use malachite_nz::integer_vector::IntegerVector;
assert_eq!(
IntegerVector::from_str("(1, -5, 2)")
.unwrap()
.sum_max_bits(),
(4, 3)
);
assert_eq!(
IntegerVector::from_str("()").unwrap().sum_max_bits(),
(0, 0)
);This is equivalent to _fmpz_vec_sum_max_bits from fmpz_vec/sum_max_bits.c, FLINT 3.6.0.
Auto Trait Implementations§
impl Freeze for IntegerVector
impl RefUnwindSafe for IntegerVector
impl Send for IntegerVector
impl Sync for IntegerVector
impl Unpin for IntegerVector
impl UnsafeUnpin for IntegerVector
impl UnwindSafe for IntegerVector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
fn imaginary_into(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more