2021-04-11 17:00:38 +08:00
|
|
|
use na::Scalar;
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
use crate::aliases::{TMat, TVec};
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// The `index`-th column of the matrix `m`.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`row`](fn.row.html)
|
|
|
|
/// * [`set_column`](fn.set_column.html)
|
|
|
|
/// * [`set_row`](fn.set_row.html)
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn column<T: Scalar, const R: usize, const C: usize>(
|
|
|
|
m: &TMat<T, R, C>,
|
|
|
|
index: usize,
|
|
|
|
) -> TVec<T, R> {
|
2018-09-20 20:23:31 +08:00
|
|
|
m.column(index).into_owned()
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// Sets to `x` the `index`-th column of the matrix `m`.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`column`](fn.column.html)
|
|
|
|
/// * [`row`](fn.row.html)
|
|
|
|
/// * [`set_row`](fn.set_row.html)
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn set_column<T: Scalar, const R: usize, const C: usize>(
|
|
|
|
m: &TMat<T, R, C>,
|
2018-10-22 04:11:27 +08:00
|
|
|
index: usize,
|
2021-04-11 17:00:38 +08:00
|
|
|
x: &TVec<T, R>,
|
|
|
|
) -> TMat<T, R, C> {
|
2018-09-20 20:23:31 +08:00
|
|
|
let mut res = m.clone();
|
|
|
|
res.set_column(index, x);
|
|
|
|
res
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// The `index`-th row of the matrix `m`.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`column`](fn.column.html)
|
|
|
|
/// * [`set_column`](fn.set_column.html)
|
|
|
|
/// * [`set_row`](fn.set_row.html)
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn row<T: Scalar, const R: usize, const C: usize>(
|
|
|
|
m: &TMat<T, R, C>,
|
|
|
|
index: usize,
|
|
|
|
) -> TVec<T, C> {
|
2018-09-20 20:23:31 +08:00
|
|
|
m.row(index).into_owned().transpose()
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// Sets to `x` the `index`-th row of the matrix `m`.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`column`](fn.column.html)
|
|
|
|
/// * [`row`](fn.row.html)
|
|
|
|
/// * [`set_column`](fn.set_column.html)
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn set_row<T: Scalar, const R: usize, const C: usize>(
|
|
|
|
m: &TMat<T, R, C>,
|
2018-10-22 04:11:27 +08:00
|
|
|
index: usize,
|
2021-04-11 17:00:38 +08:00
|
|
|
x: &TVec<T, C>,
|
|
|
|
) -> TMat<T, R, C> {
|
2018-09-20 20:23:31 +08:00
|
|
|
let mut res = m.clone();
|
|
|
|
res.set_row(index, &x.transpose());
|
|
|
|
res
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|